mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb/DOM: Avoid repeated calls to Node::navigable
Minor optimization to avoid looking up the navigable during a layout operation.
This commit is contained in:
committed by
Alexander Kalenik
parent
74d644a216
commit
02ba51f203
@@ -1071,13 +1071,13 @@ static void propagate_overflow_to_viewport(Element& root_element, Layout::Viewpo
|
|||||||
|
|
||||||
void Document::update_layout()
|
void Document::update_layout()
|
||||||
{
|
{
|
||||||
if (!is_active())
|
auto navigable = this->navigable();
|
||||||
|
if (!navigable || navigable->active_document() != this)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// NOTE: If our parent document needs a relayout, we must do that *first*.
|
// NOTE: If our parent document needs a relayout, we must do that *first*.
|
||||||
// This is necessary as the parent layout may cause our viewport to change.
|
// This is necessary as the parent layout may cause our viewport to change.
|
||||||
auto navigable = this->navigable();
|
if (navigable->container())
|
||||||
if (navigable && navigable->container())
|
|
||||||
navigable->container()->document().update_layout();
|
navigable->container()->document().update_layout();
|
||||||
|
|
||||||
update_style();
|
update_style();
|
||||||
@@ -1089,11 +1089,8 @@ void Document::update_layout()
|
|||||||
if (m_created_for_appropriate_template_contents)
|
if (m_created_for_appropriate_template_contents)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!navigable)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto* document_element = this->document_element();
|
auto* document_element = this->document_element();
|
||||||
auto viewport_rect = this->viewport_rect();
|
auto viewport_rect = navigable->viewport_rect();
|
||||||
|
|
||||||
if (!m_layout_root) {
|
if (!m_layout_root) {
|
||||||
Layout::TreeBuilder tree_builder;
|
Layout::TreeBuilder tree_builder;
|
||||||
|
|||||||
Reference in New Issue
Block a user