diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/animation/animation_test_helper.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/animation/animation_test_helper.cc | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/chromium/third_party/blink/renderer/core/animation/animation_test_helper.cc b/chromium/third_party/blink/renderer/core/animation/animation_test_helper.cc index a913190ee55..dc54c2f0062 100644 --- a/chromium/third_party/blink/renderer/core/animation/animation_test_helper.cc +++ b/chromium/third_party/blink/renderer/core/animation/animation_test_helper.cc @@ -8,6 +8,8 @@ #include "third_party/blink/renderer/core/animation/css_interpolation_environment.h" #include "third_party/blink/renderer/core/animation/css_interpolation_types_map.h" #include "third_party/blink/renderer/core/animation/invalidatable_interpolation.h" +#include "third_party/blink/renderer/core/css/css_pending_interpolation_value.h" +#include "third_party/blink/renderer/core/css/resolver/style_cascade.h" #include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/element.h" @@ -15,6 +17,39 @@ namespace blink { +namespace { + +class TestAnimator : public StyleCascade::Animator { + STACK_ALLOCATED(); + + public: + TestAnimator(StyleResolverState& state, + StyleCascade& cascade, + CSSInterpolationTypesMap& map, + const ActiveInterpolations& interpolations) + : state_(state), + cascade_(cascade), + map_(map), + interpolations_(interpolations) {} + + void Apply(const CSSProperty&, + const cssvalue::CSSPendingInterpolationValue& value, + StyleCascade::Resolver& resolver) override { + // Ignore CSSProperty here. We assume this function is only called once + // for each invocation of EnsureInterpolatedValueCached. + CSSInterpolationEnvironment environment(map_, state_, &cascade_, &resolver); + InvalidatableInterpolation::ApplyStack(interpolations_, environment); + } + + private: + StyleResolverState& state_; + StyleCascade& cascade_; + CSSInterpolationTypesMap& map_; + const ActiveInterpolations& interpolations_; +}; + +} // namespace + void SetV8ObjectPropertyAsString(v8::Isolate* isolate, v8::Local<v8::Object> object, const StringView& name, @@ -43,13 +78,26 @@ void EnsureInterpolatedValueCached(const ActiveInterpolations& interpolations, // require our callers to propertly register every animation they pass in // here, which the current tests do not do. auto style = ComputedStyle::Create(); - StyleResolverState state(document, element, nullptr /* pseudo_element */, + StyleResolverState state(document, *element, nullptr /* pseudo_element */, style.get(), style.get()); state.SetStyle(style); CSSInterpolationTypesMap map(state.GetDocument().GetPropertyRegistry(), state.GetDocument()); - CSSInterpolationEnvironment environment(map, state, nullptr); - InvalidatableInterpolation::ApplyStack(interpolations, environment); + if (RuntimeEnabledFeatures::CSSCascadeEnabled()) { + // We must apply the animation effects via StyleCascade when the cascade + // is enabled. + StyleCascade cascade(state); + auto type = cssvalue::CSSPendingInterpolationValue::Type::kCSSProperty; + auto* pending = cssvalue::CSSPendingInterpolationValue::Create(type); + auto origin = StyleCascade::Origin::kAuthor; + cascade.Add(*CSSPropertyName::From("--unused"), pending, origin); + + TestAnimator animator(state, cascade, map, interpolations); + cascade.Apply(animator); + } else { + CSSInterpolationEnvironment environment(map, state, nullptr); + InvalidatableInterpolation::ApplyStack(interpolations, environment); + } } } // namespace blink |