Bug 1361938 - Introduce a dirty flag that represents DeclarationBlock has been modified but not restyled. r?heycam
MozReview-Commit-ID: 757XcVxSvQn
--- a/layout/style/DeclarationBlock.h
+++ b/layout/style/DeclarationBlock.h
@@ -27,17 +27,22 @@ namespace css {
class Declaration;
class Rule;
} // namespace css
class DeclarationBlock
{
protected:
explicit DeclarationBlock(StyleBackendType aType)
- : mImmutable(false), mType(aType) { mContainer.mRaw = 0; }
+ : mImmutable(false)
+ , mIsDirty(false)
+ , mType(aType)
+ {
+ mContainer.mRaw = 0;
+ }
DeclarationBlock(const DeclarationBlock& aCopy)
: DeclarationBlock(aCopy.mType) {}
public:
MOZ_DECL_STYLO_METHODS(css::Declaration, ServoDeclarationBlock)
inline MozExternalRefCountType AddRef();
@@ -61,16 +66,31 @@ public:
/**
* Mark this declaration as unmodifiable. It's 'const' so it can
* be called from ToString.
*/
void SetImmutable() { mImmutable = true; }
/**
+ * Return whether |this| has been restyled after modified.
+ */
+ bool IsDirty() const { return mIsDirty; }
+
+ /**
+ * Mark this declaration as dirty.
+ */
+ void SetDirty() { mIsDirty = true; }
+
+ /**
+ * Mark this declaration as not dirty.
+ */
+ void UnsetDirty() { mIsDirty = false; }
+
+ /**
* Copy |this|, if necessary to ensure that it can be modified.
*/
inline already_AddRefed<DeclarationBlock> EnsureMutable();
void SetOwningRule(css::Rule* aRule) {
MOZ_ASSERT(!mContainer.mOwningRule || !aRule,
"should never overwrite one rule with another");
mContainer.mOwningRule = aRule;
@@ -131,15 +151,17 @@ private:
// The nsHTMLCSSStyleSheet that is responsible for this declaration.
// Only non-null for style attributes.
nsHTMLCSSStyleSheet* mHTMLCSSStyleSheet;
} mContainer;
// set when declaration put in the rule tree;
bool mImmutable;
+ // True if this declaration has not been restyled after modified.
+ bool mIsDirty;
const StyleBackendType mType;
};
} // namespace mozilla
#endif // mozilla_DeclarationBlock_h