mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-06 09:01:53 +00:00
LibWeb: Dont compute style when CSSStyleProperties lacks owner node
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some instances of CSSStyleProperties can lack an owner node, for instance the return value of a call to `window.getComputedStyle` where the specified pseudo-element is invalid. In this case we should treat the computed style as empty, as there is no node to compute the style for.
This commit is contained in:
parent
fc46abb83f
commit
a9eecf76df
Notes:
github-actions[bot]
2025-06-09 11:29:45 +00:00
Author: https://github.com/Calme1709
Commit: a9eecf76df
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5034
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 342 additions and 1 deletions
|
@ -125,8 +125,11 @@ size_t CSSStyleProperties::length() const
|
|||
// The length attribute must return the number of CSS declarations in the declarations.
|
||||
// FIXME: Include the number of custom properties.
|
||||
|
||||
if (is_computed())
|
||||
if (is_computed()) {
|
||||
if (!owner_node().has_value())
|
||||
return 0;
|
||||
return to_underlying(last_longhand_property_id) - to_underlying(first_longhand_property_id) + 1;
|
||||
}
|
||||
|
||||
return m_properties.size();
|
||||
}
|
||||
|
@ -150,6 +153,9 @@ String CSSStyleProperties::item(size_t index) const
|
|||
Optional<StyleProperty> CSSStyleProperties::property(PropertyID property_id) const
|
||||
{
|
||||
if (is_computed()) {
|
||||
if (!owner_node().has_value())
|
||||
return {};
|
||||
|
||||
auto& element = owner_node()->element();
|
||||
auto pseudo_element = owner_node()->pseudo_element();
|
||||
|
||||
|
@ -211,6 +217,9 @@ Optional<StyleProperty> CSSStyleProperties::property(PropertyID property_id) con
|
|||
Optional<StyleProperty const&> CSSStyleProperties::custom_property(FlyString const& custom_property_name) const
|
||||
{
|
||||
if (is_computed()) {
|
||||
if (!owner_node().has_value())
|
||||
return {};
|
||||
|
||||
auto& element = owner_node()->element();
|
||||
auto pseudo_element = owner_node()->pseudo_element();
|
||||
|
||||
|
@ -676,6 +685,11 @@ static RefPtr<CSSStyleValue const> resolve_color_style_value(CSSStyleValue const
|
|||
|
||||
RefPtr<CSSStyleValue const> CSSStyleProperties::style_value_for_computed_property(Layout::NodeWithStyle const& layout_node, PropertyID property_id) const
|
||||
{
|
||||
if (!owner_node().has_value()) {
|
||||
dbgln_if(LIBWEB_CSS_DEBUG, "Computed style for CSSStyleProperties without owner node was requested");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto used_value_for_property = [&layout_node, property_id](Function<CSSPixels(Painting::PaintableBox const&)>&& used_value_getter) -> Optional<CSSPixels> {
|
||||
auto const& display = layout_node.computed_values().display();
|
||||
if (!display.is_none() && !display.is_contents() && layout_node.first_paintable()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue