From 7642040d1baef0d97b5d72973cdafb483d102254 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Tue, 7 Aug 2018 15:02:07 -0700 Subject: [PATCH] Bug 1479859 patch 1 - Make inline frames be abs-pos containing blocks for reasons other than being relatively positioned. r=emilio The basic change here is making nsCSSFrameConstructor::ConstructInline use the function nsIFrame::IsAbsPosContainingBlock rather than testing for only one of the conditions in it (being relatively or absolutely positioned). The rest of the code changes follow from that change. I tested locally that the added test fails without the patch and passes with it (either with or without the next patch). Note that this causes a regression of three web-platform-test reftests: testing/web-platform/tests/css/css-contain/contain-paint-002.html testing/web-platform/tests/css/css-contain/contain-paint-011.html testing/web-platform/tests/css/css-contain/contain-paint-012.html which will be fixed in patch 4, since that fix is easier to write after patch 2. Differential Revision: https://phabricator.services.mozilla.com/D2813 --HG-- extra : rebase_source : 0d374628207c234bcd7cf4e320188994fc2680b8 --- layout/base/nsCSSFrameConstructor.cpp | 20 +++++------ testing/web-platform/meta/MANIFEST.json | 25 ++++++++++++++ .../filtered-inline-is-container.html.ini | 2 -- .../filter-cb-abspos-inline-001-ref.html | 28 ++++++++++++++++ .../filter-cb-abspos-inline-001.html | 33 +++++++++++++++++++ 5 files changed, 95 insertions(+), 13 deletions(-) delete mode 100644 testing/web-platform/meta/css/css-filter/filtered-inline-is-container.html.ini create mode 100644 testing/web-platform/tests/css/filter-effects/filter-cb-abspos-inline-001-ref.html create mode 100644 testing/web-platform/tests/css/filter-effects/filter-cb-abspos-inline-001.html diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 121cc20da887..da76a9e37f54 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -6247,9 +6247,9 @@ nsCSSFrameConstructor::AppendFramesToParent(nsFrameConstructorState& aStat } if (!aFrameList.IsEmpty()) { - bool positioned = aParentFrame->IsRelativelyPositioned(); nsFrameItems ibSiblings; - CreateIBSiblings(aState, aParentFrame, positioned, aFrameList, + CreateIBSiblings(aState, aParentFrame, + aParentFrame->IsAbsPosContainingBlock(), aFrameList, ibSiblings); // Make sure to trigger reflow of the inline that used to be our @@ -11118,11 +11118,6 @@ nsCSSFrameConstructor::ConstructInline(nsFrameConstructorState& aState, nsIContent* const content = aItem.mContent; ComputedStyle* const computedStyle = aItem.mComputedStyle; - bool positioned = - StyleDisplay::Inline == aDisplay->mDisplay && - aDisplay->IsRelativelyPositionedStyle() && - !nsSVGUtils::IsInSVGTextSubtree(aParentFrame); - nsInlineFrame* newFrame = NS_NewInlineFrame(mPresShell, computedStyle); // Initialize the frame @@ -11132,8 +11127,9 @@ nsCSSFrameConstructor::ConstructInline(nsFrameConstructorState& aState, // because the object's destructor is significant // this is part of the fix for bug 42372 + bool isAbsPosCB = newFrame->IsAbsPosContainingBlock(); newFrame->AddStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN); - if (positioned) { + if (isAbsPosCB) { // Relatively positioned frames becomes a container for child // frames that are positioned aState.PushAbsoluteContainingBlock(newFrame, newFrame, absoluteSaveState); @@ -11172,7 +11168,7 @@ nsCSSFrameConstructor::ConstructInline(nsFrameConstructorState& aState, aFrameItems.AddChild(newFrame); newFrame->AddStateBits(NS_FRAME_OWNS_ANON_BOXES); - CreateIBSiblings(aState, newFrame, positioned, childItems, aFrameItems); + CreateIBSiblings(aState, newFrame, isAbsPosCB, childItems, aFrameItems); return newFrame; } @@ -11180,10 +11176,12 @@ nsCSSFrameConstructor::ConstructInline(nsFrameConstructorState& aState, void nsCSSFrameConstructor::CreateIBSiblings(nsFrameConstructorState& aState, nsContainerFrame* aInitialInline, - bool aIsPositioned, + bool aIsAbsPosCB, nsFrameItems& aChildItems, nsFrameItems& aSiblings) { + MOZ_ASSERT(aIsAbsPosCB == aInitialInline->IsAbsPosContainingBlock()); + nsIContent* content = aInitialInline->GetContent(); ComputedStyle* computedStyle = aInitialInline->Style(); nsContainerFrame* parentFrame = aInitialInline->GetParent(); @@ -11231,7 +11229,7 @@ nsCSSFrameConstructor::CreateIBSiblings(nsFrameConstructorState& aState, nsInlineFrame* inlineFrame = NS_NewInlineFrame(mPresShell, computedStyle); InitAndRestoreFrame(aState, content, parentFrame, inlineFrame, false); inlineFrame->AddStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN); - if (aIsPositioned) { + if (aIsAbsPosCB) { inlineFrame->MarkAsAbsoluteContainingBlock(); } diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index 571fec1376d3..d433a411df72 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -163681,6 +163681,18 @@ {} ] ], + "css/filter-effects/filter-cb-abspos-inline-001.html": [ + [ + "/css/filter-effects/filter-cb-abspos-inline-001.html", + [ + [ + "/css/filter-effects/filter-cb-abspos-inline-001-ref.html", + "==" + ] + ], + {} + ] + ], "css/filter-effects/filter-contrast-001.html": [ [ "/css/filter-effects/filter-contrast-001.html", @@ -266007,6 +266019,11 @@ {} ] ], + "css/filter-effects/filter-cb-abspos-inline-001-ref.html": [ + [ + {} + ] + ], "css/filter-effects/filter-contrast-001-ref.html": [ [ {} @@ -563604,6 +563621,14 @@ "8caaede02f27a120278d9d1512084e6fd57ab27f", "reftest" ], + "css/filter-effects/filter-cb-abspos-inline-001-ref.html": [ + "6ebe4635511242cd0f5965a778a5a491cc406436", + "support" + ], + "css/filter-effects/filter-cb-abspos-inline-001.html": [ + "6f99c48d5f34761ba1bc1ce7dbdfd927469ac65a", + "reftest" + ], "css/filter-effects/filter-contrast-001-ref.html": [ "1be00e8bba72ed3203819cb51586947535ac5096", "support" diff --git a/testing/web-platform/meta/css/css-filter/filtered-inline-is-container.html.ini b/testing/web-platform/meta/css/css-filter/filtered-inline-is-container.html.ini deleted file mode 100644 index b41a8df9ac07..000000000000 --- a/testing/web-platform/meta/css/css-filter/filtered-inline-is-container.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[filtered-inline-is-container.html] - expected: FAIL diff --git a/testing/web-platform/tests/css/filter-effects/filter-cb-abspos-inline-001-ref.html b/testing/web-platform/tests/css/filter-effects/filter-cb-abspos-inline-001-ref.html new file mode 100644 index 000000000000..6ebe46355112 --- /dev/null +++ b/testing/web-platform/tests/css/filter-effects/filter-cb-abspos-inline-001-ref.html @@ -0,0 +1,28 @@ + + +CSS Filter: Establishing containing block for absolutely-positioned elements, on an inline element + + + + + +

Filler text.

+ +
+ Blue box should cover top-left corner of this sentence. +
diff --git a/testing/web-platform/tests/css/filter-effects/filter-cb-abspos-inline-001.html b/testing/web-platform/tests/css/filter-effects/filter-cb-abspos-inline-001.html new file mode 100644 index 000000000000..6f99c48d5f34 --- /dev/null +++ b/testing/web-platform/tests/css/filter-effects/filter-cb-abspos-inline-001.html @@ -0,0 +1,33 @@ + + +CSS Filter: Establishing containing block for absolutely-positioned elements, on an inline element + + + + + + + + + + +

Filler text.

+ +
+ Blue box should cover top-left corner of this sentence. +