diff --git a/layout/base/ServoRestyleManager.cpp b/layout/base/ServoRestyleManager.cpp index 375d9ca7b498..67ae61d2e7a0 100644 --- a/layout/base/ServoRestyleManager.cpp +++ b/layout/base/ServoRestyleManager.cpp @@ -250,22 +250,6 @@ private: nsChangeHint mComputedHint; }; -static void -UpdateBlockFramePseudoElements(nsBlockFrame* aFrame, - ServoRestyleState& aRestyleState) -{ - if (nsBulletFrame* bullet = aFrame->GetBullet()) { - RefPtr newContext = - aRestyleState.StyleSet().ResolvePseudoElementStyle( - aFrame->GetContent()->AsElement(), - bullet->StyleContext()->GetPseudoType(), - aFrame->StyleContext(), - /* aPseudoElement = */ nullptr); - - aFrame->UpdateStyleOfOwnedChildFrame(bullet, newContext, aRestyleState); - } -} - static void UpdateBackdropIfNeeded(nsIFrame* aFrame, ServoRestyleState& aRestyleState) { @@ -307,8 +291,7 @@ UpdateFramePseudoElementStyles(nsIFrame* aFrame, ServoRestyleState& aRestyleState) { if (aFrame->IsFrameOfType(nsIFrame::eBlockFrame)) { - UpdateBlockFramePseudoElements(static_cast(aFrame), - aRestyleState); + static_cast(aFrame)->UpdatePseudoElementStyles(aRestyleState); } UpdateBackdropIfNeeded(aFrame, aRestyleState); diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 78abb1b2ee59..9cb512a7e943 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -55,6 +55,8 @@ #include "nsISelection.h" #include "mozilla/dom/HTMLDetailsElement.h" #include "mozilla/dom/HTMLSummaryElement.h" +#include "mozilla/ServoRestyleManager.h" +#include "mozilla/ServoStyleSet.h" #include "mozilla/StyleSetHandle.h" #include "mozilla/StyleSetHandleInlines.h" #include "mozilla/Telemetry.h" @@ -7079,14 +7081,8 @@ nsBlockFrame::CreateBulletFrameForListItem(bool aCreateBulletList, CSSPseudoElementType::mozListBullet : CSSPseudoElementType::mozListNumber; - nsStyleContext* parentStyle = - CorrectStyleParentFrame(this, - nsCSSPseudoElements::GetPseudoAtom(pseudoType))-> - StyleContext(); - - RefPtr kidSC = shell->StyleSet()-> - ResolvePseudoElementStyle(mContent->AsElement(), pseudoType, - parentStyle, nullptr); + RefPtr kidSC = ResolveBulletStyle(pseudoType, + shell->StyleSet()); // Create bullet frame nsBulletFrame* bullet = new (shell) nsBulletFrame(kidSC); @@ -7519,6 +7515,30 @@ nsBlockFrame::ResolveBidi() return nsBidiPresUtils::Resolve(this); } +void +nsBlockFrame::UpdatePseudoElementStyles(ServoRestyleState& aRestyleState) +{ + if (nsBulletFrame* bullet = GetBullet()) { + CSSPseudoElementType type = bullet->StyleContext()->GetPseudoType(); + RefPtr newBulletStyle = + ResolveBulletStyle(type, &aRestyleState.StyleSet()); + UpdateStyleOfOwnedChildFrame(bullet, newBulletStyle, aRestyleState); + } +} + +already_AddRefed +nsBlockFrame::ResolveBulletStyle(CSSPseudoElementType aType, + StyleSetHandle aStyleSet) +{ + nsStyleContext* parentStyle = + CorrectStyleParentFrame(this, + nsCSSPseudoElements::GetPseudoAtom(aType))-> + StyleContext(); + + return aStyleSet->ResolvePseudoElementStyle(mContent->AsElement(), aType, + parentStyle, nullptr); +} + #ifdef DEBUG void nsBlockFrame::VerifyLines(bool aFinalCheckOK) diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index 3890639ec7ea..65219bf6b26c 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -44,6 +44,8 @@ class nsBlockInFlowLineIterator; class nsBulletFrame; namespace mozilla { class BlockReflowInput; +class ServoRestyleState; +class StyleSetHandle; } // namespace mozilla /** @@ -395,6 +397,12 @@ public: nsFrameList mFrames; }; + /** + * Update the styles of our various pseudo-elements (bullets, first-letter, + * first-line, etc). + */ + void UpdatePseudoElementStyles(mozilla::ServoRestyleState& aRestyleState); + protected: explicit nsBlockFrame(nsStyleContext* aContext, ClassID aID = kClassID) : nsContainerFrame(aContext, aID) @@ -903,6 +911,13 @@ protected: // Remove and return the pushed floats list. nsFrameList* RemovePushedFloats(); + // Resolve a style context for our bullet frame. aType should be + // mozListBullet or mozListNumber. Passing in the style set is an + // optimization, because all callsites have it. + already_AddRefed ResolveBulletStyle( + mozilla::CSSPseudoElementType aType, + mozilla::StyleSetHandle aStyleSet); + #ifdef DEBUG void VerifyLines(bool aFinalCheckOK); void VerifyOverflowSituation(); diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 9d54f99beeea..8d3d0328aabe 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -10231,6 +10231,17 @@ nsIFrame::UpdateStyleOfChildAnonBox(nsIFrame* aChildFrame, // has anon boxes to deal with. ServoRestyleState childrenState(aRestyleState, childHint); aChildFrame->UpdateStyleOfOwnedAnonBoxes(childrenState); + + // Assuming anon boxes don't have ::backdrop associated with them... if that + // ever changes, we'd need to handle that here, like we do in + // ServoRestyleManager::ProcessPostTraversal + + // We do need to handle block pseudo-elements here, though. Especially list + // bullets. + if (aChildFrame->IsFrameOfType(nsIFrame::eBlockFrame)) { + auto block = static_cast(aChildFrame); + block->UpdatePseudoElementStyles(childrenState); + } } nsChangeHint diff --git a/layout/reftests/bugs/1375315-1-ref.html b/layout/reftests/bugs/1375315-1-ref.html new file mode 100644 index 000000000000..b216c7dd4a39 --- /dev/null +++ b/layout/reftests/bugs/1375315-1-ref.html @@ -0,0 +1,6 @@ + +
    +
  • + Bullet should be green. +
  • +
diff --git a/layout/reftests/bugs/1375315-1.html b/layout/reftests/bugs/1375315-1.html new file mode 100644 index 000000000000..9fc5e427c85f --- /dev/null +++ b/layout/reftests/bugs/1375315-1.html @@ -0,0 +1,12 @@ + + +
    +
  • + Bullet should be green. +
  • +
diff --git a/layout/reftests/bugs/1375315-10-ref.html b/layout/reftests/bugs/1375315-10-ref.html new file mode 100644 index 000000000000..c20ec6f128cc --- /dev/null +++ b/layout/reftests/bugs/1375315-10-ref.html @@ -0,0 +1,4 @@ + + diff --git a/layout/reftests/bugs/1375315-10.html b/layout/reftests/bugs/1375315-10.html new file mode 100644 index 000000000000..5c2d7cb87f8e --- /dev/null +++ b/layout/reftests/bugs/1375315-10.html @@ -0,0 +1,10 @@ + + + diff --git a/layout/reftests/bugs/1375315-11-ref.html b/layout/reftests/bugs/1375315-11-ref.html new file mode 100644 index 000000000000..f9f095a087e7 --- /dev/null +++ b/layout/reftests/bugs/1375315-11-ref.html @@ -0,0 +1,4 @@ + + diff --git a/layout/reftests/bugs/1375315-11.html b/layout/reftests/bugs/1375315-11.html new file mode 100644 index 000000000000..6a5cc680a6d5 --- /dev/null +++ b/layout/reftests/bugs/1375315-11.html @@ -0,0 +1,10 @@ + + + diff --git a/layout/reftests/bugs/1375315-12-ref.html b/layout/reftests/bugs/1375315-12-ref.html new file mode 100644 index 000000000000..1ad5e52f9c70 --- /dev/null +++ b/layout/reftests/bugs/1375315-12-ref.html @@ -0,0 +1,5 @@ + + diff --git a/layout/reftests/bugs/1375315-12.html b/layout/reftests/bugs/1375315-12.html new file mode 100644 index 000000000000..b54b0a6a1a77 --- /dev/null +++ b/layout/reftests/bugs/1375315-12.html @@ -0,0 +1,11 @@ + + + diff --git a/layout/reftests/bugs/1375315-2-ref.html b/layout/reftests/bugs/1375315-2-ref.html new file mode 100644 index 000000000000..ef0edae2e4a2 --- /dev/null +++ b/layout/reftests/bugs/1375315-2-ref.html @@ -0,0 +1,6 @@ + +
    +
  • + Bullet should be green. +
  • +
diff --git a/layout/reftests/bugs/1375315-2.html b/layout/reftests/bugs/1375315-2.html new file mode 100644 index 000000000000..6ed35961fdff --- /dev/null +++ b/layout/reftests/bugs/1375315-2.html @@ -0,0 +1,12 @@ + + +
    +
  • + Bullet should be green. +
  • +
diff --git a/layout/reftests/bugs/1375315-3-ref.html b/layout/reftests/bugs/1375315-3-ref.html new file mode 100644 index 000000000000..97c5418ddbdd --- /dev/null +++ b/layout/reftests/bugs/1375315-3-ref.html @@ -0,0 +1,6 @@ + +
    +
  • + Bullet should be green. +
  • +
diff --git a/layout/reftests/bugs/1375315-3.html b/layout/reftests/bugs/1375315-3.html new file mode 100644 index 000000000000..021f9336a653 --- /dev/null +++ b/layout/reftests/bugs/1375315-3.html @@ -0,0 +1,12 @@ + + +
    +
  • + Bullet should be green. +
  • +
diff --git a/layout/reftests/bugs/1375315-4-ref.html b/layout/reftests/bugs/1375315-4-ref.html new file mode 100644 index 000000000000..97c5418ddbdd --- /dev/null +++ b/layout/reftests/bugs/1375315-4-ref.html @@ -0,0 +1,6 @@ + +
    +
  • + Bullet should be green. +
  • +
diff --git a/layout/reftests/bugs/1375315-4.html b/layout/reftests/bugs/1375315-4.html new file mode 100644 index 000000000000..021f9336a653 --- /dev/null +++ b/layout/reftests/bugs/1375315-4.html @@ -0,0 +1,12 @@ + + +
    +
  • + Bullet should be green. +
  • +
diff --git a/layout/reftests/bugs/1375315-5-ref.html b/layout/reftests/bugs/1375315-5-ref.html new file mode 100644 index 000000000000..399019718221 --- /dev/null +++ b/layout/reftests/bugs/1375315-5-ref.html @@ -0,0 +1,5 @@ + +
+ Bullet should be green. +
diff --git a/layout/reftests/bugs/1375315-5.html b/layout/reftests/bugs/1375315-5.html new file mode 100644 index 000000000000..fe5e0de5cdff --- /dev/null +++ b/layout/reftests/bugs/1375315-5.html @@ -0,0 +1,11 @@ + + +
+ Bullet should be green. +
diff --git a/layout/reftests/bugs/1375315-6-ref.html b/layout/reftests/bugs/1375315-6-ref.html new file mode 100644 index 000000000000..5e039354f909 --- /dev/null +++ b/layout/reftests/bugs/1375315-6-ref.html @@ -0,0 +1,5 @@ + +
+ Bullet should be green. +
diff --git a/layout/reftests/bugs/1375315-6.html b/layout/reftests/bugs/1375315-6.html new file mode 100644 index 000000000000..8fa1b418b0be --- /dev/null +++ b/layout/reftests/bugs/1375315-6.html @@ -0,0 +1,11 @@ + + +
+ Bullet should be green. +
diff --git a/layout/reftests/bugs/1375315-7-ref.html b/layout/reftests/bugs/1375315-7-ref.html new file mode 100644 index 000000000000..bc2a7d83d468 --- /dev/null +++ b/layout/reftests/bugs/1375315-7-ref.html @@ -0,0 +1,4 @@ + +
+ Bullet should be green +
diff --git a/layout/reftests/bugs/1375315-7.html b/layout/reftests/bugs/1375315-7.html new file mode 100644 index 000000000000..34ec338d161b --- /dev/null +++ b/layout/reftests/bugs/1375315-7.html @@ -0,0 +1,10 @@ + + +
+ Bullet should be green +
diff --git a/layout/reftests/bugs/1375315-8-ref.html b/layout/reftests/bugs/1375315-8-ref.html new file mode 100644 index 000000000000..36752162c54c --- /dev/null +++ b/layout/reftests/bugs/1375315-8-ref.html @@ -0,0 +1,4 @@ + +
+ Bullet should be green +
diff --git a/layout/reftests/bugs/1375315-8.html b/layout/reftests/bugs/1375315-8.html new file mode 100644 index 000000000000..8b8ec1bd72c1 --- /dev/null +++ b/layout/reftests/bugs/1375315-8.html @@ -0,0 +1,10 @@ + + +
+ Bullet should be green +
diff --git a/layout/reftests/bugs/1375315-9-ref.html b/layout/reftests/bugs/1375315-9-ref.html new file mode 100644 index 000000000000..4ee2a8fdca09 --- /dev/null +++ b/layout/reftests/bugs/1375315-9-ref.html @@ -0,0 +1,4 @@ + +
+ Bullet should be green +
diff --git a/layout/reftests/bugs/1375315-9.html b/layout/reftests/bugs/1375315-9.html new file mode 100644 index 000000000000..ff93e1eb26a2 --- /dev/null +++ b/layout/reftests/bugs/1375315-9.html @@ -0,0 +1,10 @@ + + +
+ Bullet should be green +
diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index 77ee93dfb7c1..729d2a32a3fa 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -2015,4 +2015,16 @@ fails-if(!stylo||styloVsGecko) == 1365162-1.html 1365162-1-ref.html == 1369954-1.xhtml 1369954-1-ref.xhtml == 1369985-1.html 1369985-1-ref.html == 1371130.xhtml 1371130-ref.xhtml +== 1375315-1.html 1375315-1-ref.html +== 1375315-2.html 1375315-2-ref.html +== 1375315-3.html 1375315-3-ref.html +== 1375315-4.html 1375315-4-ref.html +== 1375315-5.html 1375315-5-ref.html +== 1375315-6.html 1375315-6-ref.html +== 1375315-7.html 1375315-7-ref.html +== 1375315-8.html 1375315-8-ref.html +== 1375315-9.html 1375315-9-ref.html +== 1375315-10.html 1375315-10-ref.html +== 1375315-11.html 1375315-11-ref.html +== 1375315-12.html 1375315-12-ref.html == 1374062.html 1374062-ref.html