Bug 591303 - Part 2: Add getCSSRule function to nsIDOMCSSRule. r=bz

This commit is contained in:
Birunthan Mohanathas 2014-07-14 15:57:46 -07:00
parent 53f4caf2b6
commit ad2cce83e8
21 changed files with 130 additions and 29 deletions

View File

@ -5,7 +5,7 @@
#include "nsIDOMCSSRule.idl"
[scriptable, uuid(19fe78cc-65ff-4b1d-a5d7-9ea89692cec6)]
[scriptable, uuid(756c326c-eb38-4342-95e5-5eabea809174)]
interface nsIDOMCSSCharsetRule : nsIDOMCSSRule
{
attribute DOMString encoding;

View File

@ -9,7 +9,7 @@
* Interface in the CSS OM for at-rules that conditionally apply their
* child rules.
*/
[scriptable, uuid(942754f2-2c0e-461b-9c10-c0e929504fe1)]
[scriptable, uuid(44da41b2-5660-415d-8692-eae805776103)]
interface nsIDOMCSSConditionRule : nsIDOMCSSGroupingRule
{
attribute DOMString conditionText;

View File

@ -6,7 +6,7 @@
#include "nsIDOMCSSRule.idl"
[scriptable, uuid(5f9f2068-743b-42e3-becb-10ffa994d1e3)]
[scriptable, uuid(9b5e48ce-d84c-4e31-aff5-34e9f4141313)]
interface nsIDOMCSSCounterStyleRule : nsIDOMCSSRule
{
attribute DOMString name;

View File

@ -5,7 +5,7 @@
#include "nsIDOMCSSRule.idl"
[scriptable, uuid(a6cf90bb-15b3-11d2-932e-00805f8add32)]
[scriptable, uuid(db971017-fe0c-4529-972c-8217f2fee217)]
interface nsIDOMCSSFontFaceRule : nsIDOMCSSRule
{
readonly attribute nsIDOMCSSStyleDeclaration style;

View File

@ -5,7 +5,7 @@
#include "nsIDOMCSSRule.idl"
[scriptable, uuid(f4cb1776-389d-4f52-a4d8-68bea5bd00c1)]
[scriptable, uuid(a343d27f-1da6-4fc3-9355-d4ca434f958e)]
interface nsIDOMCSSFontFeatureValuesRule : nsIDOMCSSRule
{
attribute DOMString fontFamily;

View File

@ -8,7 +8,7 @@
/**
* Interface for at-rules that have child rules in the CSS OM.
*/
[scriptable, uuid(ab013eed-fa21-4c6a-bba3-79e8780f583e)]
[scriptable, uuid(a0e3324a-f911-4baf-9591-5322c76cbb0d)]
interface nsIDOMCSSGroupingRule : nsIDOMCSSRule
{
readonly attribute nsIDOMCSSRuleList cssRules;

View File

@ -5,7 +5,7 @@
#include "nsIDOMCSSRule.idl"
[scriptable, uuid(a6cf90cf-15b3-11d2-932e-00805f8add32)]
[scriptable, uuid(d3b2b914-01ef-4663-beda-a6475a26f491)]
interface nsIDOMCSSImportRule : nsIDOMCSSRule
{
readonly attribute DOMString href;

View File

@ -8,7 +8,7 @@
/**
* Interface for @media rules in the CSS OM.
*/
[scriptable, uuid(1f491b05-932b-4aa1-a1f1-466505d70898)]
[scriptable, uuid(6cf9c5b2-fa0f-43c0-aa50-ef85b4756e3a)]
interface nsIDOMCSSMediaRule : nsIDOMCSSConditionRule
{
readonly attribute nsIDOMMediaList media;

View File

@ -8,7 +8,7 @@
/**
* Interface for @-moz-document rules in the CSS OM.
*/
[scriptable, uuid(f118a5a8-ac36-464f-b993-18cf6fe76fda)]
[scriptable, uuid(2d0cef9d-c1b2-4c6c-9003-fa83040626d1)]
interface nsIDOMCSSMozDocumentRule : nsIDOMCSSConditionRule
{
// XXX Add access to the URL list.

View File

@ -5,7 +5,7 @@
#include "nsIDOMCSSRule.idl"
[scriptable, uuid(6126024d-d716-4ad8-bc53-24dd6d5846b1)]
[scriptable, uuid(c119072b-7d2f-4aeb-a90d-e2d6b606c32a)]
interface nsIDOMCSSPageRule : nsIDOMCSSRule
{
//attribute DOMString selectorText;

View File

@ -5,6 +5,16 @@
#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.
@ -13,7 +23,7 @@
* http://www.w3.org/TR/DOM-Level-2-Style
*/
[scriptable, uuid(2938307a-9d70-4b63-8afc-0197e82318ad)]
[scriptable, uuid(4d6b3bad-f53c-4585-82f6-62982e27ede8)]
interface nsIDOMCSSRule : nsISupports
{
// RuleType
@ -41,4 +51,6 @@ interface nsIDOMCSSRule : nsISupports
readonly attribute nsIDOMCSSStyleSheet parentStyleSheet;
readonly attribute nsIDOMCSSRule parentRule;
[noscript, nostdcall, notxpcom] Rule getCSSRule();
};

View File

@ -5,7 +5,7 @@
#include "nsIDOMCSSRule.idl"
[scriptable, uuid(a6cf90bf-15b3-11d2-932e-00805f8add32)]
[scriptable, uuid(b5e9af48-a7c2-4f88-aae3-58307af4b5a5)]
interface nsIDOMCSSStyleRule : nsIDOMCSSRule
{
attribute DOMString selectorText;

View File

@ -8,7 +8,7 @@
/**
* Interface for @supports rules in the CSS OM.
*/
[scriptable, uuid(5f409a4d-92f9-4a62-8e8a-cc1c02c32918)]
[scriptable, uuid(0b9e63a1-1bd7-4caf-850e-148b762b14d2)]
interface nsIDOMCSSSupportsRule : nsIDOMCSSConditionRule
{
};

View File

@ -5,7 +5,7 @@
#include "nsIDOMCSSRule.idl"
[scriptable, uuid(a6cf90d0-15b3-11d2-932e-00805f8add32)]
[scriptable, uuid(98f4c27b-fb35-4355-8fd9-546c4697d71a)]
interface nsIDOMCSSUnknownRule : nsIDOMCSSRule
{
};

View File

@ -5,7 +5,7 @@
#include "nsIDOMCSSRule.idl"
[scriptable, uuid(38a19612-dc58-414a-954c-233183808484)]
[scriptable, uuid(a281a8b4-eaa2-49a8-8b97-acc2814a57c9)]
interface nsIDOMMozCSSKeyframeRule : nsIDOMCSSRule
{
attribute DOMString keyText;

View File

@ -5,7 +5,7 @@
#include "nsIDOMCSSRule.idl"
[scriptable, uuid(aa4ea11f-791b-4671-b192-b931e6539669)]
[scriptable, uuid(400f4b70-ad0a-4047-aba4-ee8019f6b907)]
interface nsIDOMMozCSSKeyframesRule : nsIDOMCSSRule
{
attribute DOMString name;

View File

@ -259,12 +259,13 @@ GetRuleFromDOMRule(nsIDOMCSSStyleRule *aRule, ErrorResult& rv)
}
NS_IMETHODIMP
inDOMUtils::GetRuleLine(nsIDOMCSSStyleRule *aRule, uint32_t *_retval)
inDOMUtils::GetRuleLine(nsIDOMCSSRule* aRule, uint32_t* _retval)
{
ErrorResult rv;
nsRefPtr<StyleRule> rule = GetRuleFromDOMRule(aRule, rv);
if (rv.Failed()) {
return rv.ErrorCode();
NS_ENSURE_ARG_POINTER(aRule);
Rule* rule = aRule->GetCSSRule();
if (!rule) {
return NS_ERROR_FAILURE;
}
*_retval = rule->GetLineNumber();
@ -272,13 +273,15 @@ inDOMUtils::GetRuleLine(nsIDOMCSSStyleRule *aRule, uint32_t *_retval)
}
NS_IMETHODIMP
inDOMUtils::GetRuleColumn(nsIDOMCSSStyleRule *aRule, uint32_t *_retval)
inDOMUtils::GetRuleColumn(nsIDOMCSSRule* aRule, uint32_t* _retval)
{
ErrorResult rv;
nsRefPtr<StyleRule> rule = GetRuleFromDOMRule(aRule, rv);
if (rv.Failed()) {
return rv.ErrorCode();
NS_ENSURE_ARG_POINTER(aRule);
Rule* rule = aRule->GetCSSRule();
if (!rule) {
return NS_ERROR_FAILURE;
}
*_retval = rule->GetColumnNumber();
return NS_OK;
}

View File

@ -9,6 +9,7 @@ interface nsISupportsArray;
interface nsIDOMCharacterData;
interface nsIDOMElement;
interface nsIDOMDocument;
interface nsIDOMCSSRule;
interface nsIDOMCSSStyleRule;
interface nsIDOMNode;
interface nsIDOMNodeList;
@ -16,7 +17,7 @@ interface nsIDOMFontFaceList;
interface nsIDOMRange;
interface nsIDOMCSSStyleSheet;
[scriptable, uuid(5d8a1458-4b76-4aee-bf46-4eca223a01b2)]
[scriptable, uuid(fd529e53-f734-4d15-83ce-d545a631d668)]
interface inIDOMUtils : nsISupports
{
// CSS utilities
@ -24,8 +25,8 @@ interface inIDOMUtils : nsISupports
[optional] out unsigned long aLength,
[array, size_is (aLength), retval] out nsISupports aSheets);
nsISupportsArray getCSSStyleRules(in nsIDOMElement aElement, [optional] in DOMString aPseudo);
unsigned long getRuleLine(in nsIDOMCSSStyleRule aRule);
unsigned long getRuleColumn(in nsIDOMCSSStyleRule aRule);
unsigned long getRuleLine(in nsIDOMCSSRule aRule);
unsigned long getRuleColumn(in nsIDOMCSSRule aRule);
// Utilities for working with selectors. We don't have a JS OM representation
// of a single selector or a selector list yet, but given a rule we can index

View File

@ -119,6 +119,7 @@ public:
// to implement methods on nsIDOMCSSRule
nsresult GetParentRule(nsIDOMCSSRule** aParentRule);
nsresult GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet);
Rule* GetCSSRule();
// This is pure virtual because all of Rule's data members are non-owning and
// thus measured elsewhere.

View File

@ -1258,6 +1258,12 @@ DOMCSSStyleRule::GetParentRule(nsIDOMCSSRule** aParentRule)
return Rule()->GetParentRule(aParentRule);
}
css::Rule*
DOMCSSStyleRule::GetCSSRule()
{
return Rule();
}
NS_IMETHODIMP
DOMCSSStyleRule::GetSelectorText(nsAString& aSelectorText)
{

View File

@ -117,6 +117,12 @@ Rule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
return NS_OK;
}
css::Rule*
Rule::GetCSSRule()
{
return this;
}
size_t
Rule::SizeOfCOMArrayElementIncludingThis(css::Rule* aElement,
MallocSizeOf aMallocSizeOf,
@ -310,6 +316,12 @@ CharsetRule::GetParentRule(nsIDOMCSSRule** aParentRule)
return Rule::GetParentRule(aParentRule);
}
css::Rule*
CharsetRule::GetCSSRule()
{
return Rule::GetCSSRule();
}
/* virtual */ size_t
CharsetRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
@ -458,6 +470,12 @@ ImportRule::GetParentRule(nsIDOMCSSRule** aParentRule)
return Rule::GetParentRule(aParentRule);
}
css::Rule*
ImportRule::GetCSSRule()
{
return Rule::GetCSSRule();
}
NS_IMETHODIMP
ImportRule::GetHref(nsAString & aHref)
{
@ -876,6 +894,12 @@ MediaRule::GetParentRule(nsIDOMCSSRule** aParentRule)
return GroupRule::GetParentRule(aParentRule);
}
css::Rule*
MediaRule::GetCSSRule()
{
return Rule::GetCSSRule();
}
// nsIDOMCSSGroupingRule methods
NS_IMETHODIMP
MediaRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
@ -1084,6 +1108,12 @@ DocumentRule::GetParentRule(nsIDOMCSSRule** aParentRule)
return GroupRule::GetParentRule(aParentRule);
}
css::Rule*
DocumentRule::GetCSSRule()
{
return Rule::GetCSSRule();
}
// nsIDOMCSSGroupingRule methods
NS_IMETHODIMP
DocumentRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
@ -1332,6 +1362,12 @@ NameSpaceRule::GetParentRule(nsIDOMCSSRule** aParentRule)
return Rule::GetParentRule(aParentRule);
}
css::Rule*
NameSpaceRule::GetCSSRule()
{
return Rule::GetCSSRule();
}
/* virtual */ size_t
NameSpaceRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
@ -1811,6 +1847,12 @@ nsCSSFontFaceRule::GetParentRule(nsIDOMCSSRule** aParentRule)
return Rule::GetParentRule(aParentRule);
}
css::Rule*
nsCSSFontFaceRule::GetCSSRule()
{
return Rule::GetCSSRule();
}
NS_IMETHODIMP
nsCSSFontFaceRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
{
@ -1997,6 +2039,12 @@ nsCSSFontFeatureValuesRule::GetParentRule(nsIDOMCSSRule** aParentRule)
return Rule::GetParentRule(aParentRule);
}
css::Rule*
nsCSSFontFeatureValuesRule::GetCSSRule()
{
return Rule::GetCSSRule();
}
NS_IMETHODIMP
nsCSSFontFeatureValuesRule::GetFontFamily(nsAString& aFamilyListStr)
{
@ -2280,6 +2328,12 @@ nsCSSKeyframeRule::GetParentRule(nsIDOMCSSRule** aParentRule)
return Rule::GetParentRule(aParentRule);
}
css::Rule*
nsCSSKeyframeRule::GetCSSRule()
{
return Rule::GetCSSRule();
}
NS_IMETHODIMP
nsCSSKeyframeRule::GetKeyText(nsAString& aKeyText)
{
@ -2477,6 +2531,12 @@ nsCSSKeyframesRule::GetParentRule(nsIDOMCSSRule** aParentRule)
return GroupRule::GetParentRule(aParentRule);
}
css::Rule*
nsCSSKeyframesRule::GetCSSRule()
{
return GroupRule::GetCSSRule();
}
NS_IMETHODIMP
nsCSSKeyframesRule::GetName(nsAString& aName)
{
@ -2802,6 +2862,12 @@ nsCSSPageRule::GetParentRule(nsIDOMCSSRule** aParentRule)
return Rule::GetParentRule(aParentRule);
}
css::Rule*
nsCSSPageRule::GetCSSRule()
{
return Rule::GetCSSRule();
}
css::ImportantRule*
nsCSSPageRule::GetImportantRule()
{
@ -2953,6 +3019,12 @@ CSSSupportsRule::GetParentRule(nsIDOMCSSRule** aParentRule)
return css::GroupRule::GetParentRule(aParentRule);
}
css::Rule*
CSSSupportsRule::GetCSSRule()
{
return css::GroupRule::GetCSSRule();
}
// nsIDOMCSSGroupingRule methods
NS_IMETHODIMP
CSSSupportsRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
@ -3118,6 +3190,12 @@ nsCSSCounterStyleRule::GetParentRule(nsIDOMCSSRule** aParentRule)
return Rule::GetParentRule(aParentRule);
}
css::Rule*
nsCSSCounterStyleRule::GetCSSRule()
{
return Rule::GetCSSRule();
}
// nsIDOMCSSCounterStyleRule methods
NS_IMETHODIMP
nsCSSCounterStyleRule::GetName(nsAString& aName)