Bug 1304302 part 1 - Add const version of AsGecko/AsServo to StyleSheet. r=heycam
authorXidorn Quan <me@upsuper.org>
Mon, 26 Sep 2016 22:03:25 +1000
changeset 315275 ddf6782170cd09b8228702d143bafd34a8fde570
parent 315274 87aeaae19f90e0a5f0809c5bcec3ea2276f07978
child 315276 12e6d7c5a65f19c168c4dd6a4c68f2606b84a711
push id30747
push usercbook@mozilla.com
push dateTue, 27 Sep 2016 09:22:00 +0000
treeherdermozilla-central@66a77b9bfe5d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1304302
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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