mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Skip layout update for disconnected elements querying metrics
Introduce Document::update_layout_if_needed_for_node() which only calls update_layout() when the node is connected. Use it at all call sites that query layout metrics (offsets, client dimensions, image size, SVG bounding box, etc.) so disconnected elements no longer trigger an unnecessary layout.
This commit is contained in:
committed by
Alexander Kalenik
parent
63113cf5c9
commit
8f7bb7dd2e
Notes:
github-actions[bot]
2026-03-05 13:18:27 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/8f7bb7dd2ef Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8278
@@ -2352,7 +2352,7 @@ WebIDL::ExceptionOr<void> HTMLInputElement::set_size(WebIDL::UnsignedLong value)
|
||||
// https://html.spec.whatwg.org/multipage/input.html#dom-input-height
|
||||
WebIDL::UnsignedLong HTMLInputElement::height() const
|
||||
{
|
||||
const_cast<DOM::Document&>(document()).update_layout(DOM::UpdateLayoutReason::HTMLInputElementHeight);
|
||||
const_cast<DOM::Document&>(document()).update_layout_if_needed_for_node(*this, DOM::UpdateLayoutReason::HTMLInputElementHeight);
|
||||
|
||||
// When the input element's type attribute is not in the Image Button state, then no image is available.
|
||||
if (type_state() != TypeAttributeState::ImageButton)
|
||||
@@ -2387,7 +2387,7 @@ void HTMLInputElement::set_height(WebIDL::UnsignedLong value)
|
||||
// https://html.spec.whatwg.org/multipage/input.html#dom-input-width
|
||||
WebIDL::UnsignedLong HTMLInputElement::width() const
|
||||
{
|
||||
const_cast<DOM::Document&>(document()).update_layout(DOM::UpdateLayoutReason::HTMLInputElementWidth);
|
||||
const_cast<DOM::Document&>(document()).update_layout_if_needed_for_node(*this, DOM::UpdateLayoutReason::HTMLInputElementWidth);
|
||||
|
||||
// When the input element's type attribute is not in the Image Button state, then no image is available.
|
||||
if (type_state() != TypeAttributeState::ImageButton)
|
||||
|
||||
Reference in New Issue
Block a user