mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-16 21:20:18 +00:00
LibWeb: Update layout of ancestor documents when getting computed style
Pending changes to an ancestor document's layout can affect an element's computed style e.g. an IFrame's width being changed can affect media query evaluation and the value of the `vw` unit.
This commit is contained in:
parent
05c336ea4e
commit
2098e516d2
Notes:
github-actions[bot]
2025-10-07 09:34:30 +00:00
Author: https://github.com/Calme1709
Commit: 2098e516d2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6412
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 79 additions and 71 deletions
|
@ -504,6 +504,14 @@ Optional<StyleProperty> CSSStyleProperties::get_direct_property(PropertyNameAndI
|
|||
|
||||
Layout::NodeWithStyle* layout_node = abstract_element.layout_node();
|
||||
|
||||
// Pending changes to an ancestor document's layout can affect an element's computed style e.g. an IFrame's
|
||||
// width being changed can affect media query evaluation and the value of the `vw` unit.
|
||||
// FIXME: This is likely overkill and can be optimized
|
||||
for (auto const& navigable : abstract_element.document().ancestor_navigables()) {
|
||||
if (navigable->active_document())
|
||||
navigable->active_document()->update_layout(DOM::UpdateLayoutReason::ResolvedCSSStyleDeclarationProperty);
|
||||
}
|
||||
|
||||
// FIXME: Be smarter about updating layout if there's no layout node.
|
||||
// We may legitimately have no layout node if we're not visible, but this protects against situations
|
||||
// where we're requesting the computed style before layout has happened.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue