소스 검색

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--;` :^)
Sam Atkins 3 년 전
부모
커밋
f645ed199e
2개의 변경된 파일5개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 3
      Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
  2. 3 3
      Userland/Libraries/LibWeb/CSS/Parser/Parser.h

+ 2 - 3
Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp

@@ -34,7 +34,7 @@ static void log_parse_error(const SourceLocation& location = SourceLocation::cur
 
 
 namespace Web::CSS {
 namespace Web::CSS {
 
 
-ParsingContext::ParsingContext(DOM::Document& document)
+ParsingContext::ParsingContext(DOM::Document const& document)
     : m_document(&document)
     : m_document(&document)
 {
 {
 }
 }
@@ -3888,8 +3888,7 @@ RefPtr<CSS::StyleValue> parse_html_length(DOM::Document const& document, StringV
     auto integer = string.to_int();
     auto integer = string.to_int();
     if (integer.has_value())
     if (integer.has_value())
         return CSS::LengthStyleValue::create(CSS::Length::make_px(integer.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);
 }
 }
 
 
 }
 }

+ 3 - 3
Userland/Libraries/LibWeb/CSS/Parser/Parser.h

@@ -36,18 +36,18 @@ enum class PropertyID;
 class ParsingContext {
 class ParsingContext {
 public:
 public:
     ParsingContext() = default;
     ParsingContext() = default;
-    explicit ParsingContext(DOM::Document&);
+    explicit ParsingContext(DOM::Document const&);
     explicit ParsingContext(DOM::ParentNode&);
     explicit ParsingContext(DOM::ParentNode&);
 
 
     bool in_quirks_mode() const;
     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;
     AK::URL complete_url(String const&) const;
 
 
     PropertyID current_property_id() const { return m_current_property_id; }
     PropertyID current_property_id() const { return m_current_property_id; }
     void set_current_property_id(PropertyID property_id) { m_current_property_id = property_id; }
     void set_current_property_id(PropertyID property_id) { m_current_property_id = property_id; }
 
 
 private:
 private:
-    DOM::Document* m_document { nullptr };
+    DOM::Document const* m_document { nullptr };
     PropertyID m_current_property_id { PropertyID::Invalid };
     PropertyID m_current_property_id { PropertyID::Invalid };
 };
 };