Bug 1292432 part 7 - Move other WebIDL methods to StyleSheet. r?heycam
MozReview-Commit-ID: J0tXKbZvcEq
--- a/layout/style/CSSStyleSheet.h
+++ b/layout/style/CSSStyleSheet.h
@@ -215,36 +215,29 @@ public:
dom::Element* GetScopeElement() const { return mScopeElement; }
void SetScopeElement(dom::Element* aScopeElement)
{
mScopeElement = aScopeElement;
}
// WebIDL StyleSheet API
- CSSStyleSheet* GetParentStyleSheet() const { return mParent; }
- nsMediaList* Media();
+ using GetParentStyleSheet;
+ nsMediaList* Media() final;
// WebIDL CSSStyleSheet API
// 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
// version.
- nsIDOMCSSRule* GetDOMOwnerRule() const;
+ nsIDOMCSSRule* GetDOMOwnerRule() const final;
using StyleSheet::GetCssRules;
using StyleSheet::InsertRule;
using StyleSheet::DeleteRule;
// WebIDL miscellaneous bits
- dom::ParentObject GetParentObject() const {
- if (mOwningNode) {
- return dom::ParentObject(mOwningNode);
- }
-
- return dom::ParentObject(static_cast<nsIDOMCSSStyleSheet*>(mParent), mParent);
- }
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
void WillDirty();
void DidDirty();
private:
CSSStyleSheet(const CSSStyleSheet& aCopy,
CSSStyleSheet* aParentToUse,
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -12,16 +12,17 @@
#include "mozilla/net/ReferrerPolicy.h"
#include "mozilla/StyleBackendType.h"
#include "mozilla/CORSMode.h"
#include "nsIDOMCSSStyleSheet.h"
class nsIDocument;
class nsINode;
+class nsMediaList;
namespace mozilla {
class CSSStyleSheet;
class ServoStyleSheet;
class StyleSheetInfo;
namespace dom {
@@ -131,30 +132,36 @@ public:
#ifdef DEBUG
inline void List(FILE* aOut = stdout, int32_t aIndex = 0) const;
#endif
// WebIDL StyleSheet API
// The XPCOM GetType is fine for WebIDL.
// The XPCOM GetHref is fine for WebIDL
// GetOwnerNode is defined above.
+ inline StyleSheet* GetParentStyleSheet() const;
// The XPCOM GetTitle is fine for WebIDL.
+ virtual nsMediaList* Media() = 0;
bool Disabled() const { return mDisabled; }
// The XPCOM SetDisabled is fine for WebIDL
// WebIDL CSSStyleSheet API
+ virtual nsIDOMCSSRule* GetDOMOwnerRule() const = 0;
dom::CSSRuleList* GetCssRules(const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv);
uint32_t InsertRule(const nsAString& aRule, uint32_t aIndex,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv);
void DeleteRule(uint32_t aIndex,
const Maybe<nsIPrincipal*>& aSubjectPrincipal,
ErrorResult& aRv);
+ // WebIDL miscellaneous bits
+ inline dom::ParentObject GetParentObject() const;
+
// nsIDOMStyleSheet interface
NS_IMETHOD GetType(nsAString& aType) final;
NS_IMETHOD GetDisabled(bool* aDisabled) final;
NS_IMETHOD SetDisabled(bool aDisabled) final;
NS_IMETHOD GetOwnerNode(nsIDOMNode** aOwnerNode) final;
NS_IMETHOD GetHref(nsAString& aHref) final;
NS_IMETHOD GetTitle(nsAString& aTitle) final;
--- a/layout/style/StyleSheetInlines.h
+++ b/layout/style/StyleSheetInlines.h
@@ -142,16 +142,31 @@ StyleSheet::SetOwningDocument(nsIDocumen
}
StyleSheet*
StyleSheet::GetParentSheet() const
{
FORWARD(GetParentSheet, ())
}
+StyleSheet*
+StyleSheet::GetParentStyleSheet() const
+{
+ return GetParentSheet();
+}
+
+dom::ParentObject
+StyleSheet::GetParentObject() const
+{
+ if (mOwningNode) {
+ return dom::ParentObject(mOwningNode);
+ }
+ return dom::ParentObject(GetParentSheet());
+}
+
void
StyleSheet::AppendStyleSheet(StyleSheet* aSheet)
{
FORWARD_CONCRETE(AppendStyleSheet, (aSheet->AsGecko()), (aSheet->AsServo()))
}
nsIPrincipal*
StyleSheet::Principal() const