diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2021-10-22 20:59:45 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-23 11:42:24 +0200 |
commit | f645ed199e89c947f2ed0081f9c3c8f9639973a9 (patch) | |
tree | a4a03634c8ab8f9b53d0b3f5120d7ed88ad8c8e1 /Userland/Libraries/LibWeb | |
parent | 0f393771b75faa64e1b6a9653b9ac81711644daa (diff) | |
download | serenity-f645ed199e89c947f2ed0081f9c3c8f9639973a9.zip |
LibWeb: Make CSS ParsingContext's Document* be const
The only reason it wasn't const before (and why we had a const_cast
hack) was to support ImageStyleValue's constructor taking it, which no
longer applies. `hack_count--;` :^)
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Parser.h | 6 |
2 files changed, 5 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index dbb89a9cb4..66089b547c 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -34,7 +34,7 @@ static void log_parse_error(const SourceLocation& location = SourceLocation::cur namespace Web::CSS { -ParsingContext::ParsingContext(DOM::Document& document) +ParsingContext::ParsingContext(DOM::Document const& document) : m_document(&document) { } @@ -3888,8 +3888,7 @@ RefPtr<CSS::StyleValue> parse_html_length(DOM::Document const& document, StringV auto integer = string.to_int(); if (integer.has_value()) return CSS::LengthStyleValue::create(CSS::Length::make_px(integer.value())); - // FIXME: The const_cast is a hack. - return parse_css_value(CSS::ParsingContext(const_cast<DOM::Document&>(document)), string); + return parse_css_value(CSS::ParsingContext(document), string); } } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index 5adb96db8f..3bd48747c6 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -36,18 +36,18 @@ enum class PropertyID; class ParsingContext { public: ParsingContext() = default; - explicit ParsingContext(DOM::Document&); + explicit ParsingContext(DOM::Document const&); explicit ParsingContext(DOM::ParentNode&); bool in_quirks_mode() const; - DOM::Document* document() const { return m_document; } + DOM::Document const* document() const { return m_document; } AK::URL complete_url(String const&) const; PropertyID current_property_id() const { return m_current_property_id; } void set_current_property_id(PropertyID property_id) { m_current_property_id = property_id; } private: - DOM::Document* m_document { nullptr }; + DOM::Document const* m_document { nullptr }; PropertyID m_current_property_id { PropertyID::Invalid }; }; |