Bug 1367615 - Part 2: Make ServoStyleRule implement nsICSSStyleRuleDOMWrapper. r?xidorn
MozReview-Commit-ID: 20UWQl50zvl
--- a/layout/style/ServoStyleRule.cpp
+++ b/layout/style/ServoStyleRule.cpp
@@ -114,16 +114,17 @@ ServoStyleRule::ServoStyleRule(already_A
: BindingStyleRule(aLine, aColumn)
, mRawRule(aRawRule)
, mDecls(Servo_StyleRule_GetStyle(mRawRule).Consume())
{
}
// QueryInterface implementation for ServoStyleRule
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServoStyleRule)
+ NS_INTERFACE_MAP_ENTRY(nsICSSStyleRuleDOMWrapper)
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleRule)
NS_INTERFACE_MAP_END_INHERITING(css::Rule)
NS_IMPL_ADDREF_INHERITED(ServoStyleRule, css::Rule)
NS_IMPL_RELEASE_INHERITED(ServoStyleRule, css::Rule)
NS_IMPL_CYCLE_COLLECTION_CLASS(ServoStyleRule)
@@ -190,16 +191,25 @@ ServoStyleRule::List(FILE* out, int32_t
for (int32_t i = 0; i < aIndent; i++) {
str.AppendLiteral(" ");
}
Servo_StyleRule_Debug(mRawRule, &str);
fprintf_stderr(out, "%s\n", str.get());
}
#endif
+/* nsICSSStyleRuleDOMWrapper implementation */
+
+NS_IMETHODIMP
+ServoStyleRule::GetCSSStyleRule(BindingStyleRule **aResult)
+{
+ NS_ADDREF(*aResult = this);
+ return NS_OK;
+}
+
/* CSSRule implementation */
uint16_t
ServoStyleRule::Type() const
{
return nsIDOMCSSRule::STYLE_RULE;
}
--- a/layout/style/ServoStyleRule.h
+++ b/layout/style/ServoStyleRule.h
@@ -45,28 +45,31 @@ private:
inline ServoStyleRule* Rule();
inline const ServoStyleRule* Rule() const;
RefPtr<ServoDeclarationBlock> mDecls;
};
class ServoStyleRule final : public BindingStyleRule
- , public nsIDOMCSSStyleRule
+ , public nsICSSStyleRuleDOMWrapper
{
public:
ServoStyleRule(already_AddRefed<RawServoStyleRule> aRawRule,
uint32_t aLine, uint32_t aColumn);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(ServoStyleRule,
css::Rule)
bool IsCCLeaf() const final MOZ_MUST_OVERRIDE;
NS_DECL_NSIDOMCSSSTYLERULE
+ // nsICSSStyleRuleDOMWrapper
+ NS_IMETHOD GetCSSStyleRule(BindingStyleRule **aResult) override;
+
uint32_t GetSelectorCount() override;
nsresult GetSelectorText(uint32_t aSelectorIndex,
nsAString& aText) override;
nsresult GetSpecificity(uint32_t aSelectorIndex,
uint64_t* aSpecificity) override;
nsresult SelectorMatchesElement(dom::Element* aElement,
uint32_t aSelectorIndex,
const nsAString& aPseudo,