Backed out 3 changesets (bug 1901652) for causing mochitest failures @ browser_scrollToPoint.js CLOSED TREE

Backed out changeset 24bb7e89929c (bug 1901652)
Backed out changeset 8fc6e70268be (bug 1901652)
Backed out changeset a7a4eb34e7b1 (bug 1901652)
This commit is contained in:
Sandor Molnar
2024-06-17 10:06:06 +03:00
parent e249389848
commit fc33dbde1c
9 changed files with 58 additions and 150 deletions

View File

@@ -13,7 +13,6 @@
#include "CounterStyleManager.h" #include "CounterStyleManager.h"
#include "LayoutLogging.h" #include "LayoutLogging.h"
#include "mozilla/dom/HTMLInputElement.h" #include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/WritingModes.h" #include "mozilla/WritingModes.h"
#include "nsBlockFrame.h" #include "nsBlockFrame.h"
#include "nsFlexContainerFrame.h" #include "nsFlexContainerFrame.h"
@@ -1091,9 +1090,9 @@ nsIFrame* ReflowInput::GetHypotheticalBoxContainer(nsIFrame* aFrame,
struct nsHypotheticalPosition { struct nsHypotheticalPosition {
// offset from inline-start edge of containing block (which is a padding edge) // offset from inline-start edge of containing block (which is a padding edge)
nscoord mIStart = 0; nscoord mIStart;
// offset from block-start edge of containing block (which is a padding edge) // offset from block-start edge of containing block (which is a padding edge)
nscoord mBStart = 0; nscoord mBStart;
WritingMode mWritingMode; WritingMode mWritingMode;
}; };
@@ -1212,12 +1211,19 @@ static bool BlockPolarityFlipped(WritingMode aThisWm, WritingMode aOtherWm) {
return AxisPolarityFlipped(LogicalAxis::Block, aThisWm, aOtherWm); return AxisPolarityFlipped(LogicalAxis::Block, aThisWm, aOtherWm);
} }
// In the code below, |aCBReflowInput->mFrame| is the absolute containing block, // Calculate the position of the hypothetical box that the element would have
// if it were in the flow.
// The values returned are relative to the padding edge of the absolute
// containing block. The writing-mode of the hypothetical box position will
// have the same block direction as the absolute containing block, but may
// differ in inline-bidi direction.
// In the code below, |aCBReflowInput->frame| is the absolute containing block,
// while |containingBlock| is the nearest block container of the placeholder // while |containingBlock| is the nearest block container of the placeholder
// frame, which may be different from the absolute containing block. // frame, which may be different from the absolute containing block.
void ReflowInput::CalculateHypotheticalPosition( void ReflowInput::CalculateHypotheticalPosition(
nsPlaceholderFrame* aPlaceholderFrame, const ReflowInput* aCBReflowInput, nsPresContext* aPresContext, nsPlaceholderFrame* aPlaceholderFrame,
nsHypotheticalPosition& aHypotheticalPos) const { const ReflowInput* aCBReflowInput, nsHypotheticalPosition& aHypotheticalPos,
LayoutFrameType aFrameType) const {
NS_ASSERTION(mStyleDisplay->mOriginalDisplay != StyleDisplay::None, NS_ASSERTION(mStyleDisplay->mOriginalDisplay != StyleDisplay::None,
"mOriginalDisplay has not been properly initialized"); "mOriginalDisplay has not been properly initialized");
@@ -1354,9 +1360,9 @@ void ReflowInput::CalculateHypotheticalPosition(
aPlaceholderFrame->SetLineIsEmptySoFar(true); aPlaceholderFrame->SetLineIsEmptySoFar(true);
allEmpty = true; allEmpty = true;
} else { } else {
auto* prev = aPlaceholderFrame->GetPrevSibling(); auto prev = aPlaceholderFrame->GetPrevSibling();
if (prev && prev->IsPlaceholderFrame()) { if (prev && prev->IsPlaceholderFrame()) {
auto* ph = static_cast<nsPlaceholderFrame*>(prev); auto ph = static_cast<nsPlaceholderFrame*>(prev);
if (ph->GetLineIsEmptySoFar(&allEmpty)) { if (ph->GetLineIsEmptySoFar(&allEmpty)) {
aPlaceholderFrame->SetLineIsEmptySoFar(allEmpty); aPlaceholderFrame->SetLineIsEmptySoFar(allEmpty);
} }
@@ -1416,24 +1422,8 @@ void ReflowInput::CalculateHypotheticalPosition(
// The current coordinate space is that of the nearest block to the // The current coordinate space is that of the nearest block to the
// placeholder. Convert to the coordinate space of the absolute containing // placeholder. Convert to the coordinate space of the absolute containing
// block. // block.
const nsIFrame* cbFrame = aCBReflowInput->mFrame; nsPoint cbOffset =
nsPoint cbOffset = containingBlock->GetOffsetToIgnoringScrolling(cbFrame); containingBlock->GetOffsetToIgnoringScrolling(aCBReflowInput->mFrame);
if (cbFrame->IsViewportFrame()) {
// When the containing block is the ViewportFrame, i.e. we are calculating
// the static position for a fixed-positioned frame, we need to adjust the
// origin to exclude the scrollbar or scrollbar-gutter area. The
// ViewportFrame's containing block rect is passed into
// nsAbsoluteContainingBlock::ReflowAbsoluteFrame(), and it will add the
// rect's origin to the fixed-positioned frame's final position if needed.
//
// Note: The origin of the containing block rect is adjusted in
// ViewportFrame::AdjustReflowInputForScrollbars(). Ensure the code there
// remains in sync with the logic here.
if (ScrollContainerFrame* sf = cbFrame->GetScrollTargetFrame()) {
const nsMargin scrollbarSizes = sf->GetActualScrollbarSizes();
cbOffset.MoveBy(-scrollbarSizes.left, -scrollbarSizes.top);
}
}
nsSize reflowSize = aCBReflowInput->ComputedSizeAsContainerIfConstrained(); nsSize reflowSize = aCBReflowInput->ComputedSizeAsContainerIfConstrained();
LogicalPoint logCBOffs(wm, cbOffset, reflowSize - containerSize); LogicalPoint logCBOffs(wm, cbOffset, reflowSize - containerSize);
@@ -1620,14 +1610,16 @@ LogicalSize ReflowInput::CalculateAbsoluteSizeWithResolvedAutoBlockSize(
return resultSize; return resultSize;
} }
void ReflowInput::InitAbsoluteConstraints(const ReflowInput* aCBReflowInput, void ReflowInput::InitAbsoluteConstraints(nsPresContext* aPresContext,
const LogicalSize& aCBSize) { const ReflowInput* aCBReflowInput,
const LogicalSize& aCBSize,
LayoutFrameType aFrameType) {
WritingMode wm = GetWritingMode(); WritingMode wm = GetWritingMode();
WritingMode cbwm = aCBReflowInput->GetWritingMode(); WritingMode cbwm = aCBReflowInput->GetWritingMode();
NS_WARNING_ASSERTION(aCBSize.BSize(cbwm) != NS_UNCONSTRAINEDSIZE, NS_WARNING_ASSERTION(aCBSize.BSize(cbwm) != NS_UNCONSTRAINEDSIZE,
"containing block bsize must be constrained"); "containing block bsize must be constrained");
NS_ASSERTION(!mFrame->IsTableFrame(), NS_ASSERTION(aFrameType != LayoutFrameType::Table,
"InitAbsoluteConstraints should not be called on table frames"); "InitAbsoluteConstraints should not be called on table frames");
NS_ASSERTION(mFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW), NS_ASSERTION(mFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW),
"Why are we here?"); "Why are we here?");
@@ -1638,9 +1630,9 @@ void ReflowInput::InitAbsoluteConstraints(const ReflowInput* aCBReflowInput,
bool bStartIsAuto = styleOffset.GetBStart(cbwm).IsAuto(); bool bStartIsAuto = styleOffset.GetBStart(cbwm).IsAuto();
bool bEndIsAuto = styleOffset.GetBEnd(cbwm).IsAuto(); bool bEndIsAuto = styleOffset.GetBEnd(cbwm).IsAuto();
// If both 'inline-start' and 'inline-end' are 'auto' or both 'block-start' // If both 'left' and 'right' are 'auto' or both 'top' and 'bottom' are
// and 'block-end' are 'auto', then compute the hypothetical box position; // 'auto', then compute the hypothetical box position where the element would
// i.e. where the element would be, if it were in-flow. // have been if it had been in the flow
nsHypotheticalPosition hypotheticalPos; nsHypotheticalPosition hypotheticalPos;
if ((iStartIsAuto && iEndIsAuto) || (bStartIsAuto && bEndIsAuto)) { if ((iStartIsAuto && iEndIsAuto) || (bStartIsAuto && bEndIsAuto)) {
nsPlaceholderFrame* placeholderFrame = mFrame->GetPlaceholderFrame(); nsPlaceholderFrame* placeholderFrame = mFrame->GetPlaceholderFrame();
@@ -1681,8 +1673,9 @@ void ReflowInput::InitAbsoluteConstraints(const ReflowInput* aCBReflowInput,
} }
} else { } else {
// XXXmats all this is broken for orthogonal writing-modes: bug 1521988. // XXXmats all this is broken for orthogonal writing-modes: bug 1521988.
CalculateHypotheticalPosition(placeholderFrame, aCBReflowInput, CalculateHypotheticalPosition(aPresContext, placeholderFrame,
hypotheticalPos); aCBReflowInput, hypotheticalPos,
aFrameType);
if (aCBReflowInput->mFrame->IsGridContainerFrame()) { if (aCBReflowInput->mFrame->IsGridContainerFrame()) {
// 'hypotheticalPos' is relative to the padding rect of the CB *frame*. // 'hypotheticalPos' is relative to the padding rect of the CB *frame*.
// In grid layout the CB is the grid area rectangle, so we translate // In grid layout the CB is the grid area rectangle, so we translate
@@ -1704,9 +1697,12 @@ void ReflowInput::InitAbsoluteConstraints(const ReflowInput* aCBReflowInput,
} }
} }
// Initialize the 'left' and 'right' computed offsets
// XXX Handle new 'static-position' value...
// Size of the containing block in its writing mode // Size of the containing block in its writing mode
LogicalSize cbSize = aCBSize; LogicalSize cbSize = aCBSize;
LogicalMargin offsets(cbwm); LogicalMargin offsets = ComputedLogicalOffsets(cbwm);
if (iStartIsAuto) { if (iStartIsAuto) {
offsets.IStart(cbwm) = 0; offsets.IStart(cbwm) = 0;
@@ -2326,8 +2322,9 @@ void ReflowInput::InitConstraints(
// XXXfr hack for making frames behave properly when in overflow // XXXfr hack for making frames behave properly when in overflow
// container lists, see bug 154892; need to revisit later // container lists, see bug 154892; need to revisit later
!mFrame->GetPrevInFlow()) { !mFrame->GetPrevInFlow()) {
InitAbsoluteConstraints(cbri, InitAbsoluteConstraints(aPresContext, cbri,
cbSize.ConvertTo(cbri->GetWritingMode(), wm)); cbSize.ConvertTo(cbri->GetWritingMode(), wm),
aFrameType);
} else { } else {
AutoMaybeDisableFontInflation an(mFrame); AutoMaybeDisableFontInflation an(mFrame);

View File

@@ -907,17 +907,16 @@ struct ReflowInput : public SizeComputationInput {
nscoord& aCBIStartEdge, nscoord& aCBIStartEdge,
mozilla::LogicalSize& aCBSize) const; mozilla::LogicalSize& aCBSize) const;
// Calculate the position of the hypothetical box that the placeholder frame // Calculate a "hypothetical box" position where the placeholder frame
// (for a position:fixed/absolute element) would be if it were in-flow (i.e., // (for a position:fixed/absolute element) would have been placed if it were
// positioned statically). // positioned statically. The hypothetical box position will have a writing
// // mode with the same block direction as the absolute containing block
// The position of the hypothetical box is relative to the padding edge of the // (aCBReflowInput->frame), though it may differ in inline direction.
// absolute containing block (aCBReflowInput->mFrame). The writing mode of the void CalculateHypotheticalPosition(nsPresContext* aPresContext,
// hypothetical box will have the same block direction as the absolute nsPlaceholderFrame* aPlaceholderFrame,
// containing block, but it may differ in the inline direction. const ReflowInput* aCBReflowInput,
void CalculateHypotheticalPosition( nsHypotheticalPosition& aHypotheticalPos,
nsPlaceholderFrame* aPlaceholderFrame, const ReflowInput* aCBReflowInput, mozilla::LayoutFrameType aFrameType) const;
nsHypotheticalPosition& aHypotheticalPos) const;
// Check if we can use the resolved auto block size (by insets) to compute // Check if we can use the resolved auto block size (by insets) to compute
// the inline size through aspect-ratio on absolute-positioned elements. // the inline size through aspect-ratio on absolute-positioned elements.
@@ -931,8 +930,10 @@ struct ReflowInput : public SizeComputationInput {
LogicalSize CalculateAbsoluteSizeWithResolvedAutoBlockSize( LogicalSize CalculateAbsoluteSizeWithResolvedAutoBlockSize(
nscoord aAutoBSize, const LogicalSize& aTentativeComputedSize); nscoord aAutoBSize, const LogicalSize& aTentativeComputedSize);
void InitAbsoluteConstraints(const ReflowInput* aCBReflowInput, void InitAbsoluteConstraints(nsPresContext* aPresContext,
const LogicalSize& aCBSize); const ReflowInput* aCBReflowInput,
const mozilla::LogicalSize& aContainingBlockSize,
mozilla::LayoutFrameType aFrameType);
// Calculates the computed values for the 'min-inline-size', // Calculates the computed values for the 'min-inline-size',
// 'max-inline-size', 'min-block-size', and 'max-block-size' properties, and // 'max-inline-size', 'min-block-size', and 'max-block-size' properties, and

View File

@@ -285,10 +285,10 @@ nscoord ViewportFrame::GetPrefISize(gfxContext* aRenderingContext) {
nsPoint ViewportFrame::AdjustReflowInputForScrollbars( nsPoint ViewportFrame::AdjustReflowInputForScrollbars(
ReflowInput* aReflowInput) const { ReflowInput* aReflowInput) const {
if (ScrollContainerFrame* scrollContainerFrame = GetScrollTargetFrame()) { // Get our prinicpal child frame and see if we're scrollable
// Note: In ReflowInput::CalculateHypotheticalPosition(), we exclude the nsIFrame* kidFrame = mFrames.FirstChild();
// scrollbar or scrollbar-gutter area when computing the offset to
// ViewportFrame. Ensure the code there remains in sync with the logic here. if (ScrollContainerFrame* scrollContainerFrame = do_QueryFrame(kidFrame)) {
WritingMode wm = aReflowInput->GetWritingMode(); WritingMode wm = aReflowInput->GetWritingMode();
LogicalMargin scrollbars(wm, LogicalMargin scrollbars(wm,
scrollContainerFrame->GetActualScrollbarSizes()); scrollContainerFrame->GetActualScrollbarSizes());
@@ -417,10 +417,6 @@ void ViewportFrame::Reflow(nsPresContext* aPresContext,
NS_FRAME_TRACE_REFLOW_OUT("ViewportFrame::Reflow", aStatus); NS_FRAME_TRACE_REFLOW_OUT("ViewportFrame::Reflow", aStatus);
} }
ScrollContainerFrame* ViewportFrame::GetScrollTargetFrame() const {
return do_QueryFrame(mFrames.FirstChild());
}
void ViewportFrame::UpdateStyle(ServoRestyleState& aRestyleState) { void ViewportFrame::UpdateStyle(ServoRestyleState& aRestyleState) {
RefPtr<ComputedStyle> newStyle = RefPtr<ComputedStyle> newStyle =
aRestyleState.StyleSet().ResolveInheritingAnonymousBoxStyle( aRestyleState.StyleSet().ResolveInheritingAnonymousBoxStyle(

View File

@@ -61,9 +61,6 @@ class ViewportFrame : public nsContainerFrame {
const ReflowInput& aReflowInput, const ReflowInput& aReflowInput,
nsReflowStatus& aStatus) override; nsReflowStatus& aStatus) override;
// Get the root scroll container frame, if any.
ScrollContainerFrame* GetScrollTargetFrame() const override;
bool ComputeCustomOverflow(mozilla::OverflowAreas&) override { return false; } bool ComputeCustomOverflow(mozilla::OverflowAreas&) override { return false; }
/** /**

View File

@@ -2011,14 +2011,17 @@ nscoord nsComputedDOMStyle::GetUsedAbsoluteOffset(mozilla::Side aSide) {
// _not_ include the scrollbars. For fixed positioned frames, // _not_ include the scrollbars. For fixed positioned frames,
// the containing block is the viewport, which _does_ include // the containing block is the viewport, which _does_ include
// scrollbars. We have to do some extra work. // scrollbars. We have to do some extra work.
if (ScrollContainerFrame* scrollContainerFrame = // the first child in the default frame list is what we want
container->GetScrollTargetFrame()) { nsIFrame* scrollingChild = container->PrincipalChildList().FirstChild();
ScrollContainerFrame* scrollContainerFrame = do_QueryFrame(scrollingChild);
if (scrollContainerFrame) {
scrollbarSizes = scrollContainerFrame->GetActualScrollbarSizes(); scrollbarSizes = scrollContainerFrame->GetActualScrollbarSizes();
} }
// The viewport size might have been expanded by the visual viewport or // The viewport size might have been expanded by the visual viewport or
// the minimum-scale size. // the minimum-scale size.
auto* viewportFrame = static_cast<ViewportFrame*>(container); const ViewportFrame* viewportFrame = do_QueryFrame(container);
MOZ_ASSERT(viewportFrame);
containerRect.SizeTo( containerRect.SizeTo(
viewportFrame->AdjustViewportSizeForFixedPosition(containerRect)); viewportFrame->AdjustViewportSizeForFixedPosition(containerRect));
} else if (container->IsGridContainerFrame() && } else if (container->IsGridContainerFrame() &&

View File

@@ -1,20 +0,0 @@
<!DOCTYPE html>
<title>CSS Overflow Reference: Root element's scrollbar-gutter is accounted for when computing hypothetical box in fixed-pos positioning</title>
<link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
<link rel="author" title="Mozilla" href="https://www.mozilla.org/">
<style>
:root {
scrollbar-gutter: stable both-edges;
}
body {
margin: 0;
}
.box {
width: 100px;
height: 100px;
background: green;
}
</style>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div class="box"></div>

View File

@@ -1,22 +0,0 @@
<!DOCTYPE html>
<title>CSS Overflow Test: Root element's scrollbar-gutter is accounted for when computing hypothetical box in fixed-pos positioning</title>
<link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
<link rel="author" title="Mozilla" href="https://www.mozilla.org/">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1901652">
<link rel="match" href="scrollbar-gutter-fixedpos-003-ref.html">
<style>
:root {
scrollbar-gutter: stable both-edges;
}
body {
margin: 0;
}
.box {
width: 100px;
height: 100px;
}
</style>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div class="box" style="position: fixed; background: green"></div>
<div class="box" style="background: red"></div>

View File

@@ -1,21 +0,0 @@
<!DOCTYPE html>
<title>CSS Overflow Reference: Root element's scrollbar-gutter is accounted for when computing hypothetical box in fixed-pos positioning</title>
<link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
<link rel="author" title="Mozilla" href="https://www.mozilla.org/">
<style>
:root {
scrollbar-gutter: stable both-edges;
writing-mode: vertical-lr;
}
body {
margin: 0;
}
.box {
width: 100px;
height: 100px;
background: green;
}
</style>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div class="box"></div>

View File

@@ -1,23 +0,0 @@
<!DOCTYPE html>
<title>CSS Overflow Test: Root element's scrollbar-gutter is accounted for when computing hypothetical box in fixed-pos positioning</title>
<link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
<link rel="author" title="Mozilla" href="https://www.mozilla.org/">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1901652">
<link rel="match" href="scrollbar-gutter-fixedpos-004-ref.html">
<style>
:root {
scrollbar-gutter: stable both-edges;
writing-mode: vertical-lr;
}
body {
margin: 0;
}
.box {
width: 100px;
height: 100px;
}
</style>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div class="box" style="position: fixed; background: green"></div>
<div class="box" style="background: red"></div>