summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-01 18:55:47 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-01 18:56:49 +0100
commit07dd73c3510f6bd9f569e101f60e5bf6a1614108 (patch)
tree0fc36cf0b67dc968ccd22e1311a4dde315ac791b
parent3bb0cb2202a487303ece7444b4805fd0d30c97ed (diff)
downloadserenity-07dd73c3510f6bd9f569e101f60e5bf6a1614108.zip
LibWeb: Remove hand-rolled is_foo() helpers in Layout::Node classes
-rw-r--r--Libraries/LibWeb/DOM/Element.cpp3
-rw-r--r--Libraries/LibWeb/Dump.cpp6
-rw-r--r--Libraries/LibWeb/HTML/HTMLElement.cpp5
-rw-r--r--Libraries/LibWeb/Layout/BlockBox.cpp2
-rw-r--r--Libraries/LibWeb/Layout/BlockBox.h3
-rw-r--r--Libraries/LibWeb/Layout/BlockFormattingContext.cpp10
-rw-r--r--Libraries/LibWeb/Layout/Box.cpp2
-rw-r--r--Libraries/LibWeb/Layout/Box.h2
-rw-r--r--Libraries/LibWeb/Layout/BreakNode.h1
-rw-r--r--Libraries/LibWeb/Layout/ButtonBox.h1
-rw-r--r--Libraries/LibWeb/Layout/CanvasBox.h3
-rw-r--r--Libraries/LibWeb/Layout/CheckBox.h1
-rw-r--r--Libraries/LibWeb/Layout/FormattingContext.cpp7
-rw-r--r--Libraries/LibWeb/Layout/FrameBox.h1
-rw-r--r--Libraries/LibWeb/Layout/ImageBox.h2
-rw-r--r--Libraries/LibWeb/Layout/InitialContainingBlockBox.h2
-rw-r--r--Libraries/LibWeb/Layout/InlineFormattingContext.cpp2
-rw-r--r--Libraries/LibWeb/Layout/InlineNode.h3
-rw-r--r--Libraries/LibWeb/Layout/LineBoxFragment.cpp4
-rw-r--r--Libraries/LibWeb/Layout/ListItemBox.h2
-rw-r--r--Libraries/LibWeb/Layout/Node.cpp12
-rw-r--r--Libraries/LibWeb/Layout/Node.h20
-rw-r--r--Libraries/LibWeb/Layout/ReplacedBox.h2
-rw-r--r--Libraries/LibWeb/Layout/TableBox.h3
-rw-r--r--Libraries/LibWeb/Layout/TableCellBox.h1
-rw-r--r--Libraries/LibWeb/Layout/TableRowBox.h3
-rw-r--r--Libraries/LibWeb/Layout/TableRowGroupBox.h3
-rw-r--r--Libraries/LibWeb/Layout/TextNode.h2
-rw-r--r--Libraries/LibWeb/Layout/WidgetBox.h2
-rw-r--r--Libraries/LibWeb/LayoutTreeModel.cpp7
-rw-r--r--Libraries/LibWeb/Painting/StackingContext.cpp4
31 files changed, 39 insertions, 82 deletions
diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp
index 8c14451599..b7a128939d 100644
--- a/Libraries/LibWeb/DOM/Element.cpp
+++ b/Libraries/LibWeb/DOM/Element.cpp
@@ -44,6 +44,7 @@
#include <LibWeb/Layout/TableRowBox.h>
#include <LibWeb/Layout/TableRowGroupBox.h>
#include <LibWeb/Layout/TreeBuilder.h>
+#include <LibWeb/Layout/WidgetBox.h>
namespace Web::DOM {
@@ -213,7 +214,7 @@ void Element::recompute_style()
}
// Don't bother with style on widgets. NATIVE LOOK & FEEL BABY!
- if (layout_node()->is_widget())
+ if (is<Layout::WidgetBox>(layout_node()))
return;
auto diff = compute_style_difference(layout_node()->specified_style(), *style, document());
diff --git a/Libraries/LibWeb/Dump.cpp b/Libraries/LibWeb/Dump.cpp
index b82ec1243b..8256381b65 100644
--- a/Libraries/LibWeb/Dump.cpp
+++ b/Libraries/LibWeb/Dump.cpp
@@ -141,7 +141,7 @@ void dump_tree(StringBuilder& builder, const Layout::Node& layout_node, bool sho
color_off = "\033[0m";
}
- if (!layout_node.is_box()) {
+ if (!is<Layout::Box>(layout_node)) {
builder.appendff("{}{}{} <{}{}{}>",
nonbox_color_on,
layout_node.class_name(),
@@ -205,7 +205,7 @@ void dump_tree(StringBuilder& builder, const Layout::Node& layout_node, bool sho
builder.append("\n");
}
- if (layout_node.is_block() && static_cast<const Layout::BlockBox&>(layout_node).children_are_inline()) {
+ if (is<Layout::BlockBox>(layout_node) && static_cast<const Layout::BlockBox&>(layout_node).children_are_inline()) {
auto& block = static_cast<const Layout::BlockBox&>(layout_node);
for (size_t line_box_index = 0; line_box_index < block.line_boxes().size(); ++line_box_index) {
auto& line_box = block.line_boxes()[line_box_index];
@@ -231,7 +231,7 @@ void dump_tree(StringBuilder& builder, const Layout::Node& layout_node, bool sho
fragment.start(),
fragment.length(),
enclosing_int_rect(fragment.absolute_rect()).to_string());
- if (fragment.layout_node().is_text()) {
+ if (is<Layout::TextNode>(fragment.layout_node())) {
for (size_t i = 0; i < indent; ++i)
builder.append(" ");
auto& layout_text = static_cast<const Layout::TextNode&>(fragment.layout_node());
diff --git a/Libraries/LibWeb/HTML/HTMLElement.cpp b/Libraries/LibWeb/HTML/HTMLElement.cpp
index 317d4bc3ef..eb5356a594 100644
--- a/Libraries/LibWeb/HTML/HTMLElement.cpp
+++ b/Libraries/LibWeb/HTML/HTMLElement.cpp
@@ -28,6 +28,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLElement.h>
+#include <LibWeb/Layout/BreakNode.h>
#include <LibWeb/Layout/TextNode.h>
namespace Web::HTML {
@@ -119,9 +120,9 @@ String HTMLElement::inner_text()
Function<void(const Layout::Node&)> recurse = [&](auto& node) {
for (auto* child = node.first_child(); child; child = child->next_sibling()) {
- if (child->is_text())
+ if (is<Layout::TextNode>(child))
builder.append(downcast<Layout::TextNode>(*child).text_for_rendering());
- if (child->is_break())
+ if (is<Layout::BreakNode>(child))
builder.append('\n');
recurse(*child);
}
diff --git a/Libraries/LibWeb/Layout/BlockBox.cpp b/Libraries/LibWeb/Layout/BlockBox.cpp
index b01db3f579..b25a459886 100644
--- a/Libraries/LibWeb/Layout/BlockBox.cpp
+++ b/Libraries/LibWeb/Layout/BlockBox.cpp
@@ -94,7 +94,7 @@ HitTestResult BlockBox::hit_test(const Gfx::IntPoint& position, HitTestType type
if (is<Box>(fragment.layout_node()) && downcast<Box>(fragment.layout_node()).stacking_context())
continue;
if (enclosing_int_rect(fragment.absolute_rect()).contains(position)) {
- if (fragment.layout_node().is_block())
+ if (is<BlockBox>(fragment.layout_node()))
return downcast<BlockBox>(fragment.layout_node()).hit_test(position, type);
return { fragment.layout_node(), fragment.text_index_at(position.x()) };
}
diff --git a/Libraries/LibWeb/Layout/BlockBox.h b/Libraries/LibWeb/Layout/BlockBox.h
index 14fd57efcb..fb1b3ad4e5 100644
--- a/Libraries/LibWeb/Layout/BlockBox.h
+++ b/Libraries/LibWeb/Layout/BlockBox.h
@@ -51,9 +51,6 @@ public:
void for_each_fragment(Callback) const;
virtual void split_into_lines(InlineFormattingContext&, LayoutMode) override;
-
-private:
- virtual bool is_block() const override { return true; }
};
template<typename Callback>
diff --git a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
index 245efc6361..402a86f127 100644
--- a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
+++ b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
@@ -48,7 +48,7 @@ BlockFormattingContext::~BlockFormattingContext()
bool BlockFormattingContext::is_initial() const
{
- return context_box().is_initial_containing_block();
+ return is<InitialContainingBlockBox>(context_box());
}
void BlockFormattingContext::run(Box& box, LayoutMode layout_mode)
@@ -85,7 +85,7 @@ void BlockFormattingContext::run(Box& box, LayoutMode layout_mode)
void BlockFormattingContext::compute_width(Box& box)
{
- if (box.is_replaced()) {
+ if (is<ReplacedBox>(box)) {
// FIXME: This should not be done *by* ReplacedBox
auto& replaced = downcast<ReplacedBox>(box);
replaced.prepare_for_replaced_layout();
@@ -414,7 +414,7 @@ void BlockFormattingContext::compute_width_for_absolutely_positioned_block(Box&
void BlockFormattingContext::compute_height(Box& box)
{
- if (box.is_replaced()) {
+ if (is<ReplacedBox>(box)) {
compute_height_for_block_level_replaced_element_in_normal_flow(downcast<ReplacedBox>(box));
return;
}
@@ -471,9 +471,9 @@ void BlockFormattingContext::layout_block_level_children(Box& box, LayoutMode la
layout_inside(child_box, layout_mode);
compute_height(child_box);
- if (child_box.is_replaced())
+ if (is<ReplacedBox>(child_box))
place_block_level_replaced_element_in_normal_flow(child_box, box);
- else if (child_box.is_block())
+ else if (is<BlockBox>(child_box))
place_block_level_non_replaced_element_in_normal_flow(child_box, box);
// FIXME: This should be factored differently. It's uncool that we mutate the tree *during* layout!
diff --git a/Libraries/LibWeb/Layout/Box.cpp b/Libraries/LibWeb/Layout/Box.cpp
index 5a0c57accc..c7a0a868d0 100644
--- a/Libraries/LibWeb/Layout/Box.cpp
+++ b/Libraries/LibWeb/Layout/Box.cpp
@@ -165,7 +165,7 @@ void Box::set_containing_line_box_fragment(LineBoxFragment& fragment)
StackingContext* Box::enclosing_stacking_context()
{
for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
- if (!ancestor->is_box())
+ if (!is<Box>(ancestor))
continue;
auto& ancestor_box = downcast<Box>(*ancestor);
if (!ancestor_box.establishes_stacking_context())
diff --git a/Libraries/LibWeb/Layout/Box.h b/Libraries/LibWeb/Layout/Box.h
index 6c52072f40..a836761087 100644
--- a/Libraries/LibWeb/Layout/Box.h
+++ b/Libraries/LibWeb/Layout/Box.h
@@ -112,8 +112,6 @@ protected:
Vector<LineBox> m_line_boxes;
private:
- virtual bool is_box() const final { return true; }
-
Gfx::FloatPoint m_offset;
Gfx::FloatSize m_size;
diff --git a/Libraries/LibWeb/Layout/BreakNode.h b/Libraries/LibWeb/Layout/BreakNode.h
index 7ebe866b7a..58ebbe3322 100644
--- a/Libraries/LibWeb/Layout/BreakNode.h
+++ b/Libraries/LibWeb/Layout/BreakNode.h
@@ -39,7 +39,6 @@ public:
const HTML::HTMLBRElement& dom_node() const { return downcast<HTML::HTMLBRElement>(*Node::dom_node()); }
private:
- virtual bool is_break() const override { return true; }
virtual void split_into_lines(InlineFormattingContext&, LayoutMode) override;
};
diff --git a/Libraries/LibWeb/Layout/ButtonBox.h b/Libraries/LibWeb/Layout/ButtonBox.h
index a48342ad2b..f26c7ed8d8 100644
--- a/Libraries/LibWeb/Layout/ButtonBox.h
+++ b/Libraries/LibWeb/Layout/ButtonBox.h
@@ -43,7 +43,6 @@ public:
HTML::HTMLInputElement& dom_node() { return static_cast<HTML::HTMLInputElement&>(ReplacedBox::dom_node()); }
private:
- 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;
virtual void handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
diff --git a/Libraries/LibWeb/Layout/CanvasBox.h b/Libraries/LibWeb/Layout/CanvasBox.h
index 052f21aeab..150e28ae21 100644
--- a/Libraries/LibWeb/Layout/CanvasBox.h
+++ b/Libraries/LibWeb/Layout/CanvasBox.h
@@ -40,9 +40,6 @@ public:
virtual void paint(PaintContext&, PaintPhase) override;
const HTML::HTMLCanvasElement& dom_node() const { return static_cast<const HTML::HTMLCanvasElement&>(ReplacedBox::dom_node()); }
-
-private:
- virtual bool is_canvas() const override { return true; }
};
}
diff --git a/Libraries/LibWeb/Layout/CheckBox.h b/Libraries/LibWeb/Layout/CheckBox.h
index 7a97025383..47809c07f9 100644
--- a/Libraries/LibWeb/Layout/CheckBox.h
+++ b/Libraries/LibWeb/Layout/CheckBox.h
@@ -42,7 +42,6 @@ public:
HTML::HTMLInputElement& dom_node() { return static_cast<HTML::HTMLInputElement&>(ReplacedBox::dom_node()); }
private:
- 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;
virtual void handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
diff --git a/Libraries/LibWeb/Layout/FormattingContext.cpp b/Libraries/LibWeb/Layout/FormattingContext.cpp
index 8256ceccc3..c6f565aa27 100644
--- a/Libraries/LibWeb/Layout/FormattingContext.cpp
+++ b/Libraries/LibWeb/Layout/FormattingContext.cpp
@@ -31,7 +31,10 @@
#include <LibWeb/Layout/FormattingContext.h>
#include <LibWeb/Layout/InlineFormattingContext.h>
#include <LibWeb/Layout/ReplacedBox.h>
+#include <LibWeb/Layout/TableBox.h>
+#include <LibWeb/Layout/TableCellBox.h>
#include <LibWeb/Layout/TableFormattingContext.h>
+#include <LibWeb/Layout/TableRowBox.h>
namespace Web::Layout {
@@ -55,7 +58,7 @@ bool FormattingContext::creates_block_formatting_context(const Box& box)
return true;
if (box.is_inline_block())
return true;
- if (box.is_table_cell())
+ if (is<TableCellBox>(box))
return true;
// FIXME: table-caption
// FIXME: anonymous table cells
@@ -76,7 +79,7 @@ void FormattingContext::layout_inside(Box& box, LayoutMode layout_mode)
context.run(box, layout_mode);
return;
}
- if (box.is_table()) {
+ if (is<TableBox>(box)) {
TableFormattingContext context(box, this);
context.run(box, layout_mode);
} else if (box.children_are_inline()) {
diff --git a/Libraries/LibWeb/Layout/FrameBox.h b/Libraries/LibWeb/Layout/FrameBox.h
index 7c2d9db529..93a5216f3f 100644
--- a/Libraries/LibWeb/Layout/FrameBox.h
+++ b/Libraries/LibWeb/Layout/FrameBox.h
@@ -43,7 +43,6 @@ public:
HTML::HTMLIFrameElement& dom_node() { return downcast<HTML::HTMLIFrameElement>(ReplacedBox::dom_node()); }
private:
- virtual bool is_frame() const final { return true; }
virtual void did_set_rect() override;
};
diff --git a/Libraries/LibWeb/Layout/ImageBox.h b/Libraries/LibWeb/Layout/ImageBox.h
index 46c56bdf4f..a404ca1ca0 100644
--- a/Libraries/LibWeb/Layout/ImageBox.h
+++ b/Libraries/LibWeb/Layout/ImageBox.h
@@ -46,8 +46,6 @@ public:
void set_visible_in_viewport(Badge<InitialContainingBlockBox>, bool);
private:
- virtual bool is_image() const override { return true; }
-
int preferred_width() const;
int preferred_height() const;
diff --git a/Libraries/LibWeb/Layout/InitialContainingBlockBox.h b/Libraries/LibWeb/Layout/InitialContainingBlockBox.h
index 1e74cefd55..b7b4810364 100644
--- a/Libraries/LibWeb/Layout/InitialContainingBlockBox.h
+++ b/Libraries/LibWeb/Layout/InitialContainingBlockBox.h
@@ -49,8 +49,6 @@ public:
void did_set_viewport_rect(Badge<Frame>, const Gfx::IntRect&);
- virtual bool is_initial_containing_block() const override { return true; }
-
void build_stacking_context_tree();
void recompute_selection_states();
diff --git a/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
index b8d0b6cee0..74b2b6ad06 100644
--- a/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
+++ b/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
@@ -199,7 +199,7 @@ void InlineFormattingContext::run(Box&, LayoutMode layout_mode)
void InlineFormattingContext::dimension_box_on_line(Box& box, LayoutMode layout_mode)
{
- if (box.is_replaced()) {
+ if (is<ReplacedBox>(box)) {
auto& replaced = downcast<ReplacedBox>(box);
replaced.set_width(compute_width_for_replaced_element(replaced));
replaced.set_height(compute_height_for_replaced_element(replaced));
diff --git a/Libraries/LibWeb/Layout/InlineNode.h b/Libraries/LibWeb/Layout/InlineNode.h
index f35a50330a..8f47b24f34 100644
--- a/Libraries/LibWeb/Layout/InlineNode.h
+++ b/Libraries/LibWeb/Layout/InlineNode.h
@@ -38,9 +38,6 @@ public:
virtual void paint_fragment(PaintContext&, const LineBoxFragment&, PaintPhase) const override;
virtual void split_into_lines(InlineFormattingContext&, LayoutMode) override;
-
-private:
- virtual bool is_inline_node() const final { return true; }
};
}
diff --git a/Libraries/LibWeb/Layout/LineBoxFragment.cpp b/Libraries/LibWeb/Layout/LineBoxFragment.cpp
index e6a6cfeeda..106f9d18d2 100644
--- a/Libraries/LibWeb/Layout/LineBoxFragment.cpp
+++ b/Libraries/LibWeb/Layout/LineBoxFragment.cpp
@@ -75,7 +75,7 @@ const Gfx::FloatRect LineBoxFragment::absolute_rect() const
int LineBoxFragment::text_index_at(float x) const
{
- if (!layout_node().is_text())
+ if (!is<TextNode>(layout_node()))
return 0;
auto& layout_text = downcast<TextNode>(layout_node());
auto& font = layout_text.specified_style().font();
@@ -108,7 +108,7 @@ Gfx::FloatRect LineBoxFragment::selection_rect(const Gfx::Font& font) const
auto selection = layout_node().root().selection().normalized();
if (!selection.is_valid())
return {};
- if (!layout_node().is_text())
+ if (!is<TextNode>(layout_node()))
return {};
const auto start_index = m_start;
diff --git a/Libraries/LibWeb/Layout/ListItemBox.h b/Libraries/LibWeb/Layout/ListItemBox.h
index adf5e63b0f..39b5af84e3 100644
--- a/Libraries/LibWeb/Layout/ListItemBox.h
+++ b/Libraries/LibWeb/Layout/ListItemBox.h
@@ -41,8 +41,6 @@ public:
void layout_marker();
private:
- virtual bool is_list_item() const override { return true; }
-
RefPtr<ListItemMarkerBox> m_marker;
};
diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cpp
index 4376e3bb36..a85ce22f92 100644
--- a/Libraries/LibWeb/Layout/Node.cpp
+++ b/Libraries/LibWeb/Layout/Node.cpp
@@ -35,6 +35,7 @@
#include <LibWeb/Layout/InitialContainingBlockBox.h>
#include <LibWeb/Layout/Node.h>
#include <LibWeb/Layout/ReplacedBox.h>
+#include <LibWeb/Layout/TextNode.h>
#include <LibWeb/Page/Frame.h>
#include <typeinfo>
@@ -56,7 +57,7 @@ Node::~Node()
bool Node::can_contain_boxes_with_position_absolute() const
{
- return style().position() != CSS::Position::Static || is_initial_containing_block();
+ return style().position() != CSS::Position::Static || is<InitialContainingBlockBox>(*this);
}
const BlockBox* Node::containing_block() const
@@ -68,7 +69,7 @@ const BlockBox* Node::containing_block() const
return downcast<BlockBox>(ancestor);
};
- if (is_text())
+ if (is<TextNode>(*this))
return nearest_block_ancestor();
auto position = style().position();
@@ -165,7 +166,7 @@ float Node::font_size() const
Gfx::FloatPoint Node::box_type_agnostic_position() const
{
- if (is_box())
+ if (is<Box>(*this))
return downcast<Box>(*this).absolute_position();
ASSERT(is_inline());
Gfx::FloatPoint position;
@@ -303,4 +304,9 @@ String Node::class_name() const
return demangle(typeid(*this).name());
}
+bool Node::is_inline_block() const
+{
+ return is_inline() && is<BlockBox>(*this);
+}
+
}
diff --git a/Libraries/LibWeb/Layout/Node.h b/Libraries/LibWeb/Layout/Node.h
index 4ae2da141a..4af3761713 100644
--- a/Libraries/LibWeb/Layout/Node.h
+++ b/Libraries/LibWeb/Layout/Node.h
@@ -95,24 +95,6 @@ public:
String 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; }
- virtual bool is_replaced() const { return false; }
- virtual bool is_widget() const { return false; }
- virtual bool is_frame() const { return false; }
- virtual bool is_image() const { return false; }
- virtual bool is_canvas() const { return false; }
- virtual bool is_box() const { return false; }
- virtual bool is_table() const { return false; }
- virtual bool is_table_row() const { return false; }
- virtual bool is_table_cell() const { return false; }
- virtual bool is_table_row_group() const { return false; }
- virtual bool is_break() const { return false; }
- virtual bool is_check_box() const { return false; }
- virtual bool is_button() const { return false; }
- virtual bool is_list_item() const { return false; }
- virtual bool is_inline_node() const { return false; }
bool has_style() const { return m_has_style; }
virtual bool can_have_children() const { return true; }
@@ -120,7 +102,7 @@ public:
bool is_inline() const { return m_inline; }
void set_inline(bool b) { m_inline = b; }
- bool is_inline_block() const { return is_inline() && is_block(); }
+ bool is_inline_block() const;
virtual bool wants_mouse_events() const { return false; }
diff --git a/Libraries/LibWeb/Layout/ReplacedBox.h b/Libraries/LibWeb/Layout/ReplacedBox.h
index e7f1ece198..f1da91a197 100644
--- a/Libraries/LibWeb/Layout/ReplacedBox.h
+++ b/Libraries/LibWeb/Layout/ReplacedBox.h
@@ -39,8 +39,6 @@ public:
const DOM::Element& dom_node() const { return downcast<DOM::Element>(*Node::dom_node()); }
DOM::Element& dom_node() { return downcast<DOM::Element>(*Node::dom_node()); }
- virtual bool is_replaced() const final { return true; }
-
bool has_intrinsic_width() const { return m_has_intrinsic_width; }
bool has_intrinsic_height() const { return m_has_intrinsic_height; }
bool has_intrinsic_ratio() const { return m_has_intrinsic_ratio; }
diff --git a/Libraries/LibWeb/Layout/TableBox.h b/Libraries/LibWeb/Layout/TableBox.h
index 93bdb18a60..0c34c6a61c 100644
--- a/Libraries/LibWeb/Layout/TableBox.h
+++ b/Libraries/LibWeb/Layout/TableBox.h
@@ -34,9 +34,6 @@ class TableBox final : public Layout::BlockBox {
public:
TableBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~TableBox() override;
-
-private:
- virtual bool is_table() const override { return true; }
};
}
diff --git a/Libraries/LibWeb/Layout/TableCellBox.h b/Libraries/LibWeb/Layout/TableCellBox.h
index ce5d72a2d0..b1a8bb0160 100644
--- a/Libraries/LibWeb/Layout/TableCellBox.h
+++ b/Libraries/LibWeb/Layout/TableCellBox.h
@@ -41,7 +41,6 @@ public:
size_t colspan() const;
private:
- virtual bool is_table_cell() const override { return true; }
virtual float width_of_logical_containing_block() const override;
};
diff --git a/Libraries/LibWeb/Layout/TableRowBox.h b/Libraries/LibWeb/Layout/TableRowBox.h
index 154947701d..0a63f44efc 100644
--- a/Libraries/LibWeb/Layout/TableRowBox.h
+++ b/Libraries/LibWeb/Layout/TableRowBox.h
@@ -34,9 +34,6 @@ class TableRowBox final : public Box {
public:
TableRowBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~TableRowBox() override;
-
-private:
- virtual bool is_table_row() const override { return true; }
};
}
diff --git a/Libraries/LibWeb/Layout/TableRowGroupBox.h b/Libraries/LibWeb/Layout/TableRowGroupBox.h
index f1781466b8..6a9fd6956c 100644
--- a/Libraries/LibWeb/Layout/TableRowGroupBox.h
+++ b/Libraries/LibWeb/Layout/TableRowGroupBox.h
@@ -36,9 +36,6 @@ public:
virtual ~TableRowGroupBox() override;
size_t column_count() const;
-
-private:
- virtual bool is_table_row_group() const override { return true; }
};
}
diff --git a/Libraries/LibWeb/Layout/TextNode.h b/Libraries/LibWeb/Layout/TextNode.h
index 5e0ac342ba..85189a77b4 100644
--- a/Libraries/LibWeb/Layout/TextNode.h
+++ b/Libraries/LibWeb/Layout/TextNode.h
@@ -43,8 +43,6 @@ public:
const String& text_for_style(const CSS::StyleProperties&) const;
const String& text_for_rendering() const { return m_text_for_rendering; }
- virtual bool is_text() const final { return true; }
-
virtual void paint_fragment(PaintContext&, const LineBoxFragment&, PaintPhase) const override;
virtual void split_into_lines(InlineFormattingContext&, LayoutMode) override;
diff --git a/Libraries/LibWeb/Layout/WidgetBox.h b/Libraries/LibWeb/Layout/WidgetBox.h
index 24778e0f01..8c7445a1fc 100644
--- a/Libraries/LibWeb/Layout/WidgetBox.h
+++ b/Libraries/LibWeb/Layout/WidgetBox.h
@@ -38,8 +38,6 @@ public:
GUI::Widget& widget() { return m_widget; }
const GUI::Widget& widget() const { return m_widget; }
- virtual bool is_widget() const final { return true; }
-
void update_widget();
private:
diff --git a/Libraries/LibWeb/LayoutTreeModel.cpp b/Libraries/LibWeb/LayoutTreeModel.cpp
index 3bcb6f3552..02d3850509 100644
--- a/Libraries/LibWeb/LayoutTreeModel.cpp
+++ b/Libraries/LibWeb/LayoutTreeModel.cpp
@@ -29,6 +29,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/Text.h>
+#include <LibWeb/Layout/InitialContainingBlockBox.h>
#include <LibWeb/Layout/TextNode.h>
#include <ctype.h>
#include <stdio.h>
@@ -119,14 +120,14 @@ GUI::Variant LayoutTreeModel::data(const GUI::ModelIndex& index, GUI::ModelRole
{
auto& node = *static_cast<Layout::Node*>(index.internal_data());
if (role == GUI::ModelRole::Icon) {
- if (node.is_initial_containing_block())
+ if (is<Layout::InitialContainingBlockBox>(node))
return m_document_icon;
- if (node.is_text())
+ if (is<Layout::TextNode>(node))
return m_text_icon;
return m_element_icon;
}
if (role == GUI::ModelRole::Display) {
- if (node.is_text())
+ if (is<Layout::TextNode>(node))
return String::format("TextNode: %s", with_whitespace_collapsed(downcast<Layout::TextNode>(node).text_for_rendering()).characters());
StringBuilder builder;
builder.append(node.class_name());
diff --git a/Libraries/LibWeb/Painting/StackingContext.cpp b/Libraries/LibWeb/Painting/StackingContext.cpp
index fe24a4c642..e07d640613 100644
--- a/Libraries/LibWeb/Painting/StackingContext.cpp
+++ b/Libraries/LibWeb/Painting/StackingContext.cpp
@@ -50,7 +50,7 @@ StackingContext::StackingContext(Box& box, StackingContext* parent)
void StackingContext::paint(PaintContext& context, PaintPhase phase)
{
- if (!m_box.is_initial_containing_block()) {
+ if (!is<InitialContainingBlockBox>(m_box)) {
m_box.paint(context, phase);
} else {
// NOTE: InitialContainingBlockBox::paint() merely calls StackingContext::paint()
@@ -65,7 +65,7 @@ void StackingContext::paint(PaintContext& context, PaintPhase phase)
HitTestResult StackingContext::hit_test(const Gfx::IntPoint& position, HitTestType type) const
{
HitTestResult result;
- if (!m_box.is_initial_containing_block()) {
+ if (!is<InitialContainingBlockBox>(m_box)) {
result = m_box.hit_test(position, type);
} else {
// NOTE: InitialContainingBlockBox::hit_test() merely calls StackingContext::hit_test()