Bug 1304302 part 1 - Add const version of AsGecko/AsServo to StyleSheet. r?heycam
MozReview-Commit-ID: LGQQjmkTWsO
--- 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