Bug 1361938 - Set the dirty flag of DeclarationBlock when the DeclarationBlock is modified and clear the flag when it's resyled. r?heycam
MozReview-Commit-ID: 9GpFgx8N13e
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -406,16 +406,32 @@ Gecko_GetStyleAttrDeclarationBlock(RawGe
// XXX This can happen when nodes are adopted from a Gecko-style-backend
// document into a Servo-style-backend document. See bug 1330051.
NS_WARNING("stylo: requesting a Gecko declaration block?");
return nullptr;
}
return decl->AsServo()->RefRawStrong();
}
+void
+Gecko_UnsetDirtyStyleAttr(RawGeckoElementBorrowed aElement)
+{
+ DeclarationBlock* decl = aElement->GetInlineStyleDeclaration();
+ if (!decl) {
+ return;
+ }
+ if (decl->IsGecko()) {
+ // XXX This can happen when nodes are adopted from a Gecko-style-backend
+ // document into a Servo-style-backend document. See bug 1330051.
+ NS_WARNING("stylo: requesting a Gecko declaration block?");
+ return;
+ }
+ decl->UnsetDirty();
+}
+
RawServoDeclarationBlockStrongBorrowedOrNull
Gecko_GetSMILOverrideDeclarationBlock(RawGeckoElementBorrowed aElement)
{
// This function duplicates a lot of the code in
// Gecko_GetStyleAttrDeclarationBlock above because I haven't worked out a way
// to persuade hazard analysis that a pointer-to-lambda is ok yet.
MOZ_ASSERT(aElement, "Invalid GeckoElement");
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -187,16 +187,17 @@ SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNC
SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_Snapshot,
const ServoElementSnapshot*)
#undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS
// Style attributes.
RawServoDeclarationBlockStrongBorrowedOrNull
Gecko_GetStyleAttrDeclarationBlock(RawGeckoElementBorrowed element);
+void Gecko_UnsetDirtyStyleAttr(RawGeckoElementBorrowed element);
RawServoDeclarationBlockStrongBorrowedOrNull
Gecko_GetHTMLPresentationAttrDeclarationBlock(RawGeckoElementBorrowed element);
RawServoDeclarationBlockStrongBorrowedOrNull
Gecko_GetExtraContentStyleDeclarations(RawGeckoElementBorrowed element);
// Animations
bool
Gecko_GetAnimationRule(RawGeckoElementBorrowed aElementOrPseudo,
--- a/layout/style/nsDOMCSSAttrDeclaration.cpp
+++ b/layout/style/nsDOMCSSAttrDeclaration.cpp
@@ -68,16 +68,17 @@ NS_IMPL_QUERY_TAIL_INHERITING(nsDOMCSSDe
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCSSAttributeDeclaration)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCSSAttributeDeclaration)
nsresult
nsDOMCSSAttributeDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl)
{
NS_ASSERTION(mElement, "Must have Element to set the declaration!");
+ aDecl->SetDirty();
return mIsSMILOverride
? mElement->SetSMILOverrideStyleDeclaration(aDecl, true)
: mElement->SetInlineStyleDeclaration(aDecl, nullptr, true);
}
nsIDocument*
nsDOMCSSAttributeDeclaration::DocToUpdate()
{