1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 17:44:56 +09:00

LibWeb: Simplify Layout::Node::class_name() with RTTI

This commit is contained in:
Andreas Kling 2021-01-01 16:08:19 +01:00
parent 7841528cd4
commit 730af2c524
Notes: sideshowbarker 2024-07-19 00:16:05 +09:00
24 changed files with 8 additions and 37 deletions

View file

@ -36,8 +36,6 @@ public:
BlockBox(DOM::Document&, DOM::Node*, NonnullRefPtr<CSS::StyleProperties>);
virtual ~BlockBox() override;
virtual const char* class_name() const override { return "BlockBox"; }
virtual void paint(PaintContext&, PaintPhase) override;
virtual HitTestResult hit_test(const Gfx::IntPoint&, HitTestType) const override;

View file

@ -40,7 +40,6 @@ public:
private:
virtual bool is_break() const override { return true; }
virtual const char* class_name() const override { return "BreakNode"; }
virtual void split_into_lines(InlineFormattingContext&, LayoutMode) override;
};

View file

@ -43,7 +43,6 @@ public:
HTML::HTMLInputElement& dom_node() { return static_cast<HTML::HTMLInputElement&>(ReplacedBox::dom_node()); }
private:
virtual const char* class_name() const override { return "ButtonBox"; }
virtual bool is_button() const override { return true; }
virtual bool wants_mouse_events() const override { return true; }
virtual void handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;

View file

@ -42,7 +42,6 @@ public:
const HTML::HTMLCanvasElement& dom_node() const { return static_cast<const HTML::HTMLCanvasElement&>(ReplacedBox::dom_node()); }
private:
virtual const char* class_name() const override { return "CanvasBox"; }
virtual bool is_canvas() const override { return true; }
};

View file

@ -42,7 +42,6 @@ public:
HTML::HTMLInputElement& dom_node() { return static_cast<HTML::HTMLInputElement&>(ReplacedBox::dom_node()); }
private:
virtual const char* class_name() const override { return "CheckBox"; }
virtual bool is_check_box() const override { return true; }
virtual bool wants_mouse_events() const override { return true; }
virtual void handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;

View file

@ -44,7 +44,6 @@ public:
private:
virtual bool is_frame() const final { return true; }
virtual const char* class_name() const override { return "FrameBox"; }
virtual void did_set_rect() override;
};

View file

@ -46,7 +46,6 @@ public:
void set_visible_in_viewport(Badge<InitialContainingBlockBox>, bool);
private:
virtual const char* class_name() const override { return "ImageBox"; }
virtual bool is_image() const override { return true; }
int preferred_width() const;

View file

@ -37,7 +37,6 @@ public:
virtual ~InitialContainingBlockBox() override;
const DOM::Document& dom_node() const { return static_cast<const DOM::Document&>(*Node::dom_node()); }
virtual const char* class_name() const override { return "InitialContainingBlockBox"; }
void paint_all_phases(PaintContext&);
virtual void paint(PaintContext&, PaintPhase) override;

View file

@ -34,7 +34,6 @@ class InlineNode : public NodeWithStyleAndBoxModelMetrics {
public:
InlineNode(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~InlineNode() override;
virtual const char* class_name() const override { return "InlineNode"; }
virtual void paint_fragment(PaintContext&, const LineBoxFragment&, PaintPhase) const override;

View file

@ -41,7 +41,6 @@ public:
void layout_marker();
private:
virtual const char* class_name() const override { return "ListItemBox"; }
virtual bool is_list_item() const override { return true; }
RefPtr<ListItemMarkerBox> m_marker;

View file

@ -36,9 +36,6 @@ public:
virtual ~ListItemMarkerBox() override;
virtual void paint(PaintContext&, PaintPhase) override;
private:
virtual const char* class_name() const override { return "ListItemMarkerBox"; }
};
}

View file

@ -35,6 +35,7 @@
#include <LibWeb/Layout/Node.h>
#include <LibWeb/Layout/ReplacedBox.h>
#include <LibWeb/Page/Frame.h>
#include <typeinfo>
namespace Web::Layout {
@ -296,4 +297,9 @@ bool Node::is_root_element() const
return is<HTML::HTMLHtmlElement>(*dom_node());
}
const char* Node::class_name() const
{
return typeid(*this).name();
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -93,7 +93,7 @@ public:
bool is_root_element() const;
virtual const char* class_name() const = 0;
const char* class_name() const;
virtual bool is_initial_containing_block() const { return false; }
virtual bool is_text() const { return false; }
virtual bool is_block() const { return false; }

View file

@ -65,8 +65,6 @@ protected:
virtual void split_into_lines(InlineFormattingContext&, LayoutMode) override;
private:
virtual const char* class_name() const override { return "ReplacedBox"; }
bool m_has_intrinsic_width { false };
bool m_has_intrinsic_height { false };
bool m_has_intrinsic_ratio { false };

View file

@ -39,9 +39,6 @@ public:
virtual void before_children_paint(PaintContext& context, PaintPhase phase) override;
virtual void after_children_paint(PaintContext& context, PaintPhase phase) override;
private:
virtual const char* class_name() const override { return "SVGBox"; }
};
}

View file

@ -38,9 +38,6 @@ public:
virtual ~SVGGraphicsBox() override = default;
virtual void before_children_paint(PaintContext& context, PaintPhase phase) override;
private:
virtual const char* class_name() const override { return "SVGGraphicsBox"; }
};
}

View file

@ -39,9 +39,6 @@ public:
virtual void prepare_for_replaced_layout() override;
virtual void paint(PaintContext& context, PaintPhase phase) override;
private:
virtual const char* class_name() const override { return "SVGPathBox"; }
};
}

View file

@ -44,9 +44,6 @@ public:
virtual void after_children_paint(PaintContext& context, PaintPhase phase) override;
virtual bool can_have_children() const override { return true; }
private:
const char* class_name() const override { return "SVGSVGBox"; }
};
}

View file

@ -37,7 +37,6 @@ public:
private:
virtual bool is_table() const override { return true; }
virtual const char* class_name() const override { return "TableBox"; }
};
}

View file

@ -42,7 +42,6 @@ public:
private:
virtual bool is_table_cell() const override { return true; }
virtual const char* class_name() const override { return "TableCellBox"; }
virtual float width_of_logical_containing_block() const override;
};

View file

@ -37,7 +37,6 @@ public:
private:
virtual bool is_table_row() const override { return true; }
virtual const char* class_name() const override { return "TableRowBox"; }
};
}

View file

@ -39,7 +39,6 @@ public:
private:
virtual bool is_table_row_group() const override { return true; }
virtual const char* class_name() const override { return "TableRowGroupBox"; }
};
}

View file

@ -43,7 +43,6 @@ public:
const String& text_for_style(const CSS::StyleProperties&) const;
const String& text_for_rendering() const { return m_text_for_rendering; }
virtual const char* class_name() const override { return "TextNode"; }
virtual bool is_text() const final { return true; }
virtual void paint_fragment(PaintContext&, const LineBoxFragment&, PaintPhase) const override;

View file

@ -43,8 +43,6 @@ public:
void update_widget();
private:
virtual const char* class_name() const override { return "WidgetBox"; }
virtual void did_set_rect() override;
NonnullRefPtr<GUI::Widget> m_widget;