Commit 9e90a203 authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

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

This CL uses new downcast helpers for classes,
- SVGInlineFlowBox
- SVGRootInlineBox

Bug: 891908
Change-Id: Ia211ffb55e77e299c333a8bfd2ed19c053d0536c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2024987Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#736242}
parent 0b103491
......@@ -957,7 +957,7 @@ RootInlineBox* LayoutBlockFlow::CreateLineBoxesFromBidiRuns(
// text selection in RTL boxes would not work as expected.
if (is_svg_root_inline_box) {
DCHECK(IsSVGText());
ToSVGRootInlineBox(line_box)->ComputePerCharacterLayoutInformation();
To<SVGRootInlineBox>(line_box)->ComputePerCharacterLayoutInformation();
}
// Compute our overflow now.
......
......@@ -365,8 +365,8 @@ PositionWithAffinity LayoutSVGText::PositionForPoint(
DCHECK(!root_box->NextRootBox());
DCHECK(ChildrenInline());
InlineBox* closest_box =
ToSVGRootInlineBox(root_box)->ClosestLeafChildForPosition(
auto* closest_box =
To<SVGRootInlineBox>(root_box)->ClosestLeafChildForPosition(
clipped_point_in_contents);
if (!closest_box)
return CreatePositionWithAffinity(0);
......
......@@ -22,6 +22,7 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LINE_SVG_INLINE_FLOW_BOX_H_
#include "third_party/blink/renderer/core/layout/line/inline_flow_box.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -42,7 +43,12 @@ class SVGInlineFlowBox final : public InlineFlowBox {
LayoutUnit logical_height_;
};
DEFINE_INLINE_BOX_TYPE_CASTS(SVGInlineFlowBox);
template <>
struct DowncastTraits<SVGInlineFlowBox> {
static bool AllowFrom(const InlineBox& box) {
return box.IsSVGInlineFlowBox();
}
};
} // namespace blink
......
......@@ -103,10 +103,10 @@ FloatRect SVGRootInlineBox::LayoutInlineBoxes(InlineBox& box) {
box.SetLogicalWidth(logical_rect.Width());
if (box.IsSVGInlineTextBox())
ToSVGInlineTextBox(box).SetLogicalHeight(logical_rect.Height());
else if (box.IsSVGInlineFlowBox())
ToSVGInlineFlowBox(box).SetLogicalHeight(logical_rect.Height());
else if (auto* svg_inline_flow_box = DynamicTo<SVGInlineFlowBox>(box))
svg_inline_flow_box->SetLogicalHeight(logical_rect.Height());
else
ToSVGRootInlineBox(box).SetLogicalHeight(logical_rect.Height());
To<SVGRootInlineBox>(box).SetLogicalHeight(logical_rect.Height());
return rect;
}
......
......@@ -24,6 +24,7 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LINE_SVG_ROOT_INLINE_BOX_H_
#include "third_party/blink/renderer/core/layout/line/root_inline_box.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -60,7 +61,12 @@ class SVGRootInlineBox final : public RootInlineBox {
LayoutUnit logical_height_;
};
DEFINE_INLINE_BOX_TYPE_CASTS(SVGRootInlineBox);
template <>
struct DowncastTraits<SVGRootInlineBox> {
static bool AllowFrom(const InlineBox& box) {
return box.IsSVGRootInlineBox();
}
};
} // namespace blink
......
......@@ -408,7 +408,7 @@ static WTF::TextStream& operator<<(WTF::TextStream& ts,
static void WriteLayoutSVGTextBox(WTF::TextStream& ts,
const LayoutSVGText& text) {
SVGRootInlineBox* box = ToSVGRootInlineBox(text.FirstRootBox());
auto* box = To<SVGRootInlineBox>(text.FirstRootBox());
if (!box)
return;
......
......@@ -272,7 +272,7 @@ void SVGTextLayoutEngine::LayoutCharactersInTextBoxes(InlineFlowBox* start) {
if (!node)
continue;
SVGInlineFlowBox* flow_box = ToSVGInlineFlowBox(child);
auto* flow_box = To<SVGInlineFlowBox>(child);
bool is_text_path = IsA<SVGTextPathElement>(*node);
if (is_text_path)
BeginTextPathLayout(flow_box);
......
......@@ -24,8 +24,8 @@ void SVGInlineFlowBoxPainter::PaintSelectionBackground(
if (child->IsSVGInlineTextBox())
SVGInlineTextBoxPainter(*ToSVGInlineTextBox(child))
.PaintSelectionBackground(child_paint_info);
else if (child->IsSVGInlineFlowBox())
SVGInlineFlowBoxPainter(*ToSVGInlineFlowBox(child))
else if (auto* svg_inline_flow_box = DynamicTo<SVGInlineFlowBox>(child))
SVGInlineFlowBoxPainter(*svg_inline_flow_box)
.PaintSelectionBackground(child_paint_info);
}
}
......
......@@ -39,8 +39,8 @@ void SVGRootInlineBoxPainter::Paint(const PaintInfo& paint_info,
if (child->IsSVGInlineTextBox())
SVGInlineTextBoxPainter(*ToSVGInlineTextBox(child))
.PaintSelectionBackground(paint_info_before_filtering);
else if (child->IsSVGInlineFlowBox())
SVGInlineFlowBoxPainter(*ToSVGInlineFlowBox(child))
else if (auto* svg_inline_flow_box = DynamicTo<SVGInlineFlowBox>(child))
SVGInlineFlowBoxPainter(*svg_inline_flow_box)
.PaintSelectionBackground(paint_info_before_filtering);
}
}
......
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