Bug 1307357 part 5 - Implement css text getters for ServoStyleRule. r=SimonSapin,heycam
authorXidorn Quan <me@upsuper.org>
Wed, 23 Nov 2016 10:26:20 +1100
changeset 368852 d6a77d3e4bb8ad6466f58383cd946fb32a678d62
parent 368851 31fdda2f930d856d0786563d5ea1a3e8a6d076b4
child 368853 d831f568dd47614f53efeb6e2f7da0d2190a5e25
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersSimonSapin, heycam
bugs1307357
milestone53.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 1307357 part 5 - Implement css text getters for ServoStyleRule. r=SimonSapin,heycam MozReview-Commit-ID: 44bKwabU4eJ
layout/style/ServoBindingList.h
layout/style/ServoStyleRule.cpp
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -53,16 +53,22 @@ SERVO_BINDING_FUNC(Servo_StyleSet_Insert
 
 // CSSRuleList
 SERVO_BINDING_FUNC(Servo_CssRules_ListTypes, void,
                    ServoCssRulesBorrowed rules,
                    nsTArrayBorrowed_uintptr_t result)
 SERVO_BINDING_FUNC(Servo_CssRules_GetStyleRuleAt, RawServoStyleRuleStrong,
                    ServoCssRulesBorrowed rules, uint32_t index)
 
+// CSS Rules
+SERVO_BINDING_FUNC(Servo_StyleRule_GetCssText, void,
+                   RawServoStyleRuleBorrowed rule, nsAString* result)
+SERVO_BINDING_FUNC(Servo_StyleRule_GetSelectorText, void,
+                   RawServoStyleRuleBorrowed rule, nsAString* result)
+
 // Animations API
 SERVO_BINDING_FUNC(Servo_ParseProperty,
                    RawServoDeclarationBlockStrong,
                    const nsACString* property, const nsACString* value,
                    const nsACString* base_url, ThreadSafeURIHolder* base,
                    ThreadSafeURIHolder* referrer,
                    ThreadSafePrincipalHolder* principal)
 SERVO_BINDING_FUNC(Servo_RestyleWithAddedDeclaration,
--- a/layout/style/ServoStyleRule.cpp
+++ b/layout/style/ServoStyleRule.cpp
@@ -3,16 +3,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* representation of CSSStyleRule for stylo */
 
 #include "mozilla/ServoStyleRule.h"
 
+#include "mozilla/ServoBindings.h"
+
 #include "nsDOMClassInfoID.h"
 
 namespace mozilla {
 
 // -- ServoStyleRule --------------------------------------------------
 
 // QueryInterface implementation for ServoStyleRule
 NS_INTERFACE_MAP_BEGIN(ServoStyleRule)
@@ -57,17 +59,18 @@ ServoStyleRule::GetType(uint16_t* aType)
 {
   *aType = nsIDOMCSSRule::STYLE_RULE;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ServoStyleRule::GetCssText(nsAString& aCssText)
 {
-  return NS_ERROR_NOT_IMPLEMENTED;
+  Servo_StyleRule_GetCssText(mRawRule, &aCssText);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 ServoStyleRule::SetCssText(const nsAString& aCssText)
 {
   return NS_OK;
 }
 
@@ -90,23 +93,27 @@ ServoStyleRule::GetCSSRule()
   return this;
 }
 
 /* CSSStyleRule implementation */
 
 NS_IMETHODIMP
 ServoStyleRule::GetSelectorText(nsAString& aSelectorText)
 {
-  return NS_ERROR_NOT_IMPLEMENTED;
+  Servo_StyleRule_GetSelectorText(mRawRule, &aSelectorText);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 ServoStyleRule::SetSelectorText(const nsAString& aSelectorText)
 {
-  return NS_ERROR_NOT_IMPLEMENTED;
+  // XXX We need to implement this... But Gecko doesn't have this either
+  //     so it's probably okay to leave it unimplemented currently?
+  //     See bug 37468 and mozilla::css::StyleRule::SetSelectorText.
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 ServoStyleRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
 {
   *aStyle = nullptr;
   return NS_ERROR_NOT_IMPLEMENTED;
 }