Commit 7590b421 authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Use new downcast helper for blink::SVGPathElement

This CL has two goals,
  1. Use To<SVGPathElement> and DynamicTo<SVGPathElement> as new
   downcast helper
  2. Use IsA<SVGPathElement>(element) in place of
   IsSVGPathElement(element)

Bug: 891908
Change-Id: Ibbfb1dec739672a3c7a1bf9fc48b4478a4eea604
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1936613
Commit-Queue: Abhijeet | Igalia <abhijeet@igalia.com>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720442}
parent fcf7ee1f
......@@ -65,11 +65,11 @@ std::unique_ptr<PathPositionMapper> LayoutSVGTextPath::LayoutPath() const {
text_path_element.HrefString(),
text_path_element.TreeScopeForIdResolution());
if (!IsSVGPathElement(target_element))
const auto* path_element = DynamicTo<SVGPathElement>(target_element);
if (!path_element)
return nullptr;
const SVGPathElement& path_element = ToSVGPathElement(*target_element);
Path path_data = path_element.AsPath();
Path path_data = path_element->AsPath();
if (path_data.IsEmpty())
return nullptr;
......@@ -80,13 +80,13 @@ std::unique_ptr<PathPositionMapper> LayoutSVGTextPath::LayoutPath() const {
// 'transform' property on the current 'text' element.
// https://svgwg.org/svg2-draft/text.html#TextPathElement
path_data.Transform(
path_element.CalculateTransform(SVGElement::kIncludeMotionTransform));
path_element->CalculateTransform(SVGElement::kIncludeMotionTransform));
// Determine the length to resolve any percentage 'startOffset'
// against - either 'pathLength' (author path length) or the
// computed length of the path.
float computed_path_length = path_data.length();
float author_path_length = path_element.AuthorPathLength();
float author_path_length = path_element->AuthorPathLength();
float offset_scale = 1;
if (!std::isnan(author_path_length)) {
offset_scale = SVGGeometryElement::PathLengthScaleFactor(
......
......@@ -389,7 +389,7 @@ static WTF::TextStream& operator<<(WTF::TextStream& ts,
.Points()
->CurrentValue()
->ValueAsString());
} else if (IsSVGPathElement(*svg_element)) {
} else if (IsA<SVGPathElement>(*svg_element)) {
const StylePath& path =
svg_style.D() ? *svg_style.D() : *StylePath::EmptyPath();
WriteNameAndQuotedValue(
......
......@@ -46,7 +46,7 @@ bool TargetCanHaveMotionTransform(const SVGElement& target) {
// cause problems.
return IsA<SVGGElement>(target) || IsSVGDefsElement(target) ||
IsA<SVGUseElement>(target) || IsSVGImageElement(target) ||
IsSVGSwitchElement(target) || IsSVGPathElement(target) ||
IsSVGSwitchElement(target) || IsA<SVGPathElement>(target) ||
IsA<SVGRectElement>(target) || IsSVGCircleElement(target) ||
IsA<SVGEllipseElement>(target) || IsA<SVGLineElement>(target) ||
IsA<SVGPolylineElement>(target) || IsA<SVGPolygonElement>(target) ||
......
......@@ -43,7 +43,7 @@ void SVGMPathElement::BuildPendingResource() {
if (!isConnected())
return;
Element* target = ObserveTarget(target_id_observer_, *this);
if (auto* path = ToSVGPathElementOrNull(target)) {
if (auto* path = DynamicTo<SVGPathElement>(target)) {
// Register us with the target in the dependencies map. Any change of
// hrefElement that leads to relayout/repainting now informs us, so we can
// react to it.
......@@ -84,7 +84,7 @@ void SVGMPathElement::SvgAttributeChanged(const QualifiedName& attr_name) {
SVGPathElement* SVGMPathElement::PathElement() {
Element* target = TargetElementFromIRIString(HrefString(), GetTreeScope());
return ToSVGPathElementOrNull(target);
return DynamicTo<SVGPathElement>(target);
}
void SVGMPathElement::TargetPathChanged() {
......
......@@ -103,7 +103,7 @@ void SVGPathElement::CollectStyleForPresentationAttribute(
// If this is a <use> instance, return the referenced path to maximize
// geometry sharing.
if (const SVGElement* element = CorrespondingElement())
path = ToSVGPathElement(element)->GetPath();
path = To<SVGPathElement>(element)->GetPath();
AddPropertyToPresentationAttributeStyle(style, property->CssPropertyId(),
path->CssValue());
return;
......
......@@ -127,7 +127,7 @@ void SVGTextPathElement::BuildPendingResource() {
if (!isConnected())
return;
Element* target = ObserveTarget(target_id_observer_, *this);
if (IsSVGPathElement(target)) {
if (IsA<SVGPathElement>(target)) {
// Register us with the target in the dependencies map. Any change of
// hrefElement that leads to relayout/repainting now informs us, so we can
// react to it.
......
......@@ -497,7 +497,7 @@ LayoutObject* SVGUseElement::CreateLayoutObject(const ComputedStyle& style,
}
static bool IsDirectReference(const SVGElement& element) {
return IsSVGPathElement(element) || IsA<SVGRectElement>(element) ||
return IsA<SVGPathElement>(element) || IsA<SVGRectElement>(element) ||
IsSVGCircleElement(element) || IsA<SVGEllipseElement>(element) ||
IsA<SVGPolygonElement>(element) || IsA<SVGPolylineElement>(element) ||
IsA<SVGTextElement>(element);
......
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