From 06a153ffc1318296af7bad986e8365cc590369c2 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 28 Mar 2017 21:26:31 -0400 Subject: [PATCH] Bug 1351139. Use only one kind of anonymous box for the block wrappers we create for a block-inside-inline split. r=dbaron Note that this removes the useless (because this anon box is never absolutely positioned) "clip: inherit" style. MozReview-Commit-ID: iJJdv5VL06 --HG-- extra : rebase_source : d7a8697a89391eb6a80683dcbe8e3fa6f76c6a41 --- layout/base/nsCSSFrameConstructor.cpp | 6 ++---- layout/base/nsLayoutUtils.cpp | 6 ++---- layout/generic/nsFrame.cpp | 23 ++++++++------------ layout/generic/nsInlineFrame.cpp | 13 ++++++------ layout/style/nsCSSAnonBoxList.h | 3 +-- layout/style/res/ua.css | 30 +++++++++++++-------------- 6 files changed, 35 insertions(+), 46 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 67898edf4e00..72496df968e2 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -12256,10 +12256,8 @@ nsCSSFrameConstructor::CreateIBSiblings(nsFrameConstructorState& aState, // resulting translation also affects the block-level box contained // in the inline box. RefPtr blockSC = mPresShell->StyleSet()-> - ResolveInheritingAnonymousBoxStyle(aIsPositioned ? - nsCSSAnonBoxes::mozAnonymousPositionedBlock : - nsCSSAnonBoxes::mozAnonymousBlock, - styleContext); + ResolveInheritingAnonymousBoxStyle(nsCSSAnonBoxes::mozBlockInsideInlineWrapper, + styleContext); nsContainerFrame* lastNewInline = static_cast(aInitialInline->FirstContinuation()); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index b43b3ef12197..772d9c5289dc 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -3951,8 +3951,7 @@ AddBoxesForFrame(nsIFrame* aFrame, AddBoxesForFrame(kid, aCallback); } } - } else if (pseudoType == nsCSSAnonBoxes::mozAnonymousBlock || - pseudoType == nsCSSAnonBoxes::mozAnonymousPositionedBlock || + } else if (pseudoType == nsCSSAnonBoxes::mozBlockInsideInlineWrapper || pseudoType == nsCSSAnonBoxes::mozMathMLAnonymousBlock || pseudoType == nsCSSAnonBoxes::mozXULAnonymousBlock) { for (nsIFrame* kid : aFrame->PrincipalChildList()) { @@ -3990,8 +3989,7 @@ nsLayoutUtils::GetFirstNonAnonymousFrame(nsIFrame* aFrame) return f; } } - } else if (pseudoType == nsCSSAnonBoxes::mozAnonymousBlock || - pseudoType == nsCSSAnonBoxes::mozAnonymousPositionedBlock || + } else if (pseudoType == nsCSSAnonBoxes::mozBlockInsideInlineWrapper || pseudoType == nsCSSAnonBoxes::mozMathMLAnonymousBlock || pseudoType == nsCSSAnonBoxes::mozXULAnonymousBlock) { for (nsIFrame* kid : aFrame->PrincipalChildList()) { diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 99da3979d8fb..d8e32a9a5c38 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -6910,8 +6910,7 @@ bool nsIFrame::IsBlockWrapper() const { nsIAtom *pseudoType = StyleContext()->GetPseudo(); - return (pseudoType == nsCSSAnonBoxes::mozAnonymousBlock || - pseudoType == nsCSSAnonBoxes::mozAnonymousPositionedBlock || + return (pseudoType == nsCSSAnonBoxes::mozBlockInsideInlineWrapper || pseudoType == nsCSSAnonBoxes::buttonContent || pseudoType == nsCSSAnonBoxes::cellContent); } @@ -8817,17 +8816,15 @@ ComputeAndIncludeOutlineArea(nsIFrame* aFrame, nsOverflowAreas& aOverflowAreas, return; } - // When the outline property is set on :-moz-anonymous-block or - // :-moz-anonymous-positioned-block pseudo-elements, it inherited - // that outline from the inline that was broken because it - // contained a block. In that case, we don't want a really wide - // outline if the block inside the inline is narrow, so union the - // actual contents of the anonymous blocks. + // When the outline property is set on a :-moz-block-inside-inline-wrapper + // pseudo-element, it inherited that outline from the inline that was broken + // because it contained a block. In that case, we don't want a really wide + // outline if the block inside the inline is narrow, so union the actual + // contents of the anonymous blocks. nsIFrame *frameForArea = aFrame; do { nsIAtom *pseudoType = frameForArea->StyleContext()->GetPseudo(); - if (pseudoType != nsCSSAnonBoxes::mozAnonymousBlock && - pseudoType != nsCSSAnonBoxes::mozAnonymousPositionedBlock) + if (pseudoType != nsCSSAnonBoxes::mozBlockInsideInlineWrapper) break; // If we're done, we really want it and all its later siblings. frameForArea = frameForArea->PrincipalChildList().FirstChild(); @@ -9177,8 +9174,7 @@ GetIBSplitSiblingForAnonymousBlock(const nsIFrame* aFrame) "GetIBSplitSibling should only be called on ib-split frames"); nsIAtom* type = aFrame->StyleContext()->GetPseudo(); - if (type != nsCSSAnonBoxes::mozAnonymousBlock && - type != nsCSSAnonBoxes::mozAnonymousPositionedBlock) { + if (type != nsCSSAnonBoxes::mozBlockInsideInlineWrapper) { // it's not an anonymous block return nullptr; } @@ -9279,8 +9275,7 @@ nsFrame::CorrectStyleParentFrame(nsIFrame* aProspectiveParent, // for non-elements. Those should not be treated as an anon box. if (!nsCSSAnonBoxes::IsNonElement(aChildPseudo) && nsCSSAnonBoxes::IsAnonBox(aChildPseudo)) { - NS_ASSERTION(aChildPseudo != nsCSSAnonBoxes::mozAnonymousBlock && - aChildPseudo != nsCSSAnonBoxes::mozAnonymousPositionedBlock, + NS_ASSERTION(aChildPseudo != nsCSSAnonBoxes::mozBlockInsideInlineWrapper, "Should have dealt with kids that have " "NS_FRAME_PART_OF_IBSPLIT elsewhere"); return aProspectiveParent; diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index 0fb323d72028..09106dbe7061 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -1049,15 +1049,11 @@ nsInlineFrame::DoUpdateStyleOfOwnedAnonBoxes(ServoStyleSet& aStyleSet, nsIFrame* blockFrame = propTable->Get(this, nsIFrame::IBSplitSibling()); MOZ_ASSERT(blockFrame, "Why did we have an IB split?"); - nsIAtom* pseudo = blockFrame->StyleContext()->GetPseudo(); - MOZ_ASSERT(pseudo == nsCSSAnonBoxes::mozAnonymousBlock || - pseudo == nsCSSAnonBoxes::mozAnonymousPositionedBlock, - "Unexpected kind of style context"); - // The anonymous block's style inherits from ours, and we already have our new // style context. RefPtr newContext = - aStyleSet.ResolveInheritingAnonymousBoxStyle(pseudo, StyleContext()); + aStyleSet.ResolveInheritingAnonymousBoxStyle( + nsCSSAnonBoxes::mozBlockInsideInlineWrapper, StyleContext()); // We're guaranteed that newContext only differs from the old style context on // the block in things they might inherit from us. And changehint processing @@ -1068,6 +1064,11 @@ nsInlineFrame::DoUpdateStyleOfOwnedAnonBoxes(ServoStyleSet& aStyleSet, while (blockFrame) { MOZ_ASSERT(!blockFrame->GetPrevContinuation(), "Must be first continuation"); + + MOZ_ASSERT(blockFrame->StyleContext()->GetPseudo() == + nsCSSAnonBoxes::mozBlockInsideInlineWrapper, + "Unexpected kind of style context"); + // We _could_ just walk along using GetNextContinuationWithSameStyle here, // but it would involve going back to the first continuation every so often, // which is a bit silly when we can just keep track of our first diff --git a/layout/style/nsCSSAnonBoxList.h b/layout/style/nsCSSAnonBoxList.h index 6a87b3b439d3..bbdfcb25dd2b 100644 --- a/layout/style/nsCSSAnonBoxList.h +++ b/layout/style/nsCSSAnonBoxList.h @@ -42,8 +42,7 @@ CSS_NON_INHERITING_ANON_BOX(oofPlaceholder, ":-moz-oof-placeholder") // nsFirstLetterFrames for content outside the ::first-letter. CSS_ANON_BOX(firstLetterContinuation, ":-moz-first-letter-continuation") -CSS_ANON_BOX(mozAnonymousBlock, ":-moz-anonymous-block") -CSS_ANON_BOX(mozAnonymousPositionedBlock, ":-moz-anonymous-positioned-block") +CSS_ANON_BOX(mozBlockInsideInlineWrapper, ":-moz-block-inside-inline-wrapper") CSS_ANON_BOX(mozMathMLAnonymousBlock, ":-moz-mathml-anonymous-block") CSS_ANON_BOX(mozXULAnonymousBlock, ":-moz-xul-anonymous-block") diff --git a/layout/style/res/ua.css b/layout/style/res/ua.css index 8b4e923da3bf..812df1c6f95c 100644 --- a/layout/style/res/ua.css +++ b/layout/style/res/ua.css @@ -132,7 +132,7 @@ /* Miscellaneous */ -*|*::-moz-anonymous-block, *|*::-moz-cell-content { +*|*::-moz-cell-content { display: block !important; position: static !important; unicode-bidi: inherit; @@ -140,8 +140,10 @@ overflow-clip-box: inherit; } -*|*::-moz-anonymous-block, *|*::-moz-anonymous-positioned-block { +*|*::-moz-block-inside-inline-wrapper { + display: block !important; /* we currently inherit from the inline that is split */ + position: inherit; /* static or relative or sticky */ outline: inherit; outline-offset: inherit; clip-path: inherit; @@ -151,6 +153,16 @@ text-decoration: inherit; -moz-box-ordinal-group: inherit !important; overflow-clip-box: inherit; + unicode-bidi: inherit; + text-overflow: inherit; + /* The properties below here don't apply if our position is static, + and we do want them to have an effect it it's not, so it's fine + to always inherit them. */ + top: inherit; + left: inherit; + bottom: inherit; + right: inherit; + z-index: inherit; } *|*::-moz-xul-anonymous-block { @@ -268,20 +280,6 @@ display: block !important; } -*|*::-moz-anonymous-positioned-block { - display: block !important; - position: inherit; /* relative or sticky */ - top: inherit; - left: inherit; - bottom: inherit; - right: inherit; - z-index: inherit; - clip: inherit; - opacity: inherit; - unicode-bidi: inherit; - text-overflow: inherit; -} - /* Printing */ @media print {