Bug 1361938 - Do not reuse DeclarationBlock when modifying inline style. r=heycam
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 31 May 2017 09:24:57 +0900
changeset 409546 e6ba19be442ffc26a5fc05befcc563aec20f2291
parent 409545 2585796d42803deb0e4e89e95beabc8e8f52040a
child 409547 26a25602688a35b1025951a1caee12ccdbb1679d
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1361938
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1361938 - Do not reuse DeclarationBlock when modifying inline style. r=heycam In stylo, the DeclarationBlock is stored in element's RuleNode directly, so when we call setProperty(), the new property value replaces the old value immediately. This causes a problem for CSS transition. CSS transition needs before-change style. From the spec; before-change style as the computed values of all properties on the element as of the previous style change event, except with any styles derived from declarative animations such as CSS Transitions, CSS Animations, and SMIL Animations updated to the current time To get correct before-change style, when we call getProperty(), we need to preserve rule nodes tree as the rules as of the *previous style change event*. And we need to cascade the preserved rule nodes with updated animation rules during animation-only restyle, and then we can use the result of the cascading as before-change style before cascading inline style changes in normal restyle. MozReview-Commit-ID: 9bkHz3Vvqg2
layout/style/nsDOMCSSDeclaration.cpp
layout/style/test/mochitest.ini
layout/style/test/stylo-failures.md
--- a/layout/style/nsDOMCSSDeclaration.cpp
+++ b/layout/style/nsDOMCSSDeclaration.cpp
@@ -312,17 +312,27 @@ nsDOMCSSDeclaration::ModifyDeclaration(G
   }
 
   // For nsDOMCSSAttributeDeclaration, SetCSSDeclaration will lead to
   // Attribute setting code, which leads in turn to BeginUpdate.  We
   // need to start the update now so that the old rule doesn't get used
   // between when we mutate the declaration and when we set the new
   // rule (see stack in bug 209575).
   mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true);
-  RefPtr<DeclarationBlock> decl = olddecl->EnsureMutable();
+  RefPtr<DeclarationBlock> decl;
+  if (olddecl->IsServo() && !olddecl->IsDirty()) {
+    // In stylo, the old DeclarationBlock is stored in element's rule node tree
+    // directly, to avoid new values replacing the DeclarationBlock in the tree
+    // directly, we need to copy the old one here if we haven't yet copied.
+    // As a result the new value does not replace rule node tree until traversal
+    // happens.
+    decl = olddecl->Clone();
+  } else {
+    decl = olddecl->EnsureMutable();
+  }
 
   bool changed;
   if (decl->IsGecko()) {
     CSSParsingEnvironment geckoEnv;
     GetCSSParsingEnvironment(geckoEnv);
     if (!geckoEnv.mPrincipal) {
       return NS_ERROR_NOT_AVAILABLE;
     }
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -55,17 +55,16 @@ skip-if = true # bug 1352336
 support-files = file_animations_effect_timing_enddelay.html
 [test_animations_effect_timing_iterations.html]
 support-files = file_animations_effect_timing_iterations.html
 [test_animations_event_order.html]
 [test_animations_event_handler_attribute.html]
 [test_animations_iterationstart.html]
 support-files = file_animations_iterationstart.html
 [test_animations_omta.html]
-skip-if = (stylo && !e10s) # mochitest expectations are different with non-e10s, bug 1361938
 [test_animations_omta_start.html]
 skip-if = (stylo && !e10s) # mochitest expectations are different with non-e10s, bug 1362292
 [test_animations_pausing.html]
 support-files = file_animations_pausing.html
 [test_animations_playbackrate.html]
 support-files = file_animations_playbackrate.html
 [test_animations_reverse.html]
 support-files = file_animations_reverse.html
--- a/layout/style/test/stylo-failures.md
+++ b/layout/style/test/stylo-failures.md
@@ -31,18 +31,16 @@ to mochitest command.
 
 * Media query support:
   * "layout.css.prefixes.device-pixel-ratio-webkit" support bug 1366956
     * test_media_queries.html `-device-pixel-ratio` [27]
     * test_webkit_device_pixel_ratio.html [3]
   * test_media_queries_dynamic.html `restyle`: bug 1357461 [4]
   * test_media_queries_dynamic_xbl.html: xbl support bug 1290276 [2]
 * Animation support:
-  * OMTA
-    * test_animations_omta.html: bug 1361938, bug 1340005 [*]
   * SMIL Animation
     * test_restyles_in_smil_animation.html [2]
 * console support bug 1352669
   * test_bug413958.html `monitorConsole` [3]
   * test_parser_diagnostics_unprintables.html [550]
 * Transition support:
   * test_transitions.html: pseudo elements [4]
   * test_transitions_and_reframes.html `pseudo-element`: bug 1366422 [4]