--- a/devtools/server/actors/csscoverage.js
+++ b/devtools/server/actors/csscoverage.js
@@ -11,18 +11,16 @@ const Services = require("Services");
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
const protocol = require("devtools/shared/protocol");
const { cssUsageSpec } = require("devtools/shared/specs/csscoverage");
loader.lazyRequireGetter(this, "stylesheets", "devtools/server/actors/stylesheets");
loader.lazyRequireGetter(this, "prettifyCSS", "devtools/shared/inspector/css-logic", true);
-const CSSRule = Ci.nsIDOMCSSRule;
-
const MAX_UNUSED_RULES = 10000;
/**
* Allow: let foo = l10n.lookup("csscoverageFoo");
*/
const l10n = exports.l10n = {
_URI: "chrome://devtools-shared/locale/csscoverage.properties",
lookup: function (msg) {
--- a/devtools/server/actors/styles.js
+++ b/devtools/server/actors/styles.js
@@ -942,21 +942,21 @@ exports.PageStyleActor = PageStyleActor;
var StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, {
initialize: function (pageStyle, item) {
protocol.Actor.prototype.initialize.call(this, null);
this.pageStyle = pageStyle;
this.rawStyle = item.style;
this._parentSheet = null;
this._onStyleApplied = this._onStyleApplied.bind(this);
- if (item instanceof (Ci.nsIDOMCSSRule)) {
+ if (CSSRule.isCSSRule(item)) {
this.type = item.type;
this.rawRule = item;
- if ((this.type === Ci.nsIDOMCSSRule.STYLE_RULE ||
- this.type === Ci.nsIDOMCSSRule.KEYFRAME_RULE) &&
+ if ((this.type === CSSRule.STYLE_RULE ||
+ this.type === CSSRule.KEYFRAME_RULE) &&
this.rawRule.parentStyleSheet) {
this.line = InspectorUtils.getRelativeRuleLine(this.rawRule);
this.column = InspectorUtils.getRuleColumn(this.rawRule);
this._parentSheet = this.rawRule.parentStyleSheet;
this._computeRuleIndex();
this.sheetActor = this.pageStyle._sheetRef(this._parentSheet);
this.sheetActor.on("style-applied", this._onStyleApplied);
}
@@ -1049,17 +1049,17 @@ var StyleRuleActor = protocol.ActorClass
if (this.rawRule.parentRule) {
form.parentRule =
this.pageStyle._styleRef(this.rawRule.parentRule).actorID;
// CSS rules that we call media rules are STYLE_RULES that are children
// of MEDIA_RULEs. We need to check the parentRule to check if a rule is
// a media rule so we do this here instead of in the switch statement
// below.
- if (this.rawRule.parentRule.type === Ci.nsIDOMCSSRule.MEDIA_RULE) {
+ if (this.rawRule.parentRule.type === CSSRule.MEDIA_RULE) {
form.media = [];
for (let i = 0, n = this.rawRule.parentRule.media.length; i < n; i++) {
form.media.push(this.rawRule.parentRule.media.item(i));
}
}
}
if (this._parentSheet) {
form.parentStyleSheet =
@@ -1069,40 +1069,40 @@ var StyleRuleActor = protocol.ActorClass
// One tricky thing here is that other methods in this actor must
// ensure that authoredText has been set before |form| is called.
// This has to be treated specially, for now, because we cannot
// synchronously compute the authored text, but |form| also cannot
// return a promise. See bug 1205868.
form.authoredText = this.authoredText;
switch (this.type) {
- case Ci.nsIDOMCSSRule.STYLE_RULE:
+ case CSSRule.STYLE_RULE:
form.selectors = CssLogic.getSelectors(this.rawRule);
form.cssText = this.rawStyle.cssText || "";
break;
case ELEMENT_STYLE:
// Elements don't have a parent stylesheet, and therefore
// don't have an associated URI. Provide a URI for
// those.
let doc = this.rawNode.ownerDocument;
form.href = doc.location ? doc.location.href : "";
form.cssText = this.rawStyle.cssText || "";
form.authoredText = this.rawNode.getAttribute("style");
break;
- case Ci.nsIDOMCSSRule.CHARSET_RULE:
+ case CSSRule.CHARSET_RULE:
form.encoding = this.rawRule.encoding;
break;
- case Ci.nsIDOMCSSRule.IMPORT_RULE:
+ case CSSRule.IMPORT_RULE:
form.href = this.rawRule.href;
break;
- case Ci.nsIDOMCSSRule.KEYFRAMES_RULE:
+ case CSSRule.KEYFRAMES_RULE:
form.cssText = this.rawRule.cssText;
form.name = this.rawRule.name;
break;
- case Ci.nsIDOMCSSRule.KEYFRAME_RULE:
+ case CSSRule.KEYFRAME_RULE:
form.cssText = this.rawStyle.cssText || "";
form.keyText = this.rawRule.keyText || "";
break;
}
// Parse the text into a list of declarations so the client doesn't have to
// and so that we can safely determine if a declaration is valid rather than
// have the client guess it.
@@ -1230,18 +1230,18 @@ var StyleRuleActor = protocol.ActorClass
* text, if available. If the authored form is not available, the
* returned promise simply resolves to the empty string. If the
* authored form is available, this also sets |this.authoredText|.
* The authored text will include invalid and otherwise ignored
* properties.
*/
getAuthoredCssText: function () {
if (!this.canSetRuleText ||
- (this.type !== Ci.nsIDOMCSSRule.STYLE_RULE &&
- this.type !== Ci.nsIDOMCSSRule.KEYFRAME_RULE)) {
+ (this.type !== CSSRule.STYLE_RULE &&
+ this.type !== CSSRule.KEYFRAME_RULE)) {
return promise.resolve("");
}
if (typeof this.authoredText === "string") {
return promise.resolve(this.authoredText);
}
let parentStyleSheet =
--- a/devtools/server/actors/stylesheets.js
+++ b/devtools/server/actors/stylesheets.js
@@ -512,17 +512,17 @@ var StyleSheetActor = protocol.ActorClas
* @return {promise}
* A promise that resolves with an array of MediaRuleActors.
*/
_getMediaRules: function () {
return this.getCSSRules().then((rules) => {
let mediaRules = [];
for (let i = 0; i < rules.length; i++) {
let rule = rules[i];
- if (rule.type != Ci.nsIDOMCSSRule.MEDIA_RULE) {
+ if (rule.type != CSSRule.MEDIA_RULE) {
continue;
}
let actor = new MediaRuleActor(rule, this);
this.manage(actor);
mediaRules.push(actor);
}
return mediaRules;
@@ -537,33 +537,33 @@ var StyleSheetActor = protocol.ActorClas
_getCSSCharset: function () {
let sheet = this.rawSheet;
if (sheet) {
// Do we have a @charset rule in the stylesheet?
// step 2 of syndata.html (without the BOM check).
if (sheet.cssRules) {
let rules = sheet.cssRules;
if (rules.length
- && rules.item(0).type == Ci.nsIDOMCSSRule.CHARSET_RULE) {
+ && rules.item(0).type == CSSRule.CHARSET_RULE) {
return rules.item(0).encoding;
}
}
// step 3: charset attribute of <link> or <style> element, if it exists
if (sheet.ownerNode && sheet.ownerNode.getAttribute) {
let linkCharset = sheet.ownerNode.getAttribute("charset");
if (linkCharset != null) {
return linkCharset;
}
}
// step 4 (1 of 2): charset of referring stylesheet.
let parentSheet = sheet.parentStyleSheet;
if (parentSheet && parentSheet.cssRules &&
- parentSheet.cssRules[0].type == Ci.nsIDOMCSSRule.CHARSET_RULE) {
+ parentSheet.cssRules[0].type == CSSRule.CHARSET_RULE) {
return parentSheet.cssRules[0].encoding;
}
// step 4 (2 of 2): charset of referring document.
if (sheet.ownerNode && sheet.ownerNode.ownerDocument.characterSet) {
return sheet.ownerNode.ownerDocument.characterSet;
}
}
@@ -824,34 +824,34 @@ var StyleSheetsActor = protocol.ActorCla
*/
_getImported: function (doc, styleSheet) {
return Task.spawn(function* () {
let rules = yield styleSheet.getCSSRules();
let imported = [];
for (let i = 0; i < rules.length; i++) {
let rule = rules[i];
- if (rule.type == Ci.nsIDOMCSSRule.IMPORT_RULE) {
+ if (rule.type == CSSRule.IMPORT_RULE) {
// With the Gecko style system, the associated styleSheet may be null
// if it has already been seen because an import cycle for the same
// URL. With Stylo, the styleSheet will exist (which is correct per
// the latest CSSOM spec), so we also need to check ancestors for the
// same URL to avoid cycles.
let sheet = rule.styleSheet;
if (!sheet || this._haveAncestorWithSameURL(sheet) ||
!this._shouldListSheet(sheet)) {
continue;
}
let actor = this.parentActor.createStyleSheetActor(rule.styleSheet);
imported.push(actor);
// recurse imports in this stylesheet as well
let children = yield this._getImported(doc, actor);
imported = imported.concat(children);
- } else if (rule.type != Ci.nsIDOMCSSRule.CHARSET_RULE) {
+ } else if (rule.type != CSSRule.CHARSET_RULE) {
// @import rules must precede all others except @charset
break;
}
}
return imported;
}.bind(this));
},
--- a/devtools/server/css-logic.js
+++ b/devtools/server/css-logic.js
@@ -10,17 +10,17 @@
* access to 2 sets of objects: Css[Sheet|Rule|Selector] provide access to
* information that does not change when the selected element changes while
* Css[Property|Selector]Info provide information that is dependent on the
* selected element.
* Its key methods are highlight(), getPropertyInfo() and forEachSheet(), etc
*
* - CssSheet provides a more useful API to a DOM CSSSheet for our purposes,
* including shortSource and href.
- * - CssRule a more useful API to a nsIDOMCSSRule including access to the group
+ * - CssRule a more useful API to a DOM CSSRule including access to the group
* of CssSelectors that the rule provides properties for
* - CssSelector A single selector - i.e. not a selector group. In other words
* a CssSelector does not contain ','. This terminology is different from the
* standard DOM API, but more inline with the definition in the spec.
*
* - CssPropertyInfo contains style information for a single property for the
* highlighted element.
* - CssSelectorInfo is a wrapper around CssSelector, which adds sorting with
@@ -379,25 +379,25 @@ CssLogic.prototype = {
}
}
}
},
/**
/**
- * Get the number nsIDOMCSSRule objects in the document, counted from all of
+ * Get the number CSSRule objects in the document, counted from all of
* the stylesheets. System sheets are excluded. If a filter is active, this
- * tells only the number of nsIDOMCSSRule objects inside the selected
+ * tells only the number of CSSRule objects inside the selected
* CSSStyleSheet.
*
* WARNING: This only provides an estimate of the rule count, and the results
* could change at a later date. Todo remove this
*
- * @return {number} the number of nsIDOMCSSRule (all rules).
+ * @return {number} the number of CSSRule (all rules).
*/
get ruleCount() {
if (!this._sheetsCached) {
this._cacheSheets();
}
return this._ruleCount;
},
@@ -801,17 +801,17 @@ CssSheet.prototype = {
}
return this._sheetAllowed;
},
/**
* Retrieve the number of rules in this stylesheet.
*
- * @return {number} the number of nsIDOMCSSRule objects in this stylesheet.
+ * @return {number} the number of CSSRule objects in this stylesheet.
*/
get ruleCount() {
try {
return this._ruleCount > -1 ?
this._ruleCount :
this.getCssRules().length;
} catch (e) {
return 0;
--- a/devtools/shared/builtin-modules.js
+++ b/devtools/shared/builtin-modules.js
@@ -18,19 +18,21 @@ const promise = Cu.import("resource://gr
const jsmScope = Cu.import("resource://gre/modules/Services.jsm", {});
const { Services } = jsmScope;
// Steal various globals only available in JSM scope (and not Sandbox one)
const { PromiseDebugging, ChromeUtils, HeapSnapshot,
atob, btoa, TextEncoder, TextDecoder } = Cu.getGlobalForObject(jsmScope);
// Create a single Sandbox to access global properties needed in this module.
// Sandbox are memory expensive, so we should create as little as possible.
-const { CSS, FileReader, indexedDB, InspectorUtils, URL } =
+const { CSS, CSSRule, FileReader, indexedDB, InspectorUtils, URL } =
Cu.Sandbox(CC("@mozilla.org/systemprincipal;1", "nsIPrincipal")(), {
- wantGlobalProperties: ["CSS", "FileReader", "indexedDB", "InspectorUtils", "URL"]
+ wantGlobalProperties: [
+ "CSS", "CSSRule", "FileReader", "indexedDB", "InspectorUtils", "URL",
+ ]
});
/**
* Defines a getter on a specified object that will be created upon first use.
*
* @param object
* The object to define the lazy getter on.
* @param name
@@ -215,16 +217,17 @@ exports.globals = {
isWorker: false,
reportError: Cu.reportError,
atob: atob,
btoa: btoa,
TextEncoder: TextEncoder,
TextDecoder: TextDecoder,
URL,
CSS,
+ CSSRule,
loader: {
lazyGetter: defineLazyGetter,
lazyImporter: defineLazyModuleGetter,
lazyServiceGetter: defineLazyServiceGetter,
lazyRequireGetter: lazyRequireGetter,
// Defined by Loader.jsm
id: null
},
@@ -285,17 +288,16 @@ lazyGlobal("setTimeout", () => {
return Cu.import("resource://gre/modules/Timer.jsm", {}).setTimeout;
});
lazyGlobal("clearInterval", () => {
return Cu.import("resource://gre/modules/Timer.jsm", {}).clearInterval;
});
lazyGlobal("setInterval", () => {
return Cu.import("resource://gre/modules/Timer.jsm", {}).setInterval;
});
-lazyGlobal("CSSRule", () => Ci.nsIDOMCSSRule);
lazyGlobal("DOMParser", () => {
return CC("@mozilla.org/xmlextras/domparser;1", "nsIDOMParser");
});
lazyGlobal("WebSocket", () => {
return Services.appShell.hiddenDOMWindow.WebSocket;
});
lazyGlobal("indexedDB", () => {
return require("devtools/shared/indexed-db").createDevToolsIndexedDB(indexedDB);
--- a/devtools/shared/inspector/css-logic.js
+++ b/devtools/shared/inspector/css-logic.js
@@ -19,17 +19,17 @@ const MAX_DATA_URL_LENGTH = 40;
* information that does not change when the selected element changes while
* Css[Property|Selector]Info provide information that is dependent on the
* selected element.
* Its key methods are highlight(), getPropertyInfo() and forEachSheet(), etc
* It also contains a number of static methods for l10n, naming, etc
*
* - CssSheet provides a more useful API to a DOM CSSSheet for our purposes,
* including shortSource and href.
- * - CssRule a more useful API to a nsIDOMCSSRule including access to the group
+ * - CssRule a more useful API to a DOM CSSRule including access to the group
* of CssSelectors that the rule provides properties for
* - CssSelector A single selector - i.e. not a selector group. In other words
* a CssSelector does not contain ','. This terminology is different from the
* standard DOM API, but more inline with the definition in the spec.
*
* - CssPropertyInfo contains style information for a single property for the
* highlighted element.
* - CssSelectorInfo is a wrapper around CssSelector, which adds sorting with
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -63,17 +63,16 @@
#include "nsError.h"
#include "nsIDOMXULButtonElement.h"
#include "nsIDOMXULCheckboxElement.h"
// Event related includes
#include "nsIDOMEventTarget.h"
// CSS related includes
-#include "nsIDOMCSSRule.h"
#include "nsMemory.h"
// includes needed for the prototype chain interfaces
#include "nsIEventListenerService.h"
#include "nsIMessageManager.h"
#include "mozilla/dom/TouchEvent.h"
--- a/dom/base/nsTreeSanitizer.cpp
+++ b/dom/base/nsTreeSanitizer.cpp
@@ -13,17 +13,16 @@
#include "mozilla/css/Declaration.h"
#include "mozilla/css/StyleRule.h"
#include "mozilla/css/Rule.h"
#include "mozilla/dom/CSSRuleList.h"
#include "mozilla/dom/SRIMetadata.h"
#include "nsCSSParser.h"
#include "nsCSSPropertyID.h"
#include "nsUnicharInputStream.h"
-#include "nsIDOMCSSRule.h"
#include "nsAttrName.h"
#include "nsIScriptSecurityManager.h"
#include "nsNetUtil.h"
#include "nsComponentManagerUtils.h"
#include "NullPrincipal.h"
#include "nsContentUtils.h"
#include "nsIParserUtils.h"
#include "nsIDocument.h"
@@ -1133,23 +1132,18 @@ nsTreeSanitizer::SanitizeStyleSheet(cons
default:
didSanitize = true;
// Ignore these rule types.
break;
case mozilla::css::Rule::NAMESPACE_RULE:
case mozilla::css::Rule::FONT_FACE_RULE: {
// Append @namespace and @font-face rules verbatim.
nsAutoString cssText;
- nsCOMPtr<nsIDOMCSSRule> styleRule = do_QueryInterface(rule);
- if (styleRule) {
- rv = styleRule->GetCssText(cssText);
- if (NS_SUCCEEDED(rv)) {
- aSanitized.Append(cssText);
- }
- }
+ rule->GetCssText(cssText);
+ aSanitized.Append(cssText);
break;
}
case mozilla::css::Rule::STYLE_RULE: {
// For style rules, we will just look for and remove the
// -moz-binding properties.
auto styleRule = static_cast<BindingStyleRule*>(rule);
DeclarationBlock* styleDecl = styleRule->GetDeclarationBlock();
MOZ_ASSERT(styleDecl);
--- a/dom/interfaces/base/domstubs.idl
+++ b/dom/interfaces/base/domstubs.idl
@@ -59,17 +59,16 @@ interface nsIDOMEventListener;
// HTML
interface nsIDOMHTMLElement;
interface nsIDOMHTMLFormElement;
interface nsIDOMHTMLHeadElement;
// CSS
interface nsIDOMCSSValue;
interface nsIDOMCSSPrimitiveValue;
-interface nsIDOMCSSRule;
interface nsIDOMCSSRuleList;
interface nsIDOMCSSStyleSheet;
interface nsIDOMCSSStyleDeclaration;
interface nsIDOMCounter;
interface nsIDOMRect;
// Range
interface nsIDOMRange;
--- a/dom/interfaces/css/moz.build
+++ b/dom/interfaces/css/moz.build
@@ -5,17 +5,16 @@
# 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',
'nsIDOMCSSPrimitiveValue.idl',
- 'nsIDOMCSSRule.idl',
'nsIDOMCSSRuleList.idl',
'nsIDOMCSSStyleDeclaration.idl',
'nsIDOMCSSStyleSheet.idl',
'nsIDOMCSSValue.idl',
'nsIDOMCSSValueList.idl',
'nsIDOMRect.idl',
]
deleted file mode 100644
--- a/dom/interfaces/css/nsIDOMCSSRule.idl
+++ /dev/null
@@ -1,57 +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 "domstubs.idl"
-
-%{C++
-namespace mozilla {
-namespace css {
-class Rule;
-}
-}
-%}
-
-[ptr] native Rule(mozilla::css::Rule);
-
-/**
- * The nsIDOMCSSRule interface is a datatype for a CSS style rule in
- * the Document Object Model.
- *
- * For more information on this interface please see
- * http://www.w3.org/TR/DOM-Level-2-Style
- */
-
-[scriptable, uuid(4d6b3bad-f53c-4585-82f6-62982e27ede8)]
-interface nsIDOMCSSRule : nsISupports
-{
- // RuleType
- const unsigned short UNKNOWN_RULE = 0;
- const unsigned short STYLE_RULE = 1;
- const unsigned short CHARSET_RULE = 2;
- const unsigned short IMPORT_RULE = 3;
- const unsigned short MEDIA_RULE = 4;
- const unsigned short FONT_FACE_RULE = 5;
- const unsigned short PAGE_RULE = 6;
- const unsigned short KEYFRAMES_RULE = 7;
- const unsigned short KEYFRAME_RULE = 8;
- // When layout.css.prefixes.animations is disabled/removed,
- // we should remove these two MOZ_* constants.
- const unsigned short MOZ_KEYFRAMES_RULE = 7;
- const unsigned short MOZ_KEYFRAME_RULE = 8;
- const unsigned short NAMESPACE_RULE = 10;
- const unsigned short COUNTER_STYLE_RULE = 11;
- const unsigned short SUPPORTS_RULE = 12;
- const unsigned short DOCUMENT_RULE = 13;
- const unsigned short FONT_FEATURE_VALUES_RULE = 14;
-
- readonly attribute unsigned short type;
- attribute DOMString cssText;
- // raises(DOMException) on setting
-
- readonly attribute nsIDOMCSSStyleSheet parentStyleSheet;
- readonly attribute nsIDOMCSSRule parentRule;
-
- [noscript, nostdcall, notxpcom] Rule getCSSRule();
-};
--- a/dom/interfaces/css/nsIDOMCSSRuleList.idl
+++ b/dom/interfaces/css/nsIDOMCSSRuleList.idl
@@ -12,10 +12,9 @@
* For more information on this interface please see
* http://www.w3.org/TR/DOM-Level-2-Style
*/
[scriptable, uuid(a6cf90c0-15b3-11d2-932e-00805f8add32)]
interface nsIDOMCSSRuleList : nsISupports
{
readonly attribute unsigned long length;
- nsIDOMCSSRule item(in unsigned long index);
};
--- a/dom/interfaces/css/nsIDOMCSSStyleDeclaration.idl
+++ b/dom/interfaces/css/nsIDOMCSSStyleDeclaration.idl
@@ -35,10 +35,9 @@ interface nsIDOMCSSStyleDeclaration : ns
DOMString getPropertyValue(in DOMString propertyName);
nsIDOMCSSValue getPropertyCSSValue(in DOMString propertyName);
DOMString removeProperty(in DOMString propertyName)
raises(DOMException);
DOMString getPropertyPriority(in DOMString propertyName);
readonly attribute unsigned long length;
DOMString item(in unsigned long index);
- readonly attribute nsIDOMCSSRule parentRule;
};
--- a/dom/interfaces/css/nsIDOMCSSStyleSheet.idl
+++ b/dom/interfaces/css/nsIDOMCSSStyleSheet.idl
@@ -11,17 +11,16 @@
*
* For more information on this interface please see
* http://www.w3.org/TR/DOM-Level-2-Style
*/
[uuid(a6cf90c2-15b3-11d2-932e-00805f8add32)]
interface nsIDOMCSSStyleSheet : nsIDOMStyleSheet
{
- readonly attribute nsIDOMCSSRule ownerRule;
readonly attribute nsIDOMCSSRuleList cssRules;
unsigned long insertRule(in DOMString rule,
in unsigned long index)
raises(DOMException);
void deleteRule(in unsigned long index)
raises(DOMException);
};
--- a/dom/webidl/CSSRule.webidl
+++ b/dom/webidl/CSSRule.webidl
@@ -41,12 +41,18 @@ partial interface CSSRule {
const unsigned short COUNTER_STYLE_RULE = 11;
};
// https://drafts.csswg.org/css-conditional-3/#extentions-to-cssrule-interface
partial interface CSSRule {
const unsigned short SUPPORTS_RULE = 12;
};
+// Non-standard extension for @-moz-document rules.
+partial interface CSSRule {
+ [ChromeOnly]
+ const unsigned short DOCUMENT_RULE = 13;
+};
+
// https://drafts.csswg.org/css-fonts-3/#om-fontfeaturevalues
partial interface CSSRule {
const unsigned short FONT_FEATURE_VALUES_RULE = 14;
};
--- a/js/xpconnect/src/Sandbox.cpp
+++ b/js/xpconnect/src/Sandbox.cpp
@@ -26,16 +26,17 @@
#include "xpc_make_class.h"
#include "XPCWrapper.h"
#include "XrayWrapper.h"
#include "Crypto.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/BlobBinding.h"
#include "mozilla/dom/cache/CacheStorage.h"
#include "mozilla/dom/CSSBinding.h"
+#include "mozilla/dom/CSSRuleBinding.h"
#include "mozilla/dom/DirectoryBinding.h"
#include "mozilla/dom/DOMPrefs.h"
#include "mozilla/dom/IndexedDatabaseManager.h"
#include "mozilla/dom/Fetch.h"
#include "mozilla/dom/FileBinding.h"
#include "mozilla/dom/InspectorUtilsBinding.h"
#include "mozilla/dom/MessageChannelBinding.h"
#include "mozilla/dom/MessagePortBinding.h"
@@ -905,16 +906,18 @@ xpc::GlobalProperties::Parse(JSContext*
return false;
}
RootedString nameStr(cx, nameValue.toString());
JSAutoByteString name;
if (!name.encodeUtf8(cx, nameStr))
return false;
if (!strcmp(name.ptr(), "CSS")) {
CSS = true;
+ } else if (!strcmp(name.ptr(), "CSSRule")) {
+ CSSRule = true;
} else if (!strcmp(name.ptr(), "indexedDB")) {
indexedDB = true;
} else if (!strcmp(name.ptr(), "XMLHttpRequest")) {
XMLHttpRequest = true;
} else if (!strcmp(name.ptr(), "TextEncoder")) {
TextEncoder = true;
} else if (!strcmp(name.ptr(), "TextDecoder")) {
TextDecoder = true;
@@ -963,16 +966,19 @@ xpc::GlobalProperties::Define(JSContext*
// Properties will be exposed to System automatically but not to Sandboxes
// if |[Exposed=System]| is specified.
// This function holds common properties not exposed automatically but able
// to be requested either in |Cu.importGlobalProperties| or
// |wantGlobalProperties| of a sandbox.
if (CSS && !dom::CSSBinding::GetConstructorObject(cx))
return false;
+ if (CSSRule && !dom::CSSRuleBinding::GetConstructorObject(cx))
+ return false;
+
if (XMLHttpRequest &&
!dom::XMLHttpRequestBinding::GetConstructorObject(cx))
return false;
if (TextEncoder &&
!dom::TextEncoderBinding::GetConstructorObject(cx))
return false;
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -2675,16 +2675,17 @@ struct GlobalProperties {
GlobalProperties() {
mozilla::PodZero(this);
}
bool Parse(JSContext* cx, JS::HandleObject obj);
bool DefineInXPCComponents(JSContext* cx, JS::HandleObject obj);
bool DefineInSandbox(JSContext* cx, JS::HandleObject obj);
bool CSS : 1;
+ bool CSSRule : 1;
bool indexedDB : 1;
bool XMLHttpRequest : 1;
bool TextDecoder : 1;
bool TextEncoder : 1;
bool URL : 1;
bool URLSearchParams : 1;
bool atob : 1;
bool btoa : 1;
--- a/js/xpconnect/tests/mochitest/test_bug790732.html
+++ b/js/xpconnect/tests/mochitest/test_bug790732.html
@@ -19,17 +19,16 @@ https://bugzilla.mozilla.org/show_bug.cg
// Check each interface that we shim. We start by checking specific
// constants for a couple of interfaces, and then once it's pretty clear that
// it's working as intended we just check that the objects themselves are the
// same.
is(Ci.nsIXMLHttpRequest.HEADERS_RECEIVED, XMLHttpRequest.HEADERS_RECEIVED);
is(Ci.nsIDOMDOMException.DATA_CLONE_ERR, DOMException.DATA_CLONE_ERR);
is(Ci.nsIDOMNode.DOCUMENT_NODE, Node.DOCUMENT_NODE);
is(Ci.nsIDOMCSSPrimitiveValue.CSS_PX, CSSPrimitiveValue.CSS_PX);
- is(Ci.nsIDOMCSSRule.NAMESPACE_RULE, CSSRule.NAMESPACE_RULE);
is(Ci.nsIDOMCSSValue.CSS_PRIMITIVE_VALUE, CSSValue.CSS_PRIMITIVE_VALUE);
is(Ci.nsIDOMEvent.FOCUS, Event.FOCUS);
is(Ci.nsIDOMNSEvent.CLICK, Event.CLICK);
is(Ci.nsIDOMKeyEvent, KeyEvent);
is(Ci.nsIDOMMouseEvent, MouseEvent);
is(Ci.nsIDOMMouseScrollEvent, MouseScrollEvent);
is(Ci.nsIDOMMutationEvent, MutationEvent);
// XXX We can't test this here because it's only exposed to chrome
--- a/layout/inspector/ServoStyleRuleMap.cpp
+++ b/layout/inspector/ServoStyleRuleMap.cpp
@@ -2,22 +2,22 @@
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "mozilla/ServoStyleRuleMap.h"
#include "mozilla/css/GroupRule.h"
+#include "mozilla/dom/CSSRuleBinding.h"
#include "mozilla/IntegerRange.h"
#include "mozilla/ServoStyleRule.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/ServoImportRule.h"
#include "mozilla/StyleSheetInlines.h"
-
#include "nsDocument.h"
#include "nsStyleSheetService.h"
namespace mozilla {
ServoStyleRuleMap::ServoStyleRuleMap(ServoStyleSet* aStyleSet)
: mStyleSet(aStyleSet)
{
@@ -73,36 +73,36 @@ void
ServoStyleRuleMap::RuleRemoved(ServoStyleSheet& aStyleSheet,
css::Rule& aStyleRule)
{
if (IsEmpty()) {
return;
}
switch (aStyleRule.Type()) {
- case nsIDOMCSSRule::STYLE_RULE: {
+ case CSSRuleBinding::STYLE_RULE: {
auto& rule = static_cast<ServoStyleRule&>(aStyleRule);
mTable.Remove(rule.Raw());
break;
}
- case nsIDOMCSSRule::IMPORT_RULE:
- case nsIDOMCSSRule::MEDIA_RULE:
- case nsIDOMCSSRule::SUPPORTS_RULE:
- case nsIDOMCSSRule::DOCUMENT_RULE: {
+ case CSSRuleBinding::IMPORT_RULE:
+ case CSSRuleBinding::MEDIA_RULE:
+ case CSSRuleBinding::SUPPORTS_RULE:
+ case CSSRuleBinding::DOCUMENT_RULE: {
// See the comment in StyleSheetRemoved.
mTable.Clear();
break;
}
- case nsIDOMCSSRule::FONT_FACE_RULE:
- case nsIDOMCSSRule::PAGE_RULE:
- case nsIDOMCSSRule::KEYFRAMES_RULE:
- case nsIDOMCSSRule::KEYFRAME_RULE:
- case nsIDOMCSSRule::NAMESPACE_RULE:
- case nsIDOMCSSRule::COUNTER_STYLE_RULE:
- case nsIDOMCSSRule::FONT_FEATURE_VALUES_RULE:
+ case CSSRuleBinding::FONT_FACE_RULE:
+ case CSSRuleBinding::PAGE_RULE:
+ case CSSRuleBinding::KEYFRAMES_RULE:
+ case CSSRuleBinding::KEYFRAME_RULE:
+ case CSSRuleBinding::NAMESPACE_RULE:
+ case CSSRuleBinding::COUNTER_STYLE_RULE:
+ case CSSRuleBinding::FONT_FEATURE_VALUES_RULE:
break;
default:
MOZ_ASSERT_UNREACHABLE("Unhandled rule");
}
}
size_t
ServoStyleRuleMap::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
@@ -111,30 +111,30 @@ ServoStyleRuleMap::SizeOfIncludingThis(M
n += mTable.ShallowSizeOfExcludingThis(aMallocSizeOf);
return n;
}
void
ServoStyleRuleMap::FillTableFromRule(css::Rule& aRule)
{
switch (aRule.Type()) {
- case nsIDOMCSSRule::STYLE_RULE: {
+ case CSSRuleBinding::STYLE_RULE: {
auto& rule = static_cast<ServoStyleRule&>(aRule);
mTable.Put(rule.Raw(), &rule);
break;
}
- case nsIDOMCSSRule::MEDIA_RULE:
- case nsIDOMCSSRule::SUPPORTS_RULE:
- case nsIDOMCSSRule::DOCUMENT_RULE: {
+ case CSSRuleBinding::MEDIA_RULE:
+ case CSSRuleBinding::SUPPORTS_RULE:
+ case CSSRuleBinding::DOCUMENT_RULE: {
auto& rule = static_cast<css::GroupRule&>(aRule);
auto ruleList = static_cast<ServoCSSRuleList*>(rule.CssRules());
FillTableFromRuleList(*ruleList);
break;
}
- case nsIDOMCSSRule::IMPORT_RULE: {
+ case CSSRuleBinding::IMPORT_RULE: {
auto& rule = static_cast<ServoImportRule&>(aRule);
MOZ_ASSERT(aRule.GetStyleSheet());
FillTableFromStyleSheet(*rule.GetStyleSheet()->AsServo());
break;
}
}
}
--- a/layout/inspector/tests/test_parseStyleSheetImport.html
+++ b/layout/inspector/tests/test_parseStyleSheetImport.html
@@ -14,32 +14,32 @@
</head>
<body>
<script type="application/javascript">
const InspectorUtils = SpecialPowers.InspectorUtils;
function do_test() {
var sheet = document.styleSheets[1];
var importRule = sheet.cssRules[0];
- is(importRule.type, SpecialPowers.Ci.nsIDOMCSSRule.IMPORT_RULE,
+ is(importRule.type, CSSRule.IMPORT_RULE,
"initial sheet has @import rule");
var importedSheet = importRule.styleSheet;
importedSheet.deleteRule(0);
is(importedSheet.cssRules.length, 0, "imported sheet now has no rules");
// "suffixed" refers to the "-2".
var suffixedSheet = sheet.cssRules[1].styleSheet;
InspectorUtils.parseStyleSheet(suffixedSheet, "");
is(suffixedSheet.cssRules.length, 0, "second imported sheet now has no rules");
// Re-parse the style sheet, preserving the imports.
InspectorUtils.parseStyleSheet(sheet, "@import url('bug1202095.css');" +
"@import url('bug1202095-2.css');");
- is(sheet.cssRules[0].type, SpecialPowers.Ci.nsIDOMCSSRule.IMPORT_RULE,
+ is(sheet.cssRules[0].type, CSSRule.IMPORT_RULE,
"re-parsed sheet has @import rule");
is(sheet.cssRules[0].styleSheet, importedSheet,
"imported sheet has not changed");
is(sheet.cssRules[1].styleSheet, suffixedSheet,
"second imported sheet has not changed");
// Re-parse the style sheet, preserving both imports, but changing
// the order.
@@ -52,17 +52,17 @@ function do_test() {
// Re-parse the style sheet, removing the imports.
InspectorUtils.parseStyleSheet(sheet, "");
is(sheet.cssRules.length, 0, "style sheet now has no rules");
// Re-parse the style sheet, adding one import back. This should
// not allow reuse.
InspectorUtils.parseStyleSheet(sheet, "@import url('bug1202095.css');");
- is(sheet.cssRules[0].type, SpecialPowers.Ci.nsIDOMCSSRule.IMPORT_RULE,
+ is(sheet.cssRules[0].type, CSSRule.IMPORT_RULE,
"re-re-re-parsed sheet has @import rule");
isnot(sheet.cssRules[0].styleSheet, importedSheet,
"imported sheet has changed now");
// Re-parse the style sheet, importing the same URL twice.
// The style sheet should be reused once, but not two times.
importedSheet = sheet.cssRules[0].styleSheet;
InspectorUtils.parseStyleSheet(sheet, "@import url('bug1202095.css');" +
--- a/layout/style/CSSFontFeatureValuesRule.h
+++ b/layout/style/CSSFontFeatureValuesRule.h
@@ -16,21 +16,20 @@ namespace mozilla {
namespace dom {
class CSSFontFeatureValuesRule : public css::Rule
{
public:
virtual bool IsCCLeaf() const override;
int32_t GetType() const final { return Rule::FONT_FEATURE_VALUES_RULE; }
- using Rule::GetType;
virtual already_AddRefed<mozilla::css::Rule> Clone() const override = 0;
// WebIDL interfaces
- uint16_t Type() const final { return nsIDOMCSSRule::FONT_FEATURE_VALUES_RULE; }
+ uint16_t Type() const final { return CSSRuleBinding::FONT_FEATURE_VALUES_RULE; }
virtual void GetCssTextImpl(nsAString& aCssText) const override = 0;
virtual void GetFontFamily(nsAString& aFamily) = 0;
virtual void SetFontFamily(const nsAString& aFamily, mozilla::ErrorResult& aRv) = 0;
virtual void GetValueText(nsAString& aValueText) = 0;
virtual void SetValueText(const nsAString& aValueText, mozilla::ErrorResult& aRv) = 0;
virtual size_t
SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override = 0;
--- a/layout/style/CSSImportRule.h
+++ b/layout/style/CSSImportRule.h
@@ -17,23 +17,22 @@ class CSSImportRule : public css::Rule
protected:
using Rule::Rule;
virtual ~CSSImportRule() {}
public:
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;
// WebIDL interface
- uint16_t Type() const final { return nsIDOMCSSRule::IMPORT_RULE; }
+ uint16_t Type() const final { return CSSRuleBinding::IMPORT_RULE; }
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;
};
--- a/layout/style/CSSKeyframeRule.h
+++ b/layout/style/CSSKeyframeRule.h
@@ -15,21 +15,20 @@ namespace dom {
class CSSKeyframeRule : public css::Rule
{
protected:
using css::Rule::Rule;
virtual ~CSSKeyframeRule() {}
public:
int32_t GetType() const final { return Rule::KEYFRAME_RULE; }
- using Rule::GetType;
bool IsCCLeaf() const override { return Rule::IsCCLeaf(); }
// WebIDL interface
- uint16_t Type() const final { return nsIDOMCSSRule::KEYFRAME_RULE; }
+ uint16_t Type() const final { return CSSRuleBinding::KEYFRAME_RULE; }
virtual void GetKeyText(nsAString& aKey) = 0;
virtual void SetKeyText(const nsAString& aKey) = 0;
virtual nsICSSDeclaration* Style() = 0;
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override = 0;
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
};
--- a/layout/style/CSSKeyframesRule.h
+++ b/layout/style/CSSKeyframesRule.h
@@ -3,34 +3,32 @@
/* 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_CSSKeyframesRule_h
#define mozilla_dom_CSSKeyframesRule_h
#include "mozilla/css/GroupRule.h"
-
#include "mozilla/dom/CSSKeyframeRule.h"
namespace mozilla {
namespace dom {
class CSSKeyframesRule : public css::GroupRule
{
protected:
using css::GroupRule::GroupRule;
virtual ~CSSKeyframesRule() {}
public:
int32_t GetType() const final { return Rule::KEYFRAMES_RULE; }
- using Rule::GetType;
// WebIDL interface
- uint16_t Type() const final { return nsIDOMCSSRule::KEYFRAMES_RULE; }
+ uint16_t Type() const final { return CSSRuleBinding::KEYFRAMES_RULE; }
virtual void GetName(nsAString& aName) const = 0;
virtual void SetName(const nsAString& aName) = 0;
virtual CSSRuleList* CssRules() = 0;
virtual void AppendRule(const nsAString& aRule) = 0;
virtual void DeleteRule(const nsAString& aKey) = 0;
virtual CSSKeyframeRule* FindRule(const nsAString& aKey) = 0;
bool UseForPresentation(nsPresContext* aPresContext,
--- a/layout/style/CSSMediaRule.h
+++ b/layout/style/CSSMediaRule.h
@@ -16,21 +16,18 @@ class CSSMediaRule : public css::Conditi
{
protected:
using ConditionRule::ConditionRule;
virtual ~CSSMediaRule() {}
public:
int32_t GetType() const override { return css::Rule::MEDIA_RULE; }
- // XPCOM interface
- using Rule::GetType;
-
// WebIDL interface
- uint16_t Type() const override { return nsIDOMCSSRule::MEDIA_RULE; }
+ uint16_t Type() const override { return CSSRuleBinding::MEDIA_RULE; }
virtual MediaList* Media() = 0;
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
};
} // namespace dom
} // namespace mozilla
--- a/layout/style/CSSMozDocumentRule.h
+++ b/layout/style/CSSMozDocumentRule.h
@@ -16,28 +16,25 @@ namespace dom {
class CSSMozDocumentRule : public css::ConditionRule
{
protected:
using ConditionRule::ConditionRule;
virtual ~CSSMozDocumentRule() {}
public:
int32_t GetType() const final override { return css::Rule::DOCUMENT_RULE; }
- using Rule::GetType;
static bool Match(nsIDocument* aDoc,
nsIURI* aDocURI,
const nsACString& aDocURISpec,
const nsACString& aPattern,
css::URLMatchingFunction aUrlMatchingFunction);
// WebIDL interface
- uint16_t Type() const final override {
- return nsIDOMCSSRule::DOCUMENT_RULE;
- }
+ uint16_t Type() const final override { return CSSRuleBinding::DOCUMENT_RULE; }
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
};
} // namespace dom
} // namespace mozilla
--- a/layout/style/CSSNamespaceRule.h
+++ b/layout/style/CSSNamespaceRule.h
@@ -22,25 +22,22 @@ protected:
public:
bool IsCCLeaf() const final {
return Rule::IsCCLeaf();
}
int32_t GetType() const final {
return Rule::NAMESPACE_RULE;
}
- using Rule::GetType;
virtual nsAtom* GetPrefix() const = 0;
virtual void GetURLSpec(nsString& aURLSpec) const = 0;
// WebIDL interfaces
- uint16_t Type() const final {
- return nsIDOMCSSRule::NAMESPACE_RULE;
- }
+ uint16_t Type() const final { return CSSRuleBinding::NAMESPACE_RULE; }
void GetNamespaceURI(nsString& aNamespaceURI) {
GetURLSpec(aNamespaceURI);
}
void GetPrefix(DOMString& aPrefix) {
aPrefix.SetKnownLiveAtom(GetPrefix(), DOMString::eTreatNullAsEmpty);
}
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const = 0;
--- a/layout/style/CSSPageRule.h
+++ b/layout/style/CSSPageRule.h
@@ -20,20 +20,19 @@ class CSSPageRule : public css::Rule
protected:
using Rule::Rule;
virtual ~CSSPageRule() {};
public:
virtual bool IsCCLeaf() const override = 0;
int32_t GetType() const final { return Rule::PAGE_RULE; }
- using Rule::GetType;
// WebIDL interfaces
- uint16_t Type() const final { return nsIDOMCSSRule::PAGE_RULE; }
+ uint16_t Type() const final { return CSSRuleBinding::PAGE_RULE; }
virtual void GetCssTextImpl(nsAString& aCssText) const override = 0;
virtual nsICSSDeclaration* Style() = 0;
virtual size_t
SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override = 0;
JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
--- a/layout/style/CSSRuleList.h
+++ b/layout/style/CSSRuleList.h
@@ -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/. */
#ifndef mozilla_dom_CSSRuleList_h
#define mozilla_dom_CSSRuleList_h
#include "mozilla/StyleSheetInlines.h"
#include "mozilla/css/Rule.h"
-#include "nsIDOMCSSRule.h"
#include "nsIDOMCSSRuleList.h"
#include "nsWrapperCache.h"
namespace mozilla {
namespace dom {
// IID for the CSSRuleList interface
#define NS_ICSSRULELIST_IID \
@@ -34,22 +33,16 @@ public:
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override final;
NS_IMETHOD
GetLength(uint32_t* aLength) override final
{
*aLength = Length();
return NS_OK;
}
- NS_IMETHOD
- Item(uint32_t aIndex, nsIDOMCSSRule** aReturn) override final
- {
- NS_IF_ADDREF(*aReturn = Item(aIndex));
- return NS_OK;
- }
// WebIDL API
css::Rule* Item(uint32_t aIndex)
{
bool unused;
return IndexedGetter(aIndex, unused);
}
--- a/layout/style/CSSSupportsRule.h
+++ b/layout/style/CSSSupportsRule.h
@@ -15,20 +15,19 @@ namespace dom {
class CSSSupportsRule : public css::ConditionRule
{
protected:
using ConditionRule::ConditionRule;
virtual ~CSSSupportsRule() {}
public:
int32_t GetType() const override { return css::Rule::SUPPORTS_RULE; }
- using Rule::GetType;
// WebIDL interface
- uint16_t Type() const override { return nsIDOMCSSRule::SUPPORTS_RULE; }
+ uint16_t Type() const override { return CSSRuleBinding::SUPPORTS_RULE; }
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
};
} // namespace dom
} // namespace mozilla
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -1311,35 +1311,34 @@ FontFaceSet::LogMessage(gfxUserFontEntry
if (LOG_ENABLED()) {
LOG(("userfonts (%p) %s", mUserFontSet.get(), message.get()));
}
// try to give the user an indication of where the rule came from
nsCSSFontFaceRule* rule = FindRuleForUserFontEntry(aUserFontEntry);
nsString href;
nsString text;
- nsresult rv;
uint32_t line = 0;
uint32_t column = 0;
if (rule) {
- rv = rule->GetCssText(text);
- NS_ENSURE_SUCCESS(rv, rv);
+ rule->GetCssText(text);
StyleSheet* sheet = rule->GetStyleSheet();
// if the style sheet is removed while the font is loading can be null
if (sheet) {
nsCString spec = sheet->GetSheetURI()->GetSpecOrDefault();
CopyUTF8toUTF16(spec, href);
} else {
NS_WARNING("null parent stylesheet for @font-face rule");
href.AssignLiteral("unknown");
}
line = rule->GetLineNumber();
column = rule->GetColumnNumber();
}
+ nsresult rv;
nsCOMPtr<nsIScriptError> scriptError =
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
uint64_t innerWindowID = mDocument->InnerWindowID();
rv = scriptError->InitWithWindowID(NS_ConvertUTF8toUTF16(message),
href, // file
text, // src line
--- a/layout/style/GroupRule.h
+++ b/layout/style/GroupRule.h
@@ -196,17 +196,16 @@ public:
// WebIDL API
dom::CSSRuleList* CssRules();
uint32_t InsertRule(const nsAString& aRule, uint32_t aIndex,
ErrorResult& aRv);
void DeleteRule(uint32_t aIndex, ErrorResult& aRv);
protected:
- // to help implement nsIDOMCSSRule
void AppendRulesToCssText(nsAString& aCssText) const;
// to implement methods on nsIDOMCSSGroupingRule
nsresult GetCssRules(nsIDOMCSSRuleList* *aRuleList);
nsresult InsertRule(const nsAString & aRule, uint32_t aIndex,
uint32_t* _retval);
nsresult DeleteRule(uint32_t aIndex);
--- a/layout/style/NameSpaceRule.h
+++ b/layout/style/NameSpaceRule.h
@@ -8,18 +8,16 @@
#ifndef mozilla_css_NameSpaceRule_h__
#define mozilla_css_NameSpaceRule_h__
#include "mozilla/Attributes.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/dom/CSSNamespaceRule.h"
-#include "nsIDOMCSSRule.h"
-
class nsAtom;
// IID for the NameSpaceRule class {f0b0dbe1-5031-4a21-b06a-dc141ef2af98}
#define NS_CSS_NAMESPACE_RULE_IMPL_CID \
{0xf0b0dbe1, 0x5031, 0x4a21, {0xb0, 0x6a, 0xdc, 0x14, 0x1e, 0xf2, 0xaf, 0x98}}
namespace mozilla {
--- a/layout/style/Rule.cpp
+++ b/layout/style/Rule.cpp
@@ -18,17 +18,16 @@ using namespace mozilla::dom;
namespace mozilla {
namespace css {
NS_IMPL_CYCLE_COLLECTING_ADDREF(Rule)
NS_IMPL_CYCLE_COLLECTING_RELEASE(Rule)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Rule)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
- NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(Rule)
bool
Rule::IsCCLeaf() const
{
@@ -75,58 +74,21 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_E
Rule::SetStyleSheet(StyleSheet* aSheet)
{
// We don't reference count this up reference. The style sheet
// will tell us when it's going away or when we're detached from
// it.
mSheet = aSheet;
}
-NS_IMETHODIMP
-Rule::GetParentRule(nsIDOMCSSRule** aParentRule)
-{
- NS_IF_ADDREF(*aParentRule = mParentRule);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-Rule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
-{
- NS_ENSURE_ARG_POINTER(aSheet);
-
- NS_IF_ADDREF(*aSheet = GetStyleSheet());
- return NS_OK;
-}
-
-/* virtual */ css::Rule*
-Rule::GetCSSRule()
-{
- return this;
-}
-
-NS_IMETHODIMP
-Rule::GetType(uint16_t* aType)
-{
- *aType = Type();
- return NS_OK;
-}
-
-NS_IMETHODIMP
+void
Rule::SetCssText(const nsAString& aCssText)
{
// We used to throw for some rule types, but not all. Specifically, we did
// not throw for StyleRule. Let's just always not throw.
- return NS_OK;
-}
-
-NS_IMETHODIMP
-Rule::GetCssText(nsAString& aCssText)
-{
- GetCssTextImpl(aCssText);
- return NS_OK;
}
Rule*
Rule::GetParentRule() const
{
return mParentRule;
}
--- a/layout/style/Rule.h
+++ b/layout/style/Rule.h
@@ -4,32 +4,32 @@
* 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/. */
/* base class for all rule types in a CSS style sheet */
#ifndef mozilla_css_Rule_h___
#define mozilla_css_Rule_h___
+#include "mozilla/dom/CSSRuleBinding.h"
#include "mozilla/StyleSheet.h"
#include "mozilla/MemoryReporting.h"
#include "nsISupports.h"
-#include "nsIDOMCSSRule.h"
#include "nsWrapperCache.h"
class nsIDocument;
struct nsRuleData;
template<class T> struct already_AddRefed;
class nsHTMLCSSStyleSheet;
namespace mozilla {
namespace css {
class GroupRule;
-class Rule : public nsIDOMCSSRule
+class Rule : public nsISupports
, public nsWrapperCache
{
protected:
Rule(uint32_t aLineNumber, uint32_t aColumnNumber)
: mSheet(nullptr),
mParentRule(nullptr),
mLineNumber(aLineNumber),
mColumnNumber(aColumnNumber)
@@ -49,19 +49,16 @@ protected:
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(Rule)
// Return true if this rule is known to be a cycle collection leaf, in the
// sense that it doesn't have any outgoing owning edges.
virtual bool IsCCLeaf() const MOZ_MUST_OVERRIDE;
- // nsIDOMCSSRule interface
- NS_DECL_NSIDOMCSSRULE
-
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const = 0;
#endif
// The constants in this list must maintain the following invariants:
// If a rule of type N must appear before a rule of type M in stylesheets
// then N < M
// Note that CSSStyleSheet::RebuildChildList assumes that no other kinds of
@@ -111,21 +108,21 @@ public:
*/
virtual already_AddRefed<Rule> Clone() const = 0;
// This is pure virtual because all of Rule's data members are non-owning and
// thus measured elsewhere.
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
const MOZ_MUST_OVERRIDE = 0;
- // WebIDL interface, aka helpers for nsIDOMCSSRule implementation.
+ // WebIDL interface
virtual uint16_t Type() const = 0;
virtual void GetCssTextImpl(nsAString& aCssText) const = 0;
void GetCssText(nsAString& aCssText) const { GetCssTextImpl(aCssText); }
- // XPCOM SetCssText is OK, since it never throws.
+ void SetCssText(const nsAString& aCssText);
Rule* GetParentRule() const;
StyleSheet* GetParentStyleSheet() const { return GetStyleSheet(); }
nsIDocument* GetParentObject() const { return GetDocument(); }
protected:
// True if we're known-live for cycle collection purposes.
bool IsKnownLive() const;
--- a/layout/style/ServoCSSRuleList.cpp
+++ b/layout/style/ServoCSSRuleList.cpp
@@ -51,18 +51,18 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
if (!aRule->IsCCLeaf()) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mRules[i]");
cb.NoteXPCOMChild(aRule);
// Note about @font-face and @counter-style rule again, since
// there is an indirect owning edge through Servo's struct that
// FontFaceRule / CounterStyleRule in Servo owns a Gecko
// nsCSSFontFaceRule / nsCSSCounterStyleRule object.
auto type = aRule->Type();
- if (type == nsIDOMCSSRule::FONT_FACE_RULE ||
- type == nsIDOMCSSRule::COUNTER_STYLE_RULE) {
+ if (type == CSSRuleBinding::FONT_FACE_RULE ||
+ type == CSSRuleBinding::COUNTER_STYLE_RULE) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mRawRules[i]");
cb.NoteXPCOMChild(aRule);
}
}
});
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
void
@@ -86,17 +86,17 @@ ServoCSSRuleList::SetStyleSheet(StyleShe
css::Rule*
ServoCSSRuleList::GetRule(uint32_t aIndex)
{
uintptr_t rule = mRules[aIndex];
if (rule <= kMaxRuleType) {
RefPtr<css::Rule> ruleObj = nullptr;
switch (rule) {
#define CASE_RULE(const_, name_) \
- case nsIDOMCSSRule::const_##_RULE: { \
+ case CSSRuleBinding::const_##_RULE: { \
uint32_t line = 0, column = 0; \
RefPtr<RawServo##name_##Rule> rule = \
Servo_CssRules_Get##name_##RuleAt( \
mRawRules, aIndex, &line, &column \
).Consume(); \
MOZ_ASSERT(rule); \
ruleObj = new Servo##name_##Rule(rule.forget(), line, column); \
break; \
@@ -110,25 +110,25 @@ ServoCSSRuleList::GetRule(uint32_t aInde
CASE_RULE(DOCUMENT, Document)
CASE_RULE(IMPORT, Import)
CASE_RULE(FONT_FEATURE_VALUES, FontFeatureValues)
#undef CASE_RULE
// For @font-face and @counter-style rules, the function returns
// a borrowed Gecko rule object directly, so we don't need to
// create anything here. But we still need to have the style sheet
// and parent rule set properly.
- case nsIDOMCSSRule::FONT_FACE_RULE: {
+ case CSSRuleBinding::FONT_FACE_RULE: {
ruleObj = Servo_CssRules_GetFontFaceRuleAt(mRawRules, aIndex);
break;
}
- case nsIDOMCSSRule::COUNTER_STYLE_RULE: {
+ case CSSRuleBinding::COUNTER_STYLE_RULE: {
ruleObj = Servo_CssRules_GetCounterStyleRuleAt(mRawRules, aIndex);
break;
}
- case nsIDOMCSSRule::KEYFRAME_RULE:
+ case CSSRuleBinding::KEYFRAME_RULE:
MOZ_ASSERT_UNREACHABLE("keyframe rule cannot be here");
return nullptr;
default:
NS_WARNING("stylo: not implemented yet");
return nullptr;
}
ruleObj->SetStyleSheet(mStyleSheet);
ruleObj->SetParentRule(mParentRule);
--- a/layout/style/ServoKeyframeRule.cpp
+++ b/layout/style/ServoKeyframeRule.cpp
@@ -24,21 +24,17 @@ public:
mDecls = new ServoDeclarationBlock(
Servo_Keyframe_GetStyle(aRule->Raw()).Consume());
}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(
ServoKeyframeDeclaration, nsICSSDeclaration)
- NS_IMETHOD GetParentRule(nsIDOMCSSRule** aParent) final
- {
- NS_IF_ADDREF(*aParent = mRule);
- return NS_OK;
- }
+ css::Rule* GetParentRule() final { return mRule; }
void DropReference() {
mRule = nullptr;
mDecls->SetOwningRule(nullptr);
}
DeclarationBlock* GetCSSDeclaration(Operation aOperation) final
{
--- a/layout/style/ServoPageRule.cpp
+++ b/layout/style/ServoPageRule.cpp
@@ -41,21 +41,20 @@ NS_INTERFACE_MAP_BEGIN(ServoPageRuleDecl
else
NS_IMPL_QUERY_TAIL_INHERITING(nsDOMCSSDeclaration)
NS_IMPL_ADDREF_USING_AGGREGATOR(ServoPageRuleDeclaration, Rule())
NS_IMPL_RELEASE_USING_AGGREGATOR(ServoPageRuleDeclaration, Rule())
/* nsDOMCSSDeclaration implementation */
-NS_IMETHODIMP
-ServoPageRuleDeclaration::GetParentRule(nsIDOMCSSRule** aParent)
+css::Rule*
+ServoPageRuleDeclaration::GetParentRule()
{
- *aParent = do_AddRef(Rule()).take();
- return NS_OK;
+ return Rule();
}
nsINode*
ServoPageRuleDeclaration::GetParentObject()
{
return Rule()->GetDocument();
}
--- a/layout/style/ServoPageRule.h
+++ b/layout/style/ServoPageRule.h
@@ -23,17 +23,17 @@ class DocGroup;
class ServoDeclarationBlock;
class ServoPageRule;
class ServoPageRuleDeclaration final : public nsDOMCSSDeclaration
{
public:
NS_DECL_ISUPPORTS_INHERITED
- NS_IMETHOD GetParentRule(nsIDOMCSSRule** aParent) final;
+ css::Rule* GetParentRule() final;
nsINode* GetParentObject() final;
DocGroup* GetDocGroup() const final;
protected:
DeclarationBlock* GetCSSDeclaration(Operation aOperation) final;
nsresult SetCSSDeclaration(DeclarationBlock* aDecl) final;
nsIDocument* DocToUpdate() final;
void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv,
--- a/layout/style/ServoStyleRule.cpp
+++ b/layout/style/ServoStyleRule.cpp
@@ -43,21 +43,20 @@ NS_INTERFACE_MAP_BEGIN(ServoStyleRuleDec
else
NS_IMPL_QUERY_TAIL_INHERITING(nsDOMCSSDeclaration)
NS_IMPL_ADDREF_USING_AGGREGATOR(ServoStyleRuleDeclaration, Rule())
NS_IMPL_RELEASE_USING_AGGREGATOR(ServoStyleRuleDeclaration, Rule())
/* nsDOMCSSDeclaration implementation */
-NS_IMETHODIMP
-ServoStyleRuleDeclaration::GetParentRule(nsIDOMCSSRule** aParent)
+css::Rule*
+ServoStyleRuleDeclaration::GetParentRule()
{
- *aParent = do_AddRef(Rule()).take();
- return NS_OK;
+ return Rule();
}
nsINode*
ServoStyleRuleDeclaration::GetParentObject()
{
return Rule()->GetDocument();
}
@@ -213,17 +212,17 @@ ServoStyleRule::GetCSSStyleRule(BindingS
return NS_OK;
}
/* CSSRule implementation */
uint16_t
ServoStyleRule::Type() const
{
- return nsIDOMCSSRule::STYLE_RULE;
+ return CSSRuleBinding::STYLE_RULE;
}
void
ServoStyleRule::GetCssTextImpl(nsAString& aCssText) const
{
Servo_StyleRule_GetCssText(mRawRule, &aCssText);
}
--- a/layout/style/ServoStyleRule.h
+++ b/layout/style/ServoStyleRule.h
@@ -26,17 +26,17 @@ class DocGroup;
class ServoDeclarationBlock;
class ServoStyleRule;
class ServoStyleRuleDeclaration final : public nsDOMCSSDeclaration
{
public:
NS_DECL_ISUPPORTS_INHERITED
- NS_IMETHOD GetParentRule(nsIDOMCSSRule** aParent) final;
+ css::Rule* GetParentRule() final;
nsINode* GetParentObject() final;
mozilla::dom::DocGroup* GetDocGroup() const final;
protected:
DeclarationBlock* GetCSSDeclaration(Operation aOperation) final;
nsresult SetCSSDeclaration(DeclarationBlock* aDecl) final;
nsIDocument* DocToUpdate() final;
void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv,
@@ -93,17 +93,16 @@ public:
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;
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
#ifdef DEBUG
void List(FILE* out = stdout, int32_t aIndent = 0) const final;
#endif
private:
~ServoStyleRule() {}
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -1058,17 +1058,17 @@ protected:
virtual ~DOMCSSDeclarationImpl(void);
// But we need to allow UniquePtr to delete us.
friend class mozilla::DefaultDelete<DOMCSSDeclarationImpl>;
public:
explicit DOMCSSDeclarationImpl(css::StyleRule *aRule);
- NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override;
+ css::Rule* GetParentRule() final { return mRule; }
virtual DeclarationBlock* GetCSSDeclaration(Operation aOperation) override;
virtual nsresult SetCSSDeclaration(DeclarationBlock* aDecl) override;
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv,
nsIPrincipal* aSubjectPrincipal) override;
nsDOMCSSDeclaration::ServoCSSParsingEnvironment
GetServoCSSParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final;
virtual nsIDocument* DocToUpdate() override;
@@ -1141,25 +1141,16 @@ DOMCSSDeclarationImpl::GetCSSParsingEnvi
nsDOMCSSDeclaration::ServoCSSParsingEnvironment
DOMCSSDeclarationImpl::GetServoCSSParsingEnvironment(
nsIPrincipal* aSubjectPrincipal) const
{
MOZ_CRASH("GetURLData shouldn't be calling on a Gecko rule");
}
-NS_IMETHODIMP
-DOMCSSDeclarationImpl::GetParentRule(nsIDOMCSSRule **aParent)
-{
- NS_ENSURE_ARG_POINTER(aParent);
-
- NS_IF_ADDREF(*aParent = mRule);
- return NS_OK;
-}
-
nsresult
DOMCSSDeclarationImpl::SetCSSDeclaration(DeclarationBlock* aDecl)
{
NS_PRECONDITION(mRule,
"can only be called when |GetCSSDeclaration| returned a declaration");
nsCOMPtr<nsIDocument> doc;
RefPtr<CSSStyleSheet> sheet = mRule->GetStyleSheet();
@@ -1186,17 +1177,17 @@ DOMCSSDeclarationImpl::DocToUpdate()
// -- StyleRule ------------------------------------
namespace mozilla {
namespace css {
uint16_t
StyleRule::Type() const
{
- return nsIDOMCSSRule::STYLE_RULE;
+ return CSSRuleBinding::STYLE_RULE;
}
nsICSSDeclaration*
StyleRule::Style()
{
if (!mDOMDeclaration) {
mDOMDeclaration.reset(new DOMCSSDeclarationImpl(this));
}
--- a/layout/style/StyleRule.h
+++ b/layout/style/StyleRule.h
@@ -358,17 +358,16 @@ public:
// null for style attribute
nsCSSSelectorList* Selector() { return mSelector; }
Declaration* GetDeclaration() const { return mDeclaration; }
void SetDeclaration(Declaration* aDecl);
int32_t GetType() const override;
- using Rule::GetType;
CSSStyleSheet* GetStyleSheet() const
{
StyleSheet* sheet = Rule::GetStyleSheet();
return sheet ? sheet->AsGecko() : nullptr;
}
already_AddRefed<Rule> Clone() const override;
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -381,23 +381,16 @@ StyleSheet::GetParentStyleSheet(nsIDOMSt
NS_IMETHODIMP
StyleSheet::GetMedia(nsIDOMMediaList** aMedia)
{
NS_ADDREF(*aMedia = Media());
return NS_OK;
}
NS_IMETHODIMP
-StyleSheet::GetOwnerRule(nsIDOMCSSRule** aOwnerRule)
-{
- NS_IF_ADDREF(*aOwnerRule = GetDOMOwnerRule());
- return NS_OK;
-}
-
-NS_IMETHODIMP
StyleSheet::GetCssRules(nsIDOMCSSRuleList** aCssRules)
{
ErrorResult rv;
nsCOMPtr<nsIDOMCSSRuleList> rules =
GetCssRules(*nsContentUtils::SubjectPrincipal(), rv);
rules.forget(aCssRules);
return rv.StealNSResult();
}
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -244,17 +244,16 @@ public:
NS_IMETHOD SetDisabled(bool aDisabled) final;
NS_IMETHOD GetOwnerNode(nsIDOMNode** aOwnerNode) final;
NS_IMETHOD GetParentStyleSheet(nsIDOMStyleSheet** aParentStyleSheet) final;
NS_IMETHOD GetHref(nsAString& aHref) final;
NS_IMETHOD GetTitle(nsAString& aTitle) final;
NS_IMETHOD GetMedia(nsIDOMMediaList** aMedia) final;
// nsIDOMCSSStyleSheet
- NS_IMETHOD GetOwnerRule(nsIDOMCSSRule** aOwnerRule) final;
NS_IMETHOD GetCssRules(nsIDOMCSSRuleList** aCssRules) final;
NS_IMETHOD InsertRule(const nsAString& aRule, uint32_t aIndex,
uint32_t* aReturn) final;
NS_IMETHOD DeleteRule(uint32_t aIndex) final;
// Changes to sheets should be inside of a WillDirty-DidDirty pair.
// However, the calls do not need to be matched; it's ok to call
// WillDirty and then make no change and skip the DidDirty call.
--- a/layout/style/nsCSSCounterStyleRule.cpp
+++ b/layout/style/nsCSSCounterStyleRule.cpp
@@ -79,17 +79,17 @@ nsCSSCounterStyleRule::List(FILE* out, i
nsCSSCounterStyleRule::GetType() const
{
return Rule::COUNTER_STYLE_RULE;
}
uint16_t
nsCSSCounterStyleRule::Type() const
{
- return nsIDOMCSSRule::COUNTER_STYLE_RULE;
+ return CSSRuleBinding::COUNTER_STYLE_RULE;
}
void
nsCSSCounterStyleRule::GetCssTextImpl(nsAString& aCssText) const
{
aCssText.AssignLiteral(u"@counter-style ");
nsDependentAtomString name(mName);
nsStyleUtil::AppendEscapedCSSIdent(name, aCssText);
--- a/layout/style/nsCSSCounterStyleRule.h
+++ b/layout/style/nsCSSCounterStyleRule.h
@@ -28,17 +28,16 @@ private:
public:
virtual bool IsCCLeaf() const override;
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
virtual int32_t GetType() const override;
- using Rule::GetType;
virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
// WebIDL interface
uint16_t Type() const override;
void GetCssTextImpl(nsAString& aCssText) const override;
void GetName(nsAString& aName);
void SetName(const nsAString& aName);
void GetSystem(nsAString& aSystem);
--- a/layout/style/nsCSSFontFaceRule.cpp
+++ b/layout/style/nsCSSFontFaceRule.cpp
@@ -266,21 +266,20 @@ nsCSSFontFaceStyleDecl::IndexedGetter(ui
aResult.AssignASCII(nsCSSProps::GetStringValue(id).get());
return;
}
}
}
aFound = false;
}
-NS_IMETHODIMP
-nsCSSFontFaceStyleDecl::GetParentRule(nsIDOMCSSRule** aParentRule)
+css::Rule*
+nsCSSFontFaceStyleDecl::GetParentRule()
{
- NS_IF_ADDREF(*aParentRule = ContainingRule());
- return NS_OK;
+ return ContainingRule();
}
NS_IMETHODIMP
nsCSSFontFaceStyleDecl::GetPropertyValue(const nsCSSPropertyID aPropID,
nsAString& aValue)
{
return
GetPropertyValue(NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(aPropID)),
@@ -399,17 +398,17 @@ nsCSSFontFaceRule::List(FILE* out, int32
nsCSSFontFaceRule::GetType() const
{
return Rule::FONT_FACE_RULE;
}
uint16_t
nsCSSFontFaceRule::Type() const
{
- return nsIDOMCSSRule::FONT_FACE_RULE;
+ return CSSRuleBinding::FONT_FACE_RULE;
}
void
nsCSSFontFaceRule::GetCssTextImpl(nsAString& aCssText) const
{
nsAutoString propText;
mDecl.GetCssTextImpl(propText);
--- a/layout/style/nsCSSFontFaceRule.h
+++ b/layout/style/nsCSSFontFaceRule.h
@@ -92,17 +92,16 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsCSSFontFaceRule,
mozilla::css::Rule)
virtual bool IsCCLeaf() const override;
#ifdef DEBUG
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
virtual int32_t GetType() const override;
- using Rule::GetType;
virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
void SetDesc(nsCSSFontDesc aDescID, nsCSSValue const & aValue);
void GetDesc(nsCSSFontDesc aDescID, nsCSSValue & aValue);
// WebIDL interface
uint16_t Type() const override;
void GetCssTextImpl(nsAString& aCssText) const override;
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -865,23 +865,20 @@ nsCSSKeyframeStyleDeclaration::GetCSSPar
nsDOMCSSDeclaration::ServoCSSParsingEnvironment
nsCSSKeyframeStyleDeclaration::GetServoCSSParsingEnvironment(
nsIPrincipal* aSubjectPrincipal) const
{
MOZ_CRASH("GetURLData shouldn't be calling on a Gecko rule");
}
-NS_IMETHODIMP
-nsCSSKeyframeStyleDeclaration::GetParentRule(nsIDOMCSSRule **aParent)
+css::Rule*
+nsCSSKeyframeStyleDeclaration::GetParentRule()
{
- NS_ENSURE_ARG_POINTER(aParent);
-
- NS_IF_ADDREF(*aParent = mRule);
- return NS_OK;
+ return mRule;
}
nsresult
nsCSSKeyframeStyleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl)
{
MOZ_ASSERT(aDecl, "must be non-null");
mRule->ChangeDeclaration(aDecl->AsGecko());
return NS_OK;
@@ -1292,23 +1289,20 @@ nsCSSPageStyleDeclaration::GetCSSParsing
nsDOMCSSDeclaration::ServoCSSParsingEnvironment
nsCSSPageStyleDeclaration::GetServoCSSParsingEnvironment(
nsIPrincipal* aSubjectPrincipal) const
{
MOZ_CRASH("GetURLData shouldn't be calling on a Gecko rule");
}
-NS_IMETHODIMP
-nsCSSPageStyleDeclaration::GetParentRule(nsIDOMCSSRule** aParent)
+css::Rule*
+nsCSSPageStyleDeclaration::GetParentRule()
{
- NS_ENSURE_ARG_POINTER(aParent);
-
- NS_IF_ADDREF(*aParent = mRule);
- return NS_OK;
+ return mRule;
}
nsresult
nsCSSPageStyleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl)
{
MOZ_ASSERT(aDecl, "must be non-null");
mRule->ChangeDeclaration(aDecl->AsGecko());
return NS_OK;
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -202,17 +202,17 @@ protected:
class nsCSSKeyframeRule;
class nsCSSKeyframeStyleDeclaration final : public nsDOMCSSDeclaration
{
public:
explicit nsCSSKeyframeStyleDeclaration(nsCSSKeyframeRule *aRule);
- NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override;
+ mozilla::css::Rule* GetParentRule() override;
void DropReference() { mRule = nullptr; }
virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) override;
virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock* aDecl) override;
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv,
nsIPrincipal* aSubjectPrincipal) override;
nsDOMCSSDeclaration::ServoCSSParsingEnvironment
GetServoCSSParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final;
virtual nsIDocument* DocToUpdate() override;
@@ -321,17 +321,17 @@ private:
class nsCSSPageRule;
class nsCSSPageStyleDeclaration final : public nsDOMCSSDeclaration
{
public:
explicit nsCSSPageStyleDeclaration(nsCSSPageRule *aRule);
- NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override;
+ mozilla::css::Rule* GetParentRule() override;
void DropReference() { mRule = nullptr; }
virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) override;
virtual nsresult SetCSSDeclaration(mozilla::DeclarationBlock* aDecl) override;
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv,
nsIPrincipal* aSubjectPrincipal) override;
nsDOMCSSDeclaration::ServoCSSParsingEnvironment
GetServoCSSParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final;
virtual nsIDocument* DocToUpdate() override;
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -458,22 +458,20 @@ nsComputedDOMStyle::GetLength(uint32_t*
*aLength = length;
ClearCurrentStyleSources();
return NS_OK;
}
-NS_IMETHODIMP
-nsComputedDOMStyle::GetParentRule(nsIDOMCSSRule** aParentRule)
-{
- *aParentRule = nullptr;
-
- return NS_OK;
+css::Rule*
+nsComputedDOMStyle::GetParentRule()
+{
+ return nullptr;
}
NS_IMETHODIMP
nsComputedDOMStyle::GetPropertyValue(const nsAString& aPropertyName,
nsAString& aReturn)
{
aReturn.Truncate();
--- a/layout/style/nsDOMCSSAttrDeclaration.cpp
+++ b/layout/style/nsDOMCSSAttrDeclaration.cpp
@@ -183,23 +183,20 @@ nsDOMCSSAttributeDeclaration::GetServoCS
{
return {
mElement->GetURLDataForStyleAttr(aSubjectPrincipal),
mElement->OwnerDoc()->GetCompatibilityMode(),
mElement->OwnerDoc()->CSSLoader(),
};
}
-NS_IMETHODIMP
-nsDOMCSSAttributeDeclaration::GetParentRule(nsIDOMCSSRule **aParent)
+css::Rule*
+nsDOMCSSAttributeDeclaration::GetParentRule()
{
- NS_ENSURE_ARG_POINTER(aParent);
-
- *aParent = nullptr;
- return NS_OK;
+ return nullptr;
}
/* virtual */ nsINode*
nsDOMCSSAttributeDeclaration::GetParentObject()
{
return mElement;
}
--- a/layout/style/nsDOMCSSAttrDeclaration.h
+++ b/layout/style/nsDOMCSSAttrDeclaration.h
@@ -32,17 +32,17 @@ public:
// If GetCSSDeclaration returns non-null, then the decl it returns
// is owned by our current style rule.
virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) override;
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv,
nsIPrincipal* aSubjectPrincipal) override;
nsDOMCSSDeclaration::ServoCSSParsingEnvironment
GetServoCSSParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final;
- NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override;
+ mozilla::css::Rule* GetParentRule() override;
virtual nsINode* GetParentObject() override;
virtual mozilla::dom::DocGroup* GetDocGroup() const override;
NS_IMETHOD SetPropertyValue(const nsCSSPropertyID aPropID,
const nsAString& aValue,
nsIPrincipal* aSubjectPrincipal) override;
--- a/layout/style/nsDOMCSSDeclaration.h
+++ b/layout/style/nsDOMCSSDeclaration.h
@@ -61,17 +61,16 @@ public:
nsAString & _retval) override;
NS_IMETHOD GetPropertyPriority(const nsAString & propertyName,
nsAString & _retval) override;
NS_IMETHOD SetProperty(const nsAString& propertyName,
const nsAString& value,
const nsAString& priority,
nsIPrincipal* aSubjectPrincipal) override;
NS_IMETHOD GetLength(uint32_t *aLength) override;
- NS_IMETHOD GetParentRule(nsIDOMCSSRule * *aParentRule) override = 0;
// WebIDL interface for CSS2Properties
#define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) publicname_
#define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, \
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
void \
Get##method_(nsAString& aValue, mozilla::ErrorResult& rv) \
{ \
--- a/layout/style/nsICSSDeclaration.h
+++ b/layout/style/nsICSSDeclaration.h
@@ -21,24 +21,26 @@
*/
#include "mozilla/Attributes.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsCSSPropertyID.h"
#include "mozilla/dom/CSSValue.h"
#include "nsWrapperCache.h"
#include "nsString.h"
-#include "nsIDOMCSSRule.h"
#include "nsIDOMCSSValue.h"
#include "mozilla/ErrorResult.h"
#include "nsCOMPtr.h"
class nsINode;
class nsIPrincipal;
namespace mozilla {
+namespace css {
+class Rule;
+} // namespace css
namespace dom {
class DocGroup;
} // namespace dom
} // namespace mozilla
// dbeabbfa-6cb3-4f5c-aec2-dd558d9d681f
#define NS_ICSSDECLARATION_IID \
{ 0xdbeabbfa, 0x6cb3, 0x4f5c, \
@@ -104,17 +106,16 @@ public:
{
bool found;
IndexedGetter(aIndex, found, aReturn);
if (!found) {
aReturn.Truncate();
}
return NS_OK;
}
- NS_IMETHOD GetParentRule(nsIDOMCSSRule * *aParentRule) override = 0;
// WebIDL interface for CSSStyleDeclaration
void SetCssText(const nsAString& aString, nsIPrincipal* aSubjectPrincipal,
mozilla::ErrorResult& rv) {
rv = SetCssText(aString, aSubjectPrincipal);
}
void GetCssText(nsString& aString) {
// Cast to nsAString& so we end up calling our virtual
@@ -144,21 +145,17 @@ public:
const nsAString& aPriority, nsIPrincipal* aSubjectPrincipal,
mozilla::ErrorResult& rv) {
rv = SetProperty(aPropName, aValue, aPriority, aSubjectPrincipal);
}
void RemoveProperty(const nsAString& aPropName, nsString& aRetval,
mozilla::ErrorResult& rv) {
rv = RemoveProperty(aPropName, aRetval);
}
- already_AddRefed<nsIDOMCSSRule> GetParentRule() {
- nsCOMPtr<nsIDOMCSSRule> rule;
- GetParentRule(getter_AddRefs(rule));
- return rule.forget();
- }
+ virtual mozilla::css::Rule* GetParentRule() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSDeclaration, NS_ICSSDECLARATION_IID)
#define NS_DECL_NSICSSDECLARATION \
NS_IMETHOD GetPropertyValue(const nsCSSPropertyID aPropID, \
nsAString& aValue) override; \
NS_IMETHOD SetPropertyValue(const nsCSSPropertyID aPropID, \
@@ -173,11 +170,11 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSDecl
NS_IMETHOD RemoveProperty(const nsAString & propertyName, nsAString & _retval) override; \
NS_IMETHOD GetPropertyPriority(const nsAString & propertyName, nsAString & _retval) override; \
NS_IMETHOD SetProperty(const nsAString& propertyName, \
const nsAString& value, \
const nsAString& priority, \
nsIPrincipal* aSubjectPrincipal = nullptr) override; \
NS_IMETHOD GetLength(uint32_t *aLength) override; \
NS_IMETHOD Item(uint32_t index, nsAString & _retval) override; \
- NS_IMETHOD GetParentRule(nsIDOMCSSRule * *aParentRule) override;
+ mozilla::css::Rule* GetParentRule() override;
#endif // nsICSSDeclaration_h__