1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:37:34 +00:00

LibWeb: Move set_needs_display() from layout node to paintable

For this method, there is no need to go through the layout node when we
can directly reach the paintable.
This commit is contained in:
Aliaksandr Kalenik 2024-01-14 13:46:52 +01:00 committed by Andreas Kling
parent 814bed33b4
commit 7c2713c14f
21 changed files with 97 additions and 87 deletions

View file

@ -1177,14 +1177,14 @@ void Document::set_inspected_node(Node* node, Optional<CSS::Selector::PseudoElem
if (m_inspected_node.ptr() == node && m_inspected_pseudo_element == pseudo_element)
return;
if (auto layout_node = inspected_layout_node())
layout_node->set_needs_display();
if (auto layout_node = inspected_layout_node(); layout_node && layout_node->paintable())
layout_node->paintable()->set_needs_display();
m_inspected_node = node;
m_inspected_pseudo_element = pseudo_element;
if (auto layout_node = inspected_layout_node())
layout_node->set_needs_display();
if (auto layout_node = inspected_layout_node(); layout_node && layout_node->paintable())
layout_node->paintable()->set_needs_display();
}
Layout::Node* Document::inspected_layout_node()
@ -1736,8 +1736,8 @@ void Document::set_focused_element(Element* element)
m_focused_element->set_needs_style_update(true);
}
if (m_layout_root)
m_layout_root->set_needs_display();
if (paintable())
paintable()->set_needs_display();
// Scroll the viewport if necessary to make the newly focused element visible.
if (m_focused_element) {
@ -1755,8 +1755,8 @@ void Document::set_active_element(Element* element)
m_active_element = element;
if (m_layout_root)
m_layout_root->set_needs_display();
if (paintable())
paintable()->set_needs_display();
}
void Document::set_target_element(Element* element)
@ -1772,8 +1772,8 @@ void Document::set_target_element(Element* element)
if (m_target_element)
m_target_element->set_needs_style_update(true);
if (m_layout_root)
m_layout_root->set_needs_display();
if (paintable())
paintable()->set_needs_display();
}
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#the-indicated-part-of-the-document

View file

@ -602,8 +602,8 @@ Element::RequiredInvalidationAfterStyleChange Element::recompute_style()
if (!invalidation.rebuild_layout_tree && layout_node()) {
// If we're keeping the layout tree, we can just apply the new style to the existing layout tree.
layout_node()->apply_style(*m_computed_css_values);
if (invalidation.repaint)
layout_node()->set_needs_display();
if (invalidation.repaint && paintable())
paintable()->set_needs_display();
}
return invalidation;

View file

@ -22,6 +22,7 @@
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Namespace.h>
#include <LibWeb/Painting/Paintable.h>
namespace Web::DOM {
@ -94,9 +95,9 @@ void Range::update_associated_selection()
{
if (!m_associated_selection)
return;
if (auto* layout_root = m_associated_selection->document()->layout_node()) {
if (auto* layout_root = m_associated_selection->document()->layout_node(); layout_root && layout_root->paintable()) {
layout_root->recompute_selection_states();
layout_root->set_needs_display();
layout_root->paintable()->set_needs_display();
}
}