LibWeb: Add an engine-internal CSS realm for internal style parsing

This is used for default UA style right now, and we'll expand its use in
the near future.

Note that this required teaching the CSS parser to handle url()
functions when there's no document URL to resolve them against. If we
don't handle that, namespace rules in UA style don't parse correctly.
This commit is contained in:
Andreas Kling 2025-03-25 10:04:42 +00:00 committed by Andreas Kling
parent c12f8b80dc
commit ba030f0363
Notes: github-actions[bot] 2025-03-25 23:58:04 +00:00
4 changed files with 44 additions and 13 deletions

View file

@ -13,6 +13,7 @@
*/
#include <AK/Debug.h>
#include <LibURL/Parser.h>
#include <LibWeb/CSS/CSSStyleDeclaration.h>
#include <LibWeb/CSS/CSSStyleProperties.h>
#include <LibWeb/CSS/CSSStyleSheet.h>
@ -1814,6 +1815,8 @@ bool Parser::is_parsing_svg_presentation_attribute() const
// FIXME: URLs shouldn't be completed during parsing, but when used.
Optional<URL::URL> Parser::complete_url(StringView relative_url) const
{
if (!m_url.is_valid())
return URL::Parser::basic_parse(relative_url);
return m_url.complete_url(relative_url);
}