LibWeb: Use SVGPresentationAttribute mode for SVG attributes

This replaces the previous TemporarilyEnableQuirksMode hack, which has
now been removed. :^)
This commit is contained in:
Sam Atkins 2023-09-25 15:28:05 +01:00 committed by Andreas Kling
parent 79a30c209d
commit 28dbe8eb10
3 changed files with 2 additions and 29 deletions

View file

@ -11,27 +11,6 @@
namespace Web::SVG {
namespace FIXME {
class TemporarilyEnableQuirksMode {
public:
TemporarilyEnableQuirksMode(DOM::Document const& document)
: m_document(const_cast<DOM::Document&>(document))
, m_previous_quirks_mode(document.mode())
{
m_document.set_quirks_mode(DOM::QuirksMode::Yes);
}
~TemporarilyEnableQuirksMode()
{
m_document.set_quirks_mode(m_previous_quirks_mode);
}
private:
DOM::Document& m_document;
DOM::QuirksMode m_previous_quirks_mode {};
};
}
class SVGElement : public DOM::Element {
WEB_PLATFORM_OBJECT(SVGElement, DOM::Element);

View file

@ -118,10 +118,7 @@ Gfx::AffineTransform SVGGraphicsElement::get_transform() const
void SVGGraphicsElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
// FIXME: Hack to ensure unitless SVG properties (such as font-size) are parsed.
FIXME::TemporarilyEnableQuirksMode enable_quirks(document());
CSS::Parser::ParsingContext parsing_context { document() };
CSS::Parser::ParsingContext parsing_context { document(), CSS::Parser::ParsingContext::Mode::SVGPresentationAttribute };
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_ascii_case("fill"sv)) {
// FIXME: The `fill` attribute and CSS `fill` property are not the same! But our support is limited enough that they are equivalent for now.

View file

@ -38,11 +38,8 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons
{
Base::apply_presentational_hints(style);
// NOTE: Hack to ensure SVG unitless widths/heights are parsed even with <!DOCTYPE html>
FIXME::TemporarilyEnableQuirksMode enable_quirks(document());
auto width_attribute = deprecated_attribute(SVG::AttributeNames::width);
auto parsing_context = CSS::Parser::ParsingContext { document() };
auto parsing_context = CSS::Parser::ParsingContext { document(), CSS::Parser::ParsingContext::Mode::SVGPresentationAttribute };
if (auto width_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width)) {
style.set_property(CSS::PropertyID::Width, width_value.release_nonnull());
} else if (width_attribute == "") {