mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
LibWeb: Use SVGPresentationAttribute mode for SVG attributes
This replaces the previous TemporarilyEnableQuirksMode hack, which has now been removed. :^)
This commit is contained in:
parent
79a30c209d
commit
28dbe8eb10
3 changed files with 2 additions and 29 deletions
|
@ -11,27 +11,6 @@
|
||||||
|
|
||||||
namespace Web::SVG {
|
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 {
|
class SVGElement : public DOM::Element {
|
||||||
WEB_PLATFORM_OBJECT(SVGElement, DOM::Element);
|
WEB_PLATFORM_OBJECT(SVGElement, DOM::Element);
|
||||||
|
|
||||||
|
|
|
@ -118,10 +118,7 @@ Gfx::AffineTransform SVGGraphicsElement::get_transform() const
|
||||||
|
|
||||||
void SVGGraphicsElement::apply_presentational_hints(CSS::StyleProperties& style) const
|
void SVGGraphicsElement::apply_presentational_hints(CSS::StyleProperties& style) const
|
||||||
{
|
{
|
||||||
// FIXME: Hack to ensure unitless SVG properties (such as font-size) are parsed.
|
CSS::Parser::ParsingContext parsing_context { document(), CSS::Parser::ParsingContext::Mode::SVGPresentationAttribute };
|
||||||
FIXME::TemporarilyEnableQuirksMode enable_quirks(document());
|
|
||||||
|
|
||||||
CSS::Parser::ParsingContext parsing_context { document() };
|
|
||||||
for_each_attribute([&](auto& name, auto& value) {
|
for_each_attribute([&](auto& name, auto& value) {
|
||||||
if (name.equals_ignoring_ascii_case("fill"sv)) {
|
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.
|
// FIXME: The `fill` attribute and CSS `fill` property are not the same! But our support is limited enough that they are equivalent for now.
|
||||||
|
|
|
@ -38,11 +38,8 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons
|
||||||
{
|
{
|
||||||
Base::apply_presentational_hints(style);
|
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 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)) {
|
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());
|
style.set_property(CSS::PropertyID::Width, width_value.release_nonnull());
|
||||||
} else if (width_attribute == "") {
|
} else if (width_attribute == "") {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue