diff --git a/Applications/Browser/ConsoleWidget.cpp b/Applications/Browser/ConsoleWidget.cpp index a8863819ae..9d9e22f43c 100644 --- a/Applications/Browser/ConsoleWidget.cpp +++ b/Applications/Browser/ConsoleWidget.cpp @@ -47,13 +47,13 @@ ConsoleWidget::ConsoleWidget() set_layout(); set_fill_with_background_color(true); - auto base_document = adopt(*new Web::Document); - base_document->append_child(adopt(*new Web::DocumentType(base_document))); - auto html_element = create_element(base_document, "html"); + auto base_document = adopt(*new Web::DOM::Document); + base_document->append_child(adopt(*new Web::DOM::DocumentType(base_document))); + auto html_element = Web::DOM::create_element(base_document, "html"); base_document->append_child(html_element); - auto head_element = create_element(base_document, "head"); + auto head_element = Web::DOM::create_element(base_document, "head"); html_element->append_child(head_element); - auto body_element = create_element(base_document, "body"); + auto body_element = Web::DOM::create_element(base_document, "body"); html_element->append_child(body_element); m_output_container = body_element; diff --git a/Applications/Browser/ConsoleWidget.h b/Applications/Browser/ConsoleWidget.h index 44a6f881f0..cb1a1313a8 100644 --- a/Applications/Browser/ConsoleWidget.h +++ b/Applications/Browser/ConsoleWidget.h @@ -52,7 +52,7 @@ private: RefPtr m_input; RefPtr m_output_view; - RefPtr m_output_container; + RefPtr m_output_container; WeakPtr m_interpreter; OwnPtr m_console_client; }; diff --git a/Applications/Browser/InspectorWidget.cpp b/Applications/Browser/InspectorWidget.cpp index 2c0d3c0e90..7d62193791 100644 --- a/Applications/Browser/InspectorWidget.cpp +++ b/Applications/Browser/InspectorWidget.cpp @@ -38,11 +38,11 @@ namespace Browser { -void InspectorWidget::set_inspected_node(Web::Node* node) +void InspectorWidget::set_inspected_node(Web::DOM::Node* node) { m_document->set_inspected_node(node); if (node && node->is_element()) { - auto& element = downcast(*node); + auto& element = downcast(*node); if (element.resolved_style()) { m_style_table_view->set_model(Web::StylePropertiesModel::create(*element.resolved_style())); m_computed_style_table_view->set_model(Web::StylePropertiesModel::create(*element.computed_style())); @@ -62,7 +62,7 @@ InspectorWidget::InspectorWidget() m_dom_tree_view = top_tab_widget.add_tab("DOM"); m_dom_tree_view->on_selection = [this](auto& index) { - auto* node = static_cast(index.internal_data()); + auto* node = static_cast(index.internal_data()); set_inspected_node(node); }; @@ -82,7 +82,7 @@ InspectorWidget::~InspectorWidget() { } -void InspectorWidget::set_document(Web::Document* document) +void InspectorWidget::set_document(Web::DOM::Document* document) { if (m_document == document) return; diff --git a/Applications/Browser/InspectorWidget.h b/Applications/Browser/InspectorWidget.h index 5af8a3973c..37f0f95754 100644 --- a/Applications/Browser/InspectorWidget.h +++ b/Applications/Browser/InspectorWidget.h @@ -36,18 +36,18 @@ class InspectorWidget final : public GUI::Widget { public: virtual ~InspectorWidget(); - void set_document(Web::Document*); + void set_document(Web::DOM::Document*); private: InspectorWidget(); - void set_inspected_node(Web::Node*); + void set_inspected_node(Web::DOM::Node*); RefPtr m_dom_tree_view; RefPtr m_layout_tree_view; RefPtr m_style_table_view; RefPtr m_computed_style_table_view; - RefPtr m_document; + RefPtr m_document; }; } diff --git a/Applications/IRCClient/IRCLogBuffer.cpp b/Applications/IRCClient/IRCLogBuffer.cpp index 730b4d3b4a..18297dc155 100644 --- a/Applications/IRCClient/IRCLogBuffer.cpp +++ b/Applications/IRCClient/IRCLogBuffer.cpp @@ -40,14 +40,14 @@ NonnullRefPtr IRCLogBuffer::create() IRCLogBuffer::IRCLogBuffer() { - m_document = adopt(*new Web::Document); - m_document->append_child(adopt(*new Web::DocumentType(document()))); + m_document = adopt(*new Web::DOM::Document); + m_document->append_child(adopt(*new Web::DOM::DocumentType(document()))); auto html_element = create_element(document(), "html"); m_document->append_child(html_element); auto head_element = create_element(document(), "head"); html_element->append_child(head_element); auto style_element = create_element(document(), "style"); - style_element->append_child(adopt(*new Web::Text(document(), "div { font-family: Csilla; font-weight: lighter; }"))); + style_element->append_child(adopt(*new Web::DOM::Text(document(), "div { font-family: Csilla; font-weight: lighter; }"))); head_element->append_child(style_element); auto body_element = create_element(document(), "body"); html_element->append_child(body_element); @@ -76,7 +76,7 @@ void IRCLogBuffer::add_message(char prefix, const String& name, const String& te escape_html_entities(nick_string).characters(), escape_html_entities(text).characters()); - auto wrapper = Web::create_element(*m_document, Web::HTML::TagNames::div); + auto wrapper = Web::DOM::create_element(*m_document, Web::HTML::TagNames::div); wrapper->set_attribute(Web::HTML::AttributeNames::style, String::format("color: %s", color.to_string().characters())); wrapper->set_inner_html(html); m_container_element->append_child(wrapper); @@ -90,7 +90,7 @@ void IRCLogBuffer::add_message(const String& text, Color color) "%s", timestamp_string().characters(), escape_html_entities(text).characters()); - auto wrapper = Web::create_element(*m_document, Web::HTML::TagNames::div); + auto wrapper = Web::DOM::create_element(*m_document, Web::HTML::TagNames::div); wrapper->set_attribute(Web::HTML::AttributeNames::style, String::format("color: %s", color.to_string().characters())); wrapper->set_inner_html(html); m_container_element->append_child(wrapper); diff --git a/Applications/IRCClient/IRCLogBuffer.h b/Applications/IRCClient/IRCLogBuffer.h index 183ee21b01..0f62757c3f 100644 --- a/Applications/IRCClient/IRCLogBuffer.h +++ b/Applications/IRCClient/IRCLogBuffer.h @@ -49,11 +49,11 @@ public: void add_message(const String& text, Color = Color::Black); void dump() const; - const Web::Document& document() const { return *m_document; } - Web::Document& document() { return *m_document; } + const Web::DOM::Document& document() const { return *m_document; } + Web::DOM::Document& document() { return *m_document; } private: IRCLogBuffer(); - RefPtr m_document; - RefPtr m_container_element; + RefPtr m_document; + RefPtr m_container_element; }; diff --git a/Applications/IRCClient/IRCWindow.cpp b/Applications/IRCClient/IRCWindow.cpp index 26f6c62936..4272dbbb71 100644 --- a/Applications/IRCClient/IRCWindow.cpp +++ b/Applications/IRCClient/IRCWindow.cpp @@ -214,7 +214,7 @@ IRCWindow::~IRCWindow() void IRCWindow::set_log_buffer(const IRCLogBuffer& log_buffer) { m_log_buffer = &log_buffer; - m_page_view->set_document(const_cast(&log_buffer.document())); + m_page_view->set_document(const_cast(&log_buffer.document())); } bool IRCWindow::is_active() const diff --git a/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp b/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp index fa7e82b3ce..9a716702fd 100644 --- a/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp +++ b/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp @@ -33,7 +33,7 @@ namespace Web { namespace Bindings { -EventListenerWrapper::EventListenerWrapper(JS::GlobalObject& global_object, EventListener& impl) +EventListenerWrapper::EventListenerWrapper(JS::GlobalObject& global_object, DOM::EventListener& impl) : Wrapper(*global_object.object_prototype()) , m_impl(impl) { diff --git a/Libraries/LibWeb/Bindings/EventListenerWrapper.h b/Libraries/LibWeb/Bindings/EventListenerWrapper.h index 6fad8eaff2..fdd74108ea 100644 --- a/Libraries/LibWeb/Bindings/EventListenerWrapper.h +++ b/Libraries/LibWeb/Bindings/EventListenerWrapper.h @@ -35,14 +35,14 @@ class EventListenerWrapper final : public Wrapper { JS_OBJECT(EventListenerWrapper, Wrapper); public: - EventListenerWrapper(JS::GlobalObject&, EventListener&); + EventListenerWrapper(JS::GlobalObject&, DOM::EventListener&); virtual ~EventListenerWrapper() override; - EventListener& impl() { return *m_impl; } - const EventListener& impl() const { return *m_impl; } + DOM::EventListener& impl() { return *m_impl; } + const DOM::EventListener& impl() const { return *m_impl; } private: - NonnullRefPtr m_impl; + NonnullRefPtr m_impl; }; } diff --git a/Libraries/LibWeb/Bindings/EventWrapperFactory.cpp b/Libraries/LibWeb/Bindings/EventWrapperFactory.cpp index d741d678cc..cb0db37954 100644 --- a/Libraries/LibWeb/Bindings/EventWrapperFactory.cpp +++ b/Libraries/LibWeb/Bindings/EventWrapperFactory.cpp @@ -30,10 +30,10 @@ namespace Web { namespace Bindings { -EventWrapper* wrap(JS::GlobalObject& global_object, Event& event) +EventWrapper* wrap(JS::GlobalObject& global_object, DOM::Event& event) { if (event.is_mouse_event()) - return static_cast(wrap_impl(global_object, static_cast(event))); + return static_cast(wrap_impl(global_object, static_cast(event))); return static_cast(wrap_impl(global_object, event)); } diff --git a/Libraries/LibWeb/Bindings/EventWrapperFactory.h b/Libraries/LibWeb/Bindings/EventWrapperFactory.h index c5a701385e..ebe82c5e88 100644 --- a/Libraries/LibWeb/Bindings/EventWrapperFactory.h +++ b/Libraries/LibWeb/Bindings/EventWrapperFactory.h @@ -29,10 +29,8 @@ #include #include -namespace Web { -namespace Bindings { +namespace Web::Bindings { -EventWrapper* wrap(JS::GlobalObject&, Event&); +EventWrapper* wrap(JS::GlobalObject&, DOM::Event&); } -} diff --git a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp index d34f6068ec..b280016749 100644 --- a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp +++ b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp @@ -38,20 +38,20 @@ namespace Web { namespace Bindings { -NodeWrapper* wrap(JS::GlobalObject& global_object, Node& node) +NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& node) { - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); if (is(node)) return static_cast(wrap_impl(global_object, downcast(node))); if (is(node)) return static_cast(wrap_impl(global_object, downcast(node))); if (is(node)) return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); return static_cast(wrap_impl(global_object, node)); } diff --git a/Libraries/LibWeb/Bindings/NodeWrapperFactory.h b/Libraries/LibWeb/Bindings/NodeWrapperFactory.h index 28093e1b03..153e78cb32 100644 --- a/Libraries/LibWeb/Bindings/NodeWrapperFactory.h +++ b/Libraries/LibWeb/Bindings/NodeWrapperFactory.h @@ -32,7 +32,7 @@ namespace Web { namespace Bindings { -NodeWrapper* wrap(JS::GlobalObject&, Node&); +NodeWrapper* wrap(JS::GlobalObject&, DOM::Node&); } } diff --git a/Libraries/LibWeb/Bindings/WindowObject.cpp b/Libraries/LibWeb/Bindings/WindowObject.cpp index cf33529f83..6e604ec2f1 100644 --- a/Libraries/LibWeb/Bindings/WindowObject.cpp +++ b/Libraries/LibWeb/Bindings/WindowObject.cpp @@ -48,7 +48,7 @@ namespace Web { namespace Bindings { -WindowObject::WindowObject(Window& impl) +WindowObject::WindowObject(DOM::Window& impl) : m_impl(impl) { impl.set_wrapper({}, *this); @@ -91,7 +91,7 @@ void WindowObject::visit_children(Visitor& visitor) visitor.visit(m_xhr_prototype); } -static Window* impl_from(JS::Interpreter& interpreter, JS::GlobalObject& global_object) +static DOM::Window* impl_from(JS::Interpreter& interpreter, JS::GlobalObject& global_object) { auto* this_object = interpreter.this_value(global_object).to_object(interpreter, global_object); if (!this_object) { diff --git a/Libraries/LibWeb/Bindings/WindowObject.h b/Libraries/LibWeb/Bindings/WindowObject.h index 57bfeb5186..8b01a5ae3b 100644 --- a/Libraries/LibWeb/Bindings/WindowObject.h +++ b/Libraries/LibWeb/Bindings/WindowObject.h @@ -37,12 +37,12 @@ class WindowObject final : public JS::GlobalObject , public Weakable { public: - explicit WindowObject(Window&); + explicit WindowObject(DOM::Window&); virtual void initialize() override; virtual ~WindowObject() override; - Window& impl() { return *m_impl; } - const Window& impl() const { return *m_impl; } + DOM::Window& impl() { return *m_impl; } + const DOM::Window& impl() const { return *m_impl; } XMLHttpRequestPrototype* xhr_prototype() { return m_xhr_prototype; } XMLHttpRequestConstructor* xhr_constructor() { return m_xhr_constructor; } @@ -65,7 +65,7 @@ private: JS_DECLARE_NATIVE_FUNCTION(atob); JS_DECLARE_NATIVE_FUNCTION(btoa); - NonnullRefPtr m_impl; + NonnullRefPtr m_impl; XMLHttpRequestConstructor* m_xhr_constructor { nullptr }; XMLHttpRequestPrototype* m_xhr_prototype { nullptr }; diff --git a/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Libraries/LibWeb/CSS/SelectorEngine.cpp index 862d5abb3b..4589ff3f2e 100644 --- a/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -34,7 +34,7 @@ namespace Web { namespace SelectorEngine { -static bool matches_hover_pseudo_class(const Element& element) +static bool matches_hover_pseudo_class(const DOM::Element& element) { auto* hovered_node = element.document().hovered_node(); if (!hovered_node) @@ -44,7 +44,7 @@ static bool matches_hover_pseudo_class(const Element& element) return element.is_ancestor_of(*hovered_node); } -bool matches(const Selector::SimpleSelector& component, const Element& element) +bool matches(const Selector::SimpleSelector& component, const DOM::Element& element) { switch (component.pseudo_class) { case Selector::SimpleSelector::PseudoClass::None: @@ -76,7 +76,7 @@ bool matches(const Selector::SimpleSelector& component, const Element& element) return false; break; case Selector::SimpleSelector::PseudoClass::Empty: - if (element.first_child_of_type() || element.first_child_of_type()) + if (element.first_child_of_type() || element.first_child_of_type()) return false; break; case Selector::SimpleSelector::PseudoClass::Root: @@ -116,7 +116,7 @@ bool matches(const Selector::SimpleSelector& component, const Element& element) } } -bool matches(const Selector& selector, int component_list_index, const Element& element) +bool matches(const Selector& selector, int component_list_index, const DOM::Element& element) { auto& component_list = selector.complex_selectors()[component_list_index]; for (auto& component : component_list.compound_selector) { @@ -129,17 +129,17 @@ bool matches(const Selector& selector, int component_list_index, const Element& case Selector::ComplexSelector::Relation::Descendant: ASSERT(component_list_index != 0); for (auto* ancestor = element.parent(); ancestor; ancestor = ancestor->parent()) { - if (!is(*ancestor)) + if (!is(*ancestor)) continue; - if (matches(selector, component_list_index - 1, downcast(*ancestor))) + if (matches(selector, component_list_index - 1, downcast(*ancestor))) return true; } return false; case Selector::ComplexSelector::Relation::ImmediateChild: ASSERT(component_list_index != 0); - if (!element.parent() || !is(*element.parent())) + if (!element.parent() || !is(*element.parent())) return false; - return matches(selector, component_list_index - 1, downcast(*element.parent())); + return matches(selector, component_list_index - 1, downcast(*element.parent())); case Selector::ComplexSelector::Relation::AdjacentSibling: ASSERT(component_list_index != 0); if (auto* sibling = element.previous_element_sibling()) @@ -156,7 +156,7 @@ bool matches(const Selector& selector, int component_list_index, const Element& ASSERT_NOT_REACHED(); } -bool matches(const Selector& selector, const Element& element) +bool matches(const Selector& selector, const DOM::Element& element) { ASSERT(!selector.complex_selectors().is_empty()); return matches(selector, selector.complex_selectors().size() - 1, element); diff --git a/Libraries/LibWeb/CSS/SelectorEngine.h b/Libraries/LibWeb/CSS/SelectorEngine.h index e5be692ce7..7453c420fc 100644 --- a/Libraries/LibWeb/CSS/SelectorEngine.h +++ b/Libraries/LibWeb/CSS/SelectorEngine.h @@ -27,15 +27,10 @@ #pragma once #include +#include -namespace Web { +namespace Web::SelectorEngine { -class Element; - -namespace SelectorEngine { - -bool matches(const Selector&, const Element&); - -} +bool matches(const Selector&, const DOM::Element&); } diff --git a/Libraries/LibWeb/CSS/StyleProperties.cpp b/Libraries/LibWeb/CSS/StyleProperties.cpp index aa95ecf703..e8a78e1ede 100644 --- a/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -94,7 +94,7 @@ String StyleProperties::string_or_fallback(CSS::PropertyID id, const StringView& return value.value()->to_string(); } -Color StyleProperties::color_or_fallback(CSS::PropertyID id, const Document& document, Color fallback) const +Color StyleProperties::color_or_fallback(CSS::PropertyID id, const DOM::Document& document, Color fallback) const { auto value = property(id); if (!value.has_value()) diff --git a/Libraries/LibWeb/CSS/StyleProperties.h b/Libraries/LibWeb/CSS/StyleProperties.h index b95684a0bf..05e38ac846 100644 --- a/Libraries/LibWeb/CSS/StyleProperties.h +++ b/Libraries/LibWeb/CSS/StyleProperties.h @@ -59,7 +59,7 @@ public: Length length_or_fallback(CSS::PropertyID, const Length& fallback) const; LengthBox length_box(CSS::PropertyID left_id, CSS::PropertyID top_id, CSS::PropertyID right_id, CSS::PropertyID bottom_id) const; String string_or_fallback(CSS::PropertyID, const StringView& fallback) const; - Color color_or_fallback(CSS::PropertyID, const Document&, Color fallback) const; + Color color_or_fallback(CSS::PropertyID, const DOM::Document&, Color fallback) const; CSS::TextAlign text_align() const; CSS::Display display() const; Optional float_() const; diff --git a/Libraries/LibWeb/CSS/StyleResolver.cpp b/Libraries/LibWeb/CSS/StyleResolver.cpp index 513b319b1f..682aadc292 100644 --- a/Libraries/LibWeb/CSS/StyleResolver.cpp +++ b/Libraries/LibWeb/CSS/StyleResolver.cpp @@ -37,7 +37,7 @@ namespace Web { -StyleResolver::StyleResolver(Document& document) +StyleResolver::StyleResolver(DOM::Document& document) : m_document(document) { } @@ -66,7 +66,7 @@ void StyleResolver::for_each_stylesheet(Callback callback) const } } -Vector StyleResolver::collect_matching_rules(const Element& element) const +Vector StyleResolver::collect_matching_rules(const DOM::Element& element) const { Vector matching_rules; @@ -203,7 +203,7 @@ static inline void set_property_border_style(StyleProperties& style, const Style style.set_property(CSS::PropertyID::BorderLeftStyle, value); } -static void set_property_expanding_shorthands(StyleProperties& style, CSS::PropertyID property_id, const StyleValue& value, Document& document) +static void set_property_expanding_shorthands(StyleProperties& style, CSS::PropertyID property_id, const StyleValue& value, DOM::Document& document) { CSS::ParsingContext context(document); @@ -519,7 +519,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope style.set_property(property_id, value); } -NonnullRefPtr StyleResolver::resolve_style(const Element& element, const StyleProperties* parent_style) const +NonnullRefPtr StyleResolver::resolve_style(const DOM::Element& element, const StyleProperties* parent_style) const { auto style = StyleProperties::create(); diff --git a/Libraries/LibWeb/CSS/StyleResolver.h b/Libraries/LibWeb/CSS/StyleResolver.h index 54fa2fa763..cc5d3f3541 100644 --- a/Libraries/LibWeb/CSS/StyleResolver.h +++ b/Libraries/LibWeb/CSS/StyleResolver.h @@ -29,15 +29,10 @@ #include #include #include +#include namespace Web { -class Document; -class Element; -class ParentNode; -class StyleRule; -class StyleSheet; - struct MatchingRule { RefPtr rule; size_t style_sheet_index { 0 }; @@ -47,15 +42,15 @@ struct MatchingRule { class StyleResolver { public: - explicit StyleResolver(Document&); + explicit StyleResolver(DOM::Document&); ~StyleResolver(); - Document& document() { return m_document; } - const Document& document() const { return m_document; } + DOM::Document& document() { return m_document; } + const DOM::Document& document() const { return m_document; } - NonnullRefPtr resolve_style(const Element&, const StyleProperties* parent_style) const; + NonnullRefPtr resolve_style(const DOM::Element&, const StyleProperties* parent_style) const; - Vector collect_matching_rules(const Element&) const; + Vector collect_matching_rules(const DOM::Element&) const; static bool is_inherited_property(CSS::PropertyID); @@ -63,7 +58,7 @@ private: template void for_each_stylesheet(Callback) const; - Document& m_document; + DOM::Document& m_document; }; } diff --git a/Libraries/LibWeb/CSS/StyleSheetList.cpp b/Libraries/LibWeb/CSS/StyleSheetList.cpp index ec7bea2c23..addca5598d 100644 --- a/Libraries/LibWeb/CSS/StyleSheetList.cpp +++ b/Libraries/LibWeb/CSS/StyleSheetList.cpp @@ -33,7 +33,7 @@ void StyleSheetList::add_sheet(NonnullRefPtr sheet) m_sheets.append(move(sheet)); } -StyleSheetList::StyleSheetList(Document& document) +StyleSheetList::StyleSheetList(DOM::Document& document) : m_document(document) { } diff --git a/Libraries/LibWeb/CSS/StyleSheetList.h b/Libraries/LibWeb/CSS/StyleSheetList.h index 47fc2ff4ea..636e030f39 100644 --- a/Libraries/LibWeb/CSS/StyleSheetList.h +++ b/Libraries/LibWeb/CSS/StyleSheetList.h @@ -33,7 +33,7 @@ namespace Web::CSS { class StyleSheetList : public RefCounted { public: - static NonnullRefPtr create(Document& document) + static NonnullRefPtr create(DOM::Document& document) { return adopt(*new StyleSheetList(document)); } @@ -43,9 +43,9 @@ public: const NonnullRefPtrVector& sheets() const { return m_sheets; } private: - explicit StyleSheetList(Document&); + explicit StyleSheetList(DOM::Document&); - Document& m_document; + DOM::Document& m_document; NonnullRefPtrVector m_sheets; }; diff --git a/Libraries/LibWeb/CSS/StyleValue.cpp b/Libraries/LibWeb/CSS/StyleValue.cpp index c49e56a4c1..a4f1a9cc80 100644 --- a/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValue.cpp @@ -167,7 +167,7 @@ String IdentifierStyleValue::to_string() const } } -Color IdentifierStyleValue::to_color(const Document& document) const +Color IdentifierStyleValue::to_color(const DOM::Document& document) const { if (id() == CSS::ValueID::VendorSpecificLink) return document.link_color(); @@ -287,7 +287,7 @@ Color IdentifierStyleValue::to_color(const Document& document) const } } -ImageStyleValue::ImageStyleValue(const URL& url, Document& document) +ImageStyleValue::ImageStyleValue(const URL& url, DOM::Document& document) : StyleValue(Type::Image) , m_url(url) , m_document(document.make_weak_ptr()) diff --git a/Libraries/LibWeb/CSS/StyleValue.h b/Libraries/LibWeb/CSS/StyleValue.h index 18b2acdead..a6b2fbedfd 100644 --- a/Libraries/LibWeb/CSS/StyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValue.h @@ -182,7 +182,7 @@ public: virtual String to_string() const = 0; virtual Length to_length() const { return Length::make_auto(); } - virtual Color to_color(const Document&) const { return {}; } + virtual Color to_color(const DOM::Document&) const { return {}; } virtual bool is_auto() const { return false; } @@ -276,7 +276,7 @@ public: Color color() const { return m_color; } String to_string() const override { return m_color.to_string(); } - Color to_color(const Document&) const override { return m_color; } + Color to_color(const DOM::Document&) const override { return m_color; } private: explicit ColorStyleValue(Color color) @@ -299,7 +299,7 @@ public: CSS::ValueID id() const { return m_id; } virtual String to_string() const override; - virtual Color to_color(const Document&) const override; + virtual Color to_color(const DOM::Document&) const override; private: explicit IdentifierStyleValue(CSS::ValueID id) @@ -315,7 +315,7 @@ class ImageStyleValue final : public StyleValue , public ImageResourceClient { public: - static NonnullRefPtr create(const URL& url, Document& document) { return adopt(*new ImageStyleValue(url, document)); } + static NonnullRefPtr create(const URL& url, DOM::Document& document) { return adopt(*new ImageStyleValue(url, document)); } virtual ~ImageStyleValue() override { } String to_string() const override { return String::format("Image{%s}", m_url.to_string().characters()); } @@ -323,13 +323,13 @@ public: const Gfx::Bitmap* bitmap() const { return m_bitmap; } private: - ImageStyleValue(const URL&, Document&); + ImageStyleValue(const URL&, DOM::Document&); // ^ResourceClient virtual void resource_did_load() override; URL m_url; - WeakPtr m_document; + WeakPtr m_document; RefPtr m_bitmap; }; diff --git a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp index 3a111159f3..e24d29d52a 100644 --- a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -108,6 +109,7 @@ struct Interface { // Added for convenience after parsing String wrapper_class; String wrapper_base_class; + String fully_qualified_name; }; OwnPtr parse_interface(const StringView& input) @@ -312,6 +314,9 @@ int main(int argc, char** argv) return 1; } + LexicalPath lexical_path(path); + auto namespace_ = lexical_path.parts().at(lexical_path.parts().size() - 2); + auto data = file_or_error.value()->read_all(); auto interface = IDL::parse_interface(data); @@ -320,6 +325,17 @@ int main(int argc, char** argv) return 1; } + if (namespace_ == "DOM") { + StringBuilder builder; + builder.append(namespace_); + builder.append("::"); + builder.append(interface->name); + interface->fully_qualified_name = builder.to_string(); + } else { + interface->fully_qualified_name = interface->name; + } + + #if 0 dbg() << "Attributes:"; for (auto& attribute : interface->attributes) { @@ -402,22 +418,21 @@ static void generate_header(const IDL::Interface& interface) if (wrapper_base_class != "Wrapper") out() << "#include "; - out() << "namespace Web {"; - out() << "namespace Bindings {"; + out() << "namespace Web::Bindings {"; out() << "class " << wrapper_class << " : public " << wrapper_base_class << " {"; out() << " JS_OBJECT(" << wrapper_class << ", " << wrapper_base_class << ");"; out() << "public:"; - out() << " " << wrapper_class << "(JS::GlobalObject&, " << interface.name << "&);"; + out() << " " << wrapper_class << "(JS::GlobalObject&, " << interface.fully_qualified_name << "&);"; out() << " virtual void initialize(JS::GlobalObject&) override;"; out() << " virtual ~" << wrapper_class << "() override;"; if (wrapper_base_class == "Wrapper") { - out() << " " << interface.name << "& impl() { return *m_impl; }"; - out() << " const " << interface.name << "& impl() const { return *m_impl; }"; + out() << " " << interface.fully_qualified_name << "& impl() { return *m_impl; }"; + out() << " const " << interface.fully_qualified_name << "& impl() const { return *m_impl; }"; } else { - out() << " " << interface.name << "& impl() { return static_cast<" << interface.name << "&>(" << wrapper_base_class << "::impl()); }"; - out() << " const " << interface.name << "& impl() const { return static_cast(" << wrapper_base_class << "::impl()); }"; + out() << " " << interface.fully_qualified_name << "& impl() { return static_cast<" << interface.fully_qualified_name << "&>(" << wrapper_base_class << "::impl()); }"; + out() << " const " << interface.fully_qualified_name << "& impl() const { return static_cast(" << wrapper_base_class << "::impl()); }"; } auto is_foo_wrapper_name = snake_name(String::format("Is%s", wrapper_class.characters())); @@ -436,17 +451,16 @@ static void generate_header(const IDL::Interface& interface) } if (wrapper_base_class == "Wrapper") { - out() << " NonnullRefPtr<" << interface.name << "> m_impl;"; + out() << " NonnullRefPtr<" << interface.fully_qualified_name << "> m_impl;"; } out() << "};"; if (should_emit_wrapper_factory(interface)) { - out() << wrapper_class << "* wrap(JS::GlobalObject&, " << interface.name << "&);"; + out() << wrapper_class << "* wrap(JS::GlobalObject&, " << interface.fully_qualified_name << "&);"; } out() << "}"; - out() << "}"; } void generate_implementation(const IDL::Interface& interface) @@ -473,11 +487,17 @@ void generate_implementation(const IDL::Interface& interface) out() << "#include "; out() << "#include "; - out() << "namespace Web {"; - out() << "namespace Bindings {"; + // FIXME: This is a total hack until we can figure out the namespace for a given type somehow. + out() << "using Web::DOM::Node;"; + out() << "using Web::DOM::Document;"; + out() << "using Web::DOM::DocumentType;"; + out() << "using Web::DOM::Element;"; + out() << "using Web::DOM::EventListener;"; + + out() << "namespace Web::Bindings {"; // Implementation: Wrapper constructor - out() << wrapper_class << "::" << wrapper_class << "(JS::GlobalObject& global_object, " << interface.name << "& impl)"; + out() << wrapper_class << "::" << wrapper_class << "(JS::GlobalObject& global_object, " << interface.fully_qualified_name << "& impl)"; if (wrapper_base_class == "Wrapper") { out() << " : Wrapper(*global_object.object_prototype())"; out() << " , m_impl(impl)"; @@ -510,13 +530,13 @@ void generate_implementation(const IDL::Interface& interface) // Implementation: impl_from() if (!interface.attributes.is_empty() || !interface.functions.is_empty()) { - out() << "static " << interface.name << "* impl_from(JS::Interpreter& interpreter, JS::GlobalObject& global_object)"; + out() << "static " << interface.fully_qualified_name << "* impl_from(JS::Interpreter& interpreter, JS::GlobalObject& global_object)"; out() << "{"; out() << " auto* this_object = interpreter.this_value(global_object).to_object(interpreter, global_object);"; out() << " if (!this_object)"; out() << " return {};"; out() << " if (!this_object->inherits(\"" << wrapper_class << "\")) {"; - out() << " interpreter.throw_exception(JS::ErrorType::NotA, \"" << interface.name << "\");"; + out() << " interpreter.throw_exception(JS::ErrorType::NotA, \"" << interface.fully_qualified_name << "\");"; out() << " return nullptr;"; out() << " }"; out() << " return &static_cast<" << wrapper_class << "*>(this_object)->impl();"; @@ -676,12 +696,11 @@ void generate_implementation(const IDL::Interface& interface) // Implementation: Wrapper factory if (should_emit_wrapper_factory(interface)) { - out() << wrapper_class << "* wrap(JS::GlobalObject& global_object, " << interface.name << "& impl)"; + out() << wrapper_class << "* wrap(JS::GlobalObject& global_object, " << interface.fully_qualified_name << "& impl)"; out() << "{"; out() << " return static_cast<" << wrapper_class << "*>(wrap_impl(global_object, impl));"; out() << "}"; } out() << "}"; - out() << "}"; } diff --git a/Libraries/LibWeb/DOM/CharacterData.cpp b/Libraries/LibWeb/DOM/CharacterData.cpp index a7fa15eb1d..60fb60ef7f 100644 --- a/Libraries/LibWeb/DOM/CharacterData.cpp +++ b/Libraries/LibWeb/DOM/CharacterData.cpp @@ -26,7 +26,7 @@ #include -namespace Web { +namespace Web::DOM { CharacterData::CharacterData(Document& document, NodeType type, const String& data) : Node(document, type) diff --git a/Libraries/LibWeb/DOM/CharacterData.h b/Libraries/LibWeb/DOM/CharacterData.h index 89ec53b48b..4d2a9fd194 100644 --- a/Libraries/LibWeb/DOM/CharacterData.h +++ b/Libraries/LibWeb/DOM/CharacterData.h @@ -29,7 +29,7 @@ #include #include -namespace Web { +namespace Web::DOM { class CharacterData : public Node { public: @@ -49,6 +49,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::CharacterData) -static bool is_type(const Web::Node& node) { return node.is_character_data(); } +AK_BEGIN_TYPE_TRAITS(Web::DOM::CharacterData) +static bool is_type(const Web::DOM::Node& node) { return node.is_character_data(); } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/DOM/Comment.cpp b/Libraries/LibWeb/DOM/Comment.cpp index 0bd30e008e..0814bd0bf6 100644 --- a/Libraries/LibWeb/DOM/Comment.cpp +++ b/Libraries/LibWeb/DOM/Comment.cpp @@ -27,7 +27,7 @@ #include #include -namespace Web { +namespace Web::DOM { Comment::Comment(Document& document, const String& data) : CharacterData(document, NodeType::COMMENT_NODE, data) diff --git a/Libraries/LibWeb/DOM/Comment.h b/Libraries/LibWeb/DOM/Comment.h index c05f788754..f0cdc7907a 100644 --- a/Libraries/LibWeb/DOM/Comment.h +++ b/Libraries/LibWeb/DOM/Comment.h @@ -29,7 +29,7 @@ #include #include -namespace Web { +namespace Web::DOM { class Comment final : public CharacterData { public: @@ -41,6 +41,6 @@ public: } -AK_BEGIN_TYPE_TRAITS(Web::Comment) -static bool is_type(const Web::Node& node) { return node.is_comment(); } +AK_BEGIN_TYPE_TRAITS(Web::DOM::Comment) +static bool is_type(const Web::DOM::Node& node) { return node.is_comment(); } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index c207e55de8..3bd557be1e 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -59,7 +59,7 @@ #include #include -namespace Web { +namespace Web::DOM { Document::Document(const URL& url) : ParentNode(*this, NodeType::DOCUMENT_NODE) @@ -433,7 +433,7 @@ JS::Value Document::run_javascript(const StringView& source) NonnullRefPtr Document::create_element(const String& tag_name) { - return Web::create_element(*this, tag_name); + return DOM::create_element(*this, tag_name); } NonnullRefPtr Document::create_text_node(const String& data) diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h index 6caa5a06dc..3bd43513a0 100644 --- a/Libraries/LibWeb/DOM/Document.h +++ b/Libraries/LibWeb/DOM/Document.h @@ -41,7 +41,7 @@ #include #include -namespace Web { +namespace Web::DOM { enum class QuirksMode { No, @@ -190,7 +190,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::Document) -static bool is_type(const Web::Node& node) { return node.is_document(); } +AK_BEGIN_TYPE_TRAITS(Web::DOM::Document) +static bool is_type(const Web::DOM::Node& node) { return node.is_document(); } AK_END_TYPE_TRAITS() - diff --git a/Libraries/LibWeb/DOM/DocumentFragment.h b/Libraries/LibWeb/DOM/DocumentFragment.h index a92207b5c0..9bc8f39d14 100644 --- a/Libraries/LibWeb/DOM/DocumentFragment.h +++ b/Libraries/LibWeb/DOM/DocumentFragment.h @@ -30,7 +30,7 @@ #include #include -namespace Web { +namespace Web::DOM { class DocumentFragment : public ParentNode @@ -46,6 +46,6 @@ public: } -AK_BEGIN_TYPE_TRAITS(Web::DocumentFragment) -static bool is_type(const Web::Node& node) { return node.is_document_fragment(); } +AK_BEGIN_TYPE_TRAITS(Web::DOM::DocumentFragment) +static bool is_type(const Web::DOM::Node& node) { return node.is_document_fragment(); } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/DOM/DocumentType.cpp b/Libraries/LibWeb/DOM/DocumentType.cpp index c6481f7824..da0f176efc 100644 --- a/Libraries/LibWeb/DOM/DocumentType.cpp +++ b/Libraries/LibWeb/DOM/DocumentType.cpp @@ -26,7 +26,7 @@ #include -namespace Web { +namespace Web::DOM { DocumentType::DocumentType(Document& document) : Node(document, NodeType::DOCUMENT_TYPE_NODE) diff --git a/Libraries/LibWeb/DOM/DocumentType.h b/Libraries/LibWeb/DOM/DocumentType.h index 940204329f..930cd8229a 100644 --- a/Libraries/LibWeb/DOM/DocumentType.h +++ b/Libraries/LibWeb/DOM/DocumentType.h @@ -29,7 +29,7 @@ #include #include -namespace Web { +namespace Web::DOM { class DocumentType final : public Node { public: @@ -57,6 +57,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::DocumentType) -static bool is_type(const Web::Node& node) { return node.type() == Web::NodeType::DOCUMENT_TYPE_NODE; } +AK_BEGIN_TYPE_TRAITS(Web::DOM::DocumentType) +static bool is_type(const Web::DOM::Node& node) { return node.type() == Web::DOM::NodeType::DOCUMENT_TYPE_NODE; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index ec52e4b79a..169c0f254a 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -43,7 +43,7 @@ #include #include -namespace Web { +namespace Web::DOM { Element::Element(Document& document, const FlyString& tag_name) : ParentNode(document, NodeType::ELEMENT_NODE) diff --git a/Libraries/LibWeb/DOM/Element.h b/Libraries/LibWeb/DOM/Element.h index 2c6fecb2d7..12f8b9652c 100644 --- a/Libraries/LibWeb/DOM/Element.h +++ b/Libraries/LibWeb/DOM/Element.h @@ -34,9 +34,7 @@ #include #include -namespace Web { - -class LayoutNodeWithStyle; +namespace Web::DOM { class Element : public ParentNode { public: @@ -101,6 +99,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::Element) -static bool is_type(const Web::Node& node) { return node.is_element(); } +AK_BEGIN_TYPE_TRAITS(Web::DOM::Element) +static bool is_type(const Web::DOM::Node& node) { return node.is_element(); } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/DOM/ElementFactory.cpp b/Libraries/LibWeb/DOM/ElementFactory.cpp index 5b5269de34..37c6705d42 100644 --- a/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -51,7 +51,7 @@ #include #include -namespace Web { +namespace Web::DOM { NonnullRefPtr create_element(Document& document, const FlyString& tag_name) { diff --git a/Libraries/LibWeb/DOM/ElementFactory.h b/Libraries/LibWeb/DOM/ElementFactory.h index 371f571b57..2dc5ac3308 100644 --- a/Libraries/LibWeb/DOM/ElementFactory.h +++ b/Libraries/LibWeb/DOM/ElementFactory.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::DOM { NonnullRefPtr create_element(Document&, const FlyString& tag_name); diff --git a/Libraries/LibWeb/DOM/Event.h b/Libraries/LibWeb/DOM/Event.h index 67c5a5da6a..4755b35b4d 100644 --- a/Libraries/LibWeb/DOM/Event.h +++ b/Libraries/LibWeb/DOM/Event.h @@ -29,7 +29,7 @@ #include #include -namespace Web { +namespace Web::DOM { class Event : public RefCounted diff --git a/Libraries/LibWeb/DOM/EventListener.cpp b/Libraries/LibWeb/DOM/EventListener.cpp index da0c545a6e..eb64bfa503 100644 --- a/Libraries/LibWeb/DOM/EventListener.cpp +++ b/Libraries/LibWeb/DOM/EventListener.cpp @@ -27,7 +27,7 @@ #include #include -namespace Web { +namespace Web::DOM { JS::Function& EventListener::function() { diff --git a/Libraries/LibWeb/DOM/EventListener.h b/Libraries/LibWeb/DOM/EventListener.h index 83e8fd6155..2838d4dcfb 100644 --- a/Libraries/LibWeb/DOM/EventListener.h +++ b/Libraries/LibWeb/DOM/EventListener.h @@ -30,7 +30,7 @@ #include #include -namespace Web { +namespace Web::DOM { class EventListener : public RefCounted diff --git a/Libraries/LibWeb/DOM/EventTarget.cpp b/Libraries/LibWeb/DOM/EventTarget.cpp index 4f543feb61..c923c436ed 100644 --- a/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Libraries/LibWeb/DOM/EventTarget.cpp @@ -27,7 +27,7 @@ #include #include -namespace Web { +namespace Web::DOM { EventTarget::EventTarget() { diff --git a/Libraries/LibWeb/DOM/EventTarget.h b/Libraries/LibWeb/DOM/EventTarget.h index 17e421ec82..9a15ceb0bb 100644 --- a/Libraries/LibWeb/DOM/EventTarget.h +++ b/Libraries/LibWeb/DOM/EventTarget.h @@ -31,7 +31,7 @@ #include #include -namespace Web { +namespace Web::DOM { class EventTarget { AK_MAKE_NONCOPYABLE(EventTarget); diff --git a/Libraries/LibWeb/DOM/MouseEvent.h b/Libraries/LibWeb/DOM/MouseEvent.h index 79b01b5333..f60d3d2f6f 100644 --- a/Libraries/LibWeb/DOM/MouseEvent.h +++ b/Libraries/LibWeb/DOM/MouseEvent.h @@ -28,9 +28,9 @@ #include -namespace Web { +namespace Web::DOM { -class MouseEvent final : public Event { +class MouseEvent final : public DOM::Event { public: using WrapperType = Bindings::MouseEventWrapper; diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp index 3dcc40ad2a..e2b175ad3b 100644 --- a/Libraries/LibWeb/DOM/Node.cpp +++ b/Libraries/LibWeb/DOM/Node.cpp @@ -48,7 +48,7 @@ //#define EVENT_DEBUG -namespace Web { +namespace Web::DOM { Node::Node(Document& document, NodeType type) : m_document(&document) diff --git a/Libraries/LibWeb/DOM/Node.h b/Libraries/LibWeb/DOM/Node.h index 288130a29d..e206ae8ec2 100644 --- a/Libraries/LibWeb/DOM/Node.h +++ b/Libraries/LibWeb/DOM/Node.h @@ -35,7 +35,7 @@ #include #include -namespace Web { +namespace Web::DOM { enum class NodeType : unsigned { INVALID = 0, @@ -47,15 +47,6 @@ enum class NodeType : unsigned { DOCUMENT_FRAGMENT_NODE = 11, }; -class Document; -class Element; -class HTMLElement; -class HTMLAnchorElement; -class ParentNode; -class LayoutNode; -class StyleResolver; -class StyleProperties; - class Node : public TreeNode , public EventTarget diff --git a/Libraries/LibWeb/DOM/NonElementParentNode.h b/Libraries/LibWeb/DOM/NonElementParentNode.h index 837d9ffe3b..14acae72a0 100644 --- a/Libraries/LibWeb/DOM/NonElementParentNode.h +++ b/Libraries/LibWeb/DOM/NonElementParentNode.h @@ -31,7 +31,7 @@ #include #include -namespace Web { +namespace Web::DOM { template class NonElementParentNode { diff --git a/Libraries/LibWeb/DOM/ParentNode.cpp b/Libraries/LibWeb/DOM/ParentNode.cpp index 7042dcaa86..a2f6a2a735 100644 --- a/Libraries/LibWeb/DOM/ParentNode.cpp +++ b/Libraries/LibWeb/DOM/ParentNode.cpp @@ -26,7 +26,7 @@ #include -namespace Web { +namespace Web::DOM { void ParentNode::remove_all_children() { diff --git a/Libraries/LibWeb/DOM/ParentNode.h b/Libraries/LibWeb/DOM/ParentNode.h index 0f3fafab1f..1eaa968c28 100644 --- a/Libraries/LibWeb/DOM/ParentNode.h +++ b/Libraries/LibWeb/DOM/ParentNode.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::DOM { class ParentNode : public Node { public: @@ -60,6 +60,6 @@ inline void ParentNode::for_each_child(Callback callback) } -AK_BEGIN_TYPE_TRAITS(Web::ParentNode) -static bool is_type(const Web::Node& node) { return node.is_parent_node(); } +AK_BEGIN_TYPE_TRAITS(Web::DOM::ParentNode) +static bool is_type(const Web::DOM::Node& node) { return node.is_parent_node(); } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/DOM/Text.cpp b/Libraries/LibWeb/DOM/Text.cpp index 62c17a9725..d3c7e92233 100644 --- a/Libraries/LibWeb/DOM/Text.cpp +++ b/Libraries/LibWeb/DOM/Text.cpp @@ -27,7 +27,7 @@ #include #include -namespace Web { +namespace Web::DOM { Text::Text(Document& document, const String& data) : CharacterData(document, NodeType::TEXT_NODE, data) diff --git a/Libraries/LibWeb/DOM/Text.h b/Libraries/LibWeb/DOM/Text.h index 241da5cbf3..7869df0674 100644 --- a/Libraries/LibWeb/DOM/Text.h +++ b/Libraries/LibWeb/DOM/Text.h @@ -30,7 +30,7 @@ #include #include -namespace Web { +namespace Web::DOM { class Text final : public CharacterData { public: @@ -45,6 +45,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::Text) -static bool is_type(const Web::Node& node) { return node.is_text(); } +AK_BEGIN_TYPE_TRAITS(Web::DOM::Text) +static bool is_type(const Web::DOM::Node& node) { return node.is_text(); } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/DOM/Timer.cpp b/Libraries/LibWeb/DOM/Timer.cpp index 84846eaf36..5b3ac7d572 100644 --- a/Libraries/LibWeb/DOM/Timer.cpp +++ b/Libraries/LibWeb/DOM/Timer.cpp @@ -30,7 +30,7 @@ #include #include -namespace Web { +namespace Web::DOM { NonnullRefPtr Timer::create_interval(Window& window, int milliseconds, JS::Function& callback) { diff --git a/Libraries/LibWeb/DOM/Timer.h b/Libraries/LibWeb/DOM/Timer.h index 562a3cf542..bdecde92d8 100644 --- a/Libraries/LibWeb/DOM/Timer.h +++ b/Libraries/LibWeb/DOM/Timer.h @@ -31,7 +31,7 @@ #include #include -namespace Web { +namespace Web::DOM { class Timer final : public RefCounted { public: diff --git a/Libraries/LibWeb/DOM/Window.cpp b/Libraries/LibWeb/DOM/Window.cpp index c3bf22ac29..46adb627b6 100644 --- a/Libraries/LibWeb/DOM/Window.cpp +++ b/Libraries/LibWeb/DOM/Window.cpp @@ -35,7 +35,7 @@ #include #include -namespace Web { +namespace Web::DOM { NonnullRefPtr Window::create_with_document(Document& document) { diff --git a/Libraries/LibWeb/DOM/Window.h b/Libraries/LibWeb/DOM/Window.h index 4a551fb973..ed70bed472 100644 --- a/Libraries/LibWeb/DOM/Window.h +++ b/Libraries/LibWeb/DOM/Window.h @@ -33,7 +33,7 @@ #include #include -namespace Web { +namespace Web::DOM { class Window : public RefCounted { public: diff --git a/Libraries/LibWeb/DOM/XMLHttpRequest.cpp b/Libraries/LibWeb/DOM/XMLHttpRequest.cpp index 46e41187ad..6dcf43dde7 100644 --- a/Libraries/LibWeb/DOM/XMLHttpRequest.cpp +++ b/Libraries/LibWeb/DOM/XMLHttpRequest.cpp @@ -38,7 +38,7 @@ namespace Web { -XMLHttpRequest::XMLHttpRequest(Window& window) +XMLHttpRequest::XMLHttpRequest(DOM::Window& window) : m_window(window) { } @@ -78,22 +78,22 @@ void XMLHttpRequest::send() return; const_cast(*weak_this).m_response = data; const_cast(*weak_this).set_ready_state(ReadyState::Done); - const_cast(*weak_this).dispatch_event(Event::create("load")); + const_cast(*weak_this).dispatch_event(DOM::Event::create("load")); }, [weak_this = make_weak_ptr()](auto& error) { if (!weak_this) return; dbg() << "XHR failed to load: " << error; const_cast(*weak_this).set_ready_state(ReadyState::Done); - const_cast(*weak_this).dispatch_event(Event::create("error")); + const_cast(*weak_this).dispatch_event(DOM::Event::create("error")); }); } -void XMLHttpRequest::dispatch_event(NonnullRefPtr event) +void XMLHttpRequest::dispatch_event(NonnullRefPtr event) { for (auto& listener : listeners()) { if (listener.event_name == event->type()) { - auto& function = const_cast(*listener.listener).function(); + auto& function = const_cast(*listener.listener).function(); auto& global_object = function.global_object(); auto* this_value = wrap(global_object, *this); JS::MarkedValueList arguments(global_object.heap()); diff --git a/Libraries/LibWeb/DOM/XMLHttpRequest.h b/Libraries/LibWeb/DOM/XMLHttpRequest.h index 0b9917d607..468e18fc5e 100644 --- a/Libraries/LibWeb/DOM/XMLHttpRequest.h +++ b/Libraries/LibWeb/DOM/XMLHttpRequest.h @@ -37,7 +37,7 @@ namespace Web { class XMLHttpRequest final : public RefCounted , public Weakable - , public EventTarget + , public DOM::EventTarget , public Bindings::Wrappable { public: enum class ReadyState { @@ -50,7 +50,7 @@ public: using WrapperType = Bindings::XMLHttpRequestWrapper; - static NonnullRefPtr create(Window& window) { return adopt(*new XMLHttpRequest(window)); } + static NonnullRefPtr create(DOM::Window& window) { return adopt(*new XMLHttpRequest(window)); } virtual ~XMLHttpRequest() override; @@ -65,13 +65,13 @@ public: private: virtual void ref_event_target() override { ref(); } virtual void unref_event_target() override { unref(); } - virtual void dispatch_event(NonnullRefPtr) override; + virtual void dispatch_event(NonnullRefPtr) override; void set_ready_state(ReadyState); - explicit XMLHttpRequest(Window&); + explicit XMLHttpRequest(DOM::Window&); - NonnullRefPtr m_window; + NonnullRefPtr m_window; ReadyState m_ready_state { ReadyState::Unsent }; diff --git a/Libraries/LibWeb/DOMTreeModel.cpp b/Libraries/LibWeb/DOMTreeModel.cpp index e31503fabb..018b42acb1 100644 --- a/Libraries/LibWeb/DOMTreeModel.cpp +++ b/Libraries/LibWeb/DOMTreeModel.cpp @@ -34,7 +34,7 @@ namespace Web { -DOMTreeModel::DOMTreeModel(Document& document) +DOMTreeModel::DOMTreeModel(DOM::Document& document) : m_document(document) { m_document_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png")); @@ -51,7 +51,7 @@ GUI::ModelIndex DOMTreeModel::index(int row, int column, const GUI::ModelIndex& if (!parent.is_valid()) { return create_index(row, column, m_document.ptr()); } - auto& parent_node = *static_cast(parent.internal_data()); + auto& parent_node = *static_cast(parent.internal_data()); return create_index(row, column, parent_node.child_at_index(row)); } @@ -59,7 +59,7 @@ GUI::ModelIndex DOMTreeModel::parent_index(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; - auto& node = *static_cast(index.internal_data()); + auto& node = *static_cast(index.internal_data()); if (!node.parent()) return {}; @@ -85,7 +85,7 @@ int DOMTreeModel::row_count(const GUI::ModelIndex& index) const { if (!index.is_valid()) return 1; - auto& node = *static_cast(index.internal_data()); + auto& node = *static_cast(index.internal_data()); return node.child_count(); } @@ -117,7 +117,7 @@ static String with_whitespace_collapsed(const StringView& string) GUI::Variant DOMTreeModel::data(const GUI::ModelIndex& index, Role role) const { - auto& node = *static_cast(index.internal_data()); + auto& node = *static_cast(index.internal_data()); if (role == Role::Icon) { if (node.is_document()) return m_document_icon; @@ -128,10 +128,10 @@ GUI::Variant DOMTreeModel::data(const GUI::ModelIndex& index, Role role) const } if (role == Role::Display) { if (node.is_text()) - return String::format("%s", with_whitespace_collapsed(downcast(node).data()).characters()); + return String::format("%s", with_whitespace_collapsed(downcast(node).data()).characters()); if (!node.is_element()) return node.node_name(); - auto& element = downcast(node); + auto& element = downcast(node); StringBuilder builder; builder.append('<'); builder.append(element.local_name()); diff --git a/Libraries/LibWeb/DOMTreeModel.h b/Libraries/LibWeb/DOMTreeModel.h index 9e498ca4ed..d023d39f0d 100644 --- a/Libraries/LibWeb/DOMTreeModel.h +++ b/Libraries/LibWeb/DOMTreeModel.h @@ -27,14 +27,13 @@ #pragma once #include +#include namespace Web { -class Document; - class DOMTreeModel final : public GUI::Model { public: - static NonnullRefPtr create(Document& document) + static NonnullRefPtr create(DOM::Document& document) { return adopt(*new DOMTreeModel(document)); } @@ -49,9 +48,9 @@ public: virtual void update() override; private: - explicit DOMTreeModel(Document&); + explicit DOMTreeModel(DOM::Document&); - NonnullRefPtr m_document; + NonnullRefPtr m_document; GUI::Icon m_document_icon; GUI::Icon m_element_icon; diff --git a/Libraries/LibWeb/Dump.cpp b/Libraries/LibWeb/Dump.cpp index 8704827dd7..6023e2157e 100644 --- a/Libraries/LibWeb/Dump.cpp +++ b/Libraries/LibWeb/Dump.cpp @@ -43,31 +43,31 @@ namespace Web { -void dump_tree(const Node& node) +void dump_tree(const DOM::Node& node) { static int indent = 0; for (int i = 0; i < indent; ++i) dbgprintf(" "); - if (is(node)) { + if (is(node)) { dbgprintf("*Document*\n"); - } else if (is(node)) { - dbgprintf("<%s", downcast(node).local_name().characters()); - downcast(node).for_each_attribute([](auto& name, auto& value) { + } else if (is(node)) { + dbgprintf("<%s", downcast(node).local_name().characters()); + downcast(node).for_each_attribute([](auto& name, auto& value) { dbgprintf(" %s=%s", name.characters(), value.characters()); }); dbgprintf(">\n"); - } else if (is(node)) { - dbgprintf("\"%s\"\n", static_cast(node).data().characters()); - } else if (is(node)) { + } else if (is(node)) { + dbgprintf("\"%s\"\n", downcast(node).data().characters()); + } else if (is(node)) { dbgprintf("\n"); - } else if (is(node)) { - dbgprintf("\n", downcast(node).data().characters()); - } else if (is(node)) { + } else if (is(node)) { + dbgprintf("\n", downcast(node).data().characters()); + } else if (is(node)) { dbgprintf("#document-fragment\n"); } ++indent; - if (is(node)) { - static_cast(node).for_each_child([](auto& child) { + if (is(node)) { + static_cast(node).for_each_child([](auto& child) { dump_tree(child); }); } @@ -83,18 +83,18 @@ void dump_tree(const LayoutNode& layout_node) FlyString tag_name; if (layout_node.is_anonymous()) tag_name = "(anonymous)"; - else if (is(layout_node.node())) + else if (is(layout_node.node())) tag_name = "#text"; - else if (is(layout_node.node())) + else if (is(layout_node.node())) tag_name = "#document"; - else if (is(layout_node.node())) - tag_name = downcast(*layout_node.node()).local_name(); + else if (is(layout_node.node())) + tag_name = downcast(*layout_node.node()).local_name(); else tag_name = "???"; String identifier = ""; - if (layout_node.node() && is(*layout_node.node())) { - auto& element = downcast(*layout_node.node()); + if (layout_node.node() && is(*layout_node.node())) { + auto& element = downcast(*layout_node.node()); StringBuilder builder; auto id = element.attribute(HTML::AttributeNames::id); if (!id.is_empty()) { diff --git a/Libraries/LibWeb/Dump.h b/Libraries/LibWeb/Dump.h index 8108819761..c3e4bef3a6 100644 --- a/Libraries/LibWeb/Dump.h +++ b/Libraries/LibWeb/Dump.h @@ -30,7 +30,7 @@ namespace Web { -void dump_tree(const Node&); +void dump_tree(const DOM::Node&); void dump_tree(const LayoutNode&); void dump_sheet(const StyleSheet&); void dump_rule(const StyleRule&); diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index f4adf32456..a9d3f1b592 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -26,9 +26,7 @@ #pragma once -namespace Web { - -class CanvasRenderingContext2D; +namespace Web::DOM { class Document; class DocumentType; class Element; @@ -36,7 +34,19 @@ class Event; class EventHandler; class EventListener; class EventTarget; +class MouseEvent; +class Node; +class ParentNode; +class Text; +class Timer; +class Window; +enum class QuirksMode; +} + +namespace Web { +class CanvasRenderingContext2D; class Frame; +class HTMLAnchorElement; class HTMLBodyElement; class HTMLCanvasElement; class HTMLDocumentParser; @@ -46,35 +56,29 @@ class HTMLHeadElement; class HTMLHtmlElement; class HTMLImageElement; class HTMLScriptElement; -class PageView; class ImageData; -class LineBox; -class LineBoxFragment; class LayoutBlock; class LayoutDocument; class LayoutNode; class LayoutNodeWithStyle; class LayoutReplaced; +class LineBox; +class LineBoxFragment; class LoadRequest; -class MouseEvent; -class Node; class Origin; class Page; class PageClient; +class PageView; class PaintContext; class Resource; class ResourceLoader; class Selector; class StackingContext; +class StyleProperties; class StyleResolver; class StyleRule; class StyleSheet; -class Text; -class Timer; -class Window; class XMLHttpRequest; -enum class QuirksMode; - } namespace Web::Bindings { diff --git a/Libraries/LibWeb/Frame/EventHandler.cpp b/Libraries/LibWeb/Frame/EventHandler.cpp index f95661e31f..c6a340a4ef 100644 --- a/Libraries/LibWeb/Frame/EventHandler.cpp +++ b/Libraries/LibWeb/Frame/EventHandler.cpp @@ -78,14 +78,14 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button auto result = layout_root()->hit_test(position); if (result.layout_node && result.layout_node->node()) { - RefPtr node = result.layout_node->node(); + RefPtr node = result.layout_node->node(); if (is(*node)) { if (auto* subframe = downcast(*node).hosted_frame()) return subframe->event_handler().handle_mouseup(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers); return false; } auto offset = compute_mouse_event_offset(position, *result.layout_node); - node->dispatch_event(MouseEvent::create("mouseup", offset.x(), offset.y())); + node->dispatch_event(DOM::MouseEvent::create("mouseup", offset.x(), offset.y())); handled_event = true; } @@ -107,7 +107,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt if (!result.layout_node) return false; - RefPtr node = result.layout_node->node(); + RefPtr node = result.layout_node->node(); document->set_hovered_node(node); if (!node) return false; @@ -119,7 +119,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt } auto offset = compute_mouse_event_offset(position, *result.layout_node); - node->dispatch_event(MouseEvent::create("mousedown", offset.x(), offset.y())); + node->dispatch_event(DOM::MouseEvent::create("mousedown", offset.x(), offset.y())); if (!layout_root()) return true; @@ -173,7 +173,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt auto result = layout_root()->hit_test(position); const HTMLAnchorElement* hovered_link_element = nullptr; if (result.layout_node) { - RefPtr node = result.layout_node->node(); + RefPtr node = result.layout_node->node(); if (node && is(*node)) { if (auto* subframe = downcast(*node).hosted_frame()) @@ -192,7 +192,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt is_hovering_link = true; } auto offset = compute_mouse_event_offset(position, *result.layout_node); - node->dispatch_event(MouseEvent::create("mousemove", offset.x(), offset.y())); + node->dispatch_event(DOM::MouseEvent::create("mousemove", offset.x(), offset.y())); if (!layout_root()) return true; } diff --git a/Libraries/LibWeb/Frame/Frame.cpp b/Libraries/LibWeb/Frame/Frame.cpp index 0631a20595..a0e67047c8 100644 --- a/Libraries/LibWeb/Frame/Frame.cpp +++ b/Libraries/LibWeb/Frame/Frame.cpp @@ -33,7 +33,7 @@ namespace Web { -Frame::Frame(Element& host_element, Frame& main_frame) +Frame::Frame(DOM::Element& host_element, Frame& main_frame) : m_page(main_frame.page()) , m_main_frame(main_frame) , m_loader(*this) @@ -54,7 +54,7 @@ Frame::~Frame() { } -void Frame::set_document(Document* document) +void Frame::set_document(DOM::Document* document) { if (m_document == document) return; diff --git a/Libraries/LibWeb/Frame/Frame.h b/Libraries/LibWeb/Frame/Frame.h index 0b17362975..4e171adca6 100644 --- a/Libraries/LibWeb/Frame/Frame.h +++ b/Libraries/LibWeb/Frame/Frame.h @@ -41,16 +41,16 @@ namespace Web { class Frame : public TreeNode { public: - static NonnullRefPtr create_subframe(Element& host_element, Frame& main_frame) { return adopt(*new Frame(host_element, main_frame)); } + static NonnullRefPtr create_subframe(DOM::Element& host_element, Frame& main_frame) { return adopt(*new Frame(host_element, main_frame)); } static NonnullRefPtr create(Page& page) { return adopt(*new Frame(page)); } ~Frame(); bool is_main_frame() const { return this == &m_main_frame; } - const Document* document() const { return m_document; } - Document* document() { return m_document; } + const DOM::Document* document() const { return m_document; } + DOM::Document* document() { return m_document; } - void set_document(Document*); + void set_document(DOM::Document*); Page& page() { return m_page; } const Page& page() const { return m_page; } @@ -77,15 +77,15 @@ public: Frame& main_frame() { return m_main_frame; } const Frame& main_frame() const { return m_main_frame; } - Element* host_element() { return m_host_element; } - const Element* host_element() const { return m_host_element; } + DOM::Element* host_element() { return m_host_element; } + const DOM::Element* host_element() const { return m_host_element; } Gfx::IntPoint to_main_frame_position(const Gfx::IntPoint&); Gfx::IntRect to_main_frame_rect(const Gfx::IntRect&); private: - explicit Frame(Element& host_element, Frame& main_frame); + explicit Frame(DOM::Element& host_element, Frame& main_frame); explicit Frame(Page&); Page& m_page; @@ -94,8 +94,8 @@ private: FrameLoader m_loader; EventHandler m_event_handler; - WeakPtr m_host_element; - RefPtr m_document; + WeakPtr m_host_element; + RefPtr m_document; Gfx::IntSize m_size; Gfx::IntRect m_viewport_rect; }; diff --git a/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp b/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp index 4d014bd5e8..8657759625 100644 --- a/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp @@ -28,7 +28,7 @@ namespace Web { -HTMLAnchorElement::HTMLAnchorElement(Document& document, const FlyString& tag_name) +HTMLAnchorElement::HTMLAnchorElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLAnchorElement.h b/Libraries/LibWeb/HTML/HTMLAnchorElement.h index 66432a8e5d..b4fb47ece3 100644 --- a/Libraries/LibWeb/HTML/HTMLAnchorElement.h +++ b/Libraries/LibWeb/HTML/HTMLAnchorElement.h @@ -32,7 +32,7 @@ namespace Web { class HTMLAnchorElement : public HTMLElement { public: - HTMLAnchorElement(Document&, const FlyString& local_name); + HTMLAnchorElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLAnchorElement() override; String href() const { return attribute(HTML::AttributeNames::href); } @@ -42,5 +42,5 @@ public: } AK_BEGIN_TYPE_TRAITS(Web::HTMLAnchorElement) -static bool is_type(const Web::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::a; } +static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::a; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLBRElement.cpp b/Libraries/LibWeb/HTML/HTMLBRElement.cpp index b4f7f1ac64..ac2c4125a4 100644 --- a/Libraries/LibWeb/HTML/HTMLBRElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLBRElement.cpp @@ -29,7 +29,7 @@ namespace Web { -HTMLBRElement::HTMLBRElement(Document& document, const FlyString& tag_name) +HTMLBRElement::HTMLBRElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLBRElement.h b/Libraries/LibWeb/HTML/HTMLBRElement.h index 051e4d5cc7..e8ca242eea 100644 --- a/Libraries/LibWeb/HTML/HTMLBRElement.h +++ b/Libraries/LibWeb/HTML/HTMLBRElement.h @@ -32,7 +32,7 @@ namespace Web { class HTMLBRElement final : public HTMLElement { public: - HTMLBRElement(Document&, const FlyString& local_name); + HTMLBRElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLBRElement() override; virtual RefPtr create_layout_node(const StyleProperties* parent_style) override; @@ -41,5 +41,5 @@ public: } AK_BEGIN_TYPE_TRAITS(Web::HTMLBRElement) -static bool is_type(const Web::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::br; } +static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::br; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLBlinkElement.cpp b/Libraries/LibWeb/HTML/HTMLBlinkElement.cpp index f3aeaae58e..6c1648e83e 100644 --- a/Libraries/LibWeb/HTML/HTMLBlinkElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLBlinkElement.cpp @@ -32,7 +32,7 @@ namespace Web { -HTMLBlinkElement::HTMLBlinkElement(Document& document, const FlyString& tag_name) +HTMLBlinkElement::HTMLBlinkElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) , m_timer(Core::Timer::construct()) { diff --git a/Libraries/LibWeb/HTML/HTMLBlinkElement.h b/Libraries/LibWeb/HTML/HTMLBlinkElement.h index ca44276697..4b8f731ed3 100644 --- a/Libraries/LibWeb/HTML/HTMLBlinkElement.h +++ b/Libraries/LibWeb/HTML/HTMLBlinkElement.h @@ -33,7 +33,7 @@ namespace Web { class HTMLBlinkElement : public HTMLElement { public: - HTMLBlinkElement(Document&, const FlyString& local_name); + HTMLBlinkElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLBlinkElement() override; private: @@ -45,5 +45,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::HTMLBlinkElement) -static bool is_type(const Web::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::blink; } +static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::blink; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLBodyElement.cpp b/Libraries/LibWeb/HTML/HTMLBodyElement.cpp index 80ae2f73e7..846b48f696 100644 --- a/Libraries/LibWeb/HTML/HTMLBodyElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLBodyElement.cpp @@ -31,7 +31,7 @@ namespace Web { -HTMLBodyElement::HTMLBodyElement(Document& document, const FlyString& tag_name) +HTMLBodyElement::HTMLBodyElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } @@ -74,7 +74,7 @@ void HTMLBodyElement::parse_attribute(const FlyString& name, const String& value if (color.has_value()) document().set_visited_link_color(color.value()); } else if (name.equals_ignoring_case("background")) { - m_background_style_value = ImageStyleValue::create(document().complete_url(value), const_cast(document())); + m_background_style_value = ImageStyleValue::create(document().complete_url(value), const_cast(document())); } } diff --git a/Libraries/LibWeb/HTML/HTMLBodyElement.h b/Libraries/LibWeb/HTML/HTMLBodyElement.h index 66b3fe2133..fe14fc86db 100644 --- a/Libraries/LibWeb/HTML/HTMLBodyElement.h +++ b/Libraries/LibWeb/HTML/HTMLBodyElement.h @@ -32,7 +32,7 @@ namespace Web { class HTMLBodyElement : public HTMLElement { public: - HTMLBodyElement(Document&, const FlyString& local_name); + HTMLBodyElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLBodyElement() override; virtual void parse_attribute(const FlyString&, const String&) override; @@ -45,5 +45,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::HTMLBodyElement) -static bool is_type(const Web::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::body; } +static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::body; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index 3522733d3e..811b181eaf 100644 --- a/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -36,7 +36,7 @@ namespace Web { static constexpr auto max_canvas_area = 16384 * 16384; -HTMLCanvasElement::HTMLCanvasElement(Document& document, const FlyString& tag_name) +HTMLCanvasElement::HTMLCanvasElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLCanvasElement.h b/Libraries/LibWeb/HTML/HTMLCanvasElement.h index 1e2721f2b6..de25f2ba7c 100644 --- a/Libraries/LibWeb/HTML/HTMLCanvasElement.h +++ b/Libraries/LibWeb/HTML/HTMLCanvasElement.h @@ -38,7 +38,7 @@ class HTMLCanvasElement : public HTMLElement { public: using WrapperType = Bindings::HTMLCanvasElementWrapper; - HTMLCanvasElement(Document&, const FlyString& local_name); + HTMLCanvasElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLCanvasElement() override; const Gfx::Bitmap* bitmap() const { return m_bitmap; } @@ -60,5 +60,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::HTMLCanvasElement) -static bool is_type(const Web::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::canvas; } +static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::canvas; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLElement.cpp b/Libraries/LibWeb/HTML/HTMLElement.cpp index e3148f4c71..e976aae3c9 100644 --- a/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -28,7 +28,7 @@ namespace Web { -HTMLElement::HTMLElement(Document& document, const FlyString& tag_name) +HTMLElement::HTMLElement(DOM::Document& document, const FlyString& tag_name) : Element(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLElement.h b/Libraries/LibWeb/HTML/HTMLElement.h index 91af28ace8..1bf814fb40 100644 --- a/Libraries/LibWeb/HTML/HTMLElement.h +++ b/Libraries/LibWeb/HTML/HTMLElement.h @@ -30,11 +30,11 @@ namespace Web { -class HTMLElement : public Element { +class HTMLElement : public DOM::Element { public: using WrapperType = Bindings::HTMLElementWrapper; - HTMLElement(Document&, const FlyString& local_name); + HTMLElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLElement() override; String title() const { return attribute(HTML::AttributeNames::title); } @@ -46,5 +46,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::HTMLElement) -static bool is_type(const Web::Node& node) { return node.is_html_element(); } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element(); } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLFontElement.cpp b/Libraries/LibWeb/HTML/HTMLFontElement.cpp index adb0a52285..b4cef27c92 100644 --- a/Libraries/LibWeb/HTML/HTMLFontElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLFontElement.cpp @@ -30,7 +30,7 @@ namespace Web { -HTMLFontElement::HTMLFontElement(Document& document, const FlyString& tag_name) +HTMLFontElement::HTMLFontElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLFontElement.h b/Libraries/LibWeb/HTML/HTMLFontElement.h index 7b453989c2..ff787e023e 100644 --- a/Libraries/LibWeb/HTML/HTMLFontElement.h +++ b/Libraries/LibWeb/HTML/HTMLFontElement.h @@ -32,7 +32,7 @@ namespace Web { class HTMLFontElement : public HTMLElement { public: - HTMLFontElement(Document&, const FlyString& local_name); + HTMLFontElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLFontElement() override; virtual void apply_presentational_hints(StyleProperties&) const override; @@ -41,5 +41,5 @@ public: } AK_BEGIN_TYPE_TRAITS(Web::HTMLFontElement) -static bool is_type(const Web::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::font; } +static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::font; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Libraries/LibWeb/HTML/HTMLFormElement.cpp index 3fca0f4a67..3d4e216a96 100644 --- a/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -33,7 +33,7 @@ namespace Web { -HTMLFormElement::HTMLFormElement(Document& document, const FlyString& tag_name) +HTMLFormElement::HTMLFormElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.h b/Libraries/LibWeb/HTML/HTMLFormElement.h index 68fb24e07d..ca0c3e6e26 100644 --- a/Libraries/LibWeb/HTML/HTMLFormElement.h +++ b/Libraries/LibWeb/HTML/HTMLFormElement.h @@ -33,7 +33,7 @@ namespace Web { class HTMLFormElement : public HTMLElement { public: - HTMLFormElement(Document&, const FlyString& local_name); + HTMLFormElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLFormElement() override; String action() const { return attribute(HTML::AttributeNames::action); } @@ -45,5 +45,5 @@ public: } AK_BEGIN_TYPE_TRAITS(Web::HTMLFormElement) -static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::form; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::form; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLHRElement.cpp b/Libraries/LibWeb/HTML/HTMLHRElement.cpp index d1458ea299..2d403392ff 100644 --- a/Libraries/LibWeb/HTML/HTMLHRElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLHRElement.cpp @@ -28,7 +28,7 @@ namespace Web { -HTMLHRElement::HTMLHRElement(Document& document, const FlyString& tag_name) +HTMLHRElement::HTMLHRElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLHRElement.h b/Libraries/LibWeb/HTML/HTMLHRElement.h index 0cbef63841..12c72e406d 100644 --- a/Libraries/LibWeb/HTML/HTMLHRElement.h +++ b/Libraries/LibWeb/HTML/HTMLHRElement.h @@ -32,12 +32,12 @@ namespace Web { class HTMLHRElement : public HTMLElement { public: - HTMLHRElement(Document&, const FlyString& local_name); + HTMLHRElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLHRElement() override; }; } AK_BEGIN_TYPE_TRAITS(Web::HTMLHRElement) -static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::hr; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::hr; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLHeadElement.cpp b/Libraries/LibWeb/HTML/HTMLHeadElement.cpp index 5331177ebf..aade728d5b 100644 --- a/Libraries/LibWeb/HTML/HTMLHeadElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLHeadElement.cpp @@ -28,7 +28,7 @@ namespace Web { -HTMLHeadElement::HTMLHeadElement(Document& document, const FlyString& tag_name) +HTMLHeadElement::HTMLHeadElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLHeadElement.h b/Libraries/LibWeb/HTML/HTMLHeadElement.h index 050d4db344..8f2b7e9681 100644 --- a/Libraries/LibWeb/HTML/HTMLHeadElement.h +++ b/Libraries/LibWeb/HTML/HTMLHeadElement.h @@ -32,12 +32,12 @@ namespace Web { class HTMLHeadElement : public HTMLElement { public: - HTMLHeadElement(Document&, const FlyString& local_name); + HTMLHeadElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLHeadElement() override; }; } AK_BEGIN_TYPE_TRAITS(Web::HTMLHeadElement) -static bool is_type(const Web::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::head; } +static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::head; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp b/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp index 1ab6aeef3d..48c22e7b90 100644 --- a/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp @@ -28,7 +28,7 @@ namespace Web { -HTMLHeadingElement::HTMLHeadingElement(Document& document, const FlyString& tag_name) +HTMLHeadingElement::HTMLHeadingElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLHeadingElement.h b/Libraries/LibWeb/HTML/HTMLHeadingElement.h index c8f2617160..0cf80fdb41 100644 --- a/Libraries/LibWeb/HTML/HTMLHeadingElement.h +++ b/Libraries/LibWeb/HTML/HTMLHeadingElement.h @@ -32,7 +32,7 @@ namespace Web { class HTMLHeadingElement : public HTMLElement { public: - HTMLHeadingElement(Document&, const FlyString& local_name); + HTMLHeadingElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLHeadingElement() override; }; diff --git a/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp b/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp index 4ee10a5850..1c91ded368 100644 --- a/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp @@ -28,7 +28,7 @@ namespace Web { -HTMLHtmlElement::HTMLHtmlElement(Document& document, const FlyString& tag_name) +HTMLHtmlElement::HTMLHtmlElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLHtmlElement.h b/Libraries/LibWeb/HTML/HTMLHtmlElement.h index 14b28ec11a..a99cc73cdb 100644 --- a/Libraries/LibWeb/HTML/HTMLHtmlElement.h +++ b/Libraries/LibWeb/HTML/HTMLHtmlElement.h @@ -32,12 +32,12 @@ namespace Web { class HTMLHtmlElement : public HTMLElement { public: - HTMLHtmlElement(Document&, const FlyString& local_name); + HTMLHtmlElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLHtmlElement() override; }; } AK_BEGIN_TYPE_TRAITS(Web::HTMLHtmlElement) -static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::html; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::html; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 8925783fa7..70618881b7 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -41,7 +41,7 @@ namespace Web { -HTMLIFrameElement::HTMLIFrameElement(Document& document, const FlyString& tag_name) +HTMLIFrameElement::HTMLIFrameElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } @@ -82,7 +82,7 @@ void HTMLIFrameElement::load_src(const String& value) m_hosted_frame->loader().load(url, FrameLoader::Type::IFrame); } -const Document* HTMLIFrameElement::hosted_document() const +const DOM::Document* HTMLIFrameElement::hosted_document() const { return m_hosted_frame ? m_hosted_frame->document() : nullptr; } diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.h b/Libraries/LibWeb/HTML/HTMLIFrameElement.h index 27ff1ca43c..2948db0d41 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.h +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.h @@ -32,7 +32,7 @@ namespace Web { class HTMLIFrameElement final : public HTMLElement { public: - HTMLIFrameElement(Document&, const FlyString& local_name); + HTMLIFrameElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLIFrameElement() override; virtual RefPtr create_layout_node(const StyleProperties* parent_style) override; @@ -40,7 +40,7 @@ public: Frame* hosted_frame() { return m_hosted_frame; } const Frame* hosted_frame() const { return m_hosted_frame; } - const Document* hosted_document() const; + const DOM::Document* hosted_document() const; private: virtual void document_did_attach_to_frame(Frame&) override; @@ -54,5 +54,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::HTMLIFrameElement) -static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::iframe; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::iframe; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Libraries/LibWeb/HTML/HTMLImageElement.cpp index a7e545cebe..45adbd6f3c 100644 --- a/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -37,18 +37,18 @@ namespace Web { -HTMLImageElement::HTMLImageElement(Document& document, const FlyString& tag_name) +HTMLImageElement::HTMLImageElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { m_image_loader.on_load = [this] { this->document().update_layout(); - dispatch_event(Event::create("load")); + dispatch_event(DOM::Event::create("load")); }; m_image_loader.on_fail = [this] { dbg() << "HTMLImageElement: Resource did fail: " << this->src(); this->document().update_layout(); - dispatch_event(Event::create("error")); + dispatch_event(DOM::Event::create("error")); }; m_image_loader.on_animate = [this] { diff --git a/Libraries/LibWeb/HTML/HTMLImageElement.h b/Libraries/LibWeb/HTML/HTMLImageElement.h index 432df2fc89..2d991a5551 100644 --- a/Libraries/LibWeb/HTML/HTMLImageElement.h +++ b/Libraries/LibWeb/HTML/HTMLImageElement.h @@ -40,7 +40,7 @@ class HTMLImageElement final : public HTMLElement { public: using WrapperType = Bindings::HTMLImageElementWrapper; - HTMLImageElement(Document&, const FlyString& local_name); + HTMLImageElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLImageElement() override; virtual void parse_attribute(const FlyString& name, const String& value) override; @@ -63,5 +63,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::HTMLImageElement) -static bool is_type(const Web::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::img; } +static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::img; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 8d80808f6d..8883aba3e8 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -37,7 +37,7 @@ namespace Web { -HTMLInputElement::HTMLInputElement(Document& document, const FlyString& tag_name) +HTMLInputElement::HTMLInputElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } @@ -76,7 +76,7 @@ RefPtr HTMLInputElement::create_layout_node(const StyleProperties* p int text_width = Gfx::Font::default_font().width(value()); button.set_relative_rect(0, 0, text_width + 20, 20); button.on_click = [this](auto) { - const_cast(this)->dispatch_event(Event::create("click")); + const_cast(this)->dispatch_event(DOM::Event::create("click")); }; widget = button; } else { diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.h b/Libraries/LibWeb/HTML/HTMLInputElement.h index 4b438357c4..2a97ad3f34 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -32,7 +32,7 @@ namespace Web { class HTMLInputElement : public HTMLElement { public: - HTMLInputElement(Document&, const FlyString& local_name); + HTMLInputElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLInputElement() override; virtual RefPtr create_layout_node(const StyleProperties* parent_style) override; @@ -45,5 +45,5 @@ public: } AK_BEGIN_TYPE_TRAITS(Web::HTMLInputElement) -static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::input; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::input; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index e0fb62114c..adb9ce12ff 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -34,7 +34,7 @@ namespace Web { -HTMLLinkElement::HTMLLinkElement(Document& document, const FlyString& tag_name) +HTMLLinkElement::HTMLLinkElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.h b/Libraries/LibWeb/HTML/HTMLLinkElement.h index 42b6f9ac75..66f01dc3ce 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.h +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.h @@ -35,7 +35,7 @@ class HTMLLinkElement final : public HTMLElement , public ResourceClient { public: - HTMLLinkElement(Document&, const FlyString& local_name); + HTMLLinkElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLLinkElement() override; virtual void inserted_into(Node&) override; @@ -67,5 +67,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::HTMLLinkElement) -static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::link; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::link; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index e15e05c390..ab47676ca7 100644 --- a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -35,7 +35,7 @@ namespace Web { -HTMLObjectElement::HTMLObjectElement(Document& document, const FlyString& tag_name) +HTMLObjectElement::HTMLObjectElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { m_image_loader.on_load = [this] { diff --git a/Libraries/LibWeb/HTML/HTMLObjectElement.h b/Libraries/LibWeb/HTML/HTMLObjectElement.h index 6b05b5e503..e3dddab938 100644 --- a/Libraries/LibWeb/HTML/HTMLObjectElement.h +++ b/Libraries/LibWeb/HTML/HTMLObjectElement.h @@ -37,7 +37,7 @@ class LayoutDocument; class HTMLObjectElement final : public HTMLElement { public: - HTMLObjectElement(Document&, const FlyString& local_name); + HTMLObjectElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLObjectElement() override; virtual void parse_attribute(const FlyString& name, const String& value) override; @@ -55,5 +55,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::HTMLObjectElement) -static bool is_type(const Web::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::object; } +static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::object; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 38739f56f9..a30825ab05 100644 --- a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -34,7 +34,7 @@ namespace Web { -HTMLScriptElement::HTMLScriptElement(Document& document, const FlyString& tag_name) +HTMLScriptElement::HTMLScriptElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } @@ -43,7 +43,7 @@ HTMLScriptElement::~HTMLScriptElement() { } -void HTMLScriptElement::set_parser_document(Badge, Document& document) +void HTMLScriptElement::set_parser_document(Badge, DOM::Document& document) { m_parser_document = document.make_weak_ptr(); } @@ -62,7 +62,7 @@ void HTMLScriptElement::prepare_script(Badge) { if (m_already_started) return; - RefPtr parser_document = m_parser_document.ptr(); + RefPtr parser_document = m_parser_document.ptr(); m_parser_document = nullptr; if (parser_document && !has_attribute(HTML::AttributeNames::async)) { diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.h b/Libraries/LibWeb/HTML/HTMLScriptElement.h index 8d941b270d..9cb0fa953e 100644 --- a/Libraries/LibWeb/HTML/HTMLScriptElement.h +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.h @@ -33,14 +33,14 @@ namespace Web { class HTMLScriptElement : public HTMLElement { public: - HTMLScriptElement(Document&, const FlyString& local_name); + HTMLScriptElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLScriptElement() override; bool is_non_blocking() const { return m_non_blocking; } bool is_ready_to_be_parser_executed() const { return m_ready_to_be_parser_executed; } bool failed_to_load() const { return m_failed_to_load; } - void set_parser_document(Badge, Document&); + void set_parser_document(Badge, DOM::Document&); void set_non_blocking(Badge, bool); void set_already_started(Badge, bool b) { m_already_started = b; } void prepare_script(Badge); @@ -50,8 +50,8 @@ private: void script_became_ready(); void when_the_script_is_ready(Function); - WeakPtr m_parser_document; - WeakPtr m_preparation_time_document; + WeakPtr m_parser_document; + WeakPtr m_preparation_time_document; bool m_non_blocking { false }; bool m_already_started { false }; bool m_parser_inserted { false }; @@ -68,5 +68,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::HTMLScriptElement) -static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::script; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::script; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLStyleElement.cpp b/Libraries/LibWeb/HTML/HTMLStyleElement.cpp index 841203dfc6..38b1626044 100644 --- a/Libraries/LibWeb/HTML/HTMLStyleElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLStyleElement.cpp @@ -32,7 +32,7 @@ namespace Web { -HTMLStyleElement::HTMLStyleElement(Document& document, const FlyString& tag_name) +HTMLStyleElement::HTMLStyleElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } @@ -45,8 +45,8 @@ void HTMLStyleElement::children_changed() { StringBuilder builder; for_each_child([&](auto& child) { - if (is(child)) - builder.append(downcast(child).text_content()); + if (is(child)) + builder.append(downcast(child).text_content()); }); m_stylesheet = parse_css(CSS::ParsingContext(document()), builder.to_string()); if (m_stylesheet) diff --git a/Libraries/LibWeb/HTML/HTMLStyleElement.h b/Libraries/LibWeb/HTML/HTMLStyleElement.h index 217d277e7f..d0a974962c 100644 --- a/Libraries/LibWeb/HTML/HTMLStyleElement.h +++ b/Libraries/LibWeb/HTML/HTMLStyleElement.h @@ -34,7 +34,7 @@ class StyleSheet; class HTMLStyleElement : public HTMLElement { public: - HTMLStyleElement(Document&, const FlyString& local_name); + HTMLStyleElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLStyleElement() override; virtual void children_changed() override; @@ -47,5 +47,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::HTMLStyleElement) -static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::style; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::style; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp index 98beb030bb..2be05a7475 100644 --- a/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp @@ -29,7 +29,7 @@ namespace Web { -HTMLTableCellElement::HTMLTableCellElement(Document& document, const FlyString& tag_name) +HTMLTableCellElement::HTMLTableCellElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLTableCellElement.h b/Libraries/LibWeb/HTML/HTMLTableCellElement.h index 06bde35ffb..e8e50ce343 100644 --- a/Libraries/LibWeb/HTML/HTMLTableCellElement.h +++ b/Libraries/LibWeb/HTML/HTMLTableCellElement.h @@ -32,7 +32,7 @@ namespace Web { class HTMLTableCellElement final : public HTMLElement { public: - HTMLTableCellElement(Document&, const FlyString& local_name); + HTMLTableCellElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLTableCellElement() override; private: @@ -42,5 +42,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::HTMLTableCellElement) -static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::td; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::td; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Libraries/LibWeb/HTML/HTMLTableElement.cpp index fabc7eb121..33cfa299f4 100644 --- a/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -29,7 +29,7 @@ namespace Web { -HTMLTableElement::HTMLTableElement(Document& document, const FlyString& tag_name) +HTMLTableElement::HTMLTableElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLTableElement.h b/Libraries/LibWeb/HTML/HTMLTableElement.h index c26504eff8..0db486bbb1 100644 --- a/Libraries/LibWeb/HTML/HTMLTableElement.h +++ b/Libraries/LibWeb/HTML/HTMLTableElement.h @@ -32,7 +32,7 @@ namespace Web { class HTMLTableElement final : public HTMLElement { public: - HTMLTableElement(Document&, const FlyString& local_name); + HTMLTableElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLTableElement() override; private: @@ -42,5 +42,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::HTMLTableElement) -static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::table; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::table; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp b/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp index aff8ac5204..9e8a8d8deb 100644 --- a/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp @@ -28,7 +28,7 @@ namespace Web { -HTMLTableRowElement::HTMLTableRowElement(Document& document, const FlyString& tag_name) +HTMLTableRowElement::HTMLTableRowElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLTableRowElement.h b/Libraries/LibWeb/HTML/HTMLTableRowElement.h index af81083c27..8ea764b262 100644 --- a/Libraries/LibWeb/HTML/HTMLTableRowElement.h +++ b/Libraries/LibWeb/HTML/HTMLTableRowElement.h @@ -32,12 +32,12 @@ namespace Web { class HTMLTableRowElement : public HTMLElement { public: - HTMLTableRowElement(Document&, const FlyString& local_name); + HTMLTableRowElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLTableRowElement() override; }; } AK_BEGIN_TYPE_TRAITS(Web::HTMLTableRowElement) -static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::tr; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::tr; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLTitleElement.cpp b/Libraries/LibWeb/HTML/HTMLTitleElement.cpp index 398694504c..cfcde00345 100644 --- a/Libraries/LibWeb/HTML/HTMLTitleElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTitleElement.cpp @@ -28,7 +28,7 @@ namespace Web { -HTMLTitleElement::HTMLTitleElement(Document& document, const FlyString& tag_name) +HTMLTitleElement::HTMLTitleElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) { } diff --git a/Libraries/LibWeb/HTML/HTMLTitleElement.h b/Libraries/LibWeb/HTML/HTMLTitleElement.h index da2ba1dfde..3b820738bf 100644 --- a/Libraries/LibWeb/HTML/HTMLTitleElement.h +++ b/Libraries/LibWeb/HTML/HTMLTitleElement.h @@ -32,12 +32,12 @@ namespace Web { class HTMLTitleElement : public HTMLElement { public: - HTMLTitleElement(Document&, const FlyString& local_name); + HTMLTitleElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLTitleElement() override; }; } AK_BEGIN_TYPE_TRAITS(Web::HTMLTitleElement) -static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::title; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::title; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/Layout/LayoutBlock.cpp b/Libraries/LibWeb/Layout/LayoutBlock.cpp index 686662f3ef..e1c88e7958 100644 --- a/Libraries/LibWeb/Layout/LayoutBlock.cpp +++ b/Libraries/LibWeb/Layout/LayoutBlock.cpp @@ -38,7 +38,7 @@ namespace Web { -LayoutBlock::LayoutBlock(Document& document, const Node* node, NonnullRefPtr style) +LayoutBlock::LayoutBlock(DOM::Document& document, const DOM::Node* node, NonnullRefPtr style) : LayoutBox(document, node, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LayoutBlock.h b/Libraries/LibWeb/Layout/LayoutBlock.h index 563588bba3..83a6da4ccd 100644 --- a/Libraries/LibWeb/Layout/LayoutBlock.h +++ b/Libraries/LibWeb/Layout/LayoutBlock.h @@ -31,11 +31,9 @@ namespace Web { -class Element; - class LayoutBlock : public LayoutBox { public: - LayoutBlock(Document&, const Node*, NonnullRefPtr); + LayoutBlock(DOM::Document&, const DOM::Node*, NonnullRefPtr); virtual ~LayoutBlock() override; virtual const char* class_name() const override { return "LayoutBlock"; } diff --git a/Libraries/LibWeb/Layout/LayoutBox.h b/Libraries/LibWeb/Layout/LayoutBox.h index 77eea22fd9..199249572e 100644 --- a/Libraries/LibWeb/Layout/LayoutBox.h +++ b/Libraries/LibWeb/Layout/LayoutBox.h @@ -71,7 +71,7 @@ public: virtual void paint(PaintContext&, PaintPhase) override; protected: - LayoutBox(Document& document, const Node* node, NonnullRefPtr style) + LayoutBox(DOM::Document& document, const DOM::Node* node, NonnullRefPtr style) : LayoutNodeWithStyleAndBoxModelMetrics(document, node, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LayoutBreak.cpp b/Libraries/LibWeb/Layout/LayoutBreak.cpp index 790955944e..169c0e6d79 100644 --- a/Libraries/LibWeb/Layout/LayoutBreak.cpp +++ b/Libraries/LibWeb/Layout/LayoutBreak.cpp @@ -29,7 +29,7 @@ namespace Web { -LayoutBreak::LayoutBreak(Document& document, const HTMLBRElement& element) +LayoutBreak::LayoutBreak(DOM::Document& document, const HTMLBRElement& element) : LayoutNodeWithStyleAndBoxModelMetrics(document, &element, StyleProperties::create()) { set_inline(true); diff --git a/Libraries/LibWeb/Layout/LayoutBreak.h b/Libraries/LibWeb/Layout/LayoutBreak.h index cfb6e1ce8c..61a5a7ec9c 100644 --- a/Libraries/LibWeb/Layout/LayoutBreak.h +++ b/Libraries/LibWeb/Layout/LayoutBreak.h @@ -33,7 +33,7 @@ namespace Web { class LayoutBreak final : public LayoutNodeWithStyleAndBoxModelMetrics { public: - LayoutBreak(Document&, const HTMLBRElement&); + LayoutBreak(DOM::Document&, const HTMLBRElement&); virtual ~LayoutBreak() override; const HTMLBRElement& node() const { return downcast(*LayoutNode::node()); } diff --git a/Libraries/LibWeb/Layout/LayoutCanvas.cpp b/Libraries/LibWeb/Layout/LayoutCanvas.cpp index bd24c4bb0c..2a34a3a1d5 100644 --- a/Libraries/LibWeb/Layout/LayoutCanvas.cpp +++ b/Libraries/LibWeb/Layout/LayoutCanvas.cpp @@ -31,7 +31,7 @@ namespace Web { -LayoutCanvas::LayoutCanvas(Document& document, const HTMLCanvasElement& element, NonnullRefPtr style) +LayoutCanvas::LayoutCanvas(DOM::Document& document, const HTMLCanvasElement& element, NonnullRefPtr style) : LayoutReplaced(document, element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LayoutCanvas.h b/Libraries/LibWeb/Layout/LayoutCanvas.h index e6174fdc51..1084b0a023 100644 --- a/Libraries/LibWeb/Layout/LayoutCanvas.h +++ b/Libraries/LibWeb/Layout/LayoutCanvas.h @@ -35,7 +35,7 @@ class HTMLCanvasElement; class LayoutCanvas : public LayoutReplaced { public: - LayoutCanvas(Document&, const HTMLCanvasElement&, NonnullRefPtr); + LayoutCanvas(DOM::Document&, const HTMLCanvasElement&, NonnullRefPtr); virtual ~LayoutCanvas() override; virtual void layout(LayoutMode = LayoutMode::Default) override; diff --git a/Libraries/LibWeb/Layout/LayoutDocument.cpp b/Libraries/LibWeb/Layout/LayoutDocument.cpp index 566a4375cc..03e863b623 100644 --- a/Libraries/LibWeb/Layout/LayoutDocument.cpp +++ b/Libraries/LibWeb/Layout/LayoutDocument.cpp @@ -33,7 +33,7 @@ namespace Web { -LayoutDocument::LayoutDocument(Document& document, NonnullRefPtr style) +LayoutDocument::LayoutDocument(DOM::Document& document, NonnullRefPtr style) : LayoutBlock(document, &document, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LayoutDocument.h b/Libraries/LibWeb/Layout/LayoutDocument.h index cf81ca2c7e..a5fd15e765 100644 --- a/Libraries/LibWeb/Layout/LayoutDocument.h +++ b/Libraries/LibWeb/Layout/LayoutDocument.h @@ -33,10 +33,10 @@ namespace Web { class LayoutDocument final : public LayoutBlock { public: - explicit LayoutDocument(Document&, NonnullRefPtr); + explicit LayoutDocument(DOM::Document&, NonnullRefPtr); virtual ~LayoutDocument() override; - const Document& node() const { return static_cast(*LayoutNode::node()); } + const DOM::Document& node() const { return static_cast(*LayoutNode::node()); } virtual const char* class_name() const override { return "LayoutDocument"; } virtual void layout(LayoutMode = LayoutMode::Default) override; diff --git a/Libraries/LibWeb/Layout/LayoutFrame.cpp b/Libraries/LibWeb/Layout/LayoutFrame.cpp index c9f383e44e..dd7048c1ee 100644 --- a/Libraries/LibWeb/Layout/LayoutFrame.cpp +++ b/Libraries/LibWeb/Layout/LayoutFrame.cpp @@ -37,7 +37,7 @@ namespace Web { -LayoutFrame::LayoutFrame(Document& document, const Element& element, NonnullRefPtr style) +LayoutFrame::LayoutFrame(DOM::Document& document, const DOM::Element& element, NonnullRefPtr style) : LayoutReplaced(document, element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LayoutFrame.h b/Libraries/LibWeb/Layout/LayoutFrame.h index eda86fe4a8..269f7e1557 100644 --- a/Libraries/LibWeb/Layout/LayoutFrame.h +++ b/Libraries/LibWeb/Layout/LayoutFrame.h @@ -33,7 +33,7 @@ namespace Web { class LayoutFrame final : public LayoutReplaced { public: - LayoutFrame(Document&, const Element&, NonnullRefPtr); + LayoutFrame(DOM::Document&, const DOM::Element&, NonnullRefPtr); virtual ~LayoutFrame() override; virtual void paint(PaintContext&, PaintPhase) override; diff --git a/Libraries/LibWeb/Layout/LayoutImage.cpp b/Libraries/LibWeb/Layout/LayoutImage.cpp index a8025d4918..35f3114d32 100644 --- a/Libraries/LibWeb/Layout/LayoutImage.cpp +++ b/Libraries/LibWeb/Layout/LayoutImage.cpp @@ -32,7 +32,7 @@ namespace Web { -LayoutImage::LayoutImage(Document& document, const Element& element, NonnullRefPtr style, const ImageLoader& image_loader) +LayoutImage::LayoutImage(DOM::Document& document, const DOM::Element& element, NonnullRefPtr style, const ImageLoader& image_loader) : LayoutReplaced(document, element, move(style)) , m_image_loader(image_loader) { diff --git a/Libraries/LibWeb/Layout/LayoutImage.h b/Libraries/LibWeb/Layout/LayoutImage.h index 2ef47279c7..464c1341c5 100644 --- a/Libraries/LibWeb/Layout/LayoutImage.h +++ b/Libraries/LibWeb/Layout/LayoutImage.h @@ -35,13 +35,13 @@ class HTMLImageElement; class LayoutImage : public LayoutReplaced { public: - LayoutImage(Document&, const Element&, NonnullRefPtr, const ImageLoader&); + LayoutImage(DOM::Document&, const DOM::Element&, NonnullRefPtr, const ImageLoader&); virtual ~LayoutImage() override; virtual void layout(LayoutMode = LayoutMode::Default) override; virtual void paint(PaintContext&, PaintPhase) override; - const Element& node() const { return static_cast(LayoutReplaced::node()); } + const DOM::Element& node() const { return static_cast(LayoutReplaced::node()); } bool renders_as_alt_text() const; diff --git a/Libraries/LibWeb/Layout/LayoutInline.cpp b/Libraries/LibWeb/Layout/LayoutInline.cpp index 56e26f4952..9d25c0f916 100644 --- a/Libraries/LibWeb/Layout/LayoutInline.cpp +++ b/Libraries/LibWeb/Layout/LayoutInline.cpp @@ -30,7 +30,7 @@ namespace Web { -LayoutInline::LayoutInline(Document& document, const Element& element, NonnullRefPtr style) +LayoutInline::LayoutInline(DOM::Document& document, const DOM::Element& element, NonnullRefPtr style) : LayoutNodeWithStyleAndBoxModelMetrics(document, &element, move(style)) { set_inline(true); diff --git a/Libraries/LibWeb/Layout/LayoutInline.h b/Libraries/LibWeb/Layout/LayoutInline.h index 824d996070..b4c8bdf300 100644 --- a/Libraries/LibWeb/Layout/LayoutInline.h +++ b/Libraries/LibWeb/Layout/LayoutInline.h @@ -34,7 +34,7 @@ class LayoutBlock; class LayoutInline : public LayoutNodeWithStyleAndBoxModelMetrics { public: - LayoutInline(Document&, const Element&, NonnullRefPtr); + LayoutInline(DOM::Document&, const DOM::Element&, NonnullRefPtr); virtual ~LayoutInline() override; virtual const char* class_name() const override { return "LayoutInline"; } }; diff --git a/Libraries/LibWeb/Layout/LayoutListItem.cpp b/Libraries/LibWeb/Layout/LayoutListItem.cpp index 74bcb13e39..e05ea7b5eb 100644 --- a/Libraries/LibWeb/Layout/LayoutListItem.cpp +++ b/Libraries/LibWeb/Layout/LayoutListItem.cpp @@ -29,7 +29,7 @@ namespace Web { -LayoutListItem::LayoutListItem(Document& document, const Element& element, NonnullRefPtr style) +LayoutListItem::LayoutListItem(DOM::Document& document, const DOM::Element& element, NonnullRefPtr style) : LayoutBlock(document, &element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LayoutListItem.h b/Libraries/LibWeb/Layout/LayoutListItem.h index 717eaa33ad..b362f0170e 100644 --- a/Libraries/LibWeb/Layout/LayoutListItem.h +++ b/Libraries/LibWeb/Layout/LayoutListItem.h @@ -35,7 +35,7 @@ class LayoutListItemMarker; class LayoutListItem final : public LayoutBlock { public: - LayoutListItem(Document&, const Element&, NonnullRefPtr); + LayoutListItem(DOM::Document&, const DOM::Element&, NonnullRefPtr); virtual ~LayoutListItem() override; virtual void layout(LayoutMode = LayoutMode::Default) override; diff --git a/Libraries/LibWeb/Layout/LayoutListItemMarker.cpp b/Libraries/LibWeb/Layout/LayoutListItemMarker.cpp index f56eadfdaf..81c0bf92f9 100644 --- a/Libraries/LibWeb/Layout/LayoutListItemMarker.cpp +++ b/Libraries/LibWeb/Layout/LayoutListItemMarker.cpp @@ -29,7 +29,7 @@ namespace Web { -LayoutListItemMarker::LayoutListItemMarker(Document& document) +LayoutListItemMarker::LayoutListItemMarker(DOM::Document& document) : LayoutBox(document, nullptr, StyleProperties::create()) { } diff --git a/Libraries/LibWeb/Layout/LayoutListItemMarker.h b/Libraries/LibWeb/Layout/LayoutListItemMarker.h index 394262a4c9..9ad8391408 100644 --- a/Libraries/LibWeb/Layout/LayoutListItemMarker.h +++ b/Libraries/LibWeb/Layout/LayoutListItemMarker.h @@ -32,7 +32,7 @@ namespace Web { class LayoutListItemMarker final : public LayoutBox { public: - explicit LayoutListItemMarker(Document&); + explicit LayoutListItemMarker(DOM::Document&); virtual ~LayoutListItemMarker() override; virtual void paint(PaintContext&, PaintPhase) override; diff --git a/Libraries/LibWeb/Layout/LayoutNode.cpp b/Libraries/LibWeb/Layout/LayoutNode.cpp index 2b46cbe9e1..f687b6f821 100644 --- a/Libraries/LibWeb/Layout/LayoutNode.cpp +++ b/Libraries/LibWeb/Layout/LayoutNode.cpp @@ -35,7 +35,7 @@ namespace Web { -LayoutNode::LayoutNode(Document& document, const Node* node) +LayoutNode::LayoutNode(DOM::Document& document, const DOM::Node* node) : m_document(document) , m_node(node) { @@ -208,7 +208,7 @@ bool LayoutNode::is_fixed_position() const return position == CSS::Position::Fixed; } -LayoutNodeWithStyle::LayoutNodeWithStyle(Document& document, const Node* node, NonnullRefPtr specified_style) +LayoutNodeWithStyle::LayoutNodeWithStyle(DOM::Document& document, const DOM::Node* node, NonnullRefPtr specified_style) : LayoutNode(document, node) , m_specified_style(move(specified_style)) { diff --git a/Libraries/LibWeb/Layout/LayoutNode.h b/Libraries/LibWeb/Layout/LayoutNode.h index 571584baeb..efe5156756 100644 --- a/Libraries/LibWeb/Layout/LayoutNode.h +++ b/Libraries/LibWeb/Layout/LayoutNode.h @@ -53,11 +53,11 @@ public: virtual HitTestResult hit_test(const Gfx::IntPoint&) const; bool is_anonymous() const { return !m_node; } - const Node* node() const { return m_node; } - Node* node() { return const_cast(m_node); } + const DOM::Node* node() const { return m_node; } + DOM::Node* node() { return const_cast(m_node); } - Document& document() { return m_document; } - const Document& document() const { return m_document; } + DOM::Document& document() { return m_document; } + const DOM::Document& document() const { return m_document; } const Frame& frame() const; Frame& frame(); @@ -196,13 +196,13 @@ public: float font_size() const; protected: - LayoutNode(Document&, const Node*); + LayoutNode(DOM::Document&, const DOM::Node*); private: friend class LayoutNodeWithStyle; - Document& m_document; - const Node* m_node { nullptr }; + DOM::Document& m_document; + const DOM::Node* m_node { nullptr }; bool m_inline { false }; bool m_has_style { false }; @@ -222,7 +222,7 @@ public: void apply_style(const StyleProperties&); protected: - LayoutNodeWithStyle(Document&, const Node*, NonnullRefPtr); + LayoutNodeWithStyle(DOM::Document&, const DOM::Node*, NonnullRefPtr); private: LayoutStyle m_style; @@ -238,7 +238,7 @@ public: const BoxModelMetrics& box_model() const { return m_box_model; } protected: - LayoutNodeWithStyleAndBoxModelMetrics(Document& document, const Node* node, NonnullRefPtr style) + LayoutNodeWithStyleAndBoxModelMetrics(DOM::Document& document, const DOM::Node* node, NonnullRefPtr style) : LayoutNodeWithStyle(document, node, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LayoutReplaced.cpp b/Libraries/LibWeb/Layout/LayoutReplaced.cpp index f671546dbb..ebb98d7c40 100644 --- a/Libraries/LibWeb/Layout/LayoutReplaced.cpp +++ b/Libraries/LibWeb/Layout/LayoutReplaced.cpp @@ -30,7 +30,7 @@ namespace Web { -LayoutReplaced::LayoutReplaced(Document& document, const Element& element, NonnullRefPtr style) +LayoutReplaced::LayoutReplaced(DOM::Document& document, const DOM::Element& element, NonnullRefPtr style) : LayoutBox(document, &element, move(style)) { // FIXME: Allow non-inline replaced elements. diff --git a/Libraries/LibWeb/Layout/LayoutReplaced.h b/Libraries/LibWeb/Layout/LayoutReplaced.h index 6b315ffdf4..2e8a891686 100644 --- a/Libraries/LibWeb/Layout/LayoutReplaced.h +++ b/Libraries/LibWeb/Layout/LayoutReplaced.h @@ -33,11 +33,11 @@ namespace Web { class LayoutReplaced : public LayoutBox { public: - LayoutReplaced(Document&, const Element&, NonnullRefPtr); + LayoutReplaced(DOM::Document&, const DOM::Element&, NonnullRefPtr); virtual ~LayoutReplaced() override; - const Element& node() const { return downcast(*LayoutNode::node()); } - Element& node() { return downcast(*LayoutNode::node()); } + const DOM::Element& node() const { return downcast(*LayoutNode::node()); } + DOM::Element& node() { return downcast(*LayoutNode::node()); } virtual bool is_replaced() const final { return true; } diff --git a/Libraries/LibWeb/Layout/LayoutSVG.cpp b/Libraries/LibWeb/Layout/LayoutSVG.cpp index 455151aaba..1d3228646d 100644 --- a/Libraries/LibWeb/Layout/LayoutSVG.cpp +++ b/Libraries/LibWeb/Layout/LayoutSVG.cpp @@ -31,7 +31,7 @@ namespace Web { -LayoutSVG::LayoutSVG(Document& document, const SVG::SVGSVGElement& element, NonnullRefPtr style) +LayoutSVG::LayoutSVG(DOM::Document& document, const SVG::SVGSVGElement& element, NonnullRefPtr style) : LayoutReplaced(document, element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LayoutSVG.h b/Libraries/LibWeb/Layout/LayoutSVG.h index 091e536be5..a0005b2250 100644 --- a/Libraries/LibWeb/Layout/LayoutSVG.h +++ b/Libraries/LibWeb/Layout/LayoutSVG.h @@ -36,7 +36,7 @@ class SVGSVGElement; class LayoutSVG : public LayoutReplaced { public: - LayoutSVG(Document&, const SVG::SVGSVGElement&, NonnullRefPtr); + LayoutSVG(DOM::Document&, const SVG::SVGSVGElement&, NonnullRefPtr); virtual ~LayoutSVG() override = default; virtual void layout(LayoutMode = LayoutMode::Default) override; virtual void paint(PaintContext&, PaintPhase) override; diff --git a/Libraries/LibWeb/Layout/LayoutTable.cpp b/Libraries/LibWeb/Layout/LayoutTable.cpp index 98c15f8acd..6db50b6c5e 100644 --- a/Libraries/LibWeb/Layout/LayoutTable.cpp +++ b/Libraries/LibWeb/Layout/LayoutTable.cpp @@ -30,7 +30,7 @@ namespace Web { -LayoutTable::LayoutTable(Document& document, const Element& element, NonnullRefPtr style) +LayoutTable::LayoutTable(DOM::Document& document, const DOM::Element& element, NonnullRefPtr style) : LayoutBlock(document, &element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LayoutTable.h b/Libraries/LibWeb/Layout/LayoutTable.h index d8bc7492c3..c5fc58abbd 100644 --- a/Libraries/LibWeb/Layout/LayoutTable.h +++ b/Libraries/LibWeb/Layout/LayoutTable.h @@ -34,7 +34,7 @@ class LayoutTableRow; class LayoutTable final : public LayoutBlock { public: - LayoutTable(Document&, const Element&, NonnullRefPtr); + LayoutTable(DOM::Document&, const DOM::Element&, NonnullRefPtr); virtual ~LayoutTable() override; virtual void layout(LayoutMode = LayoutMode::Default) override; diff --git a/Libraries/LibWeb/Layout/LayoutTableCell.cpp b/Libraries/LibWeb/Layout/LayoutTableCell.cpp index ab9fa8990c..30e69465be 100644 --- a/Libraries/LibWeb/Layout/LayoutTableCell.cpp +++ b/Libraries/LibWeb/Layout/LayoutTableCell.cpp @@ -30,7 +30,7 @@ namespace Web { -LayoutTableCell::LayoutTableCell(Document& document, const Element& element, NonnullRefPtr style) +LayoutTableCell::LayoutTableCell(DOM::Document& document, const DOM::Element& element, NonnullRefPtr style) : LayoutBlock(document, &element, move(style)) { } @@ -42,7 +42,7 @@ LayoutTableCell::~LayoutTableCell() size_t LayoutTableCell::colspan() const { ASSERT(node()); - return downcast(*node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1); + return downcast(*node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1); } float LayoutTableCell::width_of_logical_containing_block() const diff --git a/Libraries/LibWeb/Layout/LayoutTableCell.h b/Libraries/LibWeb/Layout/LayoutTableCell.h index 1103a3f967..efb4e475d5 100644 --- a/Libraries/LibWeb/Layout/LayoutTableCell.h +++ b/Libraries/LibWeb/Layout/LayoutTableCell.h @@ -32,7 +32,7 @@ namespace Web { class LayoutTableCell final : public LayoutBlock { public: - LayoutTableCell(Document&, const Element&, NonnullRefPtr); + LayoutTableCell(DOM::Document&, const DOM::Element&, NonnullRefPtr); virtual ~LayoutTableCell() override; LayoutTableCell* next_cell() { return next_sibling_of_type(); } diff --git a/Libraries/LibWeb/Layout/LayoutTableRow.cpp b/Libraries/LibWeb/Layout/LayoutTableRow.cpp index 7421d2f575..0936f3e6d4 100644 --- a/Libraries/LibWeb/Layout/LayoutTableRow.cpp +++ b/Libraries/LibWeb/Layout/LayoutTableRow.cpp @@ -31,7 +31,7 @@ namespace Web { -LayoutTableRow::LayoutTableRow(Document& document, const Element& element, NonnullRefPtr style) +LayoutTableRow::LayoutTableRow(DOM::Document& document, const DOM::Element& element, NonnullRefPtr style) : LayoutBox(document, &element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LayoutTableRow.h b/Libraries/LibWeb/Layout/LayoutTableRow.h index 8915dfb07e..657f052f17 100644 --- a/Libraries/LibWeb/Layout/LayoutTableRow.h +++ b/Libraries/LibWeb/Layout/LayoutTableRow.h @@ -34,7 +34,7 @@ class LayoutTableCell; class LayoutTableRow final : public LayoutBox { public: - LayoutTableRow(Document&, const Element&, NonnullRefPtr); + LayoutTableRow(DOM::Document&, const DOM::Element&, NonnullRefPtr); virtual ~LayoutTableRow() override; void layout_row(const Vector& column_widths); diff --git a/Libraries/LibWeb/Layout/LayoutTableRowGroup.cpp b/Libraries/LibWeb/Layout/LayoutTableRowGroup.cpp index 5fb81d915f..82f3dab7c3 100644 --- a/Libraries/LibWeb/Layout/LayoutTableRowGroup.cpp +++ b/Libraries/LibWeb/Layout/LayoutTableRowGroup.cpp @@ -31,7 +31,7 @@ namespace Web { -LayoutTableRowGroup::LayoutTableRowGroup(Document& document, const Element& element, NonnullRefPtr style) +LayoutTableRowGroup::LayoutTableRowGroup(DOM::Document& document, const DOM::Element& element, NonnullRefPtr style) : LayoutBlock(document, &element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LayoutTableRowGroup.h b/Libraries/LibWeb/Layout/LayoutTableRowGroup.h index 8c79c894d5..54f2b4d128 100644 --- a/Libraries/LibWeb/Layout/LayoutTableRowGroup.h +++ b/Libraries/LibWeb/Layout/LayoutTableRowGroup.h @@ -32,7 +32,7 @@ namespace Web { class LayoutTableRowGroup final : public LayoutBlock { public: - LayoutTableRowGroup(Document&, const Element&, NonnullRefPtr); + LayoutTableRowGroup(DOM::Document&, const DOM::Element&, NonnullRefPtr); virtual ~LayoutTableRowGroup() override; virtual void layout(LayoutMode = LayoutMode::Default) override; diff --git a/Libraries/LibWeb/Layout/LayoutText.cpp b/Libraries/LibWeb/Layout/LayoutText.cpp index 4199a50d0f..a097f235bf 100644 --- a/Libraries/LibWeb/Layout/LayoutText.cpp +++ b/Libraries/LibWeb/Layout/LayoutText.cpp @@ -36,7 +36,7 @@ namespace Web { -LayoutText::LayoutText(Document& document, const Text& text) +LayoutText::LayoutText(DOM::Document& document, const DOM::Text& text) : LayoutNode(document, &text) { set_inline(true); diff --git a/Libraries/LibWeb/Layout/LayoutText.h b/Libraries/LibWeb/Layout/LayoutText.h index 3df9fd9035..089039def2 100644 --- a/Libraries/LibWeb/Layout/LayoutText.h +++ b/Libraries/LibWeb/Layout/LayoutText.h @@ -35,10 +35,10 @@ class LineBoxFragment; class LayoutText : public LayoutNode { public: - LayoutText(Document&, const Text&); + LayoutText(DOM::Document&, const DOM::Text&); virtual ~LayoutText() override; - const Text& node() const { return static_cast(*LayoutNode::node()); } + const DOM::Text& node() const { return static_cast(*LayoutNode::node()); } const String& text_for_style(const StyleProperties&) const; const String& text_for_rendering() const { return m_text_for_rendering; } diff --git a/Libraries/LibWeb/Layout/LayoutTreeBuilder.cpp b/Libraries/LibWeb/Layout/LayoutTreeBuilder.cpp index 8d20c1f5cc..12f4212324 100644 --- a/Libraries/LibWeb/Layout/LayoutTreeBuilder.cpp +++ b/Libraries/LibWeb/Layout/LayoutTreeBuilder.cpp @@ -37,7 +37,7 @@ LayoutTreeBuilder::LayoutTreeBuilder() { } -static RefPtr create_layout_tree(Node& node, const StyleProperties* parent_style) +static RefPtr create_layout_tree(DOM::Node& node, const StyleProperties* parent_style) { auto layout_node = node.create_layout_node(parent_style); if (!layout_node) @@ -50,7 +50,7 @@ static RefPtr create_layout_tree(Node& node, const StyleProperties* bool have_inline_children = false; bool have_noninline_children = false; - downcast(node).for_each_child([&](Node& child) { + downcast(node).for_each_child([&](DOM::Node& child) { auto layout_child = create_layout_tree(child, &layout_node->specified_style()); if (!layout_child) return; @@ -77,9 +77,9 @@ static RefPtr create_layout_tree(Node& node, const StyleProperties* return layout_node; } -RefPtr LayoutTreeBuilder::build(Node& node) +RefPtr LayoutTreeBuilder::build(DOM::Node& node) { - if (!is(node) && node.has_children()) { + if (!is(node) && node.has_children()) { dbg() << "FIXME: Support building partial layout trees."; return nullptr; } diff --git a/Libraries/LibWeb/Layout/LayoutTreeBuilder.h b/Libraries/LibWeb/Layout/LayoutTreeBuilder.h index 4e486b6218..9a41ad0b0c 100644 --- a/Libraries/LibWeb/Layout/LayoutTreeBuilder.h +++ b/Libraries/LibWeb/Layout/LayoutTreeBuilder.h @@ -27,17 +27,15 @@ #pragma once #include +#include namespace Web { -class Node; -class LayoutNode; - class LayoutTreeBuilder { public: LayoutTreeBuilder(); - RefPtr build(Node&); + RefPtr build(DOM::Node&); }; } diff --git a/Libraries/LibWeb/Layout/LayoutWidget.cpp b/Libraries/LibWeb/Layout/LayoutWidget.cpp index ea0d737db7..2a4d56e181 100644 --- a/Libraries/LibWeb/Layout/LayoutWidget.cpp +++ b/Libraries/LibWeb/Layout/LayoutWidget.cpp @@ -36,7 +36,7 @@ namespace Web { -LayoutWidget::LayoutWidget(Document& document, const Element& element, GUI::Widget& widget) +LayoutWidget::LayoutWidget(DOM::Document& document, const DOM::Element& element, GUI::Widget& widget) : LayoutReplaced(document, element, StyleProperties::create()) , m_widget(widget) { diff --git a/Libraries/LibWeb/Layout/LayoutWidget.h b/Libraries/LibWeb/Layout/LayoutWidget.h index 1928c33617..bc9d6f4857 100644 --- a/Libraries/LibWeb/Layout/LayoutWidget.h +++ b/Libraries/LibWeb/Layout/LayoutWidget.h @@ -32,7 +32,7 @@ namespace Web { class LayoutWidget final : public LayoutReplaced { public: - LayoutWidget(Document&, const Element&, GUI::Widget&); + LayoutWidget(DOM::Document&, const DOM::Element&, GUI::Widget&); virtual ~LayoutWidget() override; GUI::Widget& widget() { return m_widget; } diff --git a/Libraries/LibWeb/LayoutTreeModel.cpp b/Libraries/LibWeb/LayoutTreeModel.cpp index 23bce12fc9..43e19fa17e 100644 --- a/Libraries/LibWeb/LayoutTreeModel.cpp +++ b/Libraries/LibWeb/LayoutTreeModel.cpp @@ -35,7 +35,7 @@ namespace Web { -LayoutTreeModel::LayoutTreeModel(Document& document) +LayoutTreeModel::LayoutTreeModel(DOM::Document& document) : m_document(document) { m_document_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png")); @@ -136,7 +136,7 @@ GUI::Variant LayoutTreeModel::data(const GUI::ModelIndex& index, Role role) cons } else if (!node.node()->is_element()) { builder.append(node.node()->node_name()); } else { - auto& element = downcast(*node.node()); + auto& element = downcast(*node.node()); builder.append('<'); builder.append(element.local_name()); element.for_each_attribute([&](auto& name, auto& value) { diff --git a/Libraries/LibWeb/LayoutTreeModel.h b/Libraries/LibWeb/LayoutTreeModel.h index 2fb8bbca59..bbca5e4b22 100644 --- a/Libraries/LibWeb/LayoutTreeModel.h +++ b/Libraries/LibWeb/LayoutTreeModel.h @@ -27,14 +27,13 @@ #pragma once #include +#include namespace Web { -class Document; - class LayoutTreeModel final : public GUI::Model { public: - static NonnullRefPtr create(Document& document) + static NonnullRefPtr create(DOM::Document& document) { return adopt(*new LayoutTreeModel(document)); } @@ -49,9 +48,9 @@ public: virtual void update() override; private: - explicit LayoutTreeModel(Document&); + explicit LayoutTreeModel(DOM::Document&); - NonnullRefPtr m_document; + NonnullRefPtr m_document; GUI::Icon m_document_icon; GUI::Icon m_element_icon; diff --git a/Libraries/LibWeb/Loader/FrameLoader.cpp b/Libraries/LibWeb/Loader/FrameLoader.cpp index de63ba7ccb..cfc6b78bf5 100644 --- a/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -48,7 +48,7 @@ FrameLoader::~FrameLoader() { } -static RefPtr create_markdown_document(const ByteBuffer& data, const URL& url) +static RefPtr create_markdown_document(const ByteBuffer& data, const URL& url) { auto markdown_document = Markdown::Document::parse(data); if (!markdown_document) @@ -57,9 +57,9 @@ static RefPtr create_markdown_document(const ByteBuffer& data, const U return parse_html_document(markdown_document->render_to_html(), url, "utf-8"); } -static RefPtr create_text_document(const ByteBuffer& data, const URL& url) +static RefPtr create_text_document(const ByteBuffer& data, const URL& url) { - auto document = adopt(*new Document(url)); + auto document = adopt(*new DOM::Document(url)); auto html_element = document->create_element("html"); document->append_child(html_element); @@ -82,9 +82,9 @@ static RefPtr create_text_document(const ByteBuffer& data, const URL& return document; } -static RefPtr create_image_document(const ByteBuffer& data, const URL& url) +static RefPtr create_image_document(const ByteBuffer& data, const URL& url) { - auto document = adopt(*new Document(url)); + auto document = adopt(*new DOM::Document(url)); auto image_decoder = Gfx::ImageDecoder::create(data.data(), data.size()); auto bitmap = image_decoder->bitmap(); @@ -99,7 +99,7 @@ static RefPtr create_image_document(const ByteBuffer& data, const URL& head_element->append_child(title_element); auto basename = LexicalPath(url.path()).basename(); - auto title_text = adopt(*new Text(document, String::format("%s [%dx%d]", basename.characters(), bitmap->width(), bitmap->height()))); + auto title_text = adopt(*new DOM::Text(document, String::format("%s [%dx%d]", basename.characters(), bitmap->width(), bitmap->height()))); title_element->append_child(title_text); auto body_element = create_element(document, "body"); @@ -112,14 +112,14 @@ static RefPtr create_image_document(const ByteBuffer& data, const URL& return document; } -static RefPtr create_gemini_document(const ByteBuffer& data, const URL& url) +static RefPtr create_gemini_document(const ByteBuffer& data, const URL& url) { auto markdown_document = Gemini::Document::parse({ (const char*)data.data(), data.size() }, url); return parse_html_document(markdown_document->render_to_html(), url, "utf-8"); } -RefPtr FrameLoader::create_document_from_mime_type(const ByteBuffer& data, const URL& url, const String& mime_type, const String& encoding) +RefPtr FrameLoader::create_document_from_mime_type(const ByteBuffer& data, const URL& url, const String& mime_type, const String& encoding) { if (mime_type.starts_with("image/")) return create_image_document(data, url); diff --git a/Libraries/LibWeb/Loader/FrameLoader.h b/Libraries/LibWeb/Loader/FrameLoader.h index d883626c45..3da7854b8c 100644 --- a/Libraries/LibWeb/Loader/FrameLoader.h +++ b/Libraries/LibWeb/Loader/FrameLoader.h @@ -55,7 +55,7 @@ private: virtual void resource_did_fail() override; void load_error_page(const URL& failed_url, const String& error_message); - RefPtr create_document_from_mime_type(const ByteBuffer&, const URL&, const String& mime_type, const String& encoding); + RefPtr create_document_from_mime_type(const ByteBuffer&, const URL&, const String& mime_type, const String& encoding); Frame& m_frame; }; diff --git a/Libraries/LibWeb/Page.h b/Libraries/LibWeb/Page.h index 5ac8af8c44..a0bf0b635f 100644 --- a/Libraries/LibWeb/Page.h +++ b/Libraries/LibWeb/Page.h @@ -69,7 +69,7 @@ private: class PageClient { public: virtual Gfx::Palette palette() const = 0; - virtual void page_did_set_document_in_main_frame(Document*) { } + virtual void page_did_set_document_in_main_frame(DOM::Document*) { } virtual void page_did_change_title(const String&) { } virtual void page_did_start_loading(const URL&) { } virtual void page_did_change_selection() { } diff --git a/Libraries/LibWeb/PageView.cpp b/Libraries/LibWeb/PageView.cpp index 26e2ce49fc..491078dd3c 100644 --- a/Libraries/LibWeb/PageView.cpp +++ b/Libraries/LibWeb/PageView.cpp @@ -170,7 +170,7 @@ void PageView::page_did_change_title(const String& title) on_title_change(title); } -void PageView::page_did_set_document_in_main_frame(Document* document) +void PageView::page_did_set_document_in_main_frame(DOM::Document* document) { if (on_set_document) on_set_document(document); @@ -419,17 +419,17 @@ void PageView::load_empty_document() page().main_frame().set_document(nullptr); } -Document* PageView::document() +DOM::Document* PageView::document() { return page().main_frame().document(); } -const Document* PageView::document() const +const DOM::Document* PageView::document() const { return page().main_frame().document(); } -void PageView::set_document(Document* document) +void PageView::set_document(DOM::Document* document) { page().main_frame().set_document(document); } diff --git a/Libraries/LibWeb/PageView.h b/Libraries/LibWeb/PageView.h index be9d74532b..c16f78acb7 100644 --- a/Libraries/LibWeb/PageView.h +++ b/Libraries/LibWeb/PageView.h @@ -46,10 +46,10 @@ public: void load_html(const StringView&, const URL&); void load_empty_document(); - Document* document(); - const Document* document() const; + DOM::Document* document(); + const DOM::Document* document() const; - void set_document(Document*); + void set_document(DOM::Document*); const LayoutDocument* layout_root() const; LayoutDocument* layout_root(); @@ -88,7 +88,7 @@ private: // ^Web::PageClient virtual Gfx::Palette palette() const override { return GUI::ScrollableWidget::palette(); } virtual void page_did_change_title(const String&) override; - virtual void page_did_set_document_in_main_frame(Document*) override; + virtual void page_did_set_document_in_main_frame(DOM::Document*) override; virtual void page_did_start_loading(const URL&) override; virtual void page_did_change_selection() override; virtual void page_did_request_cursor_change(GUI::StandardCursor) override; diff --git a/Libraries/LibWeb/Parser/CSSParser.cpp b/Libraries/LibWeb/Parser/CSSParser.cpp index 3138190b70..42ac88ee03 100644 --- a/Libraries/LibWeb/Parser/CSSParser.cpp +++ b/Libraries/LibWeb/Parser/CSSParser.cpp @@ -53,7 +53,7 @@ ParsingContext::ParsingContext() { } -ParsingContext::ParsingContext(const Document& document) +ParsingContext::ParsingContext(const DOM::Document& document) : m_document(&document) { } @@ -928,7 +928,7 @@ RefPtr parse_css_declaration(const CSS::ParsingContext& contex return parser.parse_standalone_declaration(); } -RefPtr parse_html_length(const Document& document, const StringView& string) +RefPtr parse_html_length(const DOM::Document& document, const StringView& string) { auto integer = string.to_int(); if (integer.has_value()) diff --git a/Libraries/LibWeb/Parser/CSSParser.h b/Libraries/LibWeb/Parser/CSSParser.h index 1426f72306..95e96a0379 100644 --- a/Libraries/LibWeb/Parser/CSSParser.h +++ b/Libraries/LibWeb/Parser/CSSParser.h @@ -33,12 +33,12 @@ namespace Web::CSS { class ParsingContext { public: ParsingContext(); - explicit ParsingContext(const Document&); + explicit ParsingContext(const DOM::Document&); bool in_quirks_mode() const; private: - const Document* m_document { nullptr }; + const DOM::Document* m_document { nullptr }; }; } @@ -53,6 +53,6 @@ RefPtr parse_line_width(const CSS::ParsingContext&, const Stri RefPtr parse_color(const CSS::ParsingContext&, const StringView&); RefPtr parse_line_style(const CSS::ParsingContext&, const StringView&); -RefPtr parse_html_length(const Document&, const StringView&); +RefPtr parse_html_length(const DOM::Document&, const StringView&); } diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp index 3ee8eb3acb..9b5e0058eb 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp @@ -104,7 +104,7 @@ static Vector s_quirks_public_ids = { "-//WebTechs//DTD Mozilla HTML//" }; -RefPtr parse_html_document(const StringView& data, const URL& url, const String& encoding) +RefPtr parse_html_document(const StringView& data, const URL& url, const String& encoding) { HTMLDocumentParser parser(data, encoding); parser.run(url); @@ -114,10 +114,10 @@ RefPtr parse_html_document(const StringView& data, const URL& url, con HTMLDocumentParser::HTMLDocumentParser(const StringView& input, const String& encoding) : m_tokenizer(input, encoding) { - m_document = adopt(*new Document); + m_document = adopt(*new DOM::Document); } -HTMLDocumentParser::HTMLDocumentParser(const StringView& input, const String& encoding, Document& existing_document) +HTMLDocumentParser::HTMLDocumentParser(const StringView& input, const String& encoding, DOM::Document& existing_document) : m_tokenizer(input, encoding) , m_document(existing_document) { @@ -160,7 +160,7 @@ void HTMLDocumentParser::run(const URL& url) script.execute_script(); } - m_document->dispatch_event(Event::create("DOMContentLoaded")); + m_document->dispatch_event(DOM::Event::create("DOMContentLoaded")); auto scripts_to_execute_as_soon_as_possible = m_document->take_scripts_to_execute_as_soon_as_possible({}); for (auto& script : scripts_to_execute_as_soon_as_possible) { @@ -245,58 +245,58 @@ void HTMLDocumentParser::process_using_the_rules_for(InsertionMode mode, HTMLTok } } -QuirksMode HTMLDocumentParser::which_quirks_mode(const HTMLToken& doctype_token) const +DOM::QuirksMode HTMLDocumentParser::which_quirks_mode(const HTMLToken& doctype_token) const { if (doctype_token.m_doctype.force_quirks) - return QuirksMode::Yes; + return DOM::QuirksMode::Yes; // NOTE: The tokenizer puts the name into lower case for us. if (doctype_token.m_doctype.name.to_string() != "html") - return QuirksMode::Yes; + return DOM::QuirksMode::Yes; auto public_identifier = doctype_token.m_doctype.public_identifier.to_string(); auto system_identifier = doctype_token.m_doctype.system_identifier.to_string(); if (public_identifier.equals_ignoring_case("-//W3O//DTD W3 HTML Strict 3.0//EN//")) - return QuirksMode::Yes; + return DOM::QuirksMode::Yes; if (public_identifier.equals_ignoring_case("-/W3C/DTD HTML 4.0 Transitional/EN")) - return QuirksMode::Yes; + return DOM::QuirksMode::Yes; if (public_identifier.equals_ignoring_case("HTML")) - return QuirksMode::Yes; + return DOM::QuirksMode::Yes; if (system_identifier.equals_ignoring_case("http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd")) - return QuirksMode::Yes; + return DOM::QuirksMode::Yes; for (auto& public_id : s_quirks_public_ids) { if (public_identifier.starts_with(public_id, CaseSensitivity::CaseInsensitive)) - return QuirksMode::Yes; + return DOM::QuirksMode::Yes; } if (doctype_token.m_doctype.missing_system_identifier) { if (public_identifier.starts_with("-//W3C//DTD HTML 4.01 Frameset//", CaseSensitivity::CaseInsensitive)) - return QuirksMode::Yes; + return DOM::QuirksMode::Yes; if (public_identifier.starts_with("-//W3C//DTD HTML 4.01 Transitional//", CaseSensitivity::CaseInsensitive)) - return QuirksMode::Yes; + return DOM::QuirksMode::Yes; } if (public_identifier.starts_with("-//W3C//DTD XHTML 1.0 Frameset//", CaseSensitivity::CaseInsensitive)) - return QuirksMode::Limited; + return DOM::QuirksMode::Limited; if (public_identifier.starts_with("-//W3C//DTD XHTML 1.0 Transitional//", CaseSensitivity::CaseInsensitive)) - return QuirksMode::Limited; + return DOM::QuirksMode::Limited; if (!doctype_token.m_doctype.missing_system_identifier) { if (public_identifier.starts_with("-//W3C//DTD HTML 4.01 Frameset//", CaseSensitivity::CaseInsensitive)) - return QuirksMode::Limited; + return DOM::QuirksMode::Limited; if (public_identifier.starts_with("-//W3C//DTD HTML 4.01 Transitional//", CaseSensitivity::CaseInsensitive)) - return QuirksMode::Limited; + return DOM::QuirksMode::Limited; } - return QuirksMode::No; + return DOM::QuirksMode::No; } void HTMLDocumentParser::handle_initial(HTMLToken& token) @@ -306,13 +306,13 @@ void HTMLDocumentParser::handle_initial(HTMLToken& token) } if (token.is_comment()) { - auto comment = adopt(*new Comment(document(), token.m_comment_or_character.data.to_string())); + auto comment = adopt(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string())); document().append_child(move(comment)); return; } if (token.is_doctype()) { - auto doctype = adopt(*new DocumentType(document())); + auto doctype = adopt(*new DOM::DocumentType(document())); doctype->set_name(token.m_doctype.name.to_string()); doctype->set_public_id(token.m_doctype.public_identifier.to_string()); doctype->set_system_id(token.m_doctype.system_identifier.to_string()); @@ -323,7 +323,7 @@ void HTMLDocumentParser::handle_initial(HTMLToken& token) } PARSE_ERROR(); - document().set_quirks_mode(QuirksMode::Yes); + document().set_quirks_mode(DOM::QuirksMode::Yes); m_insertion_mode = InsertionMode::BeforeHTML; process_using_the_rules_for(InsertionMode::BeforeHTML, token); } @@ -336,7 +336,7 @@ void HTMLDocumentParser::handle_before_html(HTMLToken& token) } if (token.is_comment()) { - auto comment = adopt(*new Comment(document(), token.m_comment_or_character.data.to_string())); + auto comment = adopt(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string())); document().append_child(move(comment)); return; } @@ -372,12 +372,12 @@ AnythingElse: return; } -Element& HTMLDocumentParser::current_node() +DOM::Element& HTMLDocumentParser::current_node() { return m_stack_of_open_elements.current_node(); } -Element& HTMLDocumentParser::node_before_current_node() +DOM::Element& HTMLDocumentParser::node_before_current_node() { return m_stack_of_open_elements.elements().at(m_stack_of_open_elements.elements().size() - 2); } @@ -399,7 +399,7 @@ HTMLDocumentParser::AdjustedInsertionLocation HTMLDocumentParser::find_appropria return { target, nullptr }; } -NonnullRefPtr HTMLDocumentParser::create_element_for(const HTMLToken& token) +NonnullRefPtr HTMLDocumentParser::create_element_for(const HTMLToken& token) { auto element = create_element(document(), token.tag_name()); for (auto& attribute : token.m_tag.attributes) { @@ -408,7 +408,7 @@ NonnullRefPtr HTMLDocumentParser::create_element_for(const HTMLToken& t return element; } -RefPtr HTMLDocumentParser::insert_html_element(const HTMLToken& token) +RefPtr HTMLDocumentParser::insert_html_element(const HTMLToken& token) { auto adjusted_insertion_location = find_appropriate_place_for_inserting_node(); auto element = create_element_for(token); @@ -466,7 +466,7 @@ void HTMLDocumentParser::insert_comment(HTMLToken& token) { auto data = token.m_comment_or_character.data.to_string(); auto adjusted_insertion_location = find_appropriate_place_for_inserting_node(); - adjusted_insertion_location.parent->insert_before(adopt(*new Comment(document(), data)), adjusted_insertion_location.insert_before_sibling); + adjusted_insertion_location.parent->insert_before(adopt(*new DOM::Comment(document(), data)), adjusted_insertion_location.insert_before_sibling); } void HTMLDocumentParser::handle_in_head(HTMLToken& token) @@ -627,7 +627,7 @@ void HTMLDocumentParser::parse_generic_raw_text_element(HTMLToken& token) m_insertion_mode = InsertionMode::Text; } -Text* HTMLDocumentParser::find_character_insertion_node() +DOM::Text* HTMLDocumentParser::find_character_insertion_node() { auto adjusted_insertion_location = find_appropriate_place_for_inserting_node(); if (adjusted_insertion_location.insert_before_sibling) { @@ -636,8 +636,8 @@ Text* HTMLDocumentParser::find_character_insertion_node() if (adjusted_insertion_location.parent->is_document()) return nullptr; if (adjusted_insertion_location.parent->last_child() && adjusted_insertion_location.parent->last_child()->is_text()) - return downcast(adjusted_insertion_location.parent->last_child()); - auto new_text_node = adopt(*new Text(document(), "")); + return downcast(adjusted_insertion_location.parent->last_child()); + auto new_text_node = adopt(*new DOM::Text(document(), "")); adjusted_insertion_location.parent->append_child(new_text_node); return new_text_node; } @@ -758,7 +758,7 @@ void HTMLDocumentParser::handle_after_body(HTMLToken& token) if (token.is_comment()) { auto data = token.m_comment_or_character.data.to_string(); auto& insertion_location = m_stack_of_open_elements.first(); - insertion_location.append_child(adopt(*new Comment(document(), data))); + insertion_location.append_child(adopt(*new DOM::Comment(document(), data))); return; } @@ -794,7 +794,7 @@ void HTMLDocumentParser::handle_after_body(HTMLToken& token) void HTMLDocumentParser::handle_after_after_body(HTMLToken& token) { if (token.is_comment()) { - auto comment = adopt(*new Comment(document(), token.m_comment_or_character.data.to_string())); + auto comment = adopt(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string())); document().append_child(move(comment)); return; } @@ -828,7 +828,7 @@ void HTMLDocumentParser::reconstruct_the_active_formatting_elements() return; ssize_t index = m_list_of_active_formatting_elements.entries().size() - 1; - RefPtr entry = m_list_of_active_formatting_elements.entries().at(index).element; + RefPtr entry = m_list_of_active_formatting_elements.entries().at(index).element; ASSERT(entry); Rewind: @@ -898,7 +898,7 @@ HTMLDocumentParser::AdoptionAgencyAlgorithmOutcome HTMLDocumentParser::run_the_a PARSE_ERROR(); } - RefPtr furthest_block = m_stack_of_open_elements.topmost_special_node_below(*formatting_element); + RefPtr furthest_block = m_stack_of_open_elements.topmost_special_node_below(*formatting_element); if (!furthest_block) { while (¤t_node() != formatting_element) @@ -1187,7 +1187,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token) m_frameset_ok = false; for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) { - RefPtr node = m_stack_of_open_elements.elements()[i]; + RefPtr node = m_stack_of_open_elements.elements()[i]; if (node->local_name() == HTML::TagNames::li) { generate_implied_end_tags(HTML::TagNames::li); @@ -1212,7 +1212,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token) if (token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt)) { m_frameset_ok = false; for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) { - RefPtr node = m_stack_of_open_elements.elements()[i]; + RefPtr node = m_stack_of_open_elements.elements()[i]; if (node->local_name() == HTML::TagNames::dd) { generate_implied_end_tags(HTML::TagNames::dd); if (current_node().local_name() != HTML::TagNames::dd) { @@ -1627,7 +1627,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token) if (token.is_end_tag()) { AnyOtherEndTag: - RefPtr node; + RefPtr node; for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) { node = m_stack_of_open_elements.elements()[i]; if (node->local_name() == token.tag_name()) { @@ -2627,7 +2627,7 @@ void HTMLDocumentParser::handle_after_frameset(HTMLToken& token) void HTMLDocumentParser::handle_after_after_frameset(HTMLToken& token) { if (token.is_comment()) { - auto comment = adopt(*new Comment(document(), token.m_comment_or_character.data.to_string())); + auto comment = adopt(*new DOM::Comment(document(), token.m_comment_or_character.data.to_string())); document().append_child(move(comment)); return; } @@ -2655,7 +2655,7 @@ void HTMLDocumentParser::reset_the_insertion_mode_appropriately() for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) { bool last = i == 0; // NOTE: When parsing fragments, we substitute the context element for the root of the stack of open elements. - RefPtr node; + RefPtr node; if (last && m_parsing_fragment) { node = m_context_element; } else { @@ -2744,12 +2744,12 @@ const char* HTMLDocumentParser::insertion_mode_name() const ASSERT_NOT_REACHED(); } -Document& HTMLDocumentParser::document() +DOM::Document& HTMLDocumentParser::document() { return *m_document; } -NonnullRefPtrVector HTMLDocumentParser::parse_html_fragment(Element& context_element, const StringView& markup) +NonnullRefPtrVector HTMLDocumentParser::parse_html_fragment(DOM::Element& context_element, const StringView& markup) { HTMLDocumentParser parser(markup, "utf-8"); parser.m_context_element = context_element; @@ -2790,8 +2790,8 @@ NonnullRefPtrVector HTMLDocumentParser::parse_html_fragment(Element& conte parser.run(context_element.document().url()); - NonnullRefPtrVector children; - while (RefPtr child = root->first_child()) { + NonnullRefPtrVector children; + while (RefPtr child = root->first_child()) { root->remove_child(*child); context_element.document().adopt_node(*child); children.append(*child); diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.h b/Libraries/LibWeb/Parser/HTMLDocumentParser.h index dae251fb65..390f913890 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.h +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.h @@ -59,19 +59,19 @@ namespace Web { -RefPtr parse_html_document(const StringView&, const URL&, const String& encoding); +RefPtr parse_html_document(const StringView&, const URL&, const String& encoding); class HTMLDocumentParser { public: HTMLDocumentParser(const StringView& input, const String& encoding); - HTMLDocumentParser(const StringView& input, const String& encoding, Document& existing_document); + HTMLDocumentParser(const StringView& input, const String& encoding, DOM::Document& existing_document); ~HTMLDocumentParser(); void run(const URL&); - Document& document(); + DOM::Document& document(); - static NonnullRefPtrVector parse_html_fragment(Element& context_element, const StringView&); + static NonnullRefPtrVector parse_html_fragment(DOM::Element& context_element, const StringView&); enum class InsertionMode { #define __ENUMERATE_INSERTION_MODE(mode) mode, @@ -86,7 +86,7 @@ public: private: const char* insertion_mode_name() const; - QuirksMode which_quirks_mode(const HTMLToken&) const; + DOM::QuirksMode which_quirks_mode(const HTMLToken&) const; void handle_initial(HTMLToken&); void handle_before_html(HTMLToken&); @@ -116,20 +116,20 @@ private: void generate_implied_end_tags(const FlyString& exception = {}); bool stack_of_open_elements_has_element_with_tag_name_in_scope(const FlyString& tag_name); - NonnullRefPtr create_element_for(const HTMLToken&); + NonnullRefPtr create_element_for(const HTMLToken&); struct AdjustedInsertionLocation { - RefPtr parent; - RefPtr insert_before_sibling; + RefPtr parent; + RefPtr insert_before_sibling; }; AdjustedInsertionLocation find_appropriate_place_for_inserting_node(); - Text* find_character_insertion_node(); + DOM::Text* find_character_insertion_node(); void flush_character_insertions(); - RefPtr insert_html_element(const HTMLToken&); - Element& current_node(); - Element& node_before_current_node(); + RefPtr insert_html_element(const HTMLToken&); + DOM::Element& current_node(); + DOM::Element& node_before_current_node(); void insert_character(u32 data); void insert_comment(HTMLToken&); void reconstruct_the_active_formatting_elements(); @@ -175,14 +175,14 @@ private: bool m_stop_parsing { false }; size_t m_script_nesting_level { 0 }; - RefPtr m_document; + RefPtr m_document; RefPtr m_head_element; RefPtr m_form_element; - RefPtr m_context_element; + RefPtr m_context_element; Vector m_pending_table_character_tokens; - RefPtr m_character_insertion_node; + RefPtr m_character_insertion_node; StringBuilder m_character_insertion_builder; }; diff --git a/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.cpp b/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.cpp index 6ec79cbae9..d3f19e9778 100644 --- a/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.cpp +++ b/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.cpp @@ -33,7 +33,7 @@ ListOfActiveFormattingElements::~ListOfActiveFormattingElements() { } -void ListOfActiveFormattingElements::add(Element& element) +void ListOfActiveFormattingElements::add(DOM::Element& element) { m_entries.append({ element }); } @@ -43,7 +43,7 @@ void ListOfActiveFormattingElements::add_marker() m_entries.append({ nullptr }); } -bool ListOfActiveFormattingElements::contains(const Element& element) const +bool ListOfActiveFormattingElements::contains(const DOM::Element& element) const { for (auto& entry : m_entries) { if (entry.element == &element) @@ -52,7 +52,7 @@ bool ListOfActiveFormattingElements::contains(const Element& element) const return false; } -Element* ListOfActiveFormattingElements::last_element_with_tag_name_before_marker(const FlyString& tag_name) +DOM::Element* ListOfActiveFormattingElements::last_element_with_tag_name_before_marker(const FlyString& tag_name) { for (ssize_t i = m_entries.size() - 1; i >= 0; --i) { auto& entry = m_entries[i]; @@ -64,7 +64,7 @@ Element* ListOfActiveFormattingElements::last_element_with_tag_name_before_marke return nullptr; } -void ListOfActiveFormattingElements::remove(Element& element) +void ListOfActiveFormattingElements::remove(DOM::Element& element) { m_entries.remove_first_matching([&](auto& entry) { return entry.element == &element; diff --git a/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.h b/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.h index b03756b3da..40a9d091f0 100644 --- a/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.h +++ b/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.h @@ -40,21 +40,21 @@ public: struct Entry { bool is_marker() const { return !element; } - RefPtr element; + RefPtr element; }; bool is_empty() const { return m_entries.is_empty(); } - bool contains(const Element&) const; + bool contains(const DOM::Element&) const; - void add(Element& element); + void add(DOM::Element& element); void add_marker(); - void remove(Element&); + void remove(DOM::Element&); const Vector& entries() const { return m_entries; } Vector& entries() { return m_entries; } - Element* last_element_with_tag_name_before_marker(const FlyString& tag_name); + DOM::Element* last_element_with_tag_name_before_marker(const FlyString& tag_name); void clear_up_to_the_last_marker(); diff --git a/Libraries/LibWeb/Parser/StackOfOpenElements.cpp b/Libraries/LibWeb/Parser/StackOfOpenElements.cpp index 8dc70ecbbf..61632753f3 100644 --- a/Libraries/LibWeb/Parser/StackOfOpenElements.cpp +++ b/Libraries/LibWeb/Parser/StackOfOpenElements.cpp @@ -53,7 +53,7 @@ bool StackOfOpenElements::has_in_scope(const FlyString& tag_name) const return has_in_scope_impl(tag_name, s_base_list); } -bool StackOfOpenElements::has_in_scope_impl(const Element& target_node, const Vector& list) const +bool StackOfOpenElements::has_in_scope_impl(const DOM::Element& target_node, const Vector& list) const { for (ssize_t i = m_elements.size() - 1; i >= 0; --i) { auto& node = m_elements.at(i); @@ -65,7 +65,7 @@ bool StackOfOpenElements::has_in_scope_impl(const Element& target_node, const Ve ASSERT_NOT_REACHED(); } -bool StackOfOpenElements::has_in_scope(const Element& target_node) const +bool StackOfOpenElements::has_in_scope(const DOM::Element& target_node) const { return has_in_scope_impl(target_node, s_base_list); } @@ -95,7 +95,7 @@ bool StackOfOpenElements::has_in_select_scope(const FlyString& tag_name) const return has_in_scope_impl(tag_name, { "option", "optgroup" }); } -bool StackOfOpenElements::contains(const Element& element) const +bool StackOfOpenElements::contains(const DOM::Element& element) const { for (auto& element_on_stack : m_elements) { if (&element == &element_on_stack) @@ -120,9 +120,9 @@ void StackOfOpenElements::pop_until_an_element_with_tag_name_has_been_popped(con pop(); } -Element* StackOfOpenElements::topmost_special_node_below(const Element& formatting_element) +DOM::Element* StackOfOpenElements::topmost_special_node_below(const DOM::Element& formatting_element) { - Element* found_element = nullptr; + DOM::Element* found_element = nullptr; for (ssize_t i = m_elements.size() - 1; i >= 0; --i) { auto& element = m_elements[i]; if (&element == &formatting_element) @@ -133,7 +133,7 @@ Element* StackOfOpenElements::topmost_special_node_below(const Element& formatti return found_element; } -Element* StackOfOpenElements::last_element_with_tag_name(const FlyString& tag_name) +DOM::Element* StackOfOpenElements::last_element_with_tag_name(const FlyString& tag_name) { for (ssize_t i = m_elements.size() - 1; i >= 0; --i) { auto& element = m_elements[i]; @@ -143,7 +143,7 @@ Element* StackOfOpenElements::last_element_with_tag_name(const FlyString& tag_na return nullptr; } -Element* StackOfOpenElements::element_before(const Element& target) +DOM::Element* StackOfOpenElements::element_before(const DOM::Element& target) { bool found_target = false; for (ssize_t i = m_elements.size() - 1; i >= 0; --i) { diff --git a/Libraries/LibWeb/Parser/StackOfOpenElements.h b/Libraries/LibWeb/Parser/StackOfOpenElements.h index 8b8397208d..09a299c48c 100644 --- a/Libraries/LibWeb/Parser/StackOfOpenElements.h +++ b/Libraries/LibWeb/Parser/StackOfOpenElements.h @@ -37,15 +37,15 @@ public: StackOfOpenElements() { } ~StackOfOpenElements(); - Element& first() { return m_elements.first(); } - Element& last() { return m_elements.last(); } + DOM::Element& first() { return m_elements.first(); } + DOM::Element& last() { return m_elements.last(); } bool is_empty() const { return m_elements.is_empty(); } - void push(NonnullRefPtr element) { m_elements.append(move(element)); } - NonnullRefPtr pop() { return m_elements.take_last(); } + void push(NonnullRefPtr element) { m_elements.append(move(element)); } + NonnullRefPtr pop() { return m_elements.take_last(); } - const Element& current_node() const { return m_elements.last(); } - Element& current_node() { return m_elements.last(); } + const DOM::Element& current_node() const { return m_elements.last(); } + DOM::Element& current_node() { return m_elements.last(); } bool has_in_scope(const FlyString& tag_name) const; bool has_in_button_scope(const FlyString& tag_name) const; @@ -53,26 +53,26 @@ public: bool has_in_list_item_scope(const FlyString& tag_name) const; bool has_in_select_scope(const FlyString& tag_name) const; - bool has_in_scope(const Element&) const; + bool has_in_scope(const DOM::Element&) const; - bool contains(const Element&) const; + bool contains(const DOM::Element&) const; bool contains(const FlyString& tag_name) const; - const NonnullRefPtrVector& elements() const { return m_elements; } - NonnullRefPtrVector& elements() { return m_elements; } + const NonnullRefPtrVector& elements() const { return m_elements; } + NonnullRefPtrVector& elements() { return m_elements; } void pop_until_an_element_with_tag_name_has_been_popped(const FlyString&); - Element* topmost_special_node_below(const Element&); + DOM::Element* topmost_special_node_below(const DOM::Element&); - Element* last_element_with_tag_name(const FlyString&); - Element* element_before(const Element&); + DOM::Element* last_element_with_tag_name(const FlyString&); + DOM::Element* element_before(const DOM::Element&); private: bool has_in_scope_impl(const FlyString& tag_name, const Vector&) const; - bool has_in_scope_impl(const Element& target_node, const Vector&) const; + bool has_in_scope_impl(const DOM::Element& target_node, const Vector&) const; - NonnullRefPtrVector m_elements; + NonnullRefPtrVector m_elements; }; } diff --git a/Libraries/LibWeb/SVG/SVGElement.cpp b/Libraries/LibWeb/SVG/SVGElement.cpp index d351af3dd6..f3699c18eb 100644 --- a/Libraries/LibWeb/SVG/SVGElement.cpp +++ b/Libraries/LibWeb/SVG/SVGElement.cpp @@ -28,7 +28,7 @@ namespace Web::SVG { -SVGElement::SVGElement(Document& document, const FlyString& tag_name) +SVGElement::SVGElement(DOM::Document& document, const FlyString& tag_name) : Element(document, tag_name) { } diff --git a/Libraries/LibWeb/SVG/SVGElement.h b/Libraries/LibWeb/SVG/SVGElement.h index 74cd89329a..9c6c77084d 100644 --- a/Libraries/LibWeb/SVG/SVGElement.h +++ b/Libraries/LibWeb/SVG/SVGElement.h @@ -30,12 +30,12 @@ namespace Web::SVG { -class SVGElement : public Element { +class SVGElement : public DOM::Element { public: virtual bool is_graphics_element() const { return false; } protected: - SVGElement(Document&, const FlyString& tag_name); + SVGElement(DOM::Document&, const FlyString& tag_name); private: virtual bool is_svg_element() const final { return true; } @@ -44,5 +44,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::SVG::SVGElement) -static bool is_type(const Web::Node& node) { return node.is_svg_element(); } +static bool is_type(const Web::DOM::Node& node) { return node.is_svg_element(); } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/SVG/SVGGeometryElement.cpp b/Libraries/LibWeb/SVG/SVGGeometryElement.cpp index 004af0383d..47764c2363 100644 --- a/Libraries/LibWeb/SVG/SVGGeometryElement.cpp +++ b/Libraries/LibWeb/SVG/SVGGeometryElement.cpp @@ -28,7 +28,7 @@ namespace Web::SVG { -SVGGeometryElement::SVGGeometryElement(Document& document, const FlyString& tag_name) +SVGGeometryElement::SVGGeometryElement(DOM::Document& document, const FlyString& tag_name) : SVGGraphicsElement(document, tag_name) { } diff --git a/Libraries/LibWeb/SVG/SVGGeometryElement.h b/Libraries/LibWeb/SVG/SVGGeometryElement.h index 4a806b20b9..2ae4b17519 100644 --- a/Libraries/LibWeb/SVG/SVGGeometryElement.h +++ b/Libraries/LibWeb/SVG/SVGGeometryElement.h @@ -33,7 +33,7 @@ namespace Web::SVG { class SVGGeometryElement : public SVGGraphicsElement { public: protected: - SVGGeometryElement(Document& document, const FlyString& tag_name); + SVGGeometryElement(DOM::Document& document, const FlyString& tag_name); }; } diff --git a/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp index d15d5f5d7d..8844abc0dd 100644 --- a/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp +++ b/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp @@ -28,7 +28,7 @@ namespace Web::SVG { -SVGGraphicsElement::SVGGraphicsElement(Document& document, const FlyString& tag_name) +SVGGraphicsElement::SVGGraphicsElement(DOM::Document& document, const FlyString& tag_name) : SVGElement(document, tag_name) { } diff --git a/Libraries/LibWeb/SVG/SVGGraphicsElement.h b/Libraries/LibWeb/SVG/SVGGraphicsElement.h index be2fbfa8d2..ddef811284 100644 --- a/Libraries/LibWeb/SVG/SVGGraphicsElement.h +++ b/Libraries/LibWeb/SVG/SVGGraphicsElement.h @@ -47,7 +47,7 @@ static const SVGPaintingContext default_painting_context = { class SVGGraphicsElement : public SVGElement { public: - SVGGraphicsElement(Document&, const FlyString& tag_name); + SVGGraphicsElement(DOM::Document&, const FlyString& tag_name); virtual void parse_attribute(const FlyString& name, const String& value) override; @@ -67,5 +67,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::SVG::SVGGraphicsElement) -static bool is_type(const Web::Node& node) { return is(node) && downcast(node).is_graphics_element(); } +static bool is_type(const Web::DOM::Node& node) { return is(node) && downcast(node).is_graphics_element(); } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/SVG/SVGPathElement.cpp b/Libraries/LibWeb/SVG/SVGPathElement.cpp index 3ca3665134..54ab70ce60 100644 --- a/Libraries/LibWeb/SVG/SVGPathElement.cpp +++ b/Libraries/LibWeb/SVG/SVGPathElement.cpp @@ -349,7 +349,7 @@ bool PathDataParser::match_number() const return !done() && (isdigit(ch()) || ch() == '-' || ch() == '+'); } -SVGPathElement::SVGPathElement(Document& document, const FlyString& tag_name) +SVGPathElement::SVGPathElement(DOM::Document& document, const FlyString& tag_name) : SVGGeometryElement(document, tag_name) { } diff --git a/Libraries/LibWeb/SVG/SVGPathElement.h b/Libraries/LibWeb/SVG/SVGPathElement.h index 8aeed96559..898976b1dc 100644 --- a/Libraries/LibWeb/SVG/SVGPathElement.h +++ b/Libraries/LibWeb/SVG/SVGPathElement.h @@ -102,7 +102,7 @@ private: class SVGPathElement final : public SVGGeometryElement { public: - SVGPathElement(Document&, const FlyString& tag_name); + SVGPathElement(DOM::Document&, const FlyString& tag_name); virtual ~SVGPathElement() override = default; virtual void parse_attribute(const FlyString& name, const String& value) override; diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Libraries/LibWeb/SVG/SVGSVGElement.cpp index 28cd2e945d..c70f3afb73 100644 --- a/Libraries/LibWeb/SVG/SVGSVGElement.cpp +++ b/Libraries/LibWeb/SVG/SVGSVGElement.cpp @@ -38,7 +38,7 @@ namespace Web::SVG { static constexpr auto max_svg_area = 16384 * 16384; -SVGSVGElement::SVGSVGElement(Document& document, const FlyString& tag_name) +SVGSVGElement::SVGSVGElement(DOM::Document& document, const FlyString& tag_name) : SVGGraphicsElement(document, tag_name) { } diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.h b/Libraries/LibWeb/SVG/SVGSVGElement.h index a6bf355fed..1540aa3757 100644 --- a/Libraries/LibWeb/SVG/SVGSVGElement.h +++ b/Libraries/LibWeb/SVG/SVGSVGElement.h @@ -33,7 +33,7 @@ namespace Web::SVG { class SVGSVGElement final : public SVGGraphicsElement { public: - SVGSVGElement(Document&, const FlyString& tag_name); + SVGSVGElement(DOM::Document&, const FlyString& tag_name); virtual RefPtr create_layout_node(const StyleProperties* parent_style) override; diff --git a/Libraries/LibWeb/WebViewHooks.h b/Libraries/LibWeb/WebViewHooks.h index f5c9a2c2a6..5f261b4b37 100644 --- a/Libraries/LibWeb/WebViewHooks.h +++ b/Libraries/LibWeb/WebViewHooks.h @@ -43,7 +43,7 @@ public: Function on_load_start; Function on_favicon_change; Function on_url_drop; - Function on_set_document; + Function on_set_document; }; } diff --git a/Userland/test-web.cpp b/Userland/test-web.cpp index f340d5e736..cf763a08d1 100644 --- a/Userland/test-web.cpp +++ b/Userland/test-web.cpp @@ -643,7 +643,7 @@ int main(int argc, char** argv) main_widget.set_layout(); auto& view = main_widget.add(); - view.set_document(adopt(*new Web::Document)); + view.set_document(adopt(*new Web::DOM::Document)); if (show_window) { window->set_title("LibWeb Test Window");