Bug 1343964 part 6 - Add a const Rule() method for ServoStyleRule. r=heycam draft
authorXidorn Quan <me@upsuper.org>
Tue, 04 Apr 2017 16:07:44 +1000
changeset 557553 5f801d8c43d300c16ea325bfca7c3d3cee6e3cb6
parent 557552 f2201e70f58e0a89fcb90e222bcf129048056a8b
child 557554 37e6316b5e50d4c5b76101c423a7c8ff8a22196c
push id52752
push userxquan@mozilla.com
push dateFri, 07 Apr 2017 00:04:02 +0000
reviewersheycam
bugs1343964
milestone55.0a1
Bug 1343964 part 6 - Add a const Rule() method for ServoStyleRule. r=heycam MozReview-Commit-ID: 1rvWrN3Biut
layout/style/ServoStyleRule.h
--- a/layout/style/ServoStyleRule.h
+++ b/layout/style/ServoStyleRule.h
@@ -38,16 +38,17 @@ private:
   // For accessing the constructor.
   friend class ServoStyleRule;
 
   explicit ServoStyleRuleDeclaration(
     already_AddRefed<RawServoDeclarationBlock> aDecls);
   ~ServoStyleRuleDeclaration();
 
   inline ServoStyleRule* Rule();
+  inline const ServoStyleRule* Rule() const;
 
   RefPtr<ServoDeclarationBlock> mDecls;
 };
 
 class ServoStyleRule final : public BindingStyleRule
                            , public nsIDOMCSSStyleRule
 {
 public:
@@ -83,15 +84,22 @@ private:
 
   RefPtr<RawServoStyleRule> mRawRule;
   ServoStyleRuleDeclaration mDecls;
 };
 
 ServoStyleRule*
 ServoStyleRuleDeclaration::Rule()
 {
-  return reinterpret_cast<ServoStyleRule*>(reinterpret_cast<uint8_t*>(this) -
-                                           offsetof(ServoStyleRule, mDecls));
+  return reinterpret_cast<ServoStyleRule*>(
+    reinterpret_cast<uint8_t*>(this) - offsetof(ServoStyleRule, mDecls));
+}
+
+const ServoStyleRule*
+ServoStyleRuleDeclaration::Rule() const
+{
+  return reinterpret_cast<const ServoStyleRule*>(
+    reinterpret_cast<const uint8_t*>(this) - offsetof(ServoStyleRule, mDecls));
 }
 
 } // namespace mozilla
 
 #endif // mozilla_ServoStyleRule_h