Skip to content

Commit

Permalink
LibWeb: Check for missing node or invalid query in obtain_theme_color
Browse files Browse the repository at this point in the history
  • Loading branch information
Gingeh committed Jan 10, 2025
1 parent 1f4c7ac commit 4c2e907
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Libraries/LibWeb/DOM/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ void Document::obtain_theme_color()
auto media = element.attribute(HTML::AttributeNames::media);
if (media.has_value()) {
auto query = parse_media_query(context, media.value());
if (window() && !query->evaluate(*window()))
if (query.is_null() || (window() && !query->evaluate(*window())))
return TraversalDecision::Continue;
}

Expand All @@ -1503,7 +1503,7 @@ void Document::obtain_theme_color()
// 4. If color is not failure, then return color.
if (!css_value.is_null() && css_value->is_color()) {
Optional<Layout::NodeWithStyle const&> root_node;
if (html_element())
if (html_element() && html_element()->layout_node())
root_node = *html_element()->layout_node();

theme_color = css_value->to_color(root_node);
Expand Down

0 comments on commit 4c2e907

Please sign in to comment.