Jelajahi Sumber

LibWeb: Move CSS ParsingContext to its own header

The implementation is already its own file, so having the class defined
in Parser.h feels weird.
Sam Atkins 1 tahun lalu
induk
melakukan
c40e441894

+ 1 - 24
Userland/Libraries/LibWeb/CSS/Parser/Parser.h

@@ -20,6 +20,7 @@
 #include <LibWeb/CSS/Parser/DeclarationOrAtRule.h>
 #include <LibWeb/CSS/Parser/Dimension.h>
 #include <LibWeb/CSS/Parser/Function.h>
+#include <LibWeb/CSS/Parser/ParsingContext.h>
 #include <LibWeb/CSS/Parser/Rule.h>
 #include <LibWeb/CSS/Parser/TokenStream.h>
 #include <LibWeb/CSS/Parser/Tokenizer.h>
@@ -36,30 +37,6 @@
 
 namespace Web::CSS::Parser {
 
-class ParsingContext {
-public:
-    explicit ParsingContext(JS::Realm&);
-    explicit ParsingContext(DOM::Document const&);
-    explicit ParsingContext(DOM::Document const&, AK::URL);
-    explicit ParsingContext(DOM::ParentNode&);
-
-    bool in_quirks_mode() const;
-    DOM::Document const* document() const { return m_document; }
-    HTML::Window const* window() const;
-    AK::URL complete_url(StringView) 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; }
-
-    JS::Realm& realm() const { return m_realm; }
-
-private:
-    JS::NonnullGCPtr<JS::Realm> m_realm;
-    JS::GCPtr<DOM::Document const> m_document;
-    PropertyID m_current_property_id { PropertyID::Invalid };
-    AK::URL m_url;
-};
-
 class Parser {
 public:
     static ErrorOr<Parser> create(ParsingContext const&, StringView input, StringView encoding = "utf-8"sv);

+ 39 - 0
Userland/Libraries/LibWeb/CSS/Parser/ParsingContext.h

@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2020-2021, the SerenityOS developers.
+ * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibJS/Runtime/Realm.h>
+#include <LibWeb/DOM/Document.h>
+
+namespace Web::CSS::Parser {
+
+class ParsingContext {
+public:
+    explicit ParsingContext(JS::Realm&);
+    explicit ParsingContext(DOM::Document const&);
+    explicit ParsingContext(DOM::Document const&, AK::URL);
+    explicit ParsingContext(DOM::ParentNode&);
+
+    bool in_quirks_mode() const;
+    DOM::Document const* document() const { return m_document; }
+    HTML::Window const* window() const;
+    AK::URL complete_url(StringView) 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; }
+
+    JS::Realm& realm() const { return m_realm; }
+
+private:
+    JS::NonnullGCPtr<JS::Realm> m_realm;
+    JS::GCPtr<DOM::Document const> m_document;
+    PropertyID m_current_property_id { PropertyID::Invalid };
+    AK::URL m_url;
+};
+
+}