mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-31 03:27:31 +09:00
Issue #2490 - WIP: part 9. Add a CSSRule Web IDL interface.
This commit is contained in:
parent
bb2aaeac9f
commit
5a522d9145
13 changed files with 118 additions and 18 deletions
|
|
@ -205,6 +205,11 @@ DOMInterfaces = {
|
||||||
'nativeType': 'nsROCSSPrimitiveValue',
|
'nativeType': 'nsROCSSPrimitiveValue',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'CSSRule': {
|
||||||
|
# 'hasXPConnectImpls': True,
|
||||||
|
'nativeType': 'mozilla::css::Rule'
|
||||||
|
},
|
||||||
|
|
||||||
'CSSStyleDeclaration': {
|
'CSSStyleDeclaration': {
|
||||||
'nativeType': 'nsICSSDeclaration'
|
'nativeType': 'nsICSSDeclaration'
|
||||||
},
|
},
|
||||||
|
|
@ -1689,7 +1694,6 @@ def addExternalIface(iface, nativeType=None, headerFile=None,
|
||||||
|
|
||||||
addExternalIface('ApplicationCache', nativeType='nsIDOMOfflineResourceList')
|
addExternalIface('ApplicationCache', nativeType='nsIDOMOfflineResourceList')
|
||||||
addExternalIface('Counter')
|
addExternalIface('Counter')
|
||||||
addExternalIface('CSSRule')
|
|
||||||
addExternalIface('RTCDataChannel', nativeType='nsIDOMDataChannel')
|
addExternalIface('RTCDataChannel', nativeType='nsIDOMDataChannel')
|
||||||
addExternalIface('HitRegionOptions', nativeType='nsISupports')
|
addExternalIface('HitRegionOptions', nativeType='nsISupports')
|
||||||
addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
|
addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
|
||||||
|
|
|
||||||
52
dom/webidl/CSSRule.webidl
Normal file
52
dom/webidl/CSSRule.webidl
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
/* -*- 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/#the-cssrule-interface
|
||||||
|
* https://drafts.csswg.org/css-animations/#interface-cssrule
|
||||||
|
* https://drafts.csswg.org/css-counter-styles-3/#extentions-to-cssrule-interface
|
||||||
|
* https://drafts.csswg.org/css-conditional-3/#extentions-to-cssrule-interface
|
||||||
|
* https://drafts.csswg.org/css-fonts-3/#om-fontfeaturevalues
|
||||||
|
*/
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/cssom/#the-cssrule-interface
|
||||||
|
interface CSSRule {
|
||||||
|
|
||||||
|
const unsigned short STYLE_RULE = 1;
|
||||||
|
const unsigned short CHARSET_RULE = 2; // historical
|
||||||
|
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;
|
||||||
|
// FIXME: We don't support MARGIN_RULE yet.
|
||||||
|
// XXXbz Should we expose the constant anyway?
|
||||||
|
// const unsigned short MARGIN_RULE = 9;
|
||||||
|
const unsigned short NAMESPACE_RULE = 10;
|
||||||
|
readonly attribute unsigned short type;
|
||||||
|
attribute DOMString cssText;
|
||||||
|
readonly attribute CSSRule? parentRule;
|
||||||
|
readonly attribute CSSStyleSheet? parentStyleSheet;
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/css-animations/#interface-cssrule
|
||||||
|
partial interface CSSRule {
|
||||||
|
const unsigned short KEYFRAMES_RULE = 7;
|
||||||
|
const unsigned short KEYFRAME_RULE = 8;
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/css-counter-styles-3/#extentions-to-cssrule-interface
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/css-fonts-3/#om-fontfeaturevalues
|
||||||
|
partial interface CSSRule {
|
||||||
|
const unsigned short FONT_FEATURE_VALUES_RULE = 14;
|
||||||
|
};
|
||||||
|
|
@ -7,8 +7,6 @@
|
||||||
* http://dev.w3.org/csswg/cssom/
|
* http://dev.w3.org/csswg/cssom/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface CSSRule;
|
|
||||||
|
|
||||||
interface CSSStyleDeclaration {
|
interface CSSStyleDeclaration {
|
||||||
[CEReactions, SetterThrows]
|
[CEReactions, SetterThrows]
|
||||||
attribute DOMString cssText;
|
attribute DOMString cssText;
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@
|
||||||
* http://dev.w3.org/csswg/cssom/
|
* http://dev.w3.org/csswg/cssom/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface CSSRule;
|
|
||||||
|
|
||||||
enum CSSStyleSheetParsingMode {
|
enum CSSStyleSheetParsingMode {
|
||||||
"author",
|
"author",
|
||||||
"user",
|
"user",
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* 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/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
interface CSSRule;
|
|
||||||
|
|
||||||
[ChromeOnly, Constructor(DOMString type, optional StyleRuleChangeEventInit eventInitDict)]
|
[ChromeOnly, Constructor(DOMString type, optional StyleRuleChangeEventInit eventInitDict)]
|
||||||
interface StyleRuleChangeEvent : Event
|
interface StyleRuleChangeEvent : Event
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@
|
||||||
* http://dev.w3.org/csswg/cssom/
|
* http://dev.w3.org/csswg/cssom/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface CSSRule;
|
|
||||||
|
|
||||||
interface StyleSheet {
|
interface StyleSheet {
|
||||||
[Constant]
|
[Constant]
|
||||||
readonly attribute DOMString type;
|
readonly attribute DOMString type;
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ WEBIDL_FILES = [
|
||||||
'CSSLexer.webidl',
|
'CSSLexer.webidl',
|
||||||
'CSSPrimitiveValue.webidl',
|
'CSSPrimitiveValue.webidl',
|
||||||
'CSSPseudoElement.webidl',
|
'CSSPseudoElement.webidl',
|
||||||
|
'CSSRule.webidl',
|
||||||
'CSSRuleList.webidl',
|
'CSSRuleList.webidl',
|
||||||
'CSSStyleDeclaration.webidl',
|
'CSSStyleDeclaration.webidl',
|
||||||
'CSSStyleSheet.webidl',
|
'CSSStyleSheet.webidl',
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#define mozilla_dom_CSSRuleList_h
|
#define mozilla_dom_CSSRuleList_h
|
||||||
|
|
||||||
#include "mozilla/StyleSheetInlines.h"
|
#include "mozilla/StyleSheetInlines.h"
|
||||||
|
#include "mozilla/css/Rule.h"
|
||||||
#include "nsIDOMCSSRule.h"
|
#include "nsIDOMCSSRule.h"
|
||||||
#include "nsIDOMCSSRuleList.h"
|
#include "nsIDOMCSSRuleList.h"
|
||||||
#include "nsWrapperCache.h"
|
#include "nsWrapperCache.h"
|
||||||
|
|
@ -45,13 +46,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebIDL API
|
// WebIDL API
|
||||||
nsIDOMCSSRule* Item(uint32_t aIndex)
|
css::Rule* Item(uint32_t aIndex)
|
||||||
{
|
{
|
||||||
bool unused;
|
bool unused;
|
||||||
return IndexedGetter(aIndex, unused);
|
return IndexedGetter(aIndex, unused);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual nsIDOMCSSRule* IndexedGetter(uint32_t aIndex, bool& aFound) = 0;
|
virtual css::Rule* IndexedGetter(uint32_t aIndex, bool& aFound) = 0;
|
||||||
virtual uint32_t Length() = 0;
|
virtual uint32_t Length() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public:
|
||||||
|
|
||||||
virtual CSSStyleSheet* GetParentObject() override;
|
virtual CSSStyleSheet* GetParentObject() override;
|
||||||
|
|
||||||
virtual nsIDOMCSSRule*
|
virtual css::Rule*
|
||||||
IndexedGetter(uint32_t aIndex, bool& aFound) override;
|
IndexedGetter(uint32_t aIndex, bool& aFound) override;
|
||||||
virtual uint32_t
|
virtual uint32_t
|
||||||
Length() override;
|
Length() override;
|
||||||
|
|
@ -101,7 +101,7 @@ CSSRuleListImpl::Length()
|
||||||
return AssertedCast<uint32_t>(mStyleSheet->StyleRuleCount());
|
return AssertedCast<uint32_t>(mStyleSheet->StyleRuleCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIDOMCSSRule*
|
css::Rule*
|
||||||
CSSRuleListImpl::IndexedGetter(uint32_t aIndex, bool& aFound)
|
CSSRuleListImpl::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||||
{
|
{
|
||||||
aFound = false;
|
aFound = false;
|
||||||
|
|
@ -1648,7 +1648,7 @@ CSSStyleSheet::Media()
|
||||||
return mMedia;
|
return mMedia;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIDOMCSSRule*
|
css::Rule*
|
||||||
CSSStyleSheet::GetDOMOwnerRule() const
|
CSSStyleSheet::GetDOMOwnerRule() const
|
||||||
{
|
{
|
||||||
return mOwnerRule;
|
return mOwnerRule;
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,7 @@ public:
|
||||||
// Can't be inline because we can't include ImportRule here. And can't be
|
// Can't be inline because we can't include ImportRule here. And can't be
|
||||||
// called GetOwnerRule because that would be ambiguous with the ImportRule
|
// called GetOwnerRule because that would be ambiguous with the ImportRule
|
||||||
// version.
|
// version.
|
||||||
nsIDOMCSSRule* GetDOMOwnerRule() const final;
|
css::Rule* GetDOMOwnerRule() const final;
|
||||||
|
|
||||||
void WillDirty();
|
void WillDirty();
|
||||||
void DidDirty();
|
void DidDirty();
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,11 @@ public:
|
||||||
// WebIDL interface, aka helpers for nsIDOMCSSRule implementation.
|
// WebIDL interface, aka helpers for nsIDOMCSSRule implementation.
|
||||||
virtual uint16_t Type() const = 0;
|
virtual uint16_t Type() const = 0;
|
||||||
virtual void GetCssTextImpl(nsAString& aCssText) const = 0;
|
virtual void GetCssTextImpl(nsAString& aCssText) const = 0;
|
||||||
|
// XPCOM GetCssText is OK, since it never throws.
|
||||||
|
// XPCOM SetCssText is OK, since it never throws.
|
||||||
|
Rule* GetParentRule() const;
|
||||||
|
StyleSheet* GetParentStyleSheet() const { return GetStyleSheet(); }
|
||||||
|
nsIDocument* GetParentObject() const { return GetDocument(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// True if we're known-live for cycle collection purposes.
|
// True if we're known-live for cycle collection purposes.
|
||||||
|
|
@ -137,4 +142,18 @@ protected:
|
||||||
} // namespace css
|
} // namespace css
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
// Specialization of the bindings UnwrapArg setup for css::Rule, so we can avoid
|
||||||
|
// adding an IID to css::Rule. This can go away once all css::Rule subclasses
|
||||||
|
// are on WebIDL bindings.
|
||||||
|
|
||||||
|
#include "js/TypeDecls.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
template <>
|
||||||
|
nsresult
|
||||||
|
UnwrapArg(JS::Handle<JSObject*> src, css::Rule** ppArg);
|
||||||
|
} // namepace dom
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif /* mozilla_css_Rule_h___ */
|
#endif /* mozilla_css_Rule_h___ */
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,10 @@ class CSSRuleList;
|
||||||
class SRIMetadata;
|
class SRIMetadata;
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|
||||||
|
namespace css {
|
||||||
|
class Rule;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Superclass for CSSStyleSheet.
|
* Superclass for CSSStyleSheet.
|
||||||
*/
|
*/
|
||||||
|
|
@ -145,7 +149,7 @@ public:
|
||||||
// The XPCOM SetDisabled is fine for WebIDL.
|
// The XPCOM SetDisabled is fine for WebIDL.
|
||||||
|
|
||||||
// WebIDL CSSStyleSheet API
|
// WebIDL CSSStyleSheet API
|
||||||
virtual nsIDOMCSSRule* GetDOMOwnerRule() const = 0;
|
virtual css::Rule* GetDOMOwnerRule() const = 0;
|
||||||
dom::CSSRuleList* GetCssRules(nsIPrincipal& aSubjectPrincipal,
|
dom::CSSRuleList* GetCssRules(nsIPrincipal& aSubjectPrincipal,
|
||||||
ErrorResult& aRv);
|
ErrorResult& aRv);
|
||||||
uint32_t InsertRule(const nsAString& aRule, uint32_t aIndex,
|
uint32_t InsertRule(const nsAString& aRule, uint32_t aIndex,
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,27 @@ using namespace mozilla::dom;
|
||||||
|
|
||||||
// base class for all rule types in a CSS style sheet
|
// base class for all rule types in a CSS style sheet
|
||||||
|
|
||||||
|
// Temporary code that can go away once all css::Rules are on WebIDL bindings.
|
||||||
|
#include "xpcpublic.h"
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
template<>
|
||||||
|
nsresult
|
||||||
|
UnwrapArg(JS::Handle<JSObject*> src, css::Rule** ppArg)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
nsCOMPtr<nsIDOMCSSRule> rule =
|
||||||
|
do_QueryInterface(xpc::UnwrapReflectorToISupports(src));
|
||||||
|
if (!rule) {
|
||||||
|
return NS_NOINTERFACE;
|
||||||
|
}
|
||||||
|
*ppArg = rule->GetCSSRule();
|
||||||
|
NS_ADDREF(*ppArg);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace css {
|
namespace css {
|
||||||
|
|
||||||
|
|
@ -153,6 +174,12 @@ Rule::GetCssText(nsAString& aCssText)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rule*
|
||||||
|
Rule::GetParentRule() const
|
||||||
|
{
|
||||||
|
return mParentRule;
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
// Style Rule List for group rules
|
// Style Rule List for group rules
|
||||||
//
|
//
|
||||||
|
|
@ -164,7 +191,7 @@ public:
|
||||||
|
|
||||||
virtual CSSStyleSheet* GetParentObject() override;
|
virtual CSSStyleSheet* GetParentObject() override;
|
||||||
|
|
||||||
virtual nsIDOMCSSRule*
|
virtual Rule*
|
||||||
IndexedGetter(uint32_t aIndex, bool& aFound) override;
|
IndexedGetter(uint32_t aIndex, bool& aFound) override;
|
||||||
virtual uint32_t
|
virtual uint32_t
|
||||||
Length() override;
|
Length() override;
|
||||||
|
|
@ -209,7 +236,7 @@ GroupRuleRuleList::Length()
|
||||||
return AssertedCast<uint32_t>(mGroupRule->StyleRuleCount());
|
return AssertedCast<uint32_t>(mGroupRule->StyleRuleCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIDOMCSSRule*
|
Rule*
|
||||||
GroupRuleRuleList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
GroupRuleRuleList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||||
{
|
{
|
||||||
aFound = false;
|
aFound = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue