Commit 6040ad72 authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Remove DEFINE_LAYOUT_OBJECT_TYPE_CASTS and use new downcast helper (1/n)

This CL has two goals,
  1. Remove DEFINE_LAYOUT_OBJECT_TYPE_CASTS.
  2. Use new downast helpers for blink::LayoutSlider
     blink::LayoutSVGContainer and blink::LayoutSVGForeignObject

Bug: 891908
Change-Id: Ib00d9a773f9c43150d33322a7f29062d8b000119
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108308Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#751284}
parent 2148e79c
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/layout_flexible_box.h" #include "third_party/blink/renderer/core/layout/layout_flexible_box.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink { namespace blink {
...@@ -52,7 +53,12 @@ class CORE_EXPORT LayoutSlider final : public LayoutFlexibleBox { ...@@ -52,7 +53,12 @@ class CORE_EXPORT LayoutSlider final : public LayoutFlexibleBox {
LayoutUnit& max_logical_width) const override; LayoutUnit& max_logical_width) const override;
}; };
DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSlider, IsSlider()); template <>
struct DowncastTraits<LayoutSlider> {
static bool AllowFrom(const LayoutObject& object) {
return object.IsSlider();
}
};
} // namespace blink } // namespace blink
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_CONTAINER_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_CONTAINER_H_
#include "third_party/blink/renderer/core/layout/svg/layout_svg_model_object.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_model_object.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink { namespace blink {
...@@ -108,7 +109,12 @@ class LayoutSVGContainer : public LayoutSVGModelObject { ...@@ -108,7 +109,12 @@ class LayoutSVGContainer : public LayoutSVGModelObject {
mutable bool has_non_isolated_blending_descendants_dirty_ : 1; mutable bool has_non_isolated_blending_descendants_dirty_ : 1;
}; };
DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGContainer, IsSVGContainer()); template <>
struct DowncastTraits<LayoutSVGContainer> {
static bool AllowFrom(const LayoutObject& object) {
return object.IsSVGContainer();
}
};
} // namespace blink } // namespace blink
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_FOREIGN_OBJECT_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_LAYOUT_SVG_FOREIGN_OBJECT_H_
#include "third_party/blink/renderer/core/layout/svg/layout_svg_block.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_block.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink { namespace blink {
...@@ -104,7 +105,12 @@ class LayoutSVGForeignObject final : public LayoutSVGBlock { ...@@ -104,7 +105,12 @@ class LayoutSVGForeignObject final : public LayoutSVGBlock {
bool needs_transform_update_; bool needs_transform_update_;
}; };
DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGForeignObject, IsSVGForeignObject()); template <>
struct DowncastTraits<LayoutSVGForeignObject> {
static bool AllowFrom(const LayoutObject& object) {
return object.IsSVGForeignObject();
}
};
} // namespace blink } // namespace blink
......
...@@ -210,10 +210,9 @@ inline void SVGLayoutSupport::UpdateObjectBoundingBox( ...@@ -210,10 +210,9 @@ inline void SVGLayoutSupport::UpdateObjectBoundingBox(
bool& object_bounding_box_valid, bool& object_bounding_box_valid,
LayoutObject* other, LayoutObject* other,
FloatRect other_bounding_box) { FloatRect other_bounding_box) {
auto* svg_container = DynamicTo<LayoutSVGContainer>(other);
bool other_valid = bool other_valid =
other->IsSVGContainer() svg_container ? svg_container->IsObjectBoundingBoxValid() : true;
? ToLayoutSVGContainer(other)->IsObjectBoundingBoxValid()
: true;
if (!other_valid) if (!other_valid)
return; return;
...@@ -236,8 +235,8 @@ static bool HasValidBoundingBoxForContainer(const LayoutObject* object) { ...@@ -236,8 +235,8 @@ static bool HasValidBoundingBoxForContainer(const LayoutObject* object) {
if (object->IsSVGHiddenContainer()) if (object->IsSVGHiddenContainer())
return false; return false;
if (object->IsSVGForeignObject()) if (auto* foreign_object = DynamicTo<LayoutSVGForeignObject>(object))
return ToLayoutSVGForeignObject(object)->IsObjectBoundingBoxValid(); return foreign_object->IsObjectBoundingBoxValid();
if (object->IsSVGImage()) if (object->IsSVGImage())
return ToLayoutSVGImage(object)->IsObjectBoundingBoxValid(); return ToLayoutSVGImage(object)->IsObjectBoundingBoxValid();
...@@ -470,8 +469,8 @@ bool SVGLayoutSupport::HitTestChildren(LayoutObject* last_child, ...@@ -470,8 +469,8 @@ bool SVGLayoutSupport::HitTestChildren(LayoutObject* last_child,
HitTestAction hit_test_action) { HitTestAction hit_test_action) {
for (LayoutObject* child = last_child; child; for (LayoutObject* child = last_child; child;
child = child->PreviousSibling()) { child = child->PreviousSibling()) {
if (child->IsSVGForeignObject()) { if (auto* foreign_object = DynamicTo<LayoutSVGForeignObject>(child)) {
if (ToLayoutSVGForeignObject(child)->NodeAtPointFromSVG( if (foreign_object->NodeAtPointFromSVG(
result, location, accumulated_offset, hit_test_action)) result, location, accumulated_offset, hit_test_action))
return true; return true;
} else { } else {
......
...@@ -46,9 +46,8 @@ void BoxPainter::PaintChildren(const PaintInfo& paint_info) { ...@@ -46,9 +46,8 @@ void BoxPainter::PaintChildren(const PaintInfo& paint_info) {
PaintInfo child_info(paint_info); PaintInfo child_info(paint_info);
for (LayoutObject* child = layout_box_.SlowFirstChild(); child; for (LayoutObject* child = layout_box_.SlowFirstChild(); child;
child = child->NextSibling()) { child = child->NextSibling()) {
if (child->IsSVGForeignObject()) { if (auto* foreign_object = DynamicTo<LayoutSVGForeignObject>(*child)) {
SVGForeignObjectPainter(ToLayoutSVGForeignObject(*child)) SVGForeignObjectPainter(*foreign_object).PaintLayer(paint_info);
.PaintLayer(paint_info);
} else { } else {
child->Paint(child_info); child->Paint(child_info);
} }
......
...@@ -83,8 +83,9 @@ void SVGContainerPainter::Paint(const PaintInfo& paint_info) { ...@@ -83,8 +83,9 @@ void SVGContainerPainter::Paint(const PaintInfo& paint_info) {
if (continue_rendering) { if (continue_rendering) {
for (LayoutObject* child = layout_svg_container_.FirstChild(); child; for (LayoutObject* child = layout_svg_container_.FirstChild(); child;
child = child->NextSibling()) { child = child->NextSibling()) {
auto* foreign_object = DynamicTo<LayoutSVGForeignObject>(*child);
if (child->IsSVGForeignObject()) { if (child->IsSVGForeignObject()) {
SVGForeignObjectPainter(ToLayoutSVGForeignObject(*child)) SVGForeignObjectPainter(*foreign_object)
.PaintLayer(paint_state.GetPaintInfo()); .PaintLayer(paint_state.GetPaintInfo());
} else { } else {
child->Paint(paint_state.GetPaintInfo()); child->Paint(paint_state.GetPaintInfo());
......
...@@ -458,8 +458,8 @@ AXObject* AXObjectCacheImpl::CreateFromRenderer(LayoutObject* layout_object) { ...@@ -458,8 +458,8 @@ AXObject* AXObjectCacheImpl::CreateFromRenderer(LayoutObject* layout_object) {
} }
// input type=range // input type=range
if (css_box->IsSlider()) if (auto* slider = DynamicTo<LayoutSlider>(css_box))
return MakeGarbageCollected<AXSlider>(ToLayoutSlider(css_box), *this); return MakeGarbageCollected<AXSlider>(slider, *this);
} }
return MakeGarbageCollected<AXLayoutObject>(layout_object, *this); return MakeGarbageCollected<AXLayoutObject>(layout_object, *this);
......
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