Remove DEFINE_BASICSHAPE_TYPE_CASTS use from style_path.h
The primary motivation of this CL is to replace |ToStylePath| with
|To<StylePath>|.
This CL also ports other dependent files to refer to a new template
function name.
Bug: 891908
Change-Id: I7682da3cdaddf48008317099c84babe97d63df72
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1534898
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#643293}
diff --git a/third_party/blink/renderer/core/animation/css_path_interpolation_type.cc b/third_party/blink/renderer/core/animation/css_path_interpolation_type.cc
index 691c4360d..1bbe4ee8 100644
--- a/third_party/blink/renderer/core/animation/css_path_interpolation_type.cc
+++ b/third_party/blink/renderer/core/animation/css_path_interpolation_type.cc
@@ -27,7 +27,7 @@
BasicShape* offset_path = style.OffsetPath();
if (!offset_path || offset_path->GetType() != BasicShape::kStylePathType)
return nullptr;
- return ToStylePath(style.OffsetPath());
+ return To<StylePath>(style.OffsetPath());
}
default:
NOTREACHED();
diff --git a/third_party/blink/renderer/core/css/basic_shape_functions.cc b/third_party/blink/renderer/core/css/basic_shape_functions.cc
index 224ed11..95cc71c 100644
--- a/third_party/blink/renderer/core/css/basic_shape_functions.cc
+++ b/third_party/blink/renderer/core/css/basic_shape_functions.cc
@@ -129,7 +129,7 @@
}
case BasicShape::kStylePathType:
- return ToStylePath(basic_shape)->ComputedCSSValue();
+ return To<StylePath>(basic_shape)->ComputedCSSValue();
case BasicShape::kBasicShapeCircleType: {
const BasicShapeCircle* circle = ToBasicShapeCircle(basic_shape);
diff --git a/third_party/blink/renderer/core/style/computed_style.cc b/third_party/blink/renderer/core/style/computed_style.cc
index a8db95e..d124de0f 100644
--- a/third_party/blink/renderer/core/style/computed_style.cc
+++ b/third_party/blink/renderer/core/style/computed_style.cc
@@ -1181,7 +1181,7 @@
point.SetY(float_distance * sin(deg2rad(angle)));
} else {
float zoom = EffectiveZoom();
- const StylePath& motion_path = ToStylePath(*path);
+ const StylePath& motion_path = To<StylePath>(*path);
float path_length = motion_path.length();
float float_distance =
FloatValueForLength(distance, path_length * zoom) / zoom;
diff --git a/third_party/blink/renderer/core/style/style_path.cc b/third_party/blink/renderer/core/style/style_path.cc
index c6acccee4..1ada557 100644
--- a/third_party/blink/renderer/core/style/style_path.cc
+++ b/third_party/blink/renderer/core/style/style_path.cc
@@ -60,7 +60,7 @@
bool StylePath::operator==(const BasicShape& o) const {
if (!IsSameType(o))
return false;
- const StylePath& other = ToStylePath(o);
+ const StylePath& other = To<StylePath>(o);
return *byte_stream_ == *other.byte_stream_;
}
diff --git a/third_party/blink/renderer/core/style/style_path.h b/third_party/blink/renderer/core/style/style_path.h
index 085aa62..5876df04 100644
--- a/third_party/blink/renderer/core/style/style_path.h
+++ b/third_party/blink/renderer/core/style/style_path.h
@@ -8,6 +8,7 @@
#include <memory>
#include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/core/style/basic_shapes.h"
+#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
@@ -43,7 +44,12 @@
mutable float path_length_;
};
-DEFINE_BASICSHAPE_TYPE_CASTS(StylePath);
+template <>
+struct DowncastTraits<StylePath> {
+ static bool AllowFrom(const BasicShape& value) {
+ return value.GetType() == BasicShape::kStylePathType;
+ }
+};
} // namespace blink