summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/SVG
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2023-04-10 12:36:34 +0100
committerAndreas Kling <kling@serenityos.org>2023-04-12 07:40:22 +0200
commitf753a4f64049cb9af7bb33f5c20788e339a1cdec (patch)
tree86f6b05a30e3b18be17d7008c894ed81e6bd023f /Userland/Libraries/LibWeb/SVG
parent809c15d1ee9132f7abf987824e863108f1f6dcc4 (diff)
downloadserenity-f753a4f64049cb9af7bb33f5c20788e339a1cdec.zip
LibWeb: Always use quirks mode when parsing SVG width/height attributes
This is a bit if a hack, but without this unitless values for these attributes fail to parse with <!DOCTYPE html>.
Diffstat (limited to 'Userland/Libraries/LibWeb/SVG')
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
index 4b72ae58a1..abfab45dbf 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
@@ -37,6 +37,13 @@ JS::GCPtr<Layout::Node> SVGSVGElement::create_layout_node(NonnullRefPtr<CSS::Sty
void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
+ // NOTE: Hack to ensure SVG unitless widths/heights are parsed even with <!DOCTYPE html>
+ auto previous_quirks_mode = document().mode();
+ const_cast<DOM::Document&>(document()).set_quirks_mode(DOM::QuirksMode::Yes);
+ ScopeGuard reset_quirks_mode = [&] {
+ const_cast<DOM::Document&>(document()).set_quirks_mode(previous_quirks_mode);
+ };
+
auto width_attribute = attribute(SVG::AttributeNames::width);
auto parsing_context = CSS::Parser::ParsingContext { document() };
if (auto width_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width)) {