mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1290209 - Part 6: Move CSSStyleSheet::mMedia up to StyleSheet. r=bzbarsky
MozReview-Commit-ID: LZraHzme6vj
This commit is contained in:
parent
47b15a4d16
commit
ff8152efd2
@ -418,12 +418,6 @@ CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet& aCopy,
|
||||
// FIXME: handle failure?
|
||||
EnsureUniqueInner();
|
||||
}
|
||||
|
||||
if (aCopy.mMedia) {
|
||||
// XXX This is wrong; we should be keeping @import rules and
|
||||
// sheets in sync!
|
||||
mMedia = aCopy.mMedia->Clone();
|
||||
}
|
||||
}
|
||||
|
||||
CSSStyleSheet::~CSSStyleSheet()
|
||||
@ -439,7 +433,6 @@ CSSStyleSheet::~CSSStyleSheet()
|
||||
}
|
||||
}
|
||||
DropRuleCollection();
|
||||
DropMedia();
|
||||
mInner->RemoveSheet(this);
|
||||
// XXX The document reference is not reference counted and should
|
||||
// not be released. The document will let us know when it is going
|
||||
@ -462,15 +455,6 @@ CSSStyleSheet::DropRuleCollection()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CSSStyleSheet::DropMedia()
|
||||
{
|
||||
if (mMedia) {
|
||||
mMedia->SetStyleSheet(nullptr);
|
||||
mMedia = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CSSStyleSheet::UnlinkInner()
|
||||
{
|
||||
@ -543,7 +527,6 @@ NS_IMPL_RELEASE_INHERITED(CSSStyleSheet, StyleSheet)
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(CSSStyleSheet)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CSSStyleSheet)
|
||||
tmp->DropMedia();
|
||||
// We do not unlink mNext; our parent will handle that. If we
|
||||
// unlinked it here, our parent would not be able to walk its list
|
||||
// of child sheets and null out the back-references to it, if we got
|
||||
@ -553,7 +536,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CSSStyleSheet)
|
||||
tmp->mScopeElement = nullptr;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(StyleSheet)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(CSSStyleSheet, StyleSheet)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMedia)
|
||||
// We do not traverse mNext; our parent will handle that. See
|
||||
// comments in Unlink for why.
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRuleCollection)
|
||||
@ -611,12 +593,6 @@ CSSStyleSheet::UseForPresentation(nsPresContext* aPresContext,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CSSStyleSheet::SetMedia(nsMediaList* aMedia)
|
||||
{
|
||||
mMedia = aMedia;
|
||||
}
|
||||
|
||||
bool
|
||||
CSSStyleSheet::HasRules() const
|
||||
{
|
||||
@ -909,17 +885,6 @@ CSSStyleSheet::RegisterNamespaceRule(css::Rule* aRule)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsMediaList*
|
||||
CSSStyleSheet::Media()
|
||||
{
|
||||
if (!mMedia) {
|
||||
mMedia = new nsMediaList();
|
||||
mMedia->SetStyleSheet(this);
|
||||
}
|
||||
|
||||
return mMedia;
|
||||
}
|
||||
|
||||
nsIDOMCSSRule*
|
||||
CSSStyleSheet::GetDOMOwnerRule() const
|
||||
{
|
||||
|
@ -31,7 +31,6 @@
|
||||
class CSSRuleListImpl;
|
||||
class nsCSSRuleProcessor;
|
||||
class nsIURI;
|
||||
class nsMediaList;
|
||||
class nsMediaQueryResultCacheKey;
|
||||
class nsStyleSet;
|
||||
class nsPresContext;
|
||||
@ -148,8 +147,6 @@ public:
|
||||
nsresult DeleteRuleFromGroup(css::GroupRule* aGroup, uint32_t aIndex);
|
||||
nsresult InsertRuleIntoGroup(const nsAString& aRule, css::GroupRule* aGroup, uint32_t aIndex, uint32_t* _retval);
|
||||
|
||||
void SetMedia(nsMediaList* aMedia);
|
||||
|
||||
void SetOwnerRule(css::ImportRule* aOwnerRule) { mOwnerRule = aOwnerRule; /* Not ref counted */ }
|
||||
css::ImportRule* GetOwnerRule() const { return mOwnerRule; }
|
||||
// Workaround overloaded-virtual warning in GCC.
|
||||
@ -204,9 +201,6 @@ public:
|
||||
mScopeElement = aScopeElement;
|
||||
}
|
||||
|
||||
// WebIDL StyleSheet API
|
||||
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
|
||||
@ -237,9 +231,6 @@ protected:
|
||||
// Drop our reference to mRuleCollection
|
||||
void DropRuleCollection();
|
||||
|
||||
// Drop our reference to mMedia
|
||||
void DropMedia();
|
||||
|
||||
// Unlink our inner, if needed, for cycle collection
|
||||
void UnlinkInner();
|
||||
// Traverse our inner, if needed, for cycle collection
|
||||
@ -252,7 +243,6 @@ protected:
|
||||
uint32_t aIndex, ErrorResult& aRv);
|
||||
void DeleteRuleInternal(uint32_t aIndex, ErrorResult& aRv);
|
||||
|
||||
RefPtr<nsMediaList> mMedia;
|
||||
RefPtr<CSSStyleSheet> mNext;
|
||||
CSSStyleSheet* mParent; // weak ref
|
||||
css::ImportRule* mOwnerRule; // weak ref
|
||||
|
@ -1304,7 +1304,7 @@ Loader::PrepareSheet(StyleSheet* aSheet,
|
||||
mediumParser.ParseMediaList(aMediaString, nullptr, 0, mediaList);
|
||||
}
|
||||
|
||||
sheet->SetMedia(mediaList);
|
||||
aSheet->SetMedia(mediaList);
|
||||
|
||||
aSheet->SetTitle(aTitle);
|
||||
sheet->SetEnabled(!isAlternate);
|
||||
|
@ -122,12 +122,6 @@ ServoStyleSheet::List(FILE* aOut, int32_t aIndex) const
|
||||
}
|
||||
#endif
|
||||
|
||||
nsMediaList*
|
||||
ServoStyleSheet::Media()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIDOMCSSRule*
|
||||
ServoStyleSheet::GetDOMOwnerRule() const
|
||||
{
|
||||
|
@ -66,9 +66,6 @@ public:
|
||||
mSheet = aSheet;
|
||||
}
|
||||
|
||||
// WebIDL StyleSheet API
|
||||
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
|
||||
|
@ -37,6 +37,16 @@ StyleSheet::StyleSheet(const StyleSheet& aCopy,
|
||||
, mType(aCopy.mType)
|
||||
, mDisabled(aCopy.mDisabled)
|
||||
{
|
||||
if (aCopy.mMedia) {
|
||||
// XXX This is wrong; we should be keeping @import rules and
|
||||
// sheets in sync!
|
||||
mMedia = aCopy.mMedia->Clone();
|
||||
}
|
||||
}
|
||||
|
||||
StyleSheet::~StyleSheet()
|
||||
{
|
||||
DropMedia();
|
||||
}
|
||||
|
||||
// QueryInterface implementation for StyleSheet
|
||||
@ -49,7 +59,18 @@ NS_INTERFACE_MAP_END
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(StyleSheet)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(StyleSheet)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(StyleSheet)
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(StyleSheet)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(StyleSheet)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMedia)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(StyleSheet)
|
||||
tmp->DropMedia();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(StyleSheet)
|
||||
|
||||
mozilla::dom::CSSStyleSheetParsingMode
|
||||
StyleSheet::ParsingModeDOM()
|
||||
@ -320,6 +341,32 @@ StyleSheet::AreRulesAvailable(nsIPrincipal& aSubjectPrincipal,
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
StyleSheet::SetMedia(nsMediaList* aMedia)
|
||||
{
|
||||
mMedia = aMedia;
|
||||
}
|
||||
|
||||
void
|
||||
StyleSheet::DropMedia()
|
||||
{
|
||||
if (mMedia) {
|
||||
mMedia->SetStyleSheet(nullptr);
|
||||
mMedia = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
nsMediaList*
|
||||
StyleSheet::Media()
|
||||
{
|
||||
if (!mMedia) {
|
||||
mMedia = new nsMediaList();
|
||||
mMedia->SetStyleSheet(this);
|
||||
}
|
||||
|
||||
return mMedia;
|
||||
}
|
||||
|
||||
// nsWrapperCache
|
||||
|
||||
JSObject*
|
||||
|
@ -44,7 +44,7 @@ protected:
|
||||
StyleSheet(const StyleSheet& aCopy,
|
||||
nsIDocument* aDocumentToUse,
|
||||
nsINode* aOwningNodeToUse);
|
||||
virtual ~StyleSheet() {}
|
||||
virtual ~StyleSheet();
|
||||
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
@ -112,6 +112,7 @@ public:
|
||||
inline void SetPrincipal(nsIPrincipal* aPrincipal);
|
||||
|
||||
void SetTitle(const nsAString& aTitle) { mTitle = aTitle; }
|
||||
void SetMedia(nsMediaList* aMedia);
|
||||
|
||||
// Get this style sheet's CORS mode
|
||||
inline CORSMode GetCORSMode() const;
|
||||
@ -131,7 +132,7 @@ public:
|
||||
// GetOwnerNode is defined above.
|
||||
inline StyleSheet* GetParentStyleSheet() const;
|
||||
// The XPCOM GetTitle is fine for WebIDL.
|
||||
virtual nsMediaList* Media() = 0;
|
||||
nsMediaList* Media();
|
||||
bool Disabled() const { return mDisabled; }
|
||||
// The XPCOM SetDisabled is fine for WebIDL.
|
||||
|
||||
@ -194,10 +195,15 @@ protected:
|
||||
void SubjectSubsumesInnerPrincipal(nsIPrincipal& aSubjectPrincipal,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// Drop our reference to mMedia
|
||||
void DropMedia();
|
||||
|
||||
nsString mTitle;
|
||||
nsIDocument* mDocument; // weak ref; parents maintain this for their children
|
||||
nsINode* mOwningNode; // weak ref
|
||||
|
||||
RefPtr<nsMediaList> mMedia;
|
||||
|
||||
// mParsingMode controls access to nonstandard style constructs that
|
||||
// are not safe for use on the public Web but necessary in UA sheets
|
||||
// and/or useful in user sheets.
|
||||
|
Loading…
Reference in New Issue
Block a user