summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-09-27 15:16:53 +0200
committerAndreas Kling <kling@serenityos.org>2022-09-29 18:33:41 +0200
commit8fa459f2d63bde40b2704532b1364cd6a03f356b (patch)
tree2a420c6f4680b2d79e627c38f06a09e7c67c8d2f /Userland/Libraries/LibWeb
parent385657a4bf5746aa7e5c8ba72edd35e6507e6d42 (diff)
downloadserenity-8fa459f2d63bde40b2704532b1364cd6a03f356b.zip
LibWeb: Add missing null checks in Layout::Node::set_needs_display()
Let's not assume the containing block has a paintable box just because someone is calling set_needs_display(). It can just be a no-op in that case, and nobody gets hurt.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Layout/Node.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp
index e19ad3aa7e..db2ae08e4f 100644
--- a/Userland/Libraries/LibWeb/Layout/Node.cpp
+++ b/Userland/Libraries/LibWeb/Layout/Node.cpp
@@ -127,14 +127,17 @@ InitialContainingBlock& Node::root()
void Node::set_needs_display()
{
- if (auto* block = containing_block()) {
- block->paint_box()->for_each_fragment([&](auto& fragment) {
- if (&fragment.layout_node() == this || is_ancestor_of(fragment.layout_node())) {
- browsing_context().set_needs_display(enclosing_int_rect(fragment.absolute_rect()));
- }
- return IterationDecision::Continue;
- });
- }
+ auto* containing_block = this->containing_block();
+ if (!containing_block)
+ return;
+ if (!containing_block->paint_box())
+ return;
+ containing_block->paint_box()->for_each_fragment([&](auto& fragment) {
+ if (&fragment.layout_node() == this || is_ancestor_of(fragment.layout_node())) {
+ browsing_context().set_needs_display(enclosing_int_rect(fragment.absolute_rect()));
+ }
+ return IterationDecision::Continue;
+ });
}
Gfx::FloatPoint Node::box_type_agnostic_position() const