Bug 1322570 Part 7 - Use GetParentAllowServo() in nsMathMLChar. draft
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 20 Mar 2017 14:14:30 +0800
changeset 502758 9e846d347472286e7e32ba1491f39b104c480623
parent 502757 ef78afa8f1013644e42c545c19d0eb5dbf49de64
child 502759 27530e8f905cfc299913a4db8c089bb38cfbc8e1
push id50388
push userbmo:tlin@mozilla.com
push dateWed, 22 Mar 2017 09:38:19 +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;
   }