LibWeb: Let about:blank use dark color schemes

Opt empty about:blank documents into both light and dark supported
color schemes. This covers both navigation-created about:blank documents
and the initial about:blank document created with a browsing context, so
dark mode can choose the dark Canvas color before page content arrives.
This commit is contained in:
Andreas Kling 2026-05-27 10:23:30 +02:00 committed by Andreas Kling
parent 793e7dd01b
commit ab4356edea
4 changed files with 8 additions and 0 deletions

View file

@ -2492,6 +2492,11 @@ Optional<Vector<String> const&> Document::supported_color_schemes() const
return m_supported_color_schemes;
}
void Document::set_supported_color_schemes(Vector<String> supported_color_schemes)
{
m_supported_color_schemes = move(supported_color_schemes);
}
// https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme
void Document::obtain_supported_color_schemes()
{

View file

@ -372,6 +372,7 @@ public:
void set_visited_link_color(Color);
Optional<Vector<String> const&> supported_color_schemes() const;
void set_supported_color_schemes(Vector<String>);
void obtain_supported_color_schemes();
void obtain_theme_color();

View file

@ -97,6 +97,7 @@ static WebIDL::ExceptionOr<GC::Ref<DOM::Document>> load_html_document(HTML::Navi
if (document->url_string() == "about:blank"_string
&& navigation_params.response->body()->length().value_or(0) == 0) {
TRY(document->populate_with_html_head_and_body());
document->set_supported_color_schemes({ "light"_string, "dark"_string });
HTML::HTMLParser::the_end(document);
}

View file

@ -278,6 +278,7 @@ BrowsingContext::BrowsingContextAndDocument BrowsingContext::create_a_new_browsi
// 19. Populate with html/head/body given document.
populate_with_html_head_body(*document);
document->set_supported_color_schemes({ "light"_string, "dark"_string });
// 20. Make active document.
document->make_active();