Bug 1427512 - Part 15: Remove nsIDOMCSSStyleRule. r=xidorn,jryans draft
authorCameron McCormack <cam@mcc.id.au>
Mon, 01 Jan 2018 20:45:21 +1100
changeset 717716 062f0f999e2547fc55e1a41ec3d5d81081e51b47
parent 717715 597ce01341115692b3447f2666bf903e11eb9b6a
child 717717 f1a4ae4b607add343fab6632bc6dfd92586a6e02
push id94746
push userbmo:cam@mcc.id.au
push dateTue, 09 Jan 2018 10:21:54 +0000
reviewersxidorn, jryans
bugs1427512
milestone59.0a1
Bug 1427512 - Part 15: Remove nsIDOMCSSStyleRule. r=xidorn,jryans MozReview-Commit-ID: 7riPO9da5KL
devtools/server/actors/object.js
dom/base/nsDocument.cpp
dom/interfaces/base/domstubs.idl
dom/interfaces/css/moz.build
dom/interfaces/css/nsIDOMCSSStyleRule.idl
layout/style/BindingStyleRule.h
layout/style/ServoStyleRule.cpp
layout/style/ServoStyleRule.h
layout/style/StyleRule.cpp
layout/style/StyleRule.h
layout/style/nsICSSStyleRuleDOMWrapper.h
--- a/devtools/server/actors/object.js
+++ b/devtools/server/actors/object.js
@@ -1722,17 +1722,17 @@ DebuggerServer.ObjectActorPreviewers.Obj
     grip.preview = {
       kind: "ObjectWithText",
       text: hooks.createValueGrip(rawObj.conditionText),
     };
     return true;
   },
 
   function CSSStyleRule({obj, hooks}, grip, rawObj) {
-    if (isWorker || !rawObj || !(rawObj instanceof Ci.nsIDOMCSSStyleRule)) {
+    if (isWorker || !rawObj || obj.class != "CSSStyleRule") {
       return false;
     }
     grip.preview = {
       kind: "ObjectWithText",
       text: hooks.createValueGrip(rawObj.selectorText),
     };
     return true;
   },
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -232,17 +232,16 @@
 #include "mozilla/ExtensionPolicyService.h"
 #include "nsFrame.h"
 #include "nsDOMCaretPosition.h"
 #include "nsViewportInfo.h"
 #include "mozilla/StaticPtr.h"
 #include "nsITextControlElement.h"
 #include "nsIDOMNSEditableElement.h"
 #include "nsIEditor.h"
-#include "nsIDOMCSSStyleRule.h"
 #include "mozilla/css/StyleRule.h"
 #include "nsIHttpChannelInternal.h"
 #include "nsISecurityConsoleMessage.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "mozilla/dom/XPathEvaluator.h"
 #include "mozilla/dom/XPathNSResolverBinding.h"
 #include "mozilla/dom/XPathResult.h"
 #include "nsIDocumentEncoder.h"
--- a/dom/interfaces/base/domstubs.idl
+++ b/dom/interfaces/base/domstubs.idl
@@ -65,15 +65,14 @@ interface nsIDOMHTMLHeadElement;
 interface nsIDOMCSSValue;
 interface nsIDOMCSSPrimitiveValue;
 interface nsIDOMCSSRule;
 interface nsIDOMCSSRuleList;
 interface nsIDOMCSSStyleSheet;
 interface nsIDOMCSSStyleDeclaration;
 interface nsIDOMCounter;
 interface nsIDOMRect;
-interface nsIDOMCSSStyleRule;
 
 // Range
 interface nsIDOMRange;
 
 // Crypto
 interface nsIDOMCrypto;
--- a/dom/interfaces/css/moz.build
+++ b/dom/interfaces/css/moz.build
@@ -8,17 +8,16 @@ with Files("**"):
     BUG_COMPONENT = ("Core", "DOM: CSS Object Model")
 
 XPIDL_SOURCES += [
     'nsIDOMCounter.idl',
     'nsIDOMCSSPrimitiveValue.idl',
     'nsIDOMCSSRule.idl',
     'nsIDOMCSSRuleList.idl',
     'nsIDOMCSSStyleDeclaration.idl',
-    'nsIDOMCSSStyleRule.idl',
     'nsIDOMCSSStyleSheet.idl',
     'nsIDOMCSSValue.idl',
     'nsIDOMCSSValueList.idl',
     'nsIDOMRect.idl',
 ]
 
 XPIDL_MODULE = 'dom_css'
 
deleted file mode 100644
--- a/dom/interfaces/css/nsIDOMCSSStyleRule.idl
+++ /dev/null
@@ -1,17 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "nsISupports.idl"
-
-interface nsIDOMCSSStyleDeclaration;
-
-[scriptable, uuid(b5e9af48-a7c2-4f88-aae3-58307af4b5a5)]
-interface nsIDOMCSSStyleRule : nsISupports
-{
-           attribute DOMString        selectorText;
-                                        // raises(DOMException) on setting
-
-  readonly attribute nsIDOMCSSStyleDeclaration  style;
-};
--- a/layout/style/BindingStyleRule.h
+++ b/layout/style/BindingStyleRule.h
@@ -55,22 +55,18 @@ public:
                                   uint64_t* aSpecificity) = 0;
   virtual nsresult SelectorMatchesElement(dom::Element* aElement,
                                           uint32_t aSelectorIndex,
                                           const nsAString& aPseudo,
                                           bool* aMatches) = 0;
   virtual NotNull<DeclarationBlock*> GetDeclarationBlock() const = 0;
 
   // WebIDL API
-  // For GetSelectorText/SetSelectorText, we purposefully use a signature that
-  // matches the nsIDOMCSSStyleRule one for now, so subclasses can just
-  // implement both at once.  The actual implementations must never return
-  // anything other than NS_OK;
-  NS_IMETHOD GetSelectorText(nsAString& aSelectorText) = 0;
-  NS_IMETHOD SetSelectorText(const nsAString& aSelectorText) = 0;
+  virtual void GetSelectorText(nsAString& aSelectorText) = 0;
+  virtual void SetSelectorText(const nsAString& aSelectorText) = 0;
   virtual nsICSSDeclaration* Style() = 0;
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
 };
 
 } // namespace mozilla
 
--- a/layout/style/ServoStyleRule.cpp
+++ b/layout/style/ServoStyleRule.cpp
@@ -124,17 +124,16 @@ ServoStyleRule::ServoStyleRule(already_A
   , mRawRule(aRawRule)
   , mDecls(Servo_StyleRule_GetStyle(mRawRule).Consume())
 {
 }
 
 // QueryInterface implementation for ServoStyleRule
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServoStyleRule)
   NS_INTERFACE_MAP_ENTRY(nsICSSStyleRuleDOMWrapper)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleRule)
 NS_INTERFACE_MAP_END_INHERITING(css::Rule)
 
 NS_IMPL_ADDREF_INHERITED(ServoStyleRule, css::Rule)
 NS_IMPL_RELEASE_INHERITED(ServoStyleRule, css::Rule)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(ServoStyleRule)
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(ServoStyleRule, css::Rule)
@@ -231,37 +230,28 @@ ServoStyleRule::GetCssTextImpl(nsAString
 nsICSSDeclaration*
 ServoStyleRule::Style()
 {
   return &mDecls;
 }
 
 /* CSSStyleRule implementation */
 
-NS_IMETHODIMP
+void
 ServoStyleRule::GetSelectorText(nsAString& aSelectorText)
 {
   Servo_StyleRule_GetSelectorText(mRawRule, &aSelectorText);
-  return NS_OK;
 }
 
-NS_IMETHODIMP
+void
 ServoStyleRule::SetSelectorText(const nsAString& aSelectorText)
 {
   // 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 = do_AddRef(&mDecls).take();
-  return NS_OK;
 }
 
 uint32_t
 ServoStyleRule::GetSelectorCount()
 {
   uint32_t aCount;
   Servo_StyleRule_GetSelectorCount(mRawRule, &aCount);
 
--- a/layout/style/ServoStyleRule.h
+++ b/layout/style/ServoStyleRule.h
@@ -9,17 +9,16 @@
 #ifndef mozilla_ServoStyleRule_h
 #define mozilla_ServoStyleRule_h
 
 #include "mozilla/BindingStyleRule.h"
 #include "mozilla/ServoBindingTypes.h"
 #include "mozilla/WeakPtr.h"
 
 #include "nsICSSStyleRuleDOMWrapper.h"
-#include "nsIDOMCSSStyleRule.h"
 #include "nsICSSStyleRuleDOMWrapper.h"
 #include "nsDOMCSSDeclaration.h"
 
 namespace mozilla {
 
 namespace dom {
 class DocGroup;
 } // namespace dom
@@ -66,17 +65,16 @@ class ServoStyleRule final : public Bind
 public:
   ServoStyleRule(already_AddRefed<RawServoStyleRule> aRawRule,
                  uint32_t aLine, uint32_t aColumn);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(ServoStyleRule,
                                                          css::Rule)
   bool IsCCLeaf() const final MOZ_MUST_OVERRIDE;
-  NS_DECL_NSIDOMCSSSTYLERULE
 
   MOZ_DECLARE_WEAKREFERENCE_TYPENAME(ServoStyleRule)
 
   // nsICSSStyleRuleDOMWrapper
   NS_IMETHOD GetCSSStyleRule(BindingStyleRule **aResult) override;
 
   uint32_t GetSelectorCount() override;
   nsresult GetSelectorText(uint32_t aSelectorIndex,
@@ -87,16 +85,18 @@ public:
                                   uint32_t aSelectorIndex,
                                   const nsAString& aPseudo,
                                   bool* aMatches) override;
   NotNull<DeclarationBlock*> GetDeclarationBlock() const override;
 
   // WebIDL interface
   uint16_t Type() const final;
   void GetCssTextImpl(nsAString& aCssText) const final;
+  void GetSelectorText(nsAString& aSelectorText) final;
+  void SetSelectorText(const nsAString& aSelectorText) final;
   nsICSSDeclaration* Style() final;
 
   RawServoStyleRule* Raw() const { return mRawRule; }
 
   // Methods of mozilla::css::Rule
   int32_t GetType() const final { return css::Rule::STYLE_RULE; }
   using Rule::GetType;
   already_AddRefed<Rule> Clone() const final;
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -1189,23 +1189,16 @@ namespace mozilla {
 namespace css {
 
 uint16_t
 StyleRule::Type() const
 {
   return nsIDOMCSSRule::STYLE_RULE;
 }
 
-NS_IMETHODIMP
-StyleRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
-{
-  NS_ADDREF(*aStyle = Style());
-  return NS_OK;
-}
-
 nsICSSDeclaration*
 StyleRule::Style()
 {
   if (!mDOMDeclaration) {
     mDOMDeclaration.reset(new DOMCSSDeclarationImpl(this));
   }
   return mDOMDeclaration.get();
 }
@@ -1259,17 +1252,16 @@ StyleRule::DropReferences()
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StyleRule)
   if (aIID.Equals(NS_GET_IID(mozilla::css::StyleRule))) {
     *aInstancePtr = this;
     NS_ADDREF_THIS();
     return NS_OK;
   }
   else
   NS_INTERFACE_MAP_ENTRY(nsICSSStyleRuleDOMWrapper)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleRule)
 NS_INTERFACE_MAP_END_INHERITING(Rule)
 
 NS_IMPL_ADDREF_INHERITED(StyleRule, Rule)
 NS_IMPL_RELEASE_INHERITED(StyleRule, Rule)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(StyleRule)
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(StyleRule, Rule)
   // Keep this in sync with IsCCLeaf.
@@ -1384,33 +1376,31 @@ StyleRule::GetCssTextImpl(nsAString& aCs
     nsAutoString   tempString;
     mDeclaration->ToString( tempString );
     aCssText.Append( tempString );
   }
   aCssText.Append(char16_t(' '));
   aCssText.Append(char16_t('}'));
 }
 
-NS_IMETHODIMP
+void
 StyleRule::GetSelectorText(nsAString& aSelectorText)
 {
   if (mSelector)
     mSelector->ToString(aSelectorText, GetStyleSheet());
   else
     aSelectorText.Truncate();
-  return NS_OK;
 }
 
-NS_IMETHODIMP
+void
 StyleRule::SetSelectorText(const nsAString& aSelectorText)
 {
   // XXX TBI - get a parser and re-parse the selectors,
   // XXX then need to re-compute the cascade
   // XXX and dirty sheet
-  return NS_OK;
 }
 
 /* virtual */ size_t
 StyleRule::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
 {
   size_t n = aMallocSizeOf(this);
   n += mSelector ? mSelector->SizeOfIncludingThis(aMallocSizeOf) : 0;
   n += mDeclaration ? mDeclaration->SizeOfIncludingThis(aMallocSizeOf) : 0;
--- a/layout/style/StyleRule.h
+++ b/layout/style/StyleRule.h
@@ -329,18 +329,16 @@ private:
   StyleRule(const StyleRule& aCopy);
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_STYLE_RULE_IMPL_CID)
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(StyleRule, Rule)
   bool IsCCLeaf() const override;
 
-  NS_DECL_NSIDOMCSSSTYLERULE
-
   // nsICSSStyleRuleDOMWrapper
   NS_IMETHOD GetCSSStyleRule(BindingStyleRule **aResult) override;
 
   uint32_t GetSelectorCount() override;
   nsresult GetSelectorText(uint32_t aSelectorIndex,
                                    nsAString& aText) override;
   nsresult GetSpecificity(uint32_t aSelectorIndex,
                           uint64_t* aSpecificity) override;
@@ -348,16 +346,18 @@ public:
                                   uint32_t aSelectorIndex,
                                   const nsAString& aPseudo,
                                   bool* aMatches) override;
   mozilla::NotNull<DeclarationBlock*> GetDeclarationBlock() const override;
 
   // WebIDL interface
   uint16_t Type() const override;
   void GetCssTextImpl(nsAString& aCssText) const override;
+  void GetSelectorText(nsAString& aSelectorText) final;
+  void SetSelectorText(const nsAString& aSelectorText) final;
   nsICSSDeclaration* Style() override;
 
   // null for style attribute
   nsCSSSelectorList* Selector() { return mSelector; }
 
   Declaration* GetDeclaration() const { return mDeclaration; }
 
   void SetDeclaration(Declaration* aDecl);
--- a/layout/style/nsICSSStyleRuleDOMWrapper.h
+++ b/layout/style/nsICSSStyleRuleDOMWrapper.h
@@ -7,28 +7,26 @@
 /*
  * interface to provide DOM inspector with access to internal interfaces
  * via DOM interface
  */
 
 #ifndef nsICSSStyleRuleDOMWrapper_h_
 #define nsICSSStyleRuleDOMWrapper_h_
 
-#include "nsIDOMCSSStyleRule.h"
-
 // IID for the nsICSSStyleRuleDOMWrapper interface
 // {cee1bbb6-0a32-4cf3-8d42-ba3938e9ecaa}
 #define NS_ICSS_STYLE_RULE_DOM_WRAPPER_IID \
 {0xcee1bbb6, 0x0a32, 0x4cf3, {0x8d, 0x42, 0xba, 0x39, 0x38, 0xe9, 0xec, 0xaa}}
 
 namespace mozilla {
 class BindingStyleRule;
 } // namespace mozilla
 
-class nsICSSStyleRuleDOMWrapper : public nsIDOMCSSStyleRule {
+class nsICSSStyleRuleDOMWrapper : public nsISupports {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_STYLE_RULE_DOM_WRAPPER_IID)
 
   NS_IMETHOD GetCSSStyleRule(mozilla::BindingStyleRule** aResult) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSStyleRuleDOMWrapper,
                               NS_ICSS_STYLE_RULE_DOM_WRAPPER_IID)