Bug 1361938 - Set the dirty flag of DeclarationBlock when the DeclarationBlock is modified and clear the flag when it's resyled. r?heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 31 May 2017 09:24:40 +0900
changeset 586726 9ec35af239a0ced410432647903c42bbc8996ec2
parent 586725 010162149de271d11122305030a5222cdb432b1c
child 586727 cfbeddadfa7040f6e0c622eb583b752c3b4b04fb
push id61507
push userhikezoe@mozilla.com
push dateWed, 31 May 2017 00:25:44 +0000
reviewersheycam
bugs1361938
milestone55.0a1
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
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
layout/style/nsDOMCSSAttrDeclaration.cpp
--- 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()
 {