summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout')
-rw-r--r--Userland/Libraries/LibWeb/Layout/BlockBox.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Layout/BlockBox.h8
-rw-r--r--Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp12
-rw-r--r--Userland/Libraries/LibWeb/Layout/Box.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Layout/BreakNode.h2
-rw-r--r--Userland/Libraries/LibWeb/Layout/FormattingContext.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Layout/FrameBox.h4
-rw-r--r--Userland/Libraries/LibWeb/Layout/ImageBox.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp6
-rw-r--r--Userland/Libraries/LibWeb/Layout/LineBox.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Layout/Node.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/Node.h4
-rw-r--r--Userland/Libraries/LibWeb/Layout/ReplacedBox.h4
-rw-r--r--Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/SVGPathBox.h2
-rw-r--r--Userland/Libraries/LibWeb/Layout/SVGSVGBox.h2
-rw-r--r--Userland/Libraries/LibWeb/Layout/TableCellBox.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/TextNode.cpp6
-rw-r--r--Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp8
20 files changed, 43 insertions, 43 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/BlockBox.cpp b/Userland/Libraries/LibWeb/Layout/BlockBox.cpp
index 6682dbb8de..5867331aaa 100644
--- a/Userland/Libraries/LibWeb/Layout/BlockBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/BlockBox.cpp
@@ -88,11 +88,11 @@ HitTestResult BlockBox::hit_test(const Gfx::IntPoint& position, HitTestType type
HitTestResult last_good_candidate;
for (auto& line_box : m_line_boxes) {
for (auto& fragment : line_box.fragments()) {
- if (is<Box>(fragment.layout_node()) && downcast<Box>(fragment.layout_node()).stacking_context())
+ if (is<Box>(fragment.layout_node()) && verify_cast<Box>(fragment.layout_node()).stacking_context())
continue;
if (enclosing_int_rect(fragment.absolute_rect()).contains(position)) {
if (is<BlockBox>(fragment.layout_node()))
- return downcast<BlockBox>(fragment.layout_node()).hit_test(position, type);
+ return verify_cast<BlockBox>(fragment.layout_node()).hit_test(position, type);
return { fragment.layout_node(), fragment.text_index_at(position.x()) };
}
if (fragment.absolute_rect().top() <= position.y())
diff --git a/Userland/Libraries/LibWeb/Layout/BlockBox.h b/Userland/Libraries/LibWeb/Layout/BlockBox.h
index 4833d80519..edb70e8097 100644
--- a/Userland/Libraries/LibWeb/Layout/BlockBox.h
+++ b/Userland/Libraries/LibWeb/Layout/BlockBox.h
@@ -21,10 +21,10 @@ public:
virtual HitTestResult hit_test(const Gfx::IntPoint&, HitTestType) const override;
- BlockBox* previous_sibling() { return downcast<BlockBox>(Node::previous_sibling()); }
- const BlockBox* previous_sibling() const { return downcast<BlockBox>(Node::previous_sibling()); }
- BlockBox* next_sibling() { return downcast<BlockBox>(Node::next_sibling()); }
- const BlockBox* next_sibling() const { return downcast<BlockBox>(Node::next_sibling()); }
+ BlockBox* previous_sibling() { return verify_cast<BlockBox>(Node::previous_sibling()); }
+ const BlockBox* previous_sibling() const { return verify_cast<BlockBox>(Node::previous_sibling()); }
+ BlockBox* next_sibling() { return verify_cast<BlockBox>(Node::next_sibling()); }
+ const BlockBox* next_sibling() const { return verify_cast<BlockBox>(Node::next_sibling()); }
template<typename Callback>
void for_each_fragment(Callback);
diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
index f262a121a3..9e7a0f27e0 100644
--- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
@@ -72,7 +72,7 @@ void BlockFormattingContext::compute_width(Box& box)
if (is<ReplacedBox>(box)) {
// FIXME: This should not be done *by* ReplacedBox
- auto& replaced = downcast<ReplacedBox>(box);
+ auto& replaced = verify_cast<ReplacedBox>(box);
replaced.prepare_for_replaced_layout();
compute_width_for_block_level_replaced_element_in_normal_flow(replaced);
return;
@@ -304,7 +304,7 @@ float BlockFormattingContext::compute_theoretical_height(const Box& box)
// Then work out what the height is, based on box type and CSS properties.
float height = 0;
if (is<ReplacedBox>(box)) {
- height = compute_height_for_replaced_element(downcast<ReplacedBox>(box));
+ height = compute_height_for_replaced_element(verify_cast<ReplacedBox>(box));
} else {
if (box.computed_values().height().is_undefined_or_auto()
|| (computed_values.height().is_percentage() && !containing_block.computed_values().height().is_absolute())) {
@@ -410,10 +410,10 @@ void BlockFormattingContext::layout_block_level_children(Box& box, LayoutMode la
// FIXME: This should be factored differently. It's uncool that we mutate the tree *during* layout!
// Instead, we should generate the marker box during the tree build.
if (is<ListItemBox>(child_box))
- downcast<ListItemBox>(child_box).layout_marker();
+ verify_cast<ListItemBox>(child_box).layout_marker();
content_height = max(content_height, child_box.effective_offset().y() + child_box.height() + child_box.box_model().margin_box().bottom);
- content_width = max(content_width, downcast<Box>(child_box).width());
+ content_width = max(content_width, verify_cast<Box>(child_box).width());
return IterationDecision::Continue;
});
@@ -526,7 +526,7 @@ void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_m
{
auto viewport_rect = context_box().browsing_context().viewport_rect();
- auto& icb = downcast<Layout::InitialContainingBlockBox>(context_box());
+ auto& icb = verify_cast<Layout::InitialContainingBlockBox>(context_box());
icb.build_stacking_context_tree();
icb.set_width(viewport_rect.width());
@@ -551,7 +551,7 @@ static Gfx::FloatRect rect_in_coordinate_space(const Box& box, const Box& contex
Gfx::FloatRect rect = box.margin_box_as_relative_rect();
for (auto* ancestor = box.parent(); ancestor; ancestor = ancestor->parent()) {
if (is<Box>(*ancestor)) {
- auto offset = downcast<Box>(*ancestor).effective_offset();
+ auto offset = verify_cast<Box>(*ancestor).effective_offset();
rect.translate_by(offset);
}
if (ancestor == &context_box)
diff --git a/Userland/Libraries/LibWeb/Layout/Box.cpp b/Userland/Libraries/LibWeb/Layout/Box.cpp
index 398ffb4909..206746f161 100644
--- a/Userland/Libraries/LibWeb/Layout/Box.cpp
+++ b/Userland/Libraries/LibWeb/Layout/Box.cpp
@@ -50,7 +50,7 @@ void Box::paint(PaintContext& context, PaintPhase phase)
context.painter().draw_rect(enclosing_int_rect(content_rect), Color::Magenta);
}
- if (phase == PaintPhase::FocusOutline && dom_node() && dom_node()->is_element() && downcast<DOM::Element>(*dom_node()).is_focused()) {
+ if (phase == PaintPhase::FocusOutline && dom_node() && dom_node()->is_element() && verify_cast<DOM::Element>(*dom_node()).is_focused()) {
context.painter().draw_rect(enclosing_int_rect(absolute_rect()), context.palette().focus_outline());
}
}
@@ -347,7 +347,7 @@ StackingContext* Box::enclosing_stacking_context()
for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
if (!is<Box>(ancestor))
continue;
- auto& ancestor_box = downcast<Box>(*ancestor);
+ auto& ancestor_box = verify_cast<Box>(*ancestor);
if (!ancestor_box.establishes_stacking_context())
continue;
VERIFY(ancestor_box.stacking_context());
diff --git a/Userland/Libraries/LibWeb/Layout/BreakNode.h b/Userland/Libraries/LibWeb/Layout/BreakNode.h
index 8e5d52c64c..873f55ae30 100644
--- a/Userland/Libraries/LibWeb/Layout/BreakNode.h
+++ b/Userland/Libraries/LibWeb/Layout/BreakNode.h
@@ -16,7 +16,7 @@ public:
BreakNode(DOM::Document&, HTML::HTMLBRElement&);
virtual ~BreakNode() override;
- const HTML::HTMLBRElement& dom_node() const { return downcast<HTML::HTMLBRElement>(*Node::dom_node()); }
+ const HTML::HTMLBRElement& dom_node() const { return verify_cast<HTML::HTMLBRElement>(*Node::dom_node()); }
private:
virtual void split_into_lines(InlineFormattingContext&, LayoutMode) override;
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
index e701e0d692..824d7c049c 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
@@ -254,7 +254,7 @@ float FormattingContext::tentative_width_for_replaced_element(const ReplacedBox&
void FormattingContext::compute_width_for_absolutely_positioned_element(Box& box)
{
if (is<ReplacedBox>(box))
- compute_width_for_absolutely_positioned_replaced_element(downcast<ReplacedBox>(box));
+ compute_width_for_absolutely_positioned_replaced_element(verify_cast<ReplacedBox>(box));
else
compute_width_for_absolutely_positioned_non_replaced_element(box);
}
@@ -262,7 +262,7 @@ void FormattingContext::compute_width_for_absolutely_positioned_element(Box& box
void FormattingContext::compute_height_for_absolutely_positioned_element(Box& box)
{
if (is<ReplacedBox>(box))
- compute_height_for_absolutely_positioned_replaced_element(downcast<ReplacedBox>(box));
+ compute_height_for_absolutely_positioned_replaced_element(verify_cast<ReplacedBox>(box));
else
compute_height_for_absolutely_positioned_non_replaced_element(box);
}
diff --git a/Userland/Libraries/LibWeb/Layout/FrameBox.h b/Userland/Libraries/LibWeb/Layout/FrameBox.h
index 8646663550..d055bd07a1 100644
--- a/Userland/Libraries/LibWeb/Layout/FrameBox.h
+++ b/Userland/Libraries/LibWeb/Layout/FrameBox.h
@@ -19,8 +19,8 @@ public:
virtual void paint(PaintContext&, PaintPhase) override;
virtual void prepare_for_replaced_layout() override;
- const HTML::HTMLIFrameElement& dom_node() const { return downcast<HTML::HTMLIFrameElement>(ReplacedBox::dom_node()); }
- HTML::HTMLIFrameElement& dom_node() { return downcast<HTML::HTMLIFrameElement>(ReplacedBox::dom_node()); }
+ const HTML::HTMLIFrameElement& dom_node() const { return verify_cast<HTML::HTMLIFrameElement>(ReplacedBox::dom_node()); }
+ HTML::HTMLIFrameElement& dom_node() { return verify_cast<HTML::HTMLIFrameElement>(ReplacedBox::dom_node()); }
private:
virtual void did_set_rect() override;
diff --git a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp
index c1b0065002..dfb5bac7d8 100644
--- a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp
@@ -60,7 +60,7 @@ void ImageBox::prepare_for_replaced_layout()
}
if (renders_as_alt_text()) {
- auto& image_element = downcast<HTML::HTMLImageElement>(dom_node());
+ auto& image_element = verify_cast<HTML::HTMLImageElement>(dom_node());
auto& font = Gfx::FontDatabase::default_font();
auto alt = image_element.alt();
if (alt.is_empty())
@@ -88,7 +88,7 @@ void ImageBox::paint(PaintContext& context, PaintPhase phase)
if (phase == PaintPhase::Foreground) {
if (renders_as_alt_text()) {
- auto& image_element = downcast<HTML::HTMLImageElement>(dom_node());
+ auto& image_element = verify_cast<HTML::HTMLImageElement>(dom_node());
context.painter().set_font(Gfx::FontDatabase::default_font());
Gfx::StylePainter::paint_frame(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2);
auto alt = image_element.alt();
diff --git a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
index 535541a97a..99669b26aa 100644
--- a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
@@ -75,7 +75,7 @@ void InlineFormattingContext::run(Box&, LayoutMode layout_mode)
containing_block().for_each_child([&](auto& child) {
VERIFY(child.is_inline());
if (is<Box>(child) && child.is_absolutely_positioned()) {
- layout_absolutely_positioned_element(downcast<Box>(child));
+ layout_absolutely_positioned_element(verify_cast<Box>(child));
return;
}
@@ -181,14 +181,14 @@ void InlineFormattingContext::run(Box&, LayoutMode layout_mode)
void InlineFormattingContext::dimension_box_on_line(Box& box, LayoutMode layout_mode)
{
if (is<ReplacedBox>(box)) {
- auto& replaced = downcast<ReplacedBox>(box);
+ auto& replaced = verify_cast<ReplacedBox>(box);
replaced.set_width(compute_width_for_replaced_element(replaced));
replaced.set_height(compute_height_for_replaced_element(replaced));
return;
}
if (box.is_inline_block()) {
- auto& inline_block = const_cast<BlockBox&>(downcast<BlockBox>(box));
+ auto& inline_block = const_cast<BlockBox&>(verify_cast<BlockBox>(box));
if (inline_block.computed_values().width().is_undefined_or_auto()) {
auto result = calculate_shrink_to_fit_widths(inline_block);
diff --git a/Userland/Libraries/LibWeb/Layout/LineBox.cpp b/Userland/Libraries/LibWeb/Layout/LineBox.cpp
index 7d27d693f3..5f2a342dd9 100644
--- a/Userland/Libraries/LibWeb/Layout/LineBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/LineBox.cpp
@@ -27,7 +27,7 @@ void LineBox::add_fragment(Node& layout_node, int start, int length, float width
m_width += width;
if (is<Box>(layout_node))
- downcast<Box>(layout_node).set_containing_line_box_fragment(m_fragments.last());
+ verify_cast<Box>(layout_node).set_containing_line_box_fragment(m_fragments.last());
}
void LineBox::trim_trailing_whitespace()
diff --git a/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp b/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp
index 856e5849a0..325529e12e 100644
--- a/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp
+++ b/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp
@@ -41,7 +41,7 @@ StringView LineBoxFragment::text() const
{
if (!is<TextNode>(layout_node()))
return {};
- return downcast<TextNode>(layout_node()).text_for_rendering().substring_view(m_start, m_length);
+ return verify_cast<TextNode>(layout_node()).text_for_rendering().substring_view(m_start, m_length);
}
const Gfx::FloatRect LineBoxFragment::absolute_rect() const
@@ -56,7 +56,7 @@ int LineBoxFragment::text_index_at(float x) const
{
if (!is<TextNode>(layout_node()))
return 0;
- auto& layout_text = downcast<TextNode>(layout_node());
+ auto& layout_text = verify_cast<TextNode>(layout_node());
auto& font = layout_text.font();
Utf8View view(text());
diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp
index 3b167b6ba1..cbd3de1d43 100644
--- a/Userland/Libraries/LibWeb/Layout/Node.cpp
+++ b/Userland/Libraries/LibWeb/Layout/Node.cpp
@@ -150,7 +150,7 @@ void Node::set_needs_display()
Gfx::FloatPoint Node::box_type_agnostic_position() const
{
if (is<Box>(*this))
- return downcast<Box>(*this).absolute_position();
+ return verify_cast<Box>(*this).absolute_position();
VERIFY(is_inline());
Gfx::FloatPoint position;
if (auto* block = containing_block()) {
diff --git a/Userland/Libraries/LibWeb/Layout/Node.h b/Userland/Libraries/LibWeb/Layout/Node.h
index ebd2405ea4..0dc6edeb7d 100644
--- a/Userland/Libraries/LibWeb/Layout/Node.h
+++ b/Userland/Libraries/LibWeb/Layout/Node.h
@@ -158,13 +158,13 @@ public:
void for_each_child_in_paint_order(Callback callback) const
{
for_each_child([&](auto& child) {
- if (is<Box>(child) && downcast<Box>(child).stacking_context())
+ if (is<Box>(child) && verify_cast<Box>(child).stacking_context())
return;
if (!child.is_positioned())
callback(child);
});
for_each_child([&](auto& child) {
- if (is<Box>(child) && downcast<Box>(child).stacking_context())
+ if (is<Box>(child) && verify_cast<Box>(child).stacking_context())
return;
if (child.is_positioned())
callback(child);
diff --git a/Userland/Libraries/LibWeb/Layout/ReplacedBox.h b/Userland/Libraries/LibWeb/Layout/ReplacedBox.h
index 39e723c4f5..0cd01808fb 100644
--- a/Userland/Libraries/LibWeb/Layout/ReplacedBox.h
+++ b/Userland/Libraries/LibWeb/Layout/ReplacedBox.h
@@ -16,8 +16,8 @@ public:
ReplacedBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~ReplacedBox() override;
- const DOM::Element& dom_node() const { return downcast<DOM::Element>(*Node::dom_node()); }
- DOM::Element& dom_node() { return downcast<DOM::Element>(*Node::dom_node()); }
+ const DOM::Element& dom_node() const { return verify_cast<DOM::Element>(*Node::dom_node()); }
+ DOM::Element& dom_node() { return verify_cast<DOM::Element>(*Node::dom_node()); }
bool has_intrinsic_width() const { return m_has_intrinsic_width; }
bool has_intrinsic_height() const { return m_has_intrinsic_height; }
diff --git a/Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp
index c00b28286d..3126330793 100644
--- a/Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp
@@ -19,7 +19,7 @@ void SVGGraphicsBox::before_children_paint(PaintContext& context, PaintPhase pha
if (phase != PaintPhase::Foreground)
return;
- auto& graphics_element = downcast<SVG::SVGGraphicsElement>(dom_node());
+ auto& graphics_element = verify_cast<SVG::SVGGraphicsElement>(dom_node());
if (graphics_element.fill_color().has_value())
context.svg_context().set_fill_color(graphics_element.fill_color().value());
diff --git a/Userland/Libraries/LibWeb/Layout/SVGPathBox.h b/Userland/Libraries/LibWeb/Layout/SVGPathBox.h
index 449971bbe7..3060238cb9 100644
--- a/Userland/Libraries/LibWeb/Layout/SVGPathBox.h
+++ b/Userland/Libraries/LibWeb/Layout/SVGPathBox.h
@@ -16,7 +16,7 @@ public:
SVGPathBox(DOM::Document&, SVG::SVGPathElement&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~SVGPathBox() override = default;
- SVG::SVGPathElement& dom_node() { return downcast<SVG::SVGPathElement>(SVGGraphicsBox::dom_node()); }
+ SVG::SVGPathElement& dom_node() { return verify_cast<SVG::SVGPathElement>(SVGGraphicsBox::dom_node()); }
virtual void prepare_for_replaced_layout() override;
virtual void paint(PaintContext& context, PaintPhase phase) override;
diff --git a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.h b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.h
index ad4cbdafdd..241a7d3405 100644
--- a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.h
+++ b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.h
@@ -16,7 +16,7 @@ public:
SVGSVGBox(DOM::Document&, SVG::SVGSVGElement&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~SVGSVGBox() override = default;
- SVG::SVGSVGElement& dom_node() { return downcast<SVG::SVGSVGElement>(SVGGraphicsBox::dom_node()); }
+ SVG::SVGSVGElement& dom_node() { return verify_cast<SVG::SVGSVGElement>(SVGGraphicsBox::dom_node()); }
virtual void prepare_for_replaced_layout() override;
diff --git a/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp b/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp
index 4ded320186..761253794a 100644
--- a/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp
@@ -28,7 +28,7 @@ size_t TableCellBox::colspan() const
{
if (!dom_node())
return 1;
- return downcast<DOM::Element>(*dom_node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1);
+ return verify_cast<DOM::Element>(*dom_node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1);
}
float TableCellBox::width_of_logical_containing_block() const
diff --git a/Userland/Libraries/LibWeb/Layout/TextNode.cpp b/Userland/Libraries/LibWeb/Layout/TextNode.cpp
index e03097e0d9..a9dfd44669 100644
--- a/Userland/Libraries/LibWeb/Layout/TextNode.cpp
+++ b/Userland/Libraries/LibWeb/Layout/TextNode.cpp
@@ -261,7 +261,7 @@ void TextNode::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint& positi
{
if (!parent() || !is<Label>(*parent()))
return;
- downcast<Label>(*parent()).handle_mousedown_on_label({}, position, button);
+ verify_cast<Label>(*parent()).handle_mousedown_on_label({}, position, button);
browsing_context().event_handler().set_mouse_event_tracking_layout_node(this);
}
@@ -273,7 +273,7 @@ void TextNode::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position
// NOTE: Changing the state of the DOM node may run arbitrary JS, which could disappear this node.
NonnullRefPtr protect = *this;
- downcast<Label>(*parent()).handle_mouseup_on_label({}, position, button);
+ verify_cast<Label>(*parent()).handle_mouseup_on_label({}, position, button);
browsing_context().event_handler().set_mouse_event_tracking_layout_node(nullptr);
}
@@ -281,7 +281,7 @@ void TextNode::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& positi
{
if (!parent() || !is<Label>(*parent()))
return;
- downcast<Label>(*parent()).handle_mousemove_on_label({}, position, button);
+ verify_cast<Label>(*parent()).handle_mousemove_on_label({}, position, button);
}
TextNode::ChunkIterator::ChunkIterator(StringView const& text, LayoutMode layout_mode, bool wrap_lines, bool wrap_breaks)
diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
index 7b2c1ce416..47fc97363a 100644
--- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
+++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
@@ -103,13 +103,13 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node)
}
}
- auto* shadow_root = is<DOM::Element>(dom_node) ? downcast<DOM::Element>(dom_node).shadow_root() : nullptr;
+ auto* shadow_root = is<DOM::Element>(dom_node) ? verify_cast<DOM::Element>(dom_node).shadow_root() : nullptr;
if ((dom_node.has_children() || shadow_root) && layout_node->can_have_children()) {
- push_parent(downcast<NodeWithStyle>(*layout_node));
+ push_parent(verify_cast<NodeWithStyle>(*layout_node));
if (shadow_root)
create_layout_tree(*shadow_root);
- downcast<DOM::ParentNode>(dom_node).for_each_child([&](auto& dom_child) {
+ verify_cast<DOM::ParentNode>(dom_node).for_each_child([&](auto& dom_child) {
create_layout_tree(dom_child);
});
pop_parent();
@@ -121,7 +121,7 @@ RefPtr<Node> TreeBuilder::build(DOM::Node& dom_node)
if (dom_node.parent()) {
// We're building a partial layout tree, so start by building up the stack of parent layout nodes.
for (auto* ancestor = dom_node.parent()->layout_node(); ancestor; ancestor = ancestor->parent())
- m_parent_stack.prepend(downcast<NodeWithStyle>(ancestor));
+ m_parent_stack.prepend(verify_cast<NodeWithStyle>(ancestor));
}
create_layout_tree(dom_node);