Bug 1394994 - stylo: get line and column for ServoKeyframeRule. draft
authorJeremy Chen <jeremychen@mozilla.com>
Mon, 04 Sep 2017 13:38:23 +0800
changeset 658489 4fc577bb09cf0d84e7afdd4803bd586096644382
parent 658358 8e05298328da75f3056a9f1f9609938870d756a0
child 658490 d2aba23ba962a6317ad3993d6797f47124f513ab
push id77797
push userbmo:jeremychen@mozilla.com
push dateMon, 04 Sep 2017 09:39:17 +0000
bugs1394994
milestone57.0a1
Bug 1394994 - stylo: get line and column for ServoKeyframeRule. The Servo_KeyframesRule_GetKeyframe binding function has been empowerd and renamed to Servo_KeyframesRule_GetKeyframeAt in the servo side patch. In this patch, we use Servo_KeyframesRule_GetKeyframeAt to get line and column information for ServoKeyframeRule, so that the inspector can present Keyframe rules on the devtool panel properly. MozReview-Commit-ID: BGd9FFsC3Nz
layout/style/ServoBindingList.h
layout/style/ServoKeyframeRule.h
layout/style/ServoKeyframesRule.cpp
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -214,18 +214,19 @@ SERVO_BINDING_FUNC(Servo_Keyframe_SetSty
                    RawServoDeclarationBlockBorrowed declarations)
 SERVO_BINDING_FUNC(Servo_KeyframesRule_GetName, nsIAtom*,
                    RawServoKeyframesRuleBorrowed rule)
 // This method takes an addrefed nsIAtom.
 SERVO_BINDING_FUNC(Servo_KeyframesRule_SetName, void,
                    RawServoKeyframesRuleBorrowed rule, nsIAtom* name)
 SERVO_BINDING_FUNC(Servo_KeyframesRule_GetCount, uint32_t,
                    RawServoKeyframesRuleBorrowed rule)
-SERVO_BINDING_FUNC(Servo_KeyframesRule_GetKeyframe, RawServoKeyframeStrong,
-                   RawServoKeyframesRuleBorrowed rule, uint32_t index)
+SERVO_BINDING_FUNC(Servo_KeyframesRule_GetKeyframeAt, RawServoKeyframeStrong,
+                   RawServoKeyframesRuleBorrowed rule, uint32_t index,
+                   uint32_t* line, uint32_t* column)
 // Returns the index of the rule, max value of uint32_t if nothing found.
 SERVO_BINDING_FUNC(Servo_KeyframesRule_FindRule, uint32_t,
                    RawServoKeyframesRuleBorrowed rule, const nsACString* key)
 // Returns whether it successfully appends the rule.
 SERVO_BINDING_FUNC(Servo_KeyframesRule_AppendRule, bool,
                    RawServoKeyframesRuleBorrowed rule,
                    RawServoStyleSheetContentsBorrowed sheet,
                    const nsACString* css)
--- a/layout/style/ServoKeyframeRule.h
+++ b/layout/style/ServoKeyframeRule.h
@@ -13,18 +13,19 @@
 namespace mozilla {
 
 class ServoDeclarationBlock;
 class ServoKeyframeDeclaration;
 
 class ServoKeyframeRule final : public dom::CSSKeyframeRule
 {
 public:
-  explicit ServoKeyframeRule(already_AddRefed<RawServoKeyframe> aRaw)
-    : CSSKeyframeRule(0, 0)
+  ServoKeyframeRule(already_AddRefed<RawServoKeyframe> aRaw,
+                    uint32_t aLine, uint32_t aColumn)
+    : CSSKeyframeRule(aLine, aColumn)
     , mRaw(aRaw) {}
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServoKeyframeRule,
                                            dom::CSSKeyframeRule)
 
   bool IsCCLeaf() const final;
 #ifdef DEBUG
--- a/layout/style/ServoKeyframesRule.cpp
+++ b/layout/style/ServoKeyframesRule.cpp
@@ -48,21 +48,25 @@ public:
       }
     }
   }
 
   ServoStyleSheet* GetParentObject() final { return mStyleSheet; }
 
   ServoKeyframeRule* GetRule(uint32_t aIndex) {
     if (!mRules[aIndex]) {
-      ServoKeyframeRule* rule = new ServoKeyframeRule(
-        Servo_KeyframesRule_GetKeyframe(mRawRule, aIndex).Consume());
-      mRules.ReplaceObjectAt(rule, aIndex);
-      rule->SetStyleSheet(mStyleSheet);
-      rule->SetParentRule(mParentRule);
+      uint32_t line = 0, column = 0;
+      RefPtr<RawServoKeyframe> rule =
+        Servo_KeyframesRule_GetKeyframeAt(mRawRule, aIndex,
+                                          &line, &column).Consume();
+      ServoKeyframeRule* ruleObj =
+        new ServoKeyframeRule(rule.forget(), line, column);
+      mRules.ReplaceObjectAt(ruleObj, aIndex);
+      ruleObj->SetStyleSheet(mStyleSheet);
+      ruleObj->SetParentRule(mParentRule);
     }
     return static_cast<ServoKeyframeRule*>(mRules[aIndex]);
   }
 
   ServoKeyframeRule* IndexedGetter(uint32_t aIndex, bool& aFound) final
   {
     if (aIndex >= mRules.Length()) {
       aFound = false;