Commit 3a0285b2 authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Remove DEFINE_TYPE_CASTS from t_p/blink/renderer/core/animation (5/n)

The goal of this CL is to use new downcast helper and remove
DEFINE_TYPE_CASTS to adopt new downcast helpers.

This CL removes DEFINE_TYPE_CASTS for below element.
- InvalidatableInterpolation,
- SVGInterpolationEnvironment,
- TransitionInterpolation

Bug: 891908
Change-Id: Ic33ca0ca5da5bc7d70f32a621c61c95eed2d6008
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1967511Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#728142}
parent c5c01c1c
......@@ -213,7 +213,7 @@ std::unique_ptr<TypedInterpolationValue> SampleAnimation(
DCHECK_LE(sample.size(), 1u);
if (sample.IsEmpty())
return nullptr;
return ToTransitionInterpolation(*sample.at(0)).GetInterpolatedValue();
return To<TransitionInterpolation>(*sample.at(0)).GetInterpolatedValue();
}
// Returns the start time of an animation given the start delay. A negative
......
......@@ -63,7 +63,8 @@ void CopyToActiveInterpolationsMap(
!property.IsCSSProperty() || property.IsPresentationAttribute();
const bool effect_depends_on_underlying_value =
interpolation->IsInvalidatableInterpolation() &&
ToInvalidatableInterpolation(*interpolation).DependsOnUnderlyingValue();
To<InvalidatableInterpolation>(*interpolation.Get())
.DependsOnUnderlyingValue();
if (!allow_stacked_effects || !effect_depends_on_underlying_value)
active_interpolations.clear();
active_interpolations.push_back(interpolation);
......
......@@ -82,8 +82,8 @@ class AnimationEffectStackTest : public PageTestBase {
active_interpolations.at(PropertyHandle(GetCSSPropertyFontSize()));
EnsureInterpolatedValueCached(interpolations, GetDocument(), element);
const TypedInterpolationValue* typed_value =
ToInvalidatableInterpolation(*interpolations.at(0))
const auto* typed_value =
To<InvalidatableInterpolation>(*interpolations.at(0))
.GetCachedValueForTesting();
// font-size is stored as an |InterpolableLength|; here we assume pixels.
EXPECT_TRUE(typed_value->GetInterpolableValue().IsLength());
......@@ -97,8 +97,8 @@ class AnimationEffectStackTest : public PageTestBase {
active_interpolations.at(PropertyHandle(GetCSSPropertyZIndex()));
EnsureInterpolatedValueCached(interpolations, GetDocument(), element);
const TypedInterpolationValue* typed_value =
ToInvalidatableInterpolation(*interpolations.at(0))
const auto* typed_value =
To<InvalidatableInterpolation>(*interpolations.at(0))
.GetCachedValueForTesting();
// z-index is stored as a straight number value.
EXPECT_TRUE(typed_value->GetInterpolableValue().IsNumber());
......
......@@ -14,7 +14,7 @@ namespace blink {
namespace {
double GetInterpolableNumber(Interpolation* value) {
TransitionInterpolation* interpolation = ToTransitionInterpolation(value);
auto* interpolation = To<TransitionInterpolation>(value);
std::unique_ptr<TypedInterpolationValue> interpolated_value =
interpolation->GetInterpolatedValue();
return ToInterpolableNumber(interpolated_value->GetInterpolableValue())
......
......@@ -231,8 +231,8 @@ void InvalidatableInterpolation::ApplyStack(
// Compute the underlying value to composite onto.
UnderlyingValueOwner underlying_value_owner;
const InvalidatableInterpolation& first_interpolation =
ToInvalidatableInterpolation(*interpolations.at(starting_index));
const auto& first_interpolation =
To<InvalidatableInterpolation>(*interpolations.at(starting_index));
first_interpolation.EnsureValidInterpolationTypes(environment);
if (first_interpolation.DependsOnUnderlyingValue()) {
underlying_value_owner.Set(
......@@ -258,8 +258,8 @@ void InvalidatableInterpolation::ApplyStack(
// Composite interpolations onto the underlying value.
bool should_apply = false;
for (wtf_size_t i = starting_index; i < interpolations.size(); i++) {
const InvalidatableInterpolation& current_interpolation =
ToInvalidatableInterpolation(*interpolations.at(i));
const auto& current_interpolation =
To<InvalidatableInterpolation>(*interpolations.at(i));
DCHECK(current_interpolation.DependsOnUnderlyingValue());
current_interpolation.EnsureValidInterpolationTypes(environment);
const TypedInterpolationValue* current_value =
......
......@@ -98,11 +98,12 @@ class CORE_EXPORT InvalidatableInterpolation : public Interpolation {
mutable std::unique_ptr<TypedInterpolationValue> cached_value_;
};
DEFINE_TYPE_CASTS(InvalidatableInterpolation,
Interpolation,
value,
value->IsInvalidatableInterpolation(),
value.IsInvalidatableInterpolation());
template <>
struct DowncastTraits<InvalidatableInterpolation> {
static bool AllowFrom(const Interpolation& value) {
return value.IsInvalidatableInterpolation();
}
};
} // namespace blink
......
......@@ -68,8 +68,8 @@ class AnimationKeyframeEffectModel : public PageTestBase {
interpolations.push_back(interpolation_value);
EnsureInterpolatedValueCached(interpolations, GetDocument(), element);
const TypedInterpolationValue* typed_value =
ToInvalidatableInterpolation(interpolation_value)
const auto* typed_value =
To<InvalidatableInterpolation>(interpolation_value)
->GetCachedValueForTesting();
// Length values are stored as an |InterpolableLength|; here we assume
// pixels.
......@@ -89,8 +89,8 @@ class AnimationKeyframeEffectModel : public PageTestBase {
interpolations.push_back(interpolation_value);
EnsureInterpolatedValueCached(interpolations, GetDocument(), element);
const TypedInterpolationValue* typed_value =
ToInvalidatableInterpolation(interpolation_value)
const auto* typed_value =
To<InvalidatableInterpolation>(interpolation_value)
->GetCachedValueForTesting();
const NonInterpolableValue* non_interpolable_value =
typed_value->GetNonInterpolableValue();
......@@ -167,8 +167,7 @@ const PropertySpecificKeyframeVector& ConstructEffectAndGetKeyframes(
void ExpectProperty(CSSPropertyID property,
Interpolation* interpolation_value) {
InvalidatableInterpolation* interpolation =
ToInvalidatableInterpolation(interpolation_value);
auto* interpolation = To<InvalidatableInterpolation>(interpolation_value);
const PropertyHandle& property_handle = interpolation->GetProperty();
ASSERT_TRUE(property_handle.IsCSSProperty());
ASSERT_EQ(property, property_handle.GetCSSProperty().PropertyID());
......@@ -177,8 +176,8 @@ void ExpectProperty(CSSPropertyID property,
Interpolation* FindValue(HeapVector<Member<Interpolation>>& values,
CSSPropertyID id) {
for (auto& value : values) {
const PropertyHandle& property =
ToInvalidatableInterpolation(value)->GetProperty();
const auto& property =
To<InvalidatableInterpolation>(value.Get())->GetProperty();
if (property.IsCSSProperty() &&
property.GetCSSProperty().PropertyID() == id)
return value;
......
......@@ -43,11 +43,12 @@ class SVGInterpolationEnvironment : public InterpolationEnvironment {
Member<const SVGPropertyBase> svg_base_value_ = nullptr;
};
DEFINE_TYPE_CASTS(SVGInterpolationEnvironment,
InterpolationEnvironment,
value,
value->IsSVG(),
value.IsSVG());
template <>
struct DowncastTraits<SVGInterpolationEnvironment> {
static bool AllowFrom(const InterpolationEnvironment& value) {
return value.IsSVG();
}
};
} // namespace blink
......
......@@ -19,8 +19,8 @@ InterpolationValue SVGInterpolationType::MaybeConvertSingle(
if (keyframe.IsNeutral())
return MaybeConvertNeutral(underlying, conversion_checkers);
SVGPropertyBase* svg_value =
ToSVGInterpolationEnvironment(environment)
auto* svg_value =
To<SVGInterpolationEnvironment>(environment)
.SvgBaseValue()
.CloneForAnimation(To<SVGPropertySpecificKeyframe>(keyframe).Value());
return MaybeConvertSVGValue(*svg_value);
......@@ -29,14 +29,14 @@ InterpolationValue SVGInterpolationType::MaybeConvertSingle(
InterpolationValue SVGInterpolationType::MaybeConvertUnderlyingValue(
const InterpolationEnvironment& environment) const {
return MaybeConvertSVGValue(
ToSVGInterpolationEnvironment(environment).SvgBaseValue());
To<SVGInterpolationEnvironment>(environment).SvgBaseValue());
}
void SVGInterpolationType::Apply(
const InterpolableValue& interpolable_value,
const NonInterpolableValue* non_interpolable_value,
InterpolationEnvironment& environment) const {
ToSVGInterpolationEnvironment(environment)
To<SVGInterpolationEnvironment>(environment)
.SvgElement()
.SetWebAnimatedAttribute(
Attribute(),
......
......@@ -85,7 +85,7 @@ void SVGLengthInterpolationType::Apply(
const InterpolableValue& interpolable_value,
const NonInterpolableValue* non_interpolable_value,
InterpolationEnvironment& environment) const {
SVGElement& element = ToSVGInterpolationEnvironment(environment).SvgElement();
auto& element = To<SVGInterpolationEnvironment>(environment).SvgElement();
SVGLengthContext length_context(&element);
element.SetWebAnimatedAttribute(
Attribute(),
......
......@@ -91,7 +91,7 @@ void SVGLengthListInterpolationType::Apply(
const InterpolableValue& interpolable_value,
const NonInterpolableValue* non_interpolable_value,
InterpolationEnvironment& environment) const {
SVGElement& element = ToSVGInterpolationEnvironment(environment).SvgElement();
auto& element = To<SVGInterpolationEnvironment>(environment).SvgElement();
SVGLengthContext length_context(&element);
auto* result = MakeGarbageCollected<SVGLengthList>(unit_mode_);
......
......@@ -256,8 +256,8 @@ InterpolationValue SVGTransformListInterpolationType::MaybeConvertSingle(
}
if (!keyframe.IsNeutral()) {
SVGPropertyBase* svg_value =
ToSVGInterpolationEnvironment(environment)
auto* svg_value =
To<SVGInterpolationEnvironment>(environment)
.SvgBaseValue()
.CloneForAnimation(
To<SVGPropertySpecificKeyframe>(keyframe).Value());
......
......@@ -98,11 +98,12 @@ class CORE_EXPORT TransitionInterpolation : public Interpolation {
mutable std::unique_ptr<InterpolableValue> cached_interpolable_value_;
};
DEFINE_TYPE_CASTS(TransitionInterpolation,
Interpolation,
value,
value->IsTransitionInterpolation(),
value.IsTransitionInterpolation());
template <>
struct DowncastTraits<TransitionInterpolation> {
static bool AllowFrom(const Interpolation& value) {
return value.IsTransitionInterpolation();
}
};
} // namespace blink
......
......@@ -70,13 +70,13 @@ void CSSVariableAnimator::Apply(const PropertyHandle& property) {
const ActiveInterpolations& interpolations =
ActiveInterpolationsForCustomProperty(update_, property);
const Interpolation& interpolation = *interpolations.front();
if (interpolation.IsInvalidatableInterpolation()) {
if (IsA<InvalidatableInterpolation>(interpolation)) {
CSSInterpolationTypesMap map(state_.GetDocument().GetPropertyRegistry(),
state_.GetDocument());
CSSInterpolationEnvironment environment(map, state_, this);
InvalidatableInterpolation::ApplyStack(interpolations, environment);
} else {
ToTransitionInterpolation(interpolation).Apply(state_);
To<TransitionInterpolation>(interpolation).Apply(state_);
}
pending_properties_.erase(property);
}
......
......@@ -65,13 +65,13 @@ void StyleAnimator::Apply(const CSSProperty& property,
const ActiveInterpolations& interpolations =
GetActiveInterpolations(state_.AnimationUpdate(), property_handle);
const Interpolation& interpolation = *interpolations.front();
if (interpolation.IsInvalidatableInterpolation()) {
if (IsA<InvalidatableInterpolation>(interpolation)) {
CSSInterpolationTypesMap map(state_.GetDocument().GetPropertyRegistry(),
state_.GetDocument());
CSSInterpolationEnvironment environment(map, state_, &cascade_, &resolver);
InvalidatableInterpolation::ApplyStack(interpolations, environment);
} else {
ToTransitionInterpolation(interpolation).Apply(state_);
To<TransitionInterpolation>(interpolation).Apply(state_);
}
}
......
......@@ -1344,13 +1344,13 @@ void StyleResolver::ApplyAnimatedStandardProperties(
state.Style()->ForcedColorAdjust() != EForcedColorAdjust::kNone)
continue;
const Interpolation& interpolation = *entry.value.front();
if (interpolation.IsInvalidatableInterpolation()) {
if (IsA<InvalidatableInterpolation>(interpolation)) {
CSSInterpolationTypesMap map(state.GetDocument().GetPropertyRegistry(),
state.GetDocument());
CSSInterpolationEnvironment environment(map, state, nullptr);
InvalidatableInterpolation::ApplyStack(entry.value, environment);
} else {
ToTransitionInterpolation(interpolation).Apply(state);
To<TransitionInterpolation>(interpolation).Apply(state);
}
}
}
......
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