Commit 380c2759 authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Remove DEFINE_SVG_PROPERTY_TYPE_CASTS from t_p/blink/renderer/core (1/n)

This CL uses new downcast helpers for below classes,
- SVGAngle
- SVGColorProperty
- SVGInteger
- SVGIntegerOptionalInteger
- SVGLength
- SVGLengthList
- SVGNumber
- SVGNumberList
- SVGNumberOptionalNumber
- SVGPath
- SVGPointList
- SVGRect

Bug: 891908
Change-Id: I3463362c4de47115f8641a0ee294ddd8e8f11b49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2024234Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#735954}
parent db491704
......@@ -19,10 +19,11 @@ InterpolationValue SVGAngleInterpolationType::MaybeConvertNeutral(
InterpolationValue SVGAngleInterpolationType::MaybeConvertSVGValue(
const SVGPropertyBase& svg_value) const {
if (ToSVGAngle(svg_value).OrientType()->EnumValue() != kSVGMarkerOrientAngle)
if (To<SVGAngle>(svg_value).OrientType()->EnumValue() !=
kSVGMarkerOrientAngle)
return nullptr;
return InterpolationValue(
std::make_unique<InterpolableNumber>(ToSVGAngle(svg_value).Value()));
std::make_unique<InterpolableNumber>(To<SVGAngle>(svg_value).Value()));
}
SVGPropertyBase* SVGAngleInterpolationType::AppliedSVGValue(
......
......@@ -21,7 +21,7 @@ InterpolationValue SVGIntegerInterpolationType::MaybeConvertSVGValue(
if (svg_value.GetType() != kAnimatedInteger)
return nullptr;
return InterpolationValue(
std::make_unique<InterpolableNumber>(ToSVGInteger(svg_value).Value()));
std::make_unique<InterpolableNumber>(To<SVGInteger>(svg_value).Value()));
}
SVGPropertyBase* SVGIntegerInterpolationType::AppliedSVGValue(
......
......@@ -29,8 +29,8 @@ SVGIntegerOptionalIntegerInterpolationType::MaybeConvertSVGValue(
if (svg_value.GetType() != kAnimatedIntegerOptionalInteger)
return nullptr;
const SVGIntegerOptionalInteger& integer_optional_integer =
ToSVGIntegerOptionalInteger(svg_value);
const auto& integer_optional_integer =
To<SVGIntegerOptionalInteger>(svg_value);
auto result = std::make_unique<InterpolableList>(2);
result->Set(0, std::make_unique<InterpolableNumber>(
integer_optional_integer.FirstInteger()->Value()));
......
......@@ -70,7 +70,7 @@ InterpolationValue SVGLengthInterpolationType::MaybeConvertSVGValue(
if (svg_value.GetType() != kAnimatedLength)
return nullptr;
return MaybeConvertSVGLength(ToSVGLength(svg_value));
return MaybeConvertSVGLength(To<SVGLength>(svg_value));
}
SVGPropertyBase* SVGLengthInterpolationType::AppliedSVGValue(
......
......@@ -38,7 +38,7 @@ InterpolationValue SVGLengthListInterpolationType::MaybeConvertSVGValue(
if (svg_value.GetType() != kAnimatedLengthList)
return nullptr;
const SVGLengthList& length_list = ToSVGLengthList(svg_value);
const auto& length_list = To<SVGLengthList>(svg_value);
auto result = std::make_unique<InterpolableList>(length_list.length());
for (wtf_size_t i = 0; i < length_list.length(); i++) {
InterpolationValue component =
......
......@@ -32,7 +32,7 @@ InterpolationValue SVGNumberInterpolationType::MaybeConvertSVGValue(
if (svg_value.GetType() != kAnimatedNumber)
return nullptr;
return InterpolationValue(
std::make_unique<InterpolableNumber>(ToSVGNumber(svg_value).Value()));
std::make_unique<InterpolableNumber>(To<SVGNumber>(svg_value).Value()));
}
SVGPropertyBase* SVGNumberInterpolationType::AppliedSVGValue(
......
......@@ -36,7 +36,7 @@ InterpolationValue SVGNumberListInterpolationType::MaybeConvertSVGValue(
if (svg_value.GetType() != kAnimatedNumberList)
return nullptr;
const SVGNumberList& number_list = ToSVGNumberList(svg_value);
const SVGNumberList& number_list = To<SVGNumberList>(svg_value);
auto result = std::make_unique<InterpolableList>(number_list.length());
for (wtf_size_t i = 0; i < number_list.length(); i++) {
result->Set(
......
......@@ -29,8 +29,7 @@ SVGNumberOptionalNumberInterpolationType::MaybeConvertSVGValue(
if (svg_value.GetType() != kAnimatedNumberOptionalNumber)
return nullptr;
const SVGNumberOptionalNumber& number_optional_number =
ToSVGNumberOptionalNumber(svg_value);
const auto& number_optional_number = To<SVGNumberOptionalNumber>(svg_value);
auto result = std::make_unique<InterpolableList>(2);
result->Set(0, std::make_unique<InterpolableNumber>(
number_optional_number.FirstNumber()->Value()));
......
......@@ -16,7 +16,7 @@ InterpolationValue SVGPathInterpolationType::MaybeConvertSVGValue(
return nullptr;
return PathInterpolationFunctions::ConvertValue(
ToSVGPath(svg_value).ByteStream(),
To<SVGPath>(svg_value).ByteStream(),
PathInterpolationFunctions::PreserveCoordinates);
}
......
......@@ -37,7 +37,7 @@ InterpolationValue SVGPointListInterpolationType::MaybeConvertSVGValue(
if (svg_value.GetType() != kAnimatedPoints)
return nullptr;
const SVGPointList& point_list = ToSVGPointList(svg_value);
const auto& point_list = To<SVGPointList>(svg_value);
auto result = std::make_unique<InterpolableList>(point_list.length() * 2);
for (wtf_size_t i = 0; i < point_list.length(); i++) {
const SVGPoint& point = *point_list.at(i);
......
......@@ -36,7 +36,7 @@ InterpolationValue SVGRectInterpolationType::MaybeConvertSVGValue(
if (svg_value.GetType() != kAnimatedRect)
return nullptr;
const SVGRect& rect = ToSVGRect(svg_value);
const auto& rect = To<SVGRect>(svg_value);
auto result = std::make_unique<InterpolableList>(kRectComponentIndexCount);
result->Set(kRectX, std::make_unique<InterpolableNumber>(rect.X()));
result->Set(kRectY, std::make_unique<InterpolableNumber>(rect.Y()));
......
......@@ -362,7 +362,7 @@ void SVGAngle::ConvertToSpecifiedUnits(SVGAngleType unit_type) {
}
void SVGAngle::Add(SVGPropertyBase* other, SVGElement*) {
SVGAngle* other_angle = ToSVGAngle(other);
auto* other_angle = To<SVGAngle>(other);
// Only respect by animations, if from and by are both specified in angles
// (and not, for example, 'auto').
......@@ -391,8 +391,8 @@ void SVGAngle::CalculateAnimatedValue(
SVGPropertyBase* to,
SVGPropertyBase* to_at_end_of_duration,
SVGElement*) {
SVGAngle* from_angle = ToSVGAngle(from);
SVGAngle* to_angle = ToSVGAngle(to);
auto* from_angle = To<SVGAngle>(from);
auto* to_angle = To<SVGAngle>(to);
SVGMarkerOrientType from_orient_type = from_angle->OrientType()->EnumValue();
SVGMarkerOrientType to_orient_type = to_angle->OrientType()->EnumValue();
......@@ -407,13 +407,13 @@ void SVGAngle::CalculateAnimatedValue(
float animated_value = Value();
animation_element.AnimateAdditiveNumber(
percentage, repeat_count, from_angle->Value(), to_angle->Value(),
ToSVGAngle(to_at_end_of_duration)->Value(), animated_value);
To<SVGAngle>(to_at_end_of_duration)->Value(), animated_value);
OrientType()->SetEnumValue(kSVGMarkerOrientAngle);
SetValue(animated_value);
}
float SVGAngle::CalculateDistance(SVGPropertyBase* other, SVGElement*) {
return fabsf(Value() - ToSVGAngle(other)->Value());
return fabsf(Value() - To<SVGAngle>(other)->Value());
}
void SVGAngle::OrientTypeChanged() {
......
......@@ -26,6 +26,7 @@
#include "third_party/blink/renderer/core/svg/svg_enumeration.h"
#include "third_party/blink/renderer/core/svg/svg_parsing_error.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -140,7 +141,12 @@ class SVGAngle final : public SVGPropertyHelper<SVGAngle> {
Member<SVGMarkerOrientEnumeration> orient_type_;
};
DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGAngle);
template <>
struct DowncastTraits<SVGAngle> {
static bool AllowFrom(const SVGPropertyBase& value) {
return value.GetType() == SVGAngle::ClassType();
}
};
} // namespace blink
......
......@@ -60,7 +60,7 @@ void SVGColorProperty::Add(SVGPropertyBase* other,
Color fallback_color = FallbackColorForCurrentColor(context_element);
Color from_color =
ToSVGColorProperty(other)->style_color_.Resolve(fallback_color);
To<SVGColorProperty>(other)->style_color_.Resolve(fallback_color);
Color to_color = style_color_.Resolve(fallback_color);
style_color_ = StyleColor(ColorDistance::AddColors(from_color, to_color));
}
......@@ -73,10 +73,10 @@ void SVGColorProperty::CalculateAnimatedValue(
SVGPropertyBase* to_value,
SVGPropertyBase* to_at_end_of_duration_value,
SVGElement* context_element) {
StyleColor from_style_color = ToSVGColorProperty(from_value)->style_color_;
StyleColor to_style_color = ToSVGColorProperty(to_value)->style_color_;
StyleColor from_style_color = To<SVGColorProperty>(from_value)->style_color_;
StyleColor to_style_color = To<SVGColorProperty>(to_value)->style_color_;
StyleColor to_at_end_of_duration_style_color =
ToSVGColorProperty(to_at_end_of_duration_value)->style_color_;
To<SVGColorProperty>(to_at_end_of_duration_value)->style_color_;
// Apply currentColor rules.
DCHECK(context_element);
......@@ -119,7 +119,7 @@ float SVGColorProperty::CalculateDistance(SVGPropertyBase* to_value,
Color from_color = style_color_.Resolve(fallback_color);
Color to_color =
ToSVGColorProperty(to_value)->style_color_.Resolve(fallback_color);
To<SVGColorProperty>(to_value)->style_color_.Resolve(fallback_color);
return ColorDistance::Distance(from_color, to_color);
}
......
......@@ -33,6 +33,7 @@
#include "third_party/blink/renderer/core/css/style_color.h"
#include "third_party/blink/renderer/core/svg/properties/svg_property.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -63,7 +64,12 @@ class SVGColorProperty final : public SVGPropertyBase {
StyleColor style_color_;
};
DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGColorProperty);
template <>
struct DowncastTraits<SVGColorProperty> {
static bool AllowFrom(const SVGPropertyBase& value) {
return value.GetType() == SVGColorProperty::ClassType();
}
};
} // namespace blink
......
......@@ -59,7 +59,7 @@ SVGParsingError SVGInteger::SetValueAsString(const String& string) {
}
void SVGInteger::Add(SVGPropertyBase* other, SVGElement*) {
SetValue(value_ + ToSVGInteger(other)->Value());
SetValue(value_ + To<SVGInteger>(other)->Value());
}
void SVGInteger::CalculateAnimatedValue(
......@@ -70,10 +70,9 @@ void SVGInteger::CalculateAnimatedValue(
SVGPropertyBase* to,
SVGPropertyBase* to_at_end_of_duration,
SVGElement*) {
SVGInteger* from_integer = ToSVGInteger(from);
SVGInteger* to_integer = ToSVGInteger(to);
SVGInteger* to_at_end_of_duration_integer =
ToSVGInteger(to_at_end_of_duration);
auto* from_integer = To<SVGInteger>(from);
auto* to_integer = To<SVGInteger>(to);
auto* to_at_end_of_duration_integer = To<SVGInteger>(to_at_end_of_duration);
float animated_float = value_;
animation_element.AnimateAdditiveNumber(
......@@ -83,7 +82,7 @@ void SVGInteger::CalculateAnimatedValue(
}
float SVGInteger::CalculateDistance(SVGPropertyBase* other, SVGElement*) {
return abs(value_ - ToSVGInteger(other)->Value());
return abs(value_ - To<SVGInteger>(other)->Value());
}
} // namespace blink
......@@ -33,6 +33,7 @@
#include "third_party/blink/renderer/core/svg/properties/svg_property_helper.h"
#include "third_party/blink/renderer/core/svg/svg_parsing_error.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -71,7 +72,12 @@ class SVGInteger final : public SVGPropertyHelper<SVGInteger> {
int value_;
};
DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGInteger);
template <>
struct DowncastTraits<SVGInteger> {
static bool AllowFrom(const SVGPropertyBase& value) {
return value.GetType() == SVGInteger::ClassType();
}
};
} // namespace blink
......
......@@ -89,7 +89,7 @@ void SVGIntegerOptionalInteger::SetInitial(unsigned value) {
void SVGIntegerOptionalInteger::Add(SVGPropertyBase* other,
SVGElement* context_element) {
auto* other_integer_optional_integer = ToSVGIntegerOptionalInteger(other);
auto* other_integer_optional_integer = To<SVGIntegerOptionalInteger>(other);
first_integer_->Add(other_integer_optional_integer->FirstInteger(),
context_element);
second_integer_->Add(other_integer_optional_integer->SecondInteger(),
......@@ -104,10 +104,10 @@ void SVGIntegerOptionalInteger::CalculateAnimatedValue(
SVGPropertyBase* to,
SVGPropertyBase* to_at_end_of_duration,
SVGElement* context_element) {
auto* from_integer = ToSVGIntegerOptionalInteger(from);
auto* to_integer = ToSVGIntegerOptionalInteger(to);
auto* from_integer = To<SVGIntegerOptionalInteger>(from);
auto* to_integer = To<SVGIntegerOptionalInteger>(to);
auto* to_at_end_of_duration_integer =
ToSVGIntegerOptionalInteger(to_at_end_of_duration);
To<SVGIntegerOptionalInteger>(to_at_end_of_duration);
first_integer_->CalculateAnimatedValue(
animation_element, percentage, repeat_count, from_integer->FirstInteger(),
......
......@@ -34,6 +34,7 @@
#include "third_party/blink/renderer/core/svg/svg_integer.h"
#include "third_party/blink/renderer/core/svg/svg_parsing_error.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -80,7 +81,12 @@ class SVGIntegerOptionalInteger final : public SVGPropertyBase {
Member<SVGInteger> second_integer_;
};
DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGIntegerOptionalInteger);
template <>
struct DowncastTraits<SVGIntegerOptionalInteger> {
static bool AllowFrom(const SVGPropertyBase& value) {
return value.GetType() == SVGIntegerOptionalInteger::ClassType();
}
};
} // namespace blink
......
......@@ -326,7 +326,7 @@ bool SVGLength::NegativeValuesForbiddenForAnimatedLengthAttribute(
void SVGLength::Add(SVGPropertyBase* other, SVGElement* context_element) {
SVGLengthContext length_context(context_element);
SetValue(Value(length_context) + ToSVGLength(other)->Value(length_context),
SetValue(Value(length_context) + To<SVGLength>(other)->Value(length_context),
length_context);
}
......@@ -338,10 +338,10 @@ void SVGLength::CalculateAnimatedValue(
SVGPropertyBase* to_value,
SVGPropertyBase* to_at_end_of_duration_value,
SVGElement* context_element) {
SVGLength* from_length = ToSVGLength(from_value);
SVGLength* to_length = ToSVGLength(to_value);
SVGLength* to_at_end_of_duration_length =
ToSVGLength(to_at_end_of_duration_value);
auto* from_length = To<SVGLength>(from_value);
auto* to_length = To<SVGLength>(to_value);
auto* to_at_end_of_duration_length =
To<SVGLength>(to_at_end_of_duration_value);
SVGLengthContext length_context(context_element);
float animated_number = Value(length_context);
......@@ -374,7 +374,7 @@ void SVGLength::CalculateAnimatedValue(
float SVGLength::CalculateDistance(SVGPropertyBase* to_value,
SVGElement* context_element) {
SVGLengthContext length_context(context_element);
SVGLength* to_length = ToSVGLength(to_value);
auto* to_length = To<SVGLength>(to_value);
return fabsf(to_length->Value(length_context) - Value(length_context));
}
......
......@@ -27,6 +27,7 @@
#include "third_party/blink/renderer/core/svg/svg_length_context.h"
#include "third_party/blink/renderer/core/svg/svg_parsing_error.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -144,7 +145,12 @@ class SVGLength final : public SVGPropertyBase {
unsigned unit_mode_ : 2;
};
DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGLength);
template <>
struct DowncastTraits<SVGLength> {
static bool AllowFrom(const SVGPropertyBase& value) {
return value.GetType() == SVGLength::ClassType();
}
};
} // namespace blink
......
......@@ -90,7 +90,7 @@ SVGParsingError SVGLengthList::SetValueAsString(const String& value) {
}
void SVGLengthList::Add(SVGPropertyBase* other, SVGElement* context_element) {
SVGLengthList* other_list = ToSVGLengthList(other);
auto* other_list = To<SVGLengthList>(other);
if (length() != other_list->length())
return;
......@@ -114,10 +114,10 @@ void SVGLengthList::CalculateAnimatedValue(
SVGPropertyBase* to_value,
SVGPropertyBase* to_at_end_of_duration_value,
SVGElement* context_element) {
SVGLengthList* from_list = ToSVGLengthList(from_value);
SVGLengthList* to_list = ToSVGLengthList(to_value);
SVGLengthList* to_at_end_of_duration_list =
ToSVGLengthList(to_at_end_of_duration_value);
auto* from_list = To<SVGLengthList>(from_value);
auto* to_list = To<SVGLengthList>(to_value);
auto* to_at_end_of_duration_list =
To<SVGLengthList>(to_at_end_of_duration_value);
SVGLengthContext length_context(context_element);
DCHECK_EQ(mode_, SVGLength::LengthModeForAnimatedLengthAttribute(
......
......@@ -34,6 +34,7 @@
#include "third_party/blink/renderer/core/svg/properties/svg_list_property_helper.h"
#include "third_party/blink/renderer/core/svg/svg_length.h"
#include "third_party/blink/renderer/core/svg/svg_parsing_error.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -79,7 +80,12 @@ class SVGLengthList final
SVGLengthMode mode_;
};
DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGLengthList);
template <>
struct DowncastTraits<SVGLengthList> {
static bool AllowFrom(const SVGPropertyBase& value) {
return value.GetType() == SVGLengthList::ClassType();
}
};
} // namespace blink
......
......@@ -75,7 +75,7 @@ SVGParsingError SVGNumber::SetValueAsString(const String& string) {
}
void SVGNumber::Add(SVGPropertyBase* other, SVGElement*) {
SetValue(value_ + ToSVGNumber(other)->Value());
SetValue(value_ + To<SVGNumber>(other)->Value());
}
void SVGNumber::CalculateAnimatedValue(
......@@ -86,9 +86,9 @@ void SVGNumber::CalculateAnimatedValue(
SVGPropertyBase* to,
SVGPropertyBase* to_at_end_of_duration,
SVGElement*) {
SVGNumber* from_number = ToSVGNumber(from);
SVGNumber* to_number = ToSVGNumber(to);
SVGNumber* to_at_end_of_duration_number = ToSVGNumber(to_at_end_of_duration);
auto* from_number = To<SVGNumber>(from);
auto* to_number = To<SVGNumber>(to);
auto* to_at_end_of_duration_number = To<SVGNumber>(to_at_end_of_duration);
animation_element.AnimateAdditiveNumber(
percentage, repeat_count, from_number->Value(), to_number->Value(),
......@@ -96,7 +96,7 @@ void SVGNumber::CalculateAnimatedValue(
}
float SVGNumber::CalculateDistance(SVGPropertyBase* other, SVGElement*) {
return fabsf(value_ - ToSVGNumber(other)->Value());
return fabsf(value_ - To<SVGNumber>(other)->Value());
}
SVGNumber* SVGNumberAcceptPercentage::Clone() const {
......
......@@ -33,6 +33,7 @@
#include "third_party/blink/renderer/core/svg/properties/svg_property_helper.h"
#include "third_party/blink/renderer/core/svg/svg_parsing_error.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -77,7 +78,12 @@ class SVGNumber : public SVGPropertyHelper<SVGNumber> {
float value_;
};
DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGNumber);
template <>
struct DowncastTraits<SVGNumber> {
static bool AllowFrom(const SVGPropertyBase& value) {
return value.GetType() == SVGNumber::ClassType();
}
};
// SVGNumber which also accepts percentage as its value.
// This is used for <stop> "offset"
......
......@@ -69,7 +69,7 @@ SVGParsingError SVGNumberList::SetValueAsString(const String& value) {
}
void SVGNumberList::Add(SVGPropertyBase* other, SVGElement* context_element) {
SVGNumberList* other_list = ToSVGNumberList(other);
auto* other_list = To<SVGNumberList>(other);
if (length() != other_list->length())
return;
......@@ -86,10 +86,10 @@ void SVGNumberList::CalculateAnimatedValue(
SVGPropertyBase* to_value,
SVGPropertyBase* to_at_end_of_duration_value,
SVGElement* context_element) {
SVGNumberList* from_list = ToSVGNumberList(from_value);
SVGNumberList* to_list = ToSVGNumberList(to_value);
SVGNumberList* to_at_end_of_duration_list =
ToSVGNumberList(to_at_end_of_duration_value);
auto* from_list = To<SVGNumberList>(from_value);
auto* to_list = To<SVGNumberList>(to_value);
auto* to_at_end_of_duration_list =
To<SVGNumberList>(to_at_end_of_duration_value);
uint32_t from_list_size = from_list->length();
uint32_t to_list_size = to_list->length();
......
......@@ -34,6 +34,7 @@
#include "third_party/blink/renderer/core/svg/properties/svg_list_property_helper.h"
#include "third_party/blink/renderer/core/svg/svg_number.h"
#include "third_party/blink/renderer/core/svg/svg_parsing_error.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -72,7 +73,12 @@ class SVGNumberList final
SVGParsingError Parse(const CharType*& ptr, const CharType* end);
};
DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGNumberList);
template <>
struct DowncastTraits<SVGNumberList> {
static bool AllowFrom(const SVGPropertyBase& value) {
return value.GetType() == SVGNumberList::ClassType();
}
};
} // namespace blink
......
......@@ -91,7 +91,7 @@ void SVGNumberOptionalNumber::SetInitial(unsigned value) {
void SVGNumberOptionalNumber::Add(SVGPropertyBase* other,
SVGElement* context_element) {
auto* other_number_optional_number = ToSVGNumberOptionalNumber(other);
auto* other_number_optional_number = To<SVGNumberOptionalNumber>(other);
first_number_->Add(other_number_optional_number->FirstNumber(),
context_element);
second_number_->Add(other_number_optional_number->SecondNumber(),
......@@ -106,10 +106,10 @@ void SVGNumberOptionalNumber::CalculateAnimatedValue(
SVGPropertyBase* to,
SVGPropertyBase* to_at_end_of_duration,
SVGElement* context_element) {
auto* from_number = ToSVGNumberOptionalNumber(from);
auto* to_number = ToSVGNumberOptionalNumber(to);
auto* from_number = To<SVGNumberOptionalNumber>(from);
auto* to_number = To<SVGNumberOptionalNumber>(to);
auto* to_at_end_of_duration_number =
ToSVGNumberOptionalNumber(to_at_end_of_duration);
To<SVGNumberOptionalNumber>(to_at_end_of_duration);
first_number_->CalculateAnimatedValue(
animation_element, percentage, repeat_count, from_number->FirstNumber(),
......
......@@ -34,6 +34,7 @@
#include "third_party/blink/renderer/core/svg/svg_number.h"
#include "third_party/blink/renderer/core/svg/svg_parsing_error.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -79,7 +80,12 @@ class SVGNumberOptionalNumber final : public SVGPropertyBase {
Member<SVGNumber> second_number_;
};
DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGNumberOptionalNumber);
template <>
struct DowncastTraits<SVGNumberOptionalNumber> {
static bool AllowFrom(const SVGPropertyBase& value) {
return value.GetType() == SVGNumberOptionalNumber::ClassType();
}
};
} // namespace blink
......
......@@ -114,8 +114,7 @@ SVGPropertyBase* SVGPath::CloneForAnimation(const String& value) const {
}
void SVGPath::Add(SVGPropertyBase* other, SVGElement*) {
const SVGPathByteStream& other_path_byte_stream =
ToSVGPath(other)->ByteStream();
const auto& other_path_byte_stream = To<SVGPath>(other)->ByteStream();
if (ByteStream().size() != other_path_byte_stream.size() ||
ByteStream().IsEmpty() || other_path_byte_stream.IsEmpty())
return;
......@@ -134,14 +133,14 @@ void SVGPath::CalculateAnimatedValue(
SVGElement*) {
bool is_to_animation = animation_element.GetAnimationMode() == kToAnimation;
const SVGPath& to = ToSVGPath(*to_value);
const auto& to = To<SVGPath>(*to_value);
const SVGPathByteStream& to_stream = to.ByteStream();
// If no 'to' value is given, nothing to animate.
if (!to_stream.size())
return;
const SVGPath& from = ToSVGPath(*from_value);
const auto& from = To<SVGPath>(*from_value);
const SVGPathByteStream* from_stream = &from.ByteStream();
std::unique_ptr<SVGPathByteStream> copy;
......@@ -178,7 +177,7 @@ void SVGPath::CalculateAnimatedValue(
if (repeat_count && animation_element.IsAccumulated()) {
new_stream = ConditionallyAddPathByteStreams(
std::move(new_stream),
ToSVGPath(to_at_end_of_duration_value)->ByteStream(), repeat_count);
To<SVGPath>(to_at_end_of_duration_value)->ByteStream(), repeat_count);
}
}
path_value_ = MakeGarbageCollected<CSSPathValue>(std::move(new_stream));
......
......@@ -35,6 +35,7 @@
#include "third_party/blink/renderer/core/svg/properties/svg_property.h"
#include "third_party/blink/renderer/core/svg/svg_parsing_error.h"
#include "third_party/blink/renderer/core/svg/svg_path_byte_stream.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -77,7 +78,12 @@ class SVGPath final : public SVGPropertyBase {
Member<cssvalue::CSSPathValue> path_value_;
};
DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGPath);
template <>
struct DowncastTraits<SVGPath> {
static bool AllowFrom(const SVGPropertyBase& value) {
return value.GetType() == SVGPath::ClassType();
}
};
} // namespace blink
......
......@@ -83,7 +83,7 @@ SVGParsingError SVGPointList::SetValueAsString(const String& value) {
}
void SVGPointList::Add(SVGPropertyBase* other, SVGElement* context_element) {
SVGPointList* other_list = ToSVGPointList(other);
auto* other_list = To<SVGPointList>(other);
if (length() != other_list->length())
return;
......@@ -100,10 +100,10 @@ void SVGPointList::CalculateAnimatedValue(
SVGPropertyBase* to_value,
SVGPropertyBase* to_at_end_of_duration_value,
SVGElement* context_element) {
SVGPointList* from_list = ToSVGPointList(from_value);
SVGPointList* to_list = ToSVGPointList(to_value);
SVGPointList* to_at_end_of_duration_list =
ToSVGPointList(to_at_end_of_duration_value);
auto* from_list = To<SVGPointList>(from_value);
auto* to_list = To<SVGPointList>(to_value);
auto* to_at_end_of_duration_list =
To<SVGPointList>(to_at_end_of_duration_value);
uint32_t from_point_list_size = from_list->length();
uint32_t to_point_list_size = to_list->length();
......
......@@ -34,6 +34,7 @@
#include "third_party/blink/renderer/core/svg/properties/svg_list_property_helper.h"
#include "third_party/blink/renderer/core/svg/svg_parsing_error.h"
#include "third_party/blink/renderer/core/svg/svg_point.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -70,7 +71,12 @@ class SVGPointList final
SVGParsingError Parse(const CharType*& ptr, const CharType* end);
};
DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGPointList);
template <>
struct DowncastTraits<SVGPointList> {
static bool AllowFrom(const SVGPropertyBase& value) {
return value.GetType() == SVGPointList::ClassType();
}
};
} // namespace blink
......
......@@ -91,7 +91,7 @@ String SVGRect::ValueAsString() const {
}
void SVGRect::Add(SVGPropertyBase* other, SVGElement*) {
value_ += ToSVGRect(other)->Value();
value_ += To<SVGRect>(other)->Value();
}
void SVGRect::CalculateAnimatedValue(
......@@ -102,9 +102,9 @@ void SVGRect::CalculateAnimatedValue(
SVGPropertyBase* to_value,
SVGPropertyBase* to_at_end_of_duration_value,
SVGElement*) {
SVGRect* from_rect = ToSVGRect(from_value);
SVGRect* to_rect = ToSVGRect(to_value);
SVGRect* to_at_end_of_duration_rect = ToSVGRect(to_at_end_of_duration_value);
auto* from_rect = To<SVGRect>(from_value);
auto* to_rect = To<SVGRect>(to_value);
auto* to_at_end_of_duration_rect = To<SVGRect>(to_at_end_of_duration_value);
float animated_x = X();
float animated_y = Y();
......
......@@ -24,6 +24,7 @@
#include "third_party/blink/renderer/core/svg/svg_parsing_error.h"
#include "third_party/blink/renderer/platform/geometry/float_rect.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -83,7 +84,12 @@ class SVGRect final : public SVGPropertyHelper<SVGRect> {
FloatRect value_;
};
DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGRect);
template <>
struct DowncastTraits<SVGRect> {
static bool AllowFrom(const SVGPropertyBase& value) {
return value.GetType() == SVGRect::ClassType();
}
};
} // namespace blink
......
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