mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-12-27 20:30:39 +00:00
#592: implement CSSStyleSheet rules and addRule
This commit is contained in:
parent
bbc9a12a5d
commit
2eb5ba7f62
@ -18,4 +18,12 @@ interface CSSStyleSheet : StyleSheet {
|
||||
unsigned long insertRule(DOMString rule, optional unsigned long index = 0);
|
||||
[Throws]
|
||||
void deleteRule(unsigned long index);
|
||||
|
||||
// Non-standard WebKit things, see https://github.com/w3c/csswg-drafts/pull/3900.
|
||||
[Throws, BinaryName="cssRules"]
|
||||
readonly attribute CSSRuleList rules;
|
||||
[Throws, BinaryName="deleteRule"]
|
||||
void removeRule(optional unsigned long index = 0);
|
||||
[Throws]
|
||||
long addRule(optional DOMString selector = "undefined", optional DOMString style = "undefined", optional unsigned long index);
|
||||
};
|
||||
|
@ -1918,6 +1918,40 @@ CSSStyleSheet::InsertRule(const nsAString& aRule,
|
||||
return InsertRuleInternal(aRule, aIndex, aReturn);
|
||||
}
|
||||
|
||||
/* TenFourFox issue 592 */
|
||||
int32_t
|
||||
CSSStyleSheet::AddRule(const nsAString& aSelector, const nsAString& aBlock,
|
||||
const Optional<uint32_t>& aIndex, ErrorResult& aRv)
|
||||
{
|
||||
uint32_t index;
|
||||
if (aIndex.WasPassed()) {
|
||||
index = aIndex.Value();
|
||||
} else {
|
||||
CSSRuleList* collection = GetCssRules(aRv);
|
||||
if (!collection) {
|
||||
// Must have thrown.
|
||||
return -1;
|
||||
}
|
||||
index = collection->Length();
|
||||
}
|
||||
|
||||
nsAutoString rule;
|
||||
rule.Append(aSelector);
|
||||
rule.AppendLiteral(" { ");
|
||||
if (!aBlock.IsEmpty()) {
|
||||
rule.Append(aBlock);
|
||||
rule.Append(' ');
|
||||
}
|
||||
rule.Append('}');
|
||||
|
||||
uint32_t retval; // unused
|
||||
nsresult rv = InsertRuleInternal(rule, index, &retval);
|
||||
if (NS_FAILED(rv)) aRv.Throw(rv);
|
||||
|
||||
// As per Microsoft documentation, always return -1.
|
||||
return -1;
|
||||
}
|
||||
|
||||
static bool
|
||||
RuleHasPendingChildSheet(css::Rule *cssRule)
|
||||
{
|
||||
|
@ -320,6 +320,8 @@ public:
|
||||
void DeleteRule(uint32_t aIndex, ErrorResult& aRv) {
|
||||
aRv = DeleteRule(aIndex);
|
||||
}
|
||||
int32_t AddRule(const nsAString& aSelector, const nsAString& aBlock,
|
||||
const dom::Optional<uint32_t>& aIndex, ErrorResult& aRv);
|
||||
|
||||
// WebIDL miscellaneous bits
|
||||
dom::ParentObject GetParentObject() const {
|
||||
|
Loading…
Reference in New Issue
Block a user