Issue #2490 - WIP: part 9. Add a CSSRule Web IDL interface.

This commit is contained in:
Moonchild 2024-03-31 00:47:10 +01:00 committed by roytam1
commit 5a522d9145
13 changed files with 118 additions and 18 deletions

View file

@ -45,6 +45,27 @@ using namespace mozilla::dom;
// 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 css {
@ -153,6 +174,12 @@ Rule::GetCssText(nsAString& aCssText)
return NS_OK;
}
Rule*
Rule::GetParentRule() const
{
return mParentRule;
}
// -------------------------------
// Style Rule List for group rules
//
@ -164,7 +191,7 @@ public:
virtual CSSStyleSheet* GetParentObject() override;
virtual nsIDOMCSSRule*
virtual Rule*
IndexedGetter(uint32_t aIndex, bool& aFound) override;
virtual uint32_t
Length() override;
@ -209,7 +236,7 @@ GroupRuleRuleList::Length()
return AssertedCast<uint32_t>(mGroupRule->StyleRuleCount());
}
nsIDOMCSSRule*
Rule*
GroupRuleRuleList::IndexedGetter(uint32_t aIndex, bool& aFound)
{
aFound = false;