1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 07:07:34 +00:00

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>.
This commit is contained in:
MacDue 2023-04-10 12:36:34 +01:00 committed by Andreas Kling
parent 809c15d1ee
commit f753a4f640

View file

@ -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)) {