Bug 1322570 Part 1 - Add MOZ_ASSERT in nsStyleContext::GetParent() to disallow usage by stylo. draft
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 20 Mar 2017 14:11:06 +0800
changeset 504309 337820e72d9e2285e956bf216f4c564b6ae842a6
parent 504149 01d1dedf400d4be413b1a0d48090dca7acf29637
child 504310 a4ed86633048f5691eeb3ab4ba67e5de846340df
push id50776
push userbmo:tlin@mozilla.com
push dateFri, 24 Mar 2017 06:09:16 +0000
bugs1322570
milestone55.0a1
Bug 1322570 Part 1 - Add MOZ_ASSERT in nsStyleContext::GetParent() to disallow usage by stylo. Also, add GetParentAllowServo() to whitelist the usage in servo-backed style system in subsequent parts so that we could revisit them later. MozReview-Commit-ID: JthU18Ftx02
layout/style/nsStyleContext.h
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -158,17 +158,25 @@ public:
   nsPresContext* PresContext() const {
 #ifdef MOZ_STYLO
     return mPresContext;
 #else
     return mSource.AsGeckoRuleNode()->PresContext();
 #endif
   }
 
-  nsStyleContext* GetParent() const { return mParent; }
+  nsStyleContext* GetParent() const {
+    MOZ_ASSERT(mSource.IsGeckoRuleNode(),
+               "This should be used only in Gecko-backed style system!");
+    return mParent;
+  }
+
+  nsStyleContext* GetParentAllowServo() const {
+    return mParent;
+  }
 
   nsIAtom* GetPseudo() const { return mPseudoTag; }
   mozilla::CSSPseudoElementType GetPseudoType() const {
     return static_cast<mozilla::CSSPseudoElementType>(
              mBits >> NS_STYLE_CONTEXT_TYPE_SHIFT);
   }
 
   bool IsAnonBox() const {