Bug 1339629 Part 3: Uplift mDirty into StyleSheet.
MozReview-Commit-ID: iZKdg0fWss
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -323,50 +323,47 @@ CSSStyleSheetInner::SizeOfIncludingThis(
// -------------------------------
// CSS Style Sheet
//
CSSStyleSheet::CSSStyleSheet(css::SheetParsingMode aParsingMode,
CORSMode aCORSMode, ReferrerPolicy aReferrerPolicy)
: StyleSheet(StyleBackendType::Gecko, aParsingMode),
mOwnerRule(nullptr),
- mDirty(false),
mInRuleProcessorCache(false),
mScopeElement(nullptr),
mRuleProcessors(nullptr)
{
mInner = new CSSStyleSheetInner(aCORSMode, aReferrerPolicy,
SRIMetadata());
mInner->AddSheet(this);
}
CSSStyleSheet::CSSStyleSheet(css::SheetParsingMode aParsingMode,
CORSMode aCORSMode,
ReferrerPolicy aReferrerPolicy,
const SRIMetadata& aIntegrity)
: StyleSheet(StyleBackendType::Gecko, aParsingMode),
mOwnerRule(nullptr),
- mDirty(false),
mInRuleProcessorCache(false),
mScopeElement(nullptr),
mRuleProcessors(nullptr)
{
mInner = new CSSStyleSheetInner(aCORSMode, aReferrerPolicy,
aIntegrity);
mInner->AddSheet(this);
}
CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet& aCopy,
CSSStyleSheet* aParentToUse,
css::ImportRule* aOwnerRuleToUse,
nsIDocument* aDocumentToUse,
nsINode* aOwningNodeToUse)
: StyleSheet(aCopy, aDocumentToUse, aOwningNodeToUse),
mOwnerRule(aOwnerRuleToUse),
- mDirty(aCopy.mDirty),
mInRuleProcessorCache(false),
mScopeElement(nullptr),
mRuleProcessors(nullptr)
{
MOZ_ASSERT(mInner, "We should have an mInner after copy.");
MOZ_ASSERT(mInner->mSheets.Contains(this), "Our mInner should include us.");
mParent = aParentToUse;
--- a/layout/style/CSSStyleSheet.h
+++ b/layout/style/CSSStyleSheet.h
@@ -123,18 +123,16 @@ public:
return Inner()->mNameSpaceMap;
}
virtual already_AddRefed<StyleSheet> Clone(StyleSheet* aCloneParent,
css::ImportRule* aCloneOwnerRule,
nsIDocument* aCloneDocument,
nsINode* aCloneOwningNode) const final;
- bool IsModified() const final { return mDirty; }
-
void SetModifiedByChildRule() {
NS_ASSERTION(mDirty,
"sheet must be marked dirty before handing out child rules");
DidDirty();
}
nsresult AddRuleProcessor(nsCSSRuleProcessor* aProcessor);
nsresult DropRuleProcessor(nsCSSRuleProcessor* aProcessor);
@@ -218,17 +216,16 @@ protected:
css::GroupRule* aGroup,
uint32_t aIndex);
void EnabledStateChangedInternal();
css::ImportRule* mOwnerRule; // weak ref
RefPtr<CSSRuleListImpl> mRuleCollection;
- bool mDirty; // has been modified
bool mInRuleProcessorCache;
RefPtr<dom::Element> mScopeElement;
AutoTArray<nsCSSRuleProcessor*, 8>* mRuleProcessors;
nsTArray<nsStyleSet*> mStyleSets;
friend class mozilla::StyleSheet;
friend class ::nsCSSRuleProcessor;
--- a/layout/style/ServoStyleSheet.h
+++ b/layout/style/ServoStyleSheet.h
@@ -92,18 +92,16 @@ public:
// 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.
css::Rule* GetDOMOwnerRule() const final;
void WillDirty() {}
void DidDirty() {}
- bool IsModified() const final { return false; }
-
virtual already_AddRefed<StyleSheet> Clone(StyleSheet* aCloneParent,
css::ImportRule* aCloneOwnerRule,
nsIDocument* aCloneDocument,
nsINode* aCloneOwningNode) const final;
// nsICSSLoaderObserver interface
NS_IMETHOD StyleSheetLoaded(StyleSheet* aSheet, bool aWasAlternate,
nsresult aStatus) final;
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -22,16 +22,17 @@ StyleSheet::StyleSheet(StyleBackendType
: mParent(nullptr)
, mDocument(nullptr)
, mOwningNode(nullptr)
, mParsingMode(aParsingMode)
, mType(aType)
, mDisabled(false)
, mDocumentAssociationMode(NotOwnedByDocument)
, mInner(nullptr)
+ , mDirty(false)
{
}
StyleSheet::StyleSheet(const StyleSheet& aCopy,
nsIDocument* aDocumentToUse,
nsINode* aOwningNodeToUse)
: mParent(nullptr)
, mTitle(aCopy.mTitle)
@@ -39,16 +40,17 @@ StyleSheet::StyleSheet(const StyleSheet&
, mOwningNode(aOwningNodeToUse)
, mParsingMode(aCopy.mParsingMode)
, mType(aCopy.mType)
, mDisabled(aCopy.mDisabled)
// We only use this constructor during cloning. It's the cloner's
// responsibility to notify us if we end up being owned by a document.
, mDocumentAssociationMode(NotOwnedByDocument)
, mInner(aCopy.mInner) // Shallow copy, but concrete subclasses will fix up.
+ , mDirty(aCopy.mDirty)
{
MOZ_ASSERT(mInner, "Should only copy StyleSheets with an mInner.");
mInner->AddSheet(this);
if (aCopy.mMedia) {
// XXX This is wrong; we should be keeping @import rules and
// sheets in sync!
mMedia = aCopy.mMedia->Clone();
@@ -165,18 +167,17 @@ bool
StyleSheet::IsComplete() const
{
return SheetInfo().mComplete;
}
void
StyleSheet::SetComplete()
{
- NS_ASSERTION(!IsGecko() || !AsGecko()->mDirty,
- "Can't set a dirty sheet complete!");
+ NS_ASSERTION(!mDirty, "Can't set a dirty sheet complete!");
SheetInfo().mComplete = true;
if (mDocument && !mDisabled) {
// Let the document know
mDocument->BeginUpdate(UPDATE_STYLE);
mDocument->SetStyleSheetApplicableState(this, true);
mDocument->EndUpdate(UPDATE_STYLE);
}
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -113,17 +113,17 @@ public:
inline bool IsApplicable() const;
inline bool HasRules() const;
virtual already_AddRefed<StyleSheet> Clone(StyleSheet* aCloneParent,
css::ImportRule* aCloneOwnerRule,
nsIDocument* aCloneDocument,
nsINode* aCloneOwningNode) const = 0;
- virtual bool IsModified() const = 0;
+ bool IsModified() const { return mDirty; }
// style sheet owner info
enum DocumentAssociationMode {
// OwnedByDocument means mDocument owns us (possibly via a chain of other
// stylesheets).
OwnedByDocument,
// NotOwnedByDocument means we're owned by something that might have a
// different lifetime than mDocument.
@@ -286,16 +286,18 @@ protected:
// the sense that if it's known-live then we're known-live). Always
// NotOwnedByDocument when mDocument is null.
DocumentAssociationMode mDocumentAssociationMode;
// Core information we get from parsed sheets, which are shared amongst
// StyleSheet clones.
StyleSheetInfo* mInner;
+ bool mDirty; // has been modified
+
friend class ::nsCSSRuleProcessor;
// Make CSSStyleSheet and ServoStyleSheet friends so they can access
// protected members of other StyleSheet objects (useful for iterating
// through children).
friend class mozilla::CSSStyleSheet;
friend class mozilla::ServoStyleSheet;