mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 18:00:31 +00:00
LibWeb: Avoid style computation if document is detached
This commit is contained in:
parent
26389363ad
commit
c173a66754
Notes:
github-actions[bot]
2026-03-19 13:19:03 +00:00
Author: https://github.com/tcl3
Commit: c173a66754
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8503
Reviewed-by: https://github.com/gmta ✅
3 changed files with 22 additions and 3 deletions
|
|
@ -540,10 +540,19 @@ Optional<StyleProperty> CSSStyleProperties::get_direct_property(PropertyNameAndI
|
|||
|
||||
auto abstract_element = *owner_node();
|
||||
|
||||
// https://www.w3.org/TR/cssom-1/#dom-window-getcomputedstyle
|
||||
// NB: This is a partial enforcement of step 5 ("If elt is connected, ...")
|
||||
if (!abstract_element.element().is_connected())
|
||||
// https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle
|
||||
// NB: This is a partial enforcement of step 5:
|
||||
// If [...] elt is connected, part of the flat tree, and its shadow-including root has a browsing context which
|
||||
// either doesn't have a browsing context container, or whose browsing context container is being rendered.
|
||||
auto& element = abstract_element.element();
|
||||
if (!element.is_connected())
|
||||
return {};
|
||||
auto browsing_context = element.shadow_including_root().document().browsing_context();
|
||||
if (!browsing_context)
|
||||
return {};
|
||||
// FIXME: Check if the element is part of the flat tree.
|
||||
// FIXME: Check that the browsing context either doesn't have a browsing context container, or that its
|
||||
// browsing context container is being rendered.
|
||||
|
||||
// NB: We grab the layout node before deciding whether update_layout() is needed.
|
||||
// For properties that don't need layout or a layout node (the else branch below),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<script>
|
||||
var doc = document.implementation.createHTMLDocument("");
|
||||
getComputedStyle(doc.body).color;
|
||||
</script>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<script>
|
||||
var doc = document.implementation.createHTMLDocument("");
|
||||
getComputedStyle(doc.documentElement).color;
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue