mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-25 08:37:30 +09:00
Issue #2490 - Part 11: Convert CSSImportRule to WebIDL.
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
95642cb4e5
commit
525606c15d
9 changed files with 38 additions and 40 deletions
|
|
@ -74,7 +74,6 @@
|
||||||
// includes needed for the prototype chain interfaces
|
// includes needed for the prototype chain interfaces
|
||||||
#include "nsIDOMCSSKeyframeRule.h"
|
#include "nsIDOMCSSKeyframeRule.h"
|
||||||
#include "nsIDOMCSSKeyframesRule.h"
|
#include "nsIDOMCSSKeyframesRule.h"
|
||||||
#include "nsIDOMCSSImportRule.h"
|
|
||||||
#include "nsIDOMCSSMediaRule.h"
|
#include "nsIDOMCSSMediaRule.h"
|
||||||
#include "nsIDOMCSSFontFaceRule.h"
|
#include "nsIDOMCSSFontFaceRule.h"
|
||||||
#include "nsIDOMCSSMozDocumentRule.h"
|
#include "nsIDOMCSSMozDocumentRule.h"
|
||||||
|
|
@ -192,9 +191,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSStyleRule, nsCSSRuleSH,
|
NS_DEFINE_CLASSINFO_DATA(CSSStyleRule, nsCSSRuleSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
nsIXPCScriptable::WANT_PRECREATE)
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSImportRule, nsCSSRuleSH,
|
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
|
||||||
nsIXPCScriptable::WANT_PRECREATE)
|
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSMediaRule, nsCSSRuleSH,
|
NS_DEFINE_CLASSINFO_DATA(CSSMediaRule, nsCSSRuleSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
nsIXPCScriptable::WANT_PRECREATE)
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
|
|
@ -525,11 +521,6 @@ nsDOMClassInfo::Init()
|
||||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleRule)
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleRule)
|
||||||
DOM_CLASSINFO_MAP_END
|
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_BEGIN(CSSMediaRule, nsIDOMCSSMediaRule)
|
||||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule)
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule)
|
||||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMediaRule)
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMediaRule)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ DOMCI_CLASS(DOMConstructor)
|
||||||
|
|
||||||
// CSS classes
|
// CSS classes
|
||||||
DOMCI_CLASS(CSSStyleRule)
|
DOMCI_CLASS(CSSStyleRule)
|
||||||
DOMCI_CLASS(CSSImportRule)
|
|
||||||
DOMCI_CLASS(CSSMediaRule)
|
DOMCI_CLASS(CSSMediaRule)
|
||||||
|
|
||||||
// XUL classes
|
// XUL classes
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ class TabChildGlobal;
|
||||||
class ProcessGlobal;
|
class ProcessGlobal;
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
namespace css {
|
namespace css {
|
||||||
class ImportRule;
|
|
||||||
class StyleRule;
|
class StyleRule;
|
||||||
class MediaRule;
|
class MediaRule;
|
||||||
class DocumentRule;
|
class DocumentRule;
|
||||||
|
|
@ -292,7 +291,6 @@ private:
|
||||||
friend class SandboxPrivate;
|
friend class SandboxPrivate;
|
||||||
friend class nsInProcessTabChildGlobal;
|
friend class nsInProcessTabChildGlobal;
|
||||||
friend class nsWindowRoot;
|
friend class nsWindowRoot;
|
||||||
friend class mozilla::css::ImportRule;
|
|
||||||
friend class mozilla::css::StyleRule;
|
friend class mozilla::css::StyleRule;
|
||||||
friend class mozilla::css::MediaRule;
|
friend class mozilla::css::MediaRule;
|
||||||
friend class mozilla::css::DocumentRule;
|
friend class mozilla::css::DocumentRule;
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,10 @@ DOMInterfaces = {
|
||||||
'nativeType': 'nsDOMCSSDeclaration'
|
'nativeType': 'nsDOMCSSDeclaration'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'CSSImportRule': {
|
||||||
|
'nativeType': 'mozilla::css::ImportRule',
|
||||||
|
},
|
||||||
|
|
||||||
'CSSLexer': {
|
'CSSLexer': {
|
||||||
'wrapperCache': False
|
'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;
|
||||||
|
};
|
||||||
|
|
@ -90,6 +90,7 @@ WEBIDL_FILES = [
|
||||||
'CSPReport.webidl',
|
'CSPReport.webidl',
|
||||||
'CSS.webidl',
|
'CSS.webidl',
|
||||||
'CSSAnimation.webidl',
|
'CSSAnimation.webidl',
|
||||||
|
'CSSImportRule.webidl',
|
||||||
'CSSLexer.webidl',
|
'CSSLexer.webidl',
|
||||||
'CSSNamespaceRule.webidl',
|
'CSSNamespaceRule.webidl',
|
||||||
'CSSPrimitiveValue.webidl',
|
'CSSPrimitiveValue.webidl',
|
||||||
|
|
|
||||||
|
|
@ -214,28 +214,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=668855
|
||||||
|
|
||||||
make_live_map();
|
make_live_map();
|
||||||
|
|
||||||
let unpreservable_native_key = function () {
|
// We're out of ideas for unpreservable natives, now that just about
|
||||||
// We only allow natives that support wrapper preservation to be used as weak
|
// everything is on webidl, so just don't test those.
|
||||||
// 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();
|
|
||||||
|
|
||||||
/* set up for running precise GC/CC then checking the results */
|
/* set up for running precise GC/CC then checking the results */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ class nsString;
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
class CSSStyleSheet;
|
class CSSStyleSheet;
|
||||||
|
class StyleSheet;
|
||||||
|
|
||||||
namespace css {
|
namespace css {
|
||||||
|
|
||||||
|
|
@ -61,6 +62,9 @@ public:
|
||||||
// WebIDL interface
|
// WebIDL interface
|
||||||
uint16_t Type() const override;
|
uint16_t Type() const override;
|
||||||
void GetCssTextImpl(nsAString& aCssText) 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:
|
private:
|
||||||
nsString mURLSpec;
|
nsString mURLSpec;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
#include "nsDOMClassInfoID.h"
|
#include "nsDOMClassInfoID.h"
|
||||||
#include "mozilla/dom/CSSStyleDeclarationBinding.h"
|
#include "mozilla/dom/CSSStyleDeclarationBinding.h"
|
||||||
#include "mozilla/dom/CSSNamespaceRuleBinding.h"
|
#include "mozilla/dom/CSSNamespaceRuleBinding.h"
|
||||||
|
#include "mozilla/dom/CSSImportRuleBinding.h"
|
||||||
#include "StyleRule.h"
|
#include "StyleRule.h"
|
||||||
#include "nsFont.h"
|
#include "nsFont.h"
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
|
|
@ -242,7 +243,7 @@ ImportRule::ImportRule(nsMediaList* aMedia, const nsString& aURLSpec,
|
||||||
, mURLSpec(aURLSpec)
|
, mURLSpec(aURLSpec)
|
||||||
, mMedia(aMedia)
|
, mMedia(aMedia)
|
||||||
{
|
{
|
||||||
SetIsNotDOMBinding();
|
MOZ_ASSERT(aMedia);
|
||||||
// XXXbz This is really silly.... the mMedia here will be replaced
|
// XXXbz This is really silly.... the mMedia here will be replaced
|
||||||
// with itself if we manage to load a sheet. Which should really
|
// with itself if we manage to load a sheet. Which should really
|
||||||
// never fail nowadays, in sane cases.
|
// never fail nowadays, in sane cases.
|
||||||
|
|
@ -252,7 +253,6 @@ ImportRule::ImportRule(const ImportRule& aCopy)
|
||||||
: Rule(aCopy),
|
: Rule(aCopy),
|
||||||
mURLSpec(aCopy.mURLSpec)
|
mURLSpec(aCopy.mURLSpec)
|
||||||
{
|
{
|
||||||
SetIsNotDOMBinding();
|
|
||||||
// Whether or not an @import rule has a null sheet is a permanent
|
// 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
|
// property of that @import rule, since it is null only if the target
|
||||||
// sheet failed security checks.
|
// sheet failed security checks.
|
||||||
|
|
@ -284,7 +284,6 @@ ImportRule::IsCCLeaf() const
|
||||||
// QueryInterface implementation for ImportRule
|
// QueryInterface implementation for ImportRule
|
||||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ImportRule)
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ImportRule)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSImportRule)
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSImportRule)
|
||||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSImportRule)
|
|
||||||
NS_INTERFACE_MAP_END_INHERITING(Rule)
|
NS_INTERFACE_MAP_END_INHERITING(Rule)
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_CLASS(ImportRule)
|
NS_IMPL_CYCLE_COLLECTION_CLASS(ImportRule)
|
||||||
|
|
@ -373,6 +372,12 @@ ImportRule::GetCssTextImpl(nsAString& aCssText) const
|
||||||
aCssText.Append(';');
|
aCssText.Append(';');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StyleSheet*
|
||||||
|
ImportRule::GetStyleSheet() const
|
||||||
|
{
|
||||||
|
return mChildSheet;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
ImportRule::GetHref(nsAString & aHref)
|
ImportRule::GetHref(nsAString & aHref)
|
||||||
{
|
{
|
||||||
|
|
@ -385,7 +390,7 @@ ImportRule::GetMedia(nsIDOMMediaList * *aMedia)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aMedia);
|
NS_ENSURE_ARG_POINTER(aMedia);
|
||||||
|
|
||||||
NS_IF_ADDREF(*aMedia = mMedia);
|
NS_ADDREF(*aMedia = mMedia);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -416,8 +421,7 @@ ImportRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
||||||
ImportRule::WrapObject(JSContext* aCx,
|
ImportRule::WrapObject(JSContext* aCx,
|
||||||
JS::Handle<JSObject*> aGivenProto)
|
JS::Handle<JSObject*> aGivenProto)
|
||||||
{
|
{
|
||||||
NS_NOTREACHED("We called SetIsNotDOMBinding() in our constructor");
|
return CSSImportRuleBinding::Wrap(aCx, this, aGivenProto);
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupRule::GroupRule(uint32_t aLineNumber, uint32_t aColumnNumber)
|
GroupRule::GroupRule(uint32_t aLineNumber, uint32_t aColumnNumber)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue