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
--- 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 count`: support elementsRestyled [6]
* 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]