Commit c48d747e authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Use new downcast helper for SVG{DefsElement|CircleElement|A}Element

This CL has below goals,
  1. Use To<SVGDefsElement> and DynamicTo<SVGDefsElement> as new
     downcast helper
  2. Use IsA<SVGDefsElement>(element) in place of
     IsSVGDefsElement(element)
  3. Use To<SVGCircleElement> and DynamicTo<SVGCircleElement> as new
     downcast helper
  4. Use IsA<SVGCircleElement>(element) in place of
     IsSVGCircleElement(element)
  5. Use DynamicTo<SVGAElement> as new downcast helper
  6. Use IsA<SVGAElement>(element) in place of IsSVGAElement(element)

Bug: 891908
Change-Id: If2c1706899083e924a7efc762e403c81a6c6c211
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1946193
Commit-Queue: Abhijeet | Igalia <abhijeet@igalia.com>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720882}
parent 09b268ec
...@@ -5440,7 +5440,7 @@ KURL Element::HrefURL() const { ...@@ -5440,7 +5440,7 @@ KURL Element::HrefURL() const {
if (IsA<HTMLAnchorElement>(*this) || IsA<HTMLAreaElement>(*this) || if (IsA<HTMLAnchorElement>(*this) || IsA<HTMLAreaElement>(*this) ||
IsA<HTMLLinkElement>(*this)) IsA<HTMLLinkElement>(*this))
return GetURLAttribute(html_names::kHrefAttr); return GetURLAttribute(html_names::kHrefAttr);
if (auto* svg_a = ToSVGAElementOrNull(*this)) if (auto* svg_a = DynamicTo<SVGAElement>(*this))
return svg_a->LegacyHrefURL(GetDocument()); return svg_a->LegacyHrefURL(GetDocument());
return KURL(); return KURL();
} }
......
...@@ -85,7 +85,7 @@ void LayoutSVGEllipse::CalculateRadiiAndCenter() { ...@@ -85,7 +85,7 @@ void LayoutSVGEllipse::CalculateRadiiAndCenter() {
center_ = center_ =
length_context.ResolveLengthPair(svg_style.Cx(), svg_style.Cy(), style); length_context.ResolveLengthPair(svg_style.Cx(), svg_style.Cy(), style);
if (IsSVGCircleElement(*GetElement())) { if (IsA<SVGCircleElement>(*GetElement())) {
float radius = length_context.ValueForLength(svg_style.R(), style, float radius = length_context.ValueForLength(svg_style.R(), style,
SVGLengthMode::kOther); SVGLengthMode::kOther);
radii_ = FloatSize(radius, radius); radii_ = FloatSize(radius, radius);
......
...@@ -36,10 +36,10 @@ bool LayoutSVGInline::IsChildAllowed(LayoutObject* child, ...@@ -36,10 +36,10 @@ bool LayoutSVGInline::IsChildAllowed(LayoutObject* child,
if (child->IsText()) if (child->IsText())
return SVGLayoutSupport::IsLayoutableTextNode(child); return SVGLayoutSupport::IsLayoutableTextNode(child);
if (IsSVGAElement(*GetNode())) { if (IsA<SVGAElement>(*GetNode())) {
Node* child_node = child->GetNode(); Node* child_node = child->GetNode();
// Disallow direct descendant 'a'. // Disallow direct descendant 'a'.
if (child_node && IsSVGAElement(*child_node)) if (child_node && IsA<SVGAElement>(*child_node))
return false; return false;
} }
......
...@@ -56,11 +56,11 @@ bool LayoutSVGTransformableContainer::IsChildAllowed( ...@@ -56,11 +56,11 @@ bool LayoutSVGTransformableContainer::IsChildAllowed(
// Reject this child if it isn't the first valid node. // Reject this child if it isn't the first valid node.
if (HasValidPredecessor(child_node)) if (HasValidPredecessor(child_node))
return false; return false;
} else if (IsSVGAElement(*GetElement())) { } else if (IsA<SVGAElement>(*GetElement())) {
// http://www.w3.org/2003/01/REC-SVG11-20030114-errata#linking-text-environment // http://www.w3.org/2003/01/REC-SVG11-20030114-errata#linking-text-environment
// The 'a' element may contain any element that its parent may contain, // The 'a' element may contain any element that its parent may contain,
// except itself. // except itself.
if (child_node && IsSVGAElement(*child_node)) if (child_node && IsA<SVGAElement>(*child_node))
return false; return false;
if (Parent() && Parent()->IsSVG()) if (Parent() && Parent()->IsSVG())
return Parent()->IsChildAllowed(child, style); return Parent()->IsChildAllowed(child, style);
......
...@@ -373,7 +373,7 @@ static WTF::TextStream& operator<<(WTF::TextStream& ts, ...@@ -373,7 +373,7 @@ static WTF::TextStream& operator<<(WTF::TextStream& ts,
WriteNameValuePair(ts, "ry", WriteNameValuePair(ts, "ry",
length_context.ValueForLength(svg_style.Ry(), style, length_context.ValueForLength(svg_style.Ry(), style,
SVGLengthMode::kHeight)); SVGLengthMode::kHeight));
} else if (IsSVGCircleElement(*svg_element)) { } else if (IsA<SVGCircleElement>(*svg_element)) {
WriteNameValuePair(ts, "cx", WriteNameValuePair(ts, "cx",
length_context.ValueForLength(svg_style.Cx(), style, length_context.ValueForLength(svg_style.Cx(), style,
SVGLengthMode::kWidth)); SVGLengthMode::kWidth));
......
...@@ -44,14 +44,14 @@ bool TargetCanHaveMotionTransform(const SVGElement& target) { ...@@ -44,14 +44,14 @@ bool TargetCanHaveMotionTransform(const SVGElement& target) {
// Spec: SVG 1.1 section 19.2.15 // Spec: SVG 1.1 section 19.2.15
// FIXME: svgTag is missing. Needs to be checked, if transforming <svg> could // FIXME: svgTag is missing. Needs to be checked, if transforming <svg> could
// cause problems. // cause problems.
return IsA<SVGGElement>(target) || IsSVGDefsElement(target) || return IsA<SVGGElement>(target) || IsA<SVGDefsElement>(target) ||
IsA<SVGUseElement>(target) || IsA<SVGImageElement>(target) || IsA<SVGUseElement>(target) || IsA<SVGImageElement>(target) ||
IsSVGSwitchElement(target) || IsA<SVGPathElement>(target) || IsSVGSwitchElement(target) || IsA<SVGPathElement>(target) ||
IsA<SVGRectElement>(target) || IsSVGCircleElement(target) || IsA<SVGRectElement>(target) || IsA<SVGCircleElement>(target) ||
IsA<SVGEllipseElement>(target) || IsA<SVGLineElement>(target) || IsA<SVGEllipseElement>(target) || IsA<SVGLineElement>(target) ||
IsA<SVGPolylineElement>(target) || IsA<SVGPolygonElement>(target) || IsA<SVGPolylineElement>(target) || IsA<SVGPolygonElement>(target) ||
IsA<SVGTextElement>(target) || IsA<SVGClipPathElement>(target) || IsA<SVGTextElement>(target) || IsA<SVGClipPathElement>(target) ||
IsA<SVGMaskElement>(target) || IsSVGAElement(target) || IsA<SVGMaskElement>(target) || IsA<SVGAElement>(target) ||
IsA<SVGForeignObjectElement>(target); IsA<SVGForeignObjectElement>(target);
} }
} }
......
...@@ -116,7 +116,7 @@ LayoutObject* SVGTextPathElement::CreateLayoutObject(const ComputedStyle&, ...@@ -116,7 +116,7 @@ LayoutObject* SVGTextPathElement::CreateLayoutObject(const ComputedStyle&,
bool SVGTextPathElement::LayoutObjectIsNeeded( bool SVGTextPathElement::LayoutObjectIsNeeded(
const ComputedStyle& style) const { const ComputedStyle& style) const {
if (parentNode() && if (parentNode() &&
(IsSVGAElement(*parentNode()) || IsA<SVGTextElement>(*parentNode()))) (IsA<SVGAElement>(*parentNode()) || IsA<SVGTextElement>(*parentNode())))
return SVGElement::LayoutObjectIsNeeded(style); return SVGElement::LayoutObjectIsNeeded(style);
return false; return false;
......
...@@ -35,7 +35,7 @@ LayoutObject* SVGTSpanElement::CreateLayoutObject(const ComputedStyle&, ...@@ -35,7 +35,7 @@ LayoutObject* SVGTSpanElement::CreateLayoutObject(const ComputedStyle&,
bool SVGTSpanElement::LayoutObjectIsNeeded(const ComputedStyle& style) const { bool SVGTSpanElement::LayoutObjectIsNeeded(const ComputedStyle& style) const {
if (parentNode() && if (parentNode() &&
(IsSVGAElement(*parentNode()) || IsA<SVGTextElement>(*parentNode()) || (IsA<SVGAElement>(*parentNode()) || IsA<SVGTextElement>(*parentNode()) ||
IsA<SVGTextPathElement>(*parentNode()) || IsA<SVGTextPathElement>(*parentNode()) ||
IsA<SVGTSpanElement>(*parentNode()))) IsA<SVGTSpanElement>(*parentNode())))
return SVGElement::LayoutObjectIsNeeded(style); return SVGElement::LayoutObjectIsNeeded(style);
......
...@@ -498,7 +498,7 @@ LayoutObject* SVGUseElement::CreateLayoutObject(const ComputedStyle& style, ...@@ -498,7 +498,7 @@ LayoutObject* SVGUseElement::CreateLayoutObject(const ComputedStyle& style,
static bool IsDirectReference(const SVGElement& element) { static bool IsDirectReference(const SVGElement& element) {
return IsA<SVGPathElement>(element) || IsA<SVGRectElement>(element) || return IsA<SVGPathElement>(element) || IsA<SVGRectElement>(element) ||
IsSVGCircleElement(element) || IsA<SVGEllipseElement>(element) || IsA<SVGCircleElement>(element) || IsA<SVGEllipseElement>(element) ||
IsA<SVGPolygonElement>(element) || IsA<SVGPolylineElement>(element) || IsA<SVGPolygonElement>(element) || IsA<SVGPolylineElement>(element) ||
IsA<SVGTextElement>(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