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