Bug 1304302 part 1 - Add const version of AsGecko/AsServo to StyleSheet. r?heycam draft
authorXidorn Quan <me@upsuper.org>
Thu, 22 Sep 2016 11:14:12 +1000
changeset 416841 d5d55414f4722ab5acd9f7b490fd7933ddd48844
parent 416840 3b3333fc9db85e289f71b37cb19e18a295a08256
child 416842 034787b75c19bac92e58b265471152e84d398542
child 416881 e44544f6598793025fcdeab810bc0d4a36fe837e
push id30264
push userxquan@mozilla.com
push dateFri, 23 Sep 2016 06:02:40 +0000
reviewersheycam
bugs1304302
milestone51.0a1
Bug 1304302 part 1 - Add const version of AsGecko/AsServo to StyleSheet. r?heycam MozReview-Commit-ID: LGQQjmkTWsO
layout/style/StyleSheet.h
layout/style/StyleSheetInlines.h
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -67,16 +67,18 @@ public:
 #endif
   }
 
   // Only safe to call if the caller has verified that that |this| is of the
   // correct type.
   inline CSSStyleSheet& AsGecko();
   inline ServoStyleSheet& AsServo();
   inline StyleSheetHandle AsHandle();
+  inline const CSSStyleSheet& AsGecko() const;
+  inline const ServoStyleSheet& AsServo() const;
 
 protected:
   nsIDocument*          mDocument; // weak ref; parents maintain this for their children
   nsINode*              mOwningNode; // weak ref
 
   // mParsingMode controls access to nonstandard style constructs that
   // are not safe for use on the public Web but necessary in UA sheets
   // and/or useful in user sheets.
--- a/layout/style/StyleSheetInlines.h
+++ b/layout/style/StyleSheetInlines.h
@@ -30,11 +30,25 @@ StyleSheetHandle
 StyleSheet::AsHandle()
 {
   if (IsServo()) {
     return &AsServo();
   }
   return &AsGecko();
 }
 
+const CSSStyleSheet&
+StyleSheet::AsGecko() const
+{
+  MOZ_ASSERT(IsGecko());
+  return *static_cast<const CSSStyleSheet*>(this);
+}
+
+const ServoStyleSheet&
+StyleSheet::AsServo() const
+{
+  MOZ_ASSERT(IsServo());
+  return *static_cast<const ServoStyleSheet*>(this);
+}
+
 }
 
 #endif // mozilla_StyleSheetInlines_h