Bug 1322570 Part 7 - Use GetParentAllowServo() in nsMathMLChar. draft
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 20 Mar 2017 14:14:30 +0800
changeset 504315 7a183183e8561c99c7d6e943be04cae4986312ad
parent 504314 6e585573c65944ed4f9cda2fbbf121b6a9ed6ed4
child 504316 d9748087105620e13ee472e84e15122d37dfc4a5
push id50776
push userbmo:tlin@mozilla.com
push dateFri, 24 Mar 2017 06:09:16 +0000
bugs1322570, 347348
milestone55.0a1
Bug 1322570 Part 7 - Use GetParentAllowServo() in nsMathMLChar. The nsMathMLChar has SetStyleContext() that can change nsStyleContext. It's not obvious how to get parent style context other than calling GetParent(). So white-list this case for now. Fixed tests like layout/reftests/bugs/347348-1.xhtml. MozReview-Commit-ID: JZU1IzcMxs8
layout/mathml/nsMathMLChar.cpp
--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -1516,17 +1516,17 @@ nsMathMLChar::StretchInternal(nsPresCont
   // if we have been called before, and we didn't actually stretch, our
   // direction may have been set to NS_STRETCH_DIRECTION_UNSUPPORTED.
   // So first set our direction back to its instrinsic value
   nsStretchDirection direction = nsMathMLOperators::GetStretchyDirection(mData);
 
   // Set default font and get the default bounding metrics
   // mStyleContext is a leaf context used only when stretching happens.
   // For the base size, the default font should come from the parent context
-  nsFont font = mStyleContext->GetParent()->StyleFont()->mFont;
+  nsFont font = mStyleContext->GetParentAllowServo()->StyleFont()->mFont;
   NormalizeDefaultFont(font, aFontSizeInflation);
 
   const nsStyleFont* styleFont = mStyleContext->StyleFont();
   nsFontMetrics::Params params;
   params.language = styleFont->mLanguage;
   params.explicitLanguage = styleFont->mExplicitLanguage;
   params.userFontSet = aPresContext->GetUserFontSet();
   params.textPerf = aPresContext->GetTextPerfMetrics();
@@ -1956,17 +1956,17 @@ void nsDisplayMathMLCharDebug::Paint(nsD
 
 void
 nsMathMLChar::Display(nsDisplayListBuilder*   aBuilder,
                       nsIFrame*               aForFrame,
                       const nsDisplayListSet& aLists,
                       uint32_t                aIndex,
                       const nsRect*           aSelectedRect)
 {
-  nsStyleContext* parentContext = mStyleContext->GetParent();
+  nsStyleContext* parentContext = mStyleContext->GetParentAllowServo();
   nsStyleContext* styleContext = mStyleContext;
 
   if (mDraw == DRAW_NORMAL) {
     // normal drawing if there is nothing special about this char
     // Set default context to the parent context
     styleContext = parentContext;
   }
 
@@ -2034,17 +2034,17 @@ nsMathMLChar::ApplyTransforms(gfxContext
 }
 
 void
 nsMathMLChar::PaintForeground(nsPresContext* aPresContext,
                               nsRenderingContext& aRenderingContext,
                               nsPoint aPt,
                               bool aIsSelected)
 {
-  nsStyleContext* parentContext = mStyleContext->GetParent();
+  nsStyleContext* parentContext = mStyleContext->GetParentAllowServo();
   nsStyleContext* styleContext = mStyleContext;
 
   if (mDraw == DRAW_NORMAL) {
     // normal drawing if there is nothing special about this char
     // Set default context to the parent context
     styleContext = parentContext;
   }