Bug 1384542: Remove the use of GetParentAllowServo in nsFirstLetterFrame. r?heycam draft
authorBoris Zbarsky <bzbarsky@mit.edu>
Sat, 24 Jun 2017 03:17:37 -0400
changeset 618415 72fc2f08da3cc5e18afc926cd21f47e6215bff59
parent 618414 f5922a7ed25a9aa0683f57bb43e2a53709c385ee
child 618416 9f4aac621592b9a63cb43a2cee2bee40a387337c
push id71323
push userbmo:emilio+bugs@crisal.io
push dateMon, 31 Jul 2017 12:35:01 +0000
reviewersheycam
bugs1384542
milestone56.0a1
Bug 1384542: Remove the use of GetParentAllowServo in nsFirstLetterFrame. r?heycam MozReview-Commit-ID: Gt9MX8t3vUh
layout/generic/nsFirstLetterFrame.cpp
--- a/layout/generic/nsFirstLetterFrame.cpp
+++ b/layout/generic/nsFirstLetterFrame.cpp
@@ -54,23 +54,23 @@ void
 nsFirstLetterFrame::Init(nsIContent*       aContent,
                          nsContainerFrame* aParent,
                          nsIFrame*         aPrevInFlow)
 {
   RefPtr<nsStyleContext> newSC;
   if (aPrevInFlow) {
     // Get proper style context for ourselves.  We're creating the frame
     // that represents everything *except* the first letter, so just create
-    // a style context like we would for a text node.
-    nsStyleContext* parentStyleContext = mStyleContext->GetParentAllowServo();
-    if (parentStyleContext) {
-      newSC = PresContext()->StyleSet()->
-        ResolveStyleForFirstLetterContinuation(parentStyleContext);
-      SetStyleContextWithoutNotification(newSC);
-    }
+    // a style context that inherits from our style parent, with no extra rules.
+    nsIFrame* styleParent =
+      CorrectStyleParentFrame(aParent, nsCSSPseudoElements::firstLetter);
+    nsStyleContext* parentStyleContext = styleParent->StyleContext();
+    newSC = PresContext()->StyleSet()->
+      ResolveStyleForFirstLetterContinuation(parentStyleContext);
+    SetStyleContextWithoutNotification(newSC);
   }
 
   nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
 }
 
 void
 nsFirstLetterFrame::SetInitialChildList(ChildListID  aListID,
                                         nsFrameList& aChildList)
@@ -373,24 +373,33 @@ nsFirstLetterFrame::DrainOverflowFrames(
     mFrames.AppendFrames(nullptr, *overflowFrames);
   }
 
   // Now repair our first frames style context (since we only reflow
   // one frame there is no point in doing any other ones until they
   // are reflowed)
   nsIFrame* kid = mFrames.FirstChild();
   if (kid) {
-    RefPtr<nsStyleContext> sc;
     nsIContent* kidContent = kid->GetContent();
     if (kidContent) {
       NS_ASSERTION(kidContent->IsNodeOfType(nsINode::eTEXT),
                    "should contain only text nodes");
-      nsStyleContext* parentSC = prevInFlow ? mStyleContext->GetParentAllowServo() :
-                                              mStyleContext;
-      sc = aPresContext->StyleSet()->ResolveStyleForText(kidContent, parentSC);
+      nsStyleContext* parentSC;
+      if (prevInFlow) {
+        // This is for the rest of the content not in the first-letter.
+        nsIFrame* styleParent =
+          CorrectStyleParentFrame(GetParent(),
+                                  nsCSSPseudoElements::firstLetter);
+        parentSC = styleParent->StyleContext();
+      } else {
+        // And this for the first-letter style.
+        parentSC = mStyleContext;
+      }
+      RefPtr<nsStyleContext> sc =
+        aPresContext->StyleSet()->ResolveStyleForText(kidContent, parentSC);
       kid->SetStyleContext(sc);
       nsLayoutUtils::MarkDescendantsDirty(kid);
     }
   }
 }
 
 nscoord
 nsFirstLetterFrame::GetLogicalBaseline(WritingMode aWritingMode) const