Commit 2f84421f authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

Don't crash when animating with CSSCascade disabled

Running without the CSSCascade flag doesn't work anymore, since we
hit a DCHECK. We're not supposed to calculate the animation update more
than once, and with CSSCascade disabled it can potentially already have
happened once we reach ApplyAnimatedStandardProperties. This CL re-
introduces an if-check that was removed in [1] to fix the issue.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2064248

Change-Id: I340f31543f63ed05a6a033ece0779ffaa8d57e28
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132400Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756062}
parent b0c9bf43
...@@ -1357,7 +1357,10 @@ bool StyleResolver::ApplyAnimatedStandardProperties( ...@@ -1357,7 +1357,10 @@ bool StyleResolver::ApplyAnimatedStandardProperties(
if (!HasAnimationsOrTransitions(state)) if (!HasAnimationsOrTransitions(state))
return false; return false;
CalculateAnimationUpdate(state); if (!state.IsAnimationInterpolationMapReady() ||
RuntimeEnabledFeatures::CSSCascadeEnabled()) {
CalculateAnimationUpdate(state);
}
CSSAnimations::CalculateCompositorAnimationUpdate( CSSAnimations::CalculateCompositorAnimationUpdate(
state.AnimationUpdate(), animating_element, element, *state.Style(), state.AnimationUpdate(), animating_element, element, *state.Style(),
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "third_party/blink/renderer/core/dom/shadow_root.h" #include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/dom/text.h" #include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h" #include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
namespace blink { namespace blink {
...@@ -126,6 +127,24 @@ TEST_F(StyleResolverTest, BasePresentIfFontRelativeUnitsAbsent) { ...@@ -126,6 +127,24 @@ TEST_F(StyleResolverTest, BasePresentIfFontRelativeUnitsAbsent) {
EXPECT_TRUE(animations.BaseComputedStyle()); EXPECT_TRUE(animations.BaseComputedStyle());
} }
TEST_F(StyleResolverTest, NoCrashWhenAnimatingWithoutCascade) {
ScopedCSSCascadeForTest scoped_cascade(false);
GetDocument().documentElement()->setInnerHTML(R"HTML(
<style>
@keyframes test {
from { width: 10px; }
to { width: 20px; }
}
div {
animation: test 1s;
}
</style>
<div id="div">Test</div>
)HTML");
UpdateAllLifecyclePhasesForTest();
}
class StyleResolverFontRelativeUnitTest class StyleResolverFontRelativeUnitTest
: public testing::WithParamInterface<const char*>, : public testing::WithParamInterface<const char*>,
public StyleResolverTest {}; public StyleResolverTest {};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment