mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 851892 part 11. Convert CSSImportRule to WebIDL. r=peterv,heycam,mccr8
Note that the .media PutForwards is a new feature coming along for the ride now that we're using the spec IDL.
This commit is contained in:
parent
64dbc532d5
commit
3379caebf7
@ -76,7 +76,6 @@
|
||||
// includes needed for the prototype chain interfaces
|
||||
#include "nsIDOMCSSKeyframeRule.h"
|
||||
#include "nsIDOMCSSKeyframesRule.h"
|
||||
#include "nsIDOMCSSImportRule.h"
|
||||
#include "nsIDOMCSSMediaRule.h"
|
||||
#include "nsIDOMCSSFontFaceRule.h"
|
||||
#include "nsIDOMCSSMozDocumentRule.h"
|
||||
@ -193,9 +192,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSStyleRule, nsCSSRuleSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||
nsIXPCScriptable::WANT_PRECREATE)
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSImportRule, nsCSSRuleSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||
nsIXPCScriptable::WANT_PRECREATE)
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSMediaRule, nsCSSRuleSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||
nsIXPCScriptable::WANT_PRECREATE)
|
||||
@ -526,11 +522,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleRule)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CSSImportRule, nsIDOMCSSImportRule)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSImportRule)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CSSMediaRule, nsIDOMCSSMediaRule)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMediaRule)
|
||||
|
@ -21,7 +21,6 @@ enum nsDOMClassInfoID
|
||||
|
||||
// CSS classes
|
||||
eDOMClassInfo_CSSStyleRule_id,
|
||||
eDOMClassInfo_CSSImportRule_id,
|
||||
eDOMClassInfo_CSSMediaRule_id,
|
||||
|
||||
// XUL classes
|
||||
|
@ -20,7 +20,6 @@ class TabChildGlobal;
|
||||
class ProcessGlobal;
|
||||
} // namespace dom
|
||||
namespace css {
|
||||
class ImportRule;
|
||||
class StyleRule;
|
||||
class MediaRule;
|
||||
class DocumentRule;
|
||||
@ -294,7 +293,6 @@ private:
|
||||
friend class SandboxPrivate;
|
||||
friend class nsInProcessTabChildGlobal;
|
||||
friend class nsWindowRoot;
|
||||
friend class mozilla::css::ImportRule;
|
||||
friend class mozilla::css::StyleRule;
|
||||
friend class mozilla::css::MediaRule;
|
||||
friend class mozilla::css::DocumentRule;
|
||||
|
@ -196,6 +196,10 @@ DOMInterfaces = {
|
||||
'nativeType': 'nsDOMCSSDeclaration'
|
||||
},
|
||||
|
||||
'CSSImportRule': {
|
||||
'nativeType': 'mozilla::css::ImportRule',
|
||||
},
|
||||
|
||||
'CSSLexer': {
|
||||
'wrapperCache': False
|
||||
},
|
||||
|
17
dom/webidl/CSSImportRule.webidl
Normal file
17
dom/webidl/CSSImportRule.webidl
Normal file
@ -0,0 +1,17 @@
|
||||
/* -*- 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/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://drafts.csswg.org/cssom/#cssimportrule
|
||||
*/
|
||||
|
||||
// https://drafts.csswg.org/cssom/#cssimportrule
|
||||
interface CSSImportRule : CSSRule {
|
||||
readonly attribute DOMString href;
|
||||
[SameObject, PutForwards=mediaText] readonly attribute MediaList media;
|
||||
// Per spec, the .styleSheet is never null, but in our implementation it can
|
||||
// be. See <https://bugzilla.mozilla.org/show_bug.cgi?id=1326509>.
|
||||
[SameObject] readonly attribute CSSStyleSheet? styleSheet;
|
||||
};
|
@ -89,6 +89,7 @@ WEBIDL_FILES = [
|
||||
'CSPReport.webidl',
|
||||
'CSS.webidl',
|
||||
'CSSAnimation.webidl',
|
||||
'CSSImportRule.webidl',
|
||||
'CSSLexer.webidl',
|
||||
'CSSNamespaceRule.webidl',
|
||||
'CSSPrimitiveValue.webidl',
|
||||
|
@ -214,28 +214,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=668855
|
||||
|
||||
make_live_map();
|
||||
|
||||
let unpreservable_native_key = function () {
|
||||
// We only allow natives that support wrapper preservation to be used as weak
|
||||
// map keys. We should be able to try to add unpreservable natives as keys without
|
||||
// crashing (bug 711616), but we should throw an error (bug 761620).
|
||||
|
||||
let dummy_test_map = new WeakMap;
|
||||
|
||||
let rule_fail = false;
|
||||
let got_rule = false;
|
||||
try {
|
||||
var rule = document.styleSheets[0].cssRules[0];
|
||||
got_rule = true;
|
||||
dummy_test_map.set(rule, 1);
|
||||
} catch (e) {
|
||||
rule_fail = true;
|
||||
}
|
||||
ok(got_rule, "Got the CSS rule");
|
||||
ok(rule_fail, "Using a CSS rule as a weak map key should produce an exception because it can't be wrapper preserved.");
|
||||
|
||||
}
|
||||
|
||||
unpreservable_native_key();
|
||||
// We're out of ideas for unpreservable natives, now that just about
|
||||
// everything is on webidl, so just don't test those.
|
||||
|
||||
/* set up for running precise GC/CC then checking the results */
|
||||
|
||||
|
@ -20,6 +20,7 @@ class nsString;
|
||||
namespace mozilla {
|
||||
|
||||
class CSSStyleSheet;
|
||||
class StyleSheet;
|
||||
|
||||
namespace css {
|
||||
|
||||
@ -60,6 +61,9 @@ public:
|
||||
// WebIDL interface
|
||||
uint16_t Type() const override;
|
||||
void GetCssTextImpl(nsAString& aCssText) const override;
|
||||
// The XPCOM GetHref is fine, since it never fails.
|
||||
nsMediaList* Media() const { return mMedia; }
|
||||
StyleSheet* GetStyleSheet() const;
|
||||
|
||||
private:
|
||||
nsString mURLSpec;
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "mozilla/dom/CSSStyleDeclarationBinding.h"
|
||||
#include "mozilla/dom/CSSNamespaceRuleBinding.h"
|
||||
#include "mozilla/dom/CSSImportRuleBinding.h"
|
||||
#include "StyleRule.h"
|
||||
#include "nsFont.h"
|
||||
#include "nsIURI.h"
|
||||
@ -220,7 +221,7 @@ ImportRule::ImportRule(nsMediaList* aMedia, const nsString& aURLSpec,
|
||||
, mURLSpec(aURLSpec)
|
||||
, mMedia(aMedia)
|
||||
{
|
||||
SetIsNotDOMBinding();
|
||||
MOZ_ASSERT(aMedia);
|
||||
// XXXbz This is really silly.... the mMedia here will be replaced
|
||||
// with itself if we manage to load a sheet. Which should really
|
||||
// never fail nowadays, in sane cases.
|
||||
@ -230,7 +231,6 @@ ImportRule::ImportRule(const ImportRule& aCopy)
|
||||
: Rule(aCopy),
|
||||
mURLSpec(aCopy.mURLSpec)
|
||||
{
|
||||
SetIsNotDOMBinding();
|
||||
// Whether or not an @import rule has a null sheet is a permanent
|
||||
// property of that @import rule, since it is null only if the target
|
||||
// sheet failed security checks.
|
||||
@ -257,7 +257,6 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(ImportRule, Rule, mMedia, mChildSheet)
|
||||
// QueryInterface implementation for ImportRule
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ImportRule)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSImportRule)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSImportRule)
|
||||
NS_INTERFACE_MAP_END_INHERITING(Rule)
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -331,6 +330,12 @@ ImportRule::GetCssTextImpl(nsAString& aCssText) const
|
||||
aCssText.Append(';');
|
||||
}
|
||||
|
||||
StyleSheet*
|
||||
ImportRule::GetStyleSheet() const
|
||||
{
|
||||
return mChildSheet;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImportRule::GetHref(nsAString & aHref)
|
||||
{
|
||||
@ -343,7 +348,7 @@ ImportRule::GetMedia(nsIDOMMediaList * *aMedia)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aMedia);
|
||||
|
||||
NS_IF_ADDREF(*aMedia = mMedia);
|
||||
NS_ADDREF(*aMedia = mMedia);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -374,8 +379,7 @@ ImportRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
ImportRule::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
NS_NOTREACHED("We called SetIsNotDOMBinding() in our constructor");
|
||||
return nullptr;
|
||||
return CSSImportRuleBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
GroupRule::GroupRule(uint32_t aLineNumber, uint32_t aColumnNumber)
|
||||
|
Loading…
Reference in New Issue
Block a user