Bug 1427512 - Part 9: Remove nsIDOMCSSImportRule. r=xidorn,jryans
MozReview-Commit-ID: 9XG6412Z5iY
--- a/devtools/server/actors/object.js
+++ b/devtools/server/actors/object.js
@@ -1733,17 +1733,17 @@ DebuggerServer.ObjectActorPreviewers.Obj
grip.preview = {
kind: "ObjectWithText",
text: hooks.createValueGrip(rawObj.selectorText),
};
return true;
},
function ObjectWithURL({obj, hooks}, grip, rawObj) {
- if (isWorker || !rawObj || !(rawObj instanceof Ci.nsIDOMCSSImportRule ||
+ if (isWorker || !rawObj || !(obj.class == "CSSImportRule" ||
rawObj instanceof Ci.nsIDOMCSSStyleSheet ||
obj.class == "Location" ||
rawObj instanceof Ci.nsIDOMWindow)) {
return false;
}
let url;
if (rawObj instanceof Ci.nsIDOMWindow && rawObj.location) {
--- a/devtools/server/actors/styles.js
+++ b/devtools/server/actors/styles.js
@@ -1309,18 +1309,17 @@ var StyleRuleActor = protocol.ActorClass
// effects that pop up based on property values that were already set on the
// element.
let document;
if (this.rawNode) {
document = this.rawNode.ownerDocument;
} else {
let parentStyleSheet = this._parentSheet;
- while (parentStyleSheet.ownerRule &&
- parentStyleSheet.ownerRule instanceof Ci.nsIDOMCSSImportRule) {
+ while (parentStyleSheet.ownerRule) {
parentStyleSheet = parentStyleSheet.ownerRule.parentStyleSheet;
}
document = this.getDocument(parentStyleSheet);
}
let tempElement = document.createElementNS(XHTML_NS, "div");
--- a/dom/interfaces/css/moz.build
+++ b/dom/interfaces/css/moz.build
@@ -4,17 +4,16 @@
# 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/.
with Files("**"):
BUG_COMPONENT = ("Core", "DOM: CSS Object Model")
XPIDL_SOURCES += [
'nsIDOMCounter.idl',
- 'nsIDOMCSSImportRule.idl',
'nsIDOMCSSKeyframeRule.idl',
'nsIDOMCSSKeyframesRule.idl',
'nsIDOMCSSPageRule.idl',
'nsIDOMCSSPrimitiveValue.idl',
'nsIDOMCSSRule.idl',
'nsIDOMCSSRuleList.idl',
'nsIDOMCSSStyleDeclaration.idl',
'nsIDOMCSSStyleRule.idl',
deleted file mode 100644
--- a/dom/interfaces/css/nsIDOMCSSImportRule.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 nsIDOMMediaList;
-interface nsIDOMCSSStyleSheet;
-
-[scriptable, uuid(d3b2b914-01ef-4663-beda-a6475a26f491)]
-interface nsIDOMCSSImportRule : nsISupports
-{
- readonly attribute DOMString href;
- readonly attribute nsIDOMMediaList media;
- readonly attribute nsIDOMCSSStyleSheet styleSheet;
-};
--- a/layout/style/CSSImportRule.cpp
+++ b/layout/style/CSSImportRule.cpp
@@ -7,47 +7,23 @@
#include "mozilla/dom/CSSImportRule.h"
#include "mozilla/dom/CSSImportRuleBinding.h"
#include "mozilla/dom/MediaList.h"
namespace mozilla {
namespace dom {
-NS_IMPL_ADDREF_INHERITED(CSSImportRule, css::Rule)
-NS_IMPL_RELEASE_INHERITED(CSSImportRule, css::Rule)
-
-// QueryInterface implementation for CSSImportRule
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSImportRule)
- NS_INTERFACE_MAP_ENTRY(nsIDOMCSSImportRule)
-NS_INTERFACE_MAP_END_INHERITING(css::Rule)
-
bool
CSSImportRule::IsCCLeaf() const
{
// We're not a leaf.
return false;
}
-NS_IMETHODIMP
-CSSImportRule::GetMedia(nsIDOMMediaList** aMedia)
-{
- NS_ENSURE_ARG_POINTER(aMedia);
- NS_IF_ADDREF(*aMedia = GetMedia());
- return NS_OK;
-}
-
-NS_IMETHODIMP
-CSSImportRule::GetStyleSheet(nsIDOMCSSStyleSheet** aStyleSheet)
-{
- NS_ENSURE_ARG_POINTER(aStyleSheet);
- NS_IF_ADDREF(*aStyleSheet = GetStyleSheet());
- return NS_OK;
-}
-
/* virtual */ JSObject*
CSSImportRule::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
{
return CSSImportRuleBinding::Wrap(aCx, this, aGivenProto);
}
} // namespace dom
--- a/layout/style/CSSImportRule.h
+++ b/layout/style/CSSImportRule.h
@@ -3,45 +3,38 @@
/* 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/. */
#ifndef mozilla_dom_CSSImportRule_h
#define mozilla_dom_CSSImportRule_h
#include "mozilla/css/Rule.h"
-#include "nsIDOMCSSImportRule.h"
namespace mozilla {
namespace dom {
class CSSImportRule : public css::Rule
- , public nsIDOMCSSImportRule
{
protected:
using Rule::Rule;
virtual ~CSSImportRule() {}
public:
- NS_DECL_ISUPPORTS_INHERITED
bool IsCCLeaf() const final;
int32_t GetType() const final { return css::Rule::IMPORT_RULE; }
using Rule::GetType;
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
const override = 0;
- // nsIDOMCSSImportRule interface
- NS_IMETHOD GetMedia(nsIDOMMediaList** aMedia) final;
- NS_IMETHOD GetStyleSheet(nsIDOMCSSStyleSheet** aStyleSheet) final;
-
// WebIDL interface
uint16_t Type() const final { return nsIDOMCSSRule::IMPORT_RULE; }
- // The XPCOM GetHref is fine, since it never fails.
+ virtual void GetHref(nsAString& aHref) const = 0;
virtual dom::MediaList* GetMedia() const = 0;
virtual StyleSheet* GetStyleSheet() const = 0;
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
};
} // namespace dom
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -144,28 +144,19 @@ CSSStyleSheet::RebuildChildList(css::Rul
return true;
}
if (type != css::Rule::IMPORT_RULE) {
// We're past all the import rules; stop the enumeration.
return false;
}
- // XXXbz We really need to decomtaminate all this stuff. Is there a reason
- // that I can't just QI to ImportRule and get a CSSStyleSheet
- // directly from it?
- nsCOMPtr<nsIDOMCSSImportRule> importRule(do_QueryInterface(aRule));
- NS_ASSERTION(importRule, "GetType lied");
+ css::ImportRule* importRule = static_cast<css::ImportRule*>(aRule);
+ StyleSheet* sheet = importRule->GetStyleSheet();
- nsCOMPtr<nsIDOMCSSStyleSheet> childSheet;
- importRule->GetStyleSheet(getter_AddRefs(childSheet));
-
- // Have to do this QI to be safe, since XPConnect can fake
- // nsIDOMCSSStyleSheets
- RefPtr<CSSStyleSheet> sheet = do_QueryObject(childSheet);
if (!sheet) {
return true;
}
(*aBuilder->sheetSlot) = sheet;
aBuilder->SetParentLinks(*aBuilder->sheetSlot);
aBuilder->sheetSlot = &(*aBuilder->sheetSlot)->mNext;
return true;
@@ -893,25 +884,20 @@ CSSStyleSheet::ReparseSheet(const nsAStr
// detach existing rules (including child sheets via import rules)
css::LoaderReusableStyleSheets reusableSheets;
int ruleCount;
while ((ruleCount = Inner()->mOrderedRules.Count()) != 0) {
RefPtr<css::Rule> rule = Inner()->mOrderedRules.ObjectAt(ruleCount - 1);
Inner()->mOrderedRules.RemoveObjectAt(ruleCount - 1);
rule->SetStyleSheet(nullptr);
if (rule->GetType() == css::Rule::IMPORT_RULE) {
- nsCOMPtr<nsIDOMCSSImportRule> importRule(do_QueryInterface(rule));
- NS_ASSERTION(importRule, "GetType lied");
-
- nsCOMPtr<nsIDOMCSSStyleSheet> childSheet;
- importRule->GetStyleSheet(getter_AddRefs(childSheet));
-
- RefPtr<CSSStyleSheet> cssSheet = do_QueryObject(childSheet);
- if (cssSheet && cssSheet->GetOriginalURI()) {
- reusableSheets.AddReusableSheet(cssSheet);
+ auto importRule = static_cast<css::ImportRule*>(rule.get());
+ RefPtr<StyleSheet> sheet = importRule->GetStyleSheet();
+ if (sheet && sheet->GetOriginalURI()) {
+ reusableSheets.AddReusableSheet(sheet);
}
}
RuleRemoved(*rule);
}
// nuke child sheets list and current namespace map
for (StyleSheet* child = GetFirstChild(); child; ) {
NS_ASSERTION(child->mParent == this, "Child sheet is not parented to this!");
--- a/layout/style/ImportRule.h
+++ b/layout/style/ImportRule.h
@@ -34,38 +34,32 @@ class ImportRule final : public dom::CSS
public:
ImportRule(nsMediaList* aMedia, const nsString& aURLSpec,
uint32_t aLineNumber, uint32_t aColumnNumber);
private:
// for |Clone|
ImportRule(const ImportRule& aCopy);
~ImportRule();
public:
+ NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ImportRule, Rule)
- NS_DECL_ISUPPORTS_INHERITED
-
- // unhide since nsIDOMCSSImportRule has its own GetStyleSheet and GetMedia
- using dom::CSSImportRule::GetStyleSheet;
- using dom::CSSImportRule::GetMedia;
// Rule methods
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
virtual already_AddRefed<Rule> Clone() const override;
void SetSheet(CSSStyleSheet*);
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
- // nsIDOMCSSImportRule interface
- NS_IMETHOD GetHref(nsAString& aHref) final;
-
// WebIDL interface
void GetCssTextImpl(nsAString& aCssText) const override;
+ void GetHref(nsAString& aHref) const final;
dom::MediaList* GetMedia() const final;
StyleSheet* GetStyleSheet() const final;
private:
nsString mURLSpec;
RefPtr<nsMediaList> mMedia;
RefPtr<CSSStyleSheet> mChildSheet;
};
--- a/layout/style/ServoImportRule.cpp
+++ b/layout/style/ServoImportRule.cpp
@@ -91,21 +91,20 @@ ServoImportRule::GetMedia() const
}
StyleSheet*
ServoImportRule::GetStyleSheet() const
{
return mChildSheet;
}
-NS_IMETHODIMP
-ServoImportRule::GetHref(nsAString& aHref)
+void
+ServoImportRule::GetHref(nsAString& aHref) const
{
Servo_ImportRule_GetHref(mRawRule, &aHref);
- return NS_OK;
}
/* virtual */ void
ServoImportRule::GetCssTextImpl(nsAString& aCssText) const
{
Servo_ImportRule_GetCssText(mRawRule, &aCssText);
}
--- a/layout/style/ServoImportRule.h
+++ b/layout/style/ServoImportRule.h
@@ -21,31 +21,25 @@ class ServoImportRule final : public dom
{
public:
ServoImportRule(RefPtr<RawServoImportRule> aRawRule,
uint32_t aLine, uint32_t aColumn);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServoImportRule, dom::CSSImportRule)
- // unhide since nsIDOMCSSImportRule has its own GetStyleSheet and GetMedia
- using dom::CSSImportRule::GetStyleSheet;
- using dom::CSSImportRule::GetMedia;
-
#ifdef DEBUG
void List(FILE* out = stdout, int32_t aIndent = 0) const final;
#endif
already_AddRefed<css::Rule> Clone() const final;
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const final;
- // nsIDOMCSSImportRule interface
- NS_IMETHOD GetHref(nsAString& aHref) final;
-
// WebIDL interface
void GetCssTextImpl(nsAString& aCssText) const override;
+ void GetHref(nsAString& aHref) const final;
dom::MediaList* GetMedia() const final;
StyleSheet* GetStyleSheet() const final;
private:
~ServoImportRule();
RefPtr<RawServoImportRule> mRawRule;
RefPtr<ServoStyleSheet> mChildSheet;
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -179,21 +179,20 @@ ImportRule::GetMedia() const
}
StyleSheet*
ImportRule::GetStyleSheet() const
{
return mChildSheet;
}
-NS_IMETHODIMP
-ImportRule::GetHref(nsAString & aHref)
+void
+ImportRule::GetHref(nsAString& aHref) const
{
aHref = mURLSpec;
- return NS_OK;
}
/* virtual */ size_t
ImportRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
return aMallocSizeOf(this);
// Measurement of the following members may be added later if DMD finds it is