mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:12:45 +00:00 
			
		
		
		
	LibWeb: Move DOM classes into the Web::DOM namespace
LibWeb keeps growing and the Web namespace is filling up fast. Let's put DOM stuff into Web::DOM, just like we already started doing with SVG stuff in Web::SVG.
This commit is contained in:
		
							parent
							
								
									96d13f75cf
								
							
						
					
					
						commit
						11ff9d0f17
					
				
					 178 changed files with 516 additions and 523 deletions
				
			
		|  | @ -47,13 +47,13 @@ ConsoleWidget::ConsoleWidget() | ||||||
|     set_layout<GUI::VerticalBoxLayout>(); |     set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     set_fill_with_background_color(true); |     set_fill_with_background_color(true); | ||||||
| 
 | 
 | ||||||
|     auto base_document = adopt(*new Web::Document); |     auto base_document = adopt(*new Web::DOM::Document); | ||||||
|     base_document->append_child(adopt(*new Web::DocumentType(base_document))); |     base_document->append_child(adopt(*new Web::DOM::DocumentType(base_document))); | ||||||
|     auto html_element = create_element(base_document, "html"); |     auto html_element = Web::DOM::create_element(base_document, "html"); | ||||||
|     base_document->append_child(html_element); |     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); |     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); |     html_element->append_child(body_element); | ||||||
|     m_output_container = body_element; |     m_output_container = body_element; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -52,7 +52,7 @@ private: | ||||||
| 
 | 
 | ||||||
|     RefPtr<GUI::TextBox> m_input; |     RefPtr<GUI::TextBox> m_input; | ||||||
|     RefPtr<Web::PageView> m_output_view; |     RefPtr<Web::PageView> m_output_view; | ||||||
|     RefPtr<Web::Element> m_output_container; |     RefPtr<Web::DOM::Element> m_output_container; | ||||||
|     WeakPtr<JS::Interpreter> m_interpreter; |     WeakPtr<JS::Interpreter> m_interpreter; | ||||||
|     OwnPtr<BrowserConsoleClient> m_console_client; |     OwnPtr<BrowserConsoleClient> m_console_client; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -38,11 +38,11 @@ | ||||||
| 
 | 
 | ||||||
| namespace Browser { | 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); |     m_document->set_inspected_node(node); | ||||||
|     if (node && node->is_element()) { |     if (node && node->is_element()) { | ||||||
|         auto& element = downcast<Web::Element>(*node); |         auto& element = downcast<Web::DOM::Element>(*node); | ||||||
|         if (element.resolved_style()) { |         if (element.resolved_style()) { | ||||||
|             m_style_table_view->set_model(Web::StylePropertiesModel::create(*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())); |             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<GUI::TreeView>("DOM"); |     m_dom_tree_view = top_tab_widget.add_tab<GUI::TreeView>("DOM"); | ||||||
|     m_dom_tree_view->on_selection = [this](auto& index) { |     m_dom_tree_view->on_selection = [this](auto& index) { | ||||||
|         auto* node = static_cast<Web::Node*>(index.internal_data()); |         auto* node = static_cast<Web::DOM::Node*>(index.internal_data()); | ||||||
|         set_inspected_node(node); |         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) |     if (m_document == document) | ||||||
|         return; |         return; | ||||||
|  |  | ||||||
|  | @ -36,18 +36,18 @@ class InspectorWidget final : public GUI::Widget { | ||||||
| public: | public: | ||||||
|     virtual ~InspectorWidget(); |     virtual ~InspectorWidget(); | ||||||
| 
 | 
 | ||||||
|     void set_document(Web::Document*); |     void set_document(Web::DOM::Document*); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     InspectorWidget(); |     InspectorWidget(); | ||||||
| 
 | 
 | ||||||
|     void set_inspected_node(Web::Node*); |     void set_inspected_node(Web::DOM::Node*); | ||||||
| 
 | 
 | ||||||
|     RefPtr<GUI::TreeView> m_dom_tree_view; |     RefPtr<GUI::TreeView> m_dom_tree_view; | ||||||
|     RefPtr<GUI::TreeView> m_layout_tree_view; |     RefPtr<GUI::TreeView> m_layout_tree_view; | ||||||
|     RefPtr<GUI::TableView> m_style_table_view; |     RefPtr<GUI::TableView> m_style_table_view; | ||||||
|     RefPtr<GUI::TableView> m_computed_style_table_view; |     RefPtr<GUI::TableView> m_computed_style_table_view; | ||||||
|     RefPtr<Web::Document> m_document; |     RefPtr<Web::DOM::Document> m_document; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -40,14 +40,14 @@ NonnullRefPtr<IRCLogBuffer> IRCLogBuffer::create() | ||||||
| 
 | 
 | ||||||
| IRCLogBuffer::IRCLogBuffer() | IRCLogBuffer::IRCLogBuffer() | ||||||
| { | { | ||||||
|     m_document = adopt(*new Web::Document); |     m_document = adopt(*new Web::DOM::Document); | ||||||
|     m_document->append_child(adopt(*new Web::DocumentType(document()))); |     m_document->append_child(adopt(*new Web::DOM::DocumentType(document()))); | ||||||
|     auto html_element = create_element(document(), "html"); |     auto html_element = create_element(document(), "html"); | ||||||
|     m_document->append_child(html_element); |     m_document->append_child(html_element); | ||||||
|     auto head_element = create_element(document(), "head"); |     auto head_element = create_element(document(), "head"); | ||||||
|     html_element->append_child(head_element); |     html_element->append_child(head_element); | ||||||
|     auto style_element = create_element(document(), "style"); |     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); |     head_element->append_child(style_element); | ||||||
|     auto body_element = create_element(document(), "body"); |     auto body_element = create_element(document(), "body"); | ||||||
|     html_element->append_child(body_element); |     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(nick_string).characters(), | ||||||
|         escape_html_entities(text).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_attribute(Web::HTML::AttributeNames::style, String::format("color: %s", color.to_string().characters())); | ||||||
|     wrapper->set_inner_html(html); |     wrapper->set_inner_html(html); | ||||||
|     m_container_element->append_child(wrapper); |     m_container_element->append_child(wrapper); | ||||||
|  | @ -90,7 +90,7 @@ void IRCLogBuffer::add_message(const String& text, Color color) | ||||||
|         "<span>%s</span>", |         "<span>%s</span>", | ||||||
|         timestamp_string().characters(), |         timestamp_string().characters(), | ||||||
|         escape_html_entities(text).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_attribute(Web::HTML::AttributeNames::style, String::format("color: %s", color.to_string().characters())); | ||||||
|     wrapper->set_inner_html(html); |     wrapper->set_inner_html(html); | ||||||
|     m_container_element->append_child(wrapper); |     m_container_element->append_child(wrapper); | ||||||
|  |  | ||||||
|  | @ -49,11 +49,11 @@ public: | ||||||
|     void add_message(const String& text, Color = Color::Black); |     void add_message(const String& text, Color = Color::Black); | ||||||
|     void dump() const; |     void dump() const; | ||||||
| 
 | 
 | ||||||
|     const Web::Document& document() const { return *m_document; } |     const Web::DOM::Document& document() const { return *m_document; } | ||||||
|     Web::Document& document() { return *m_document; } |     Web::DOM::Document& document() { return *m_document; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     IRCLogBuffer(); |     IRCLogBuffer(); | ||||||
|     RefPtr<Web::Document> m_document; |     RefPtr<Web::DOM::Document> m_document; | ||||||
|     RefPtr<Web::Element> m_container_element; |     RefPtr<Web::DOM::Element> m_container_element; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -214,7 +214,7 @@ IRCWindow::~IRCWindow() | ||||||
| void IRCWindow::set_log_buffer(const IRCLogBuffer& log_buffer) | void IRCWindow::set_log_buffer(const IRCLogBuffer& log_buffer) | ||||||
| { | { | ||||||
|     m_log_buffer = &log_buffer; |     m_log_buffer = &log_buffer; | ||||||
|     m_page_view->set_document(const_cast<Web::Document*>(&log_buffer.document())); |     m_page_view->set_document(const_cast<Web::DOM::Document*>(&log_buffer.document())); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool IRCWindow::is_active() const | bool IRCWindow::is_active() const | ||||||
|  |  | ||||||
|  | @ -33,7 +33,7 @@ | ||||||
| namespace Web { | namespace Web { | ||||||
| namespace Bindings { | namespace Bindings { | ||||||
| 
 | 
 | ||||||
| EventListenerWrapper::EventListenerWrapper(JS::GlobalObject& global_object, EventListener& impl) | EventListenerWrapper::EventListenerWrapper(JS::GlobalObject& global_object, DOM::EventListener& impl) | ||||||
|     : Wrapper(*global_object.object_prototype()) |     : Wrapper(*global_object.object_prototype()) | ||||||
|     , m_impl(impl) |     , m_impl(impl) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -35,14 +35,14 @@ class EventListenerWrapper final : public Wrapper { | ||||||
|     JS_OBJECT(EventListenerWrapper, Wrapper); |     JS_OBJECT(EventListenerWrapper, Wrapper); | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
|     EventListenerWrapper(JS::GlobalObject&, EventListener&); |     EventListenerWrapper(JS::GlobalObject&, DOM::EventListener&); | ||||||
|     virtual ~EventListenerWrapper() override; |     virtual ~EventListenerWrapper() override; | ||||||
| 
 | 
 | ||||||
|     EventListener& impl() { return *m_impl; } |     DOM::EventListener& impl() { return *m_impl; } | ||||||
|     const EventListener& impl() const { return *m_impl; } |     const DOM::EventListener& impl() const { return *m_impl; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     NonnullRefPtr<EventListener> m_impl; |     NonnullRefPtr<DOM::EventListener> m_impl; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -30,10 +30,10 @@ | ||||||
| namespace Web { | namespace Web { | ||||||
| namespace Bindings { | namespace Bindings { | ||||||
| 
 | 
 | ||||||
| EventWrapper* wrap(JS::GlobalObject& global_object, Event& event) | EventWrapper* wrap(JS::GlobalObject& global_object, DOM::Event& event) | ||||||
| { | { | ||||||
|     if (event.is_mouse_event()) |     if (event.is_mouse_event()) | ||||||
|         return static_cast<MouseEventWrapper*>(wrap_impl(global_object, static_cast<MouseEvent&>(event))); |         return static_cast<MouseEventWrapper*>(wrap_impl(global_object, static_cast<DOM::MouseEvent&>(event))); | ||||||
|     return static_cast<EventWrapper*>(wrap_impl(global_object, event)); |     return static_cast<EventWrapper*>(wrap_impl(global_object, event)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -29,10 +29,8 @@ | ||||||
| #include <LibJS/Forward.h> | #include <LibJS/Forward.h> | ||||||
| #include <LibWeb/Forward.h> | #include <LibWeb/Forward.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::Bindings { | ||||||
| namespace Bindings { |  | ||||||
| 
 | 
 | ||||||
| EventWrapper* wrap(JS::GlobalObject&, Event&); | EventWrapper* wrap(JS::GlobalObject&, DOM::Event&); | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| } |  | ||||||
|  |  | ||||||
|  | @ -38,20 +38,20 @@ | ||||||
| namespace Web { | namespace Web { | ||||||
| namespace Bindings { | namespace Bindings { | ||||||
| 
 | 
 | ||||||
| NodeWrapper* wrap(JS::GlobalObject& global_object, Node& node) | NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& node) | ||||||
| { | { | ||||||
|     if (is<Document>(node)) |     if (is<DOM::Document>(node)) | ||||||
|         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<Document>(node))); |         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DOM::Document>(node))); | ||||||
|     if (is<DocumentType>(node)) |     if (is<DOM::DocumentType>(node)) | ||||||
|         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DocumentType>(node))); |         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DOM::DocumentType>(node))); | ||||||
|     if (is<HTMLCanvasElement>(node)) |     if (is<HTMLCanvasElement>(node)) | ||||||
|         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLCanvasElement>(node))); |         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLCanvasElement>(node))); | ||||||
|     if (is<HTMLImageElement>(node)) |     if (is<HTMLImageElement>(node)) | ||||||
|         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLImageElement>(node))); |         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLImageElement>(node))); | ||||||
|     if (is<HTMLElement>(node)) |     if (is<HTMLElement>(node)) | ||||||
|         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLElement>(node))); |         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLElement>(node))); | ||||||
|     if (is<Element>(node)) |     if (is<DOM::Element>(node)) | ||||||
|         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<Element>(node))); |         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DOM::Element>(node))); | ||||||
|     return static_cast<NodeWrapper*>(wrap_impl(global_object, node)); |     return static_cast<NodeWrapper*>(wrap_impl(global_object, node)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ | ||||||
| namespace Web { | namespace Web { | ||||||
| namespace Bindings { | namespace Bindings { | ||||||
| 
 | 
 | ||||||
| NodeWrapper* wrap(JS::GlobalObject&, Node&); | NodeWrapper* wrap(JS::GlobalObject&, DOM::Node&); | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -48,7 +48,7 @@ | ||||||
| namespace Web { | namespace Web { | ||||||
| namespace Bindings { | namespace Bindings { | ||||||
| 
 | 
 | ||||||
| WindowObject::WindowObject(Window& impl) | WindowObject::WindowObject(DOM::Window& impl) | ||||||
|     : m_impl(impl) |     : m_impl(impl) | ||||||
| { | { | ||||||
|     impl.set_wrapper({}, *this); |     impl.set_wrapper({}, *this); | ||||||
|  | @ -91,7 +91,7 @@ void WindowObject::visit_children(Visitor& visitor) | ||||||
|     visitor.visit(m_xhr_prototype); |     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); |     auto* this_object = interpreter.this_value(global_object).to_object(interpreter, global_object); | ||||||
|     if (!this_object) { |     if (!this_object) { | ||||||
|  |  | ||||||
|  | @ -37,12 +37,12 @@ class WindowObject final | ||||||
|     : public JS::GlobalObject |     : public JS::GlobalObject | ||||||
|     , public Weakable<WindowObject> { |     , public Weakable<WindowObject> { | ||||||
| public: | public: | ||||||
|     explicit WindowObject(Window&); |     explicit WindowObject(DOM::Window&); | ||||||
|     virtual void initialize() override; |     virtual void initialize() override; | ||||||
|     virtual ~WindowObject() override; |     virtual ~WindowObject() override; | ||||||
| 
 | 
 | ||||||
|     Window& impl() { return *m_impl; } |     DOM::Window& impl() { return *m_impl; } | ||||||
|     const Window& impl() const { return *m_impl; } |     const DOM::Window& impl() const { return *m_impl; } | ||||||
| 
 | 
 | ||||||
|     XMLHttpRequestPrototype* xhr_prototype() { return m_xhr_prototype; } |     XMLHttpRequestPrototype* xhr_prototype() { return m_xhr_prototype; } | ||||||
|     XMLHttpRequestConstructor* xhr_constructor() { return m_xhr_constructor; } |     XMLHttpRequestConstructor* xhr_constructor() { return m_xhr_constructor; } | ||||||
|  | @ -65,7 +65,7 @@ private: | ||||||
|     JS_DECLARE_NATIVE_FUNCTION(atob); |     JS_DECLARE_NATIVE_FUNCTION(atob); | ||||||
|     JS_DECLARE_NATIVE_FUNCTION(btoa); |     JS_DECLARE_NATIVE_FUNCTION(btoa); | ||||||
| 
 | 
 | ||||||
|     NonnullRefPtr<Window> m_impl; |     NonnullRefPtr<DOM::Window> m_impl; | ||||||
| 
 | 
 | ||||||
|     XMLHttpRequestConstructor* m_xhr_constructor { nullptr }; |     XMLHttpRequestConstructor* m_xhr_constructor { nullptr }; | ||||||
|     XMLHttpRequestPrototype* m_xhr_prototype { nullptr }; |     XMLHttpRequestPrototype* m_xhr_prototype { nullptr }; | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| namespace SelectorEngine { | 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(); |     auto* hovered_node = element.document().hovered_node(); | ||||||
|     if (!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); |     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) { |     switch (component.pseudo_class) { | ||||||
|     case Selector::SimpleSelector::PseudoClass::None: |     case Selector::SimpleSelector::PseudoClass::None: | ||||||
|  | @ -76,7 +76,7 @@ bool matches(const Selector::SimpleSelector& component, const Element& element) | ||||||
|             return false; |             return false; | ||||||
|         break; |         break; | ||||||
|     case Selector::SimpleSelector::PseudoClass::Empty: |     case Selector::SimpleSelector::PseudoClass::Empty: | ||||||
|         if (element.first_child_of_type<Element>() || element.first_child_of_type<Text>()) |         if (element.first_child_of_type<DOM::Element>() || element.first_child_of_type<DOM::Text>()) | ||||||
|             return false; |             return false; | ||||||
|         break; |         break; | ||||||
|     case Selector::SimpleSelector::PseudoClass::Root: |     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]; |     auto& component_list = selector.complex_selectors()[component_list_index]; | ||||||
|     for (auto& component : component_list.compound_selector) { |     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: |     case Selector::ComplexSelector::Relation::Descendant: | ||||||
|         ASSERT(component_list_index != 0); |         ASSERT(component_list_index != 0); | ||||||
|         for (auto* ancestor = element.parent(); ancestor; ancestor = ancestor->parent()) { |         for (auto* ancestor = element.parent(); ancestor; ancestor = ancestor->parent()) { | ||||||
|             if (!is<Element>(*ancestor)) |             if (!is<DOM::Element>(*ancestor)) | ||||||
|                 continue; |                 continue; | ||||||
|             if (matches(selector, component_list_index - 1, downcast<Element>(*ancestor))) |             if (matches(selector, component_list_index - 1, downcast<DOM::Element>(*ancestor))) | ||||||
|                 return true; |                 return true; | ||||||
|         } |         } | ||||||
|         return false; |         return false; | ||||||
|     case Selector::ComplexSelector::Relation::ImmediateChild: |     case Selector::ComplexSelector::Relation::ImmediateChild: | ||||||
|         ASSERT(component_list_index != 0); |         ASSERT(component_list_index != 0); | ||||||
|         if (!element.parent() || !is<Element>(*element.parent())) |         if (!element.parent() || !is<DOM::Element>(*element.parent())) | ||||||
|             return false; |             return false; | ||||||
|         return matches(selector, component_list_index - 1, downcast<Element>(*element.parent())); |         return matches(selector, component_list_index - 1, downcast<DOM::Element>(*element.parent())); | ||||||
|     case Selector::ComplexSelector::Relation::AdjacentSibling: |     case Selector::ComplexSelector::Relation::AdjacentSibling: | ||||||
|         ASSERT(component_list_index != 0); |         ASSERT(component_list_index != 0); | ||||||
|         if (auto* sibling = element.previous_element_sibling()) |         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(); |     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()); |     ASSERT(!selector.complex_selectors().is_empty()); | ||||||
|     return matches(selector, selector.complex_selectors().size() - 1, element); |     return matches(selector, selector.complex_selectors().size() - 1, element); | ||||||
|  |  | ||||||
|  | @ -27,15 +27,10 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibWeb/CSS/Selector.h> | #include <LibWeb/CSS/Selector.h> | ||||||
|  | #include <LibWeb/DOM/Element.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::SelectorEngine { | ||||||
| 
 | 
 | ||||||
| class Element; | bool matches(const Selector&, const DOM::Element&); | ||||||
| 
 |  | ||||||
| namespace SelectorEngine { |  | ||||||
| 
 |  | ||||||
| bool matches(const Selector&, const Element&); |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -94,7 +94,7 @@ String StyleProperties::string_or_fallback(CSS::PropertyID id, const StringView& | ||||||
|     return value.value()->to_string(); |     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); |     auto value = property(id); | ||||||
|     if (!value.has_value()) |     if (!value.has_value()) | ||||||
|  |  | ||||||
|  | @ -59,7 +59,7 @@ public: | ||||||
|     Length length_or_fallback(CSS::PropertyID, const Length& fallback) const; |     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; |     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; |     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::TextAlign text_align() const; | ||||||
|     CSS::Display display() const; |     CSS::Display display() const; | ||||||
|     Optional<CSS::Float> float_() const; |     Optional<CSS::Float> float_() const; | ||||||
|  |  | ||||||
|  | @ -37,7 +37,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| StyleResolver::StyleResolver(Document& document) | StyleResolver::StyleResolver(DOM::Document& document) | ||||||
|     : m_document(document) |     : m_document(document) | ||||||
| { | { | ||||||
| } | } | ||||||
|  | @ -66,7 +66,7 @@ void StyleResolver::for_each_stylesheet(Callback callback) const | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Vector<MatchingRule> StyleResolver::collect_matching_rules(const Element& element) const | Vector<MatchingRule> StyleResolver::collect_matching_rules(const DOM::Element& element) const | ||||||
| { | { | ||||||
|     Vector<MatchingRule> matching_rules; |     Vector<MatchingRule> matching_rules; | ||||||
| 
 | 
 | ||||||
|  | @ -203,7 +203,7 @@ static inline void set_property_border_style(StyleProperties& style, const Style | ||||||
|         style.set_property(CSS::PropertyID::BorderLeftStyle, value); |         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); |     CSS::ParsingContext context(document); | ||||||
| 
 | 
 | ||||||
|  | @ -519,7 +519,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope | ||||||
|     style.set_property(property_id, value); |     style.set_property(property_id, value); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| NonnullRefPtr<StyleProperties> StyleResolver::resolve_style(const Element& element, const StyleProperties* parent_style) const | NonnullRefPtr<StyleProperties> StyleResolver::resolve_style(const DOM::Element& element, const StyleProperties* parent_style) const | ||||||
| { | { | ||||||
|     auto style = StyleProperties::create(); |     auto style = StyleProperties::create(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -29,15 +29,10 @@ | ||||||
| #include <AK/NonnullRefPtrVector.h> | #include <AK/NonnullRefPtrVector.h> | ||||||
| #include <AK/OwnPtr.h> | #include <AK/OwnPtr.h> | ||||||
| #include <LibWeb/CSS/StyleProperties.h> | #include <LibWeb/CSS/StyleProperties.h> | ||||||
|  | #include <LibWeb/Forward.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| class Document; |  | ||||||
| class Element; |  | ||||||
| class ParentNode; |  | ||||||
| class StyleRule; |  | ||||||
| class StyleSheet; |  | ||||||
| 
 |  | ||||||
| struct MatchingRule { | struct MatchingRule { | ||||||
|     RefPtr<StyleRule> rule; |     RefPtr<StyleRule> rule; | ||||||
|     size_t style_sheet_index { 0 }; |     size_t style_sheet_index { 0 }; | ||||||
|  | @ -47,15 +42,15 @@ struct MatchingRule { | ||||||
| 
 | 
 | ||||||
| class StyleResolver { | class StyleResolver { | ||||||
| public: | public: | ||||||
|     explicit StyleResolver(Document&); |     explicit StyleResolver(DOM::Document&); | ||||||
|     ~StyleResolver(); |     ~StyleResolver(); | ||||||
| 
 | 
 | ||||||
|     Document& document() { return m_document; } |     DOM::Document& document() { return m_document; } | ||||||
|     const Document& document() const { return m_document; } |     const DOM::Document& document() const { return m_document; } | ||||||
| 
 | 
 | ||||||
|     NonnullRefPtr<StyleProperties> resolve_style(const Element&, const StyleProperties* parent_style) const; |     NonnullRefPtr<StyleProperties> resolve_style(const DOM::Element&, const StyleProperties* parent_style) const; | ||||||
| 
 | 
 | ||||||
|     Vector<MatchingRule> collect_matching_rules(const Element&) const; |     Vector<MatchingRule> collect_matching_rules(const DOM::Element&) const; | ||||||
| 
 | 
 | ||||||
|     static bool is_inherited_property(CSS::PropertyID); |     static bool is_inherited_property(CSS::PropertyID); | ||||||
| 
 | 
 | ||||||
|  | @ -63,7 +58,7 @@ private: | ||||||
|     template<typename Callback> |     template<typename Callback> | ||||||
|     void for_each_stylesheet(Callback) const; |     void for_each_stylesheet(Callback) const; | ||||||
| 
 | 
 | ||||||
|     Document& m_document; |     DOM::Document& m_document; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -33,7 +33,7 @@ void StyleSheetList::add_sheet(NonnullRefPtr<StyleSheet> sheet) | ||||||
|     m_sheets.append(move(sheet)); |     m_sheets.append(move(sheet)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| StyleSheetList::StyleSheetList(Document& document) | StyleSheetList::StyleSheetList(DOM::Document& document) | ||||||
|     : m_document(document) |     : m_document(document) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -33,7 +33,7 @@ namespace Web::CSS { | ||||||
| 
 | 
 | ||||||
| class StyleSheetList : public RefCounted<StyleSheetList> { | class StyleSheetList : public RefCounted<StyleSheetList> { | ||||||
| public: | public: | ||||||
|     static NonnullRefPtr<StyleSheetList> create(Document& document) |     static NonnullRefPtr<StyleSheetList> create(DOM::Document& document) | ||||||
|     { |     { | ||||||
|         return adopt(*new StyleSheetList(document)); |         return adopt(*new StyleSheetList(document)); | ||||||
|     } |     } | ||||||
|  | @ -43,9 +43,9 @@ public: | ||||||
|     const NonnullRefPtrVector<StyleSheet>& sheets() const { return m_sheets; } |     const NonnullRefPtrVector<StyleSheet>& sheets() const { return m_sheets; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit StyleSheetList(Document&); |     explicit StyleSheetList(DOM::Document&); | ||||||
| 
 | 
 | ||||||
|     Document& m_document; |     DOM::Document& m_document; | ||||||
|     NonnullRefPtrVector<StyleSheet> m_sheets; |     NonnullRefPtrVector<StyleSheet> m_sheets; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -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) |     if (id() == CSS::ValueID::VendorSpecificLink) | ||||||
|         return document.link_color(); |         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) |     : StyleValue(Type::Image) | ||||||
|     , m_url(url) |     , m_url(url) | ||||||
|     , m_document(document.make_weak_ptr()) |     , m_document(document.make_weak_ptr()) | ||||||
|  |  | ||||||
|  | @ -182,7 +182,7 @@ public: | ||||||
| 
 | 
 | ||||||
|     virtual String to_string() const = 0; |     virtual String to_string() const = 0; | ||||||
|     virtual Length to_length() const { return Length::make_auto(); } |     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; } |     virtual bool is_auto() const { return false; } | ||||||
| 
 | 
 | ||||||
|  | @ -276,7 +276,7 @@ public: | ||||||
| 
 | 
 | ||||||
|     Color color() const { return m_color; } |     Color color() const { return m_color; } | ||||||
|     String to_string() const override { return m_color.to_string(); } |     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: | private: | ||||||
|     explicit ColorStyleValue(Color color) |     explicit ColorStyleValue(Color color) | ||||||
|  | @ -299,7 +299,7 @@ public: | ||||||
|     CSS::ValueID id() const { return m_id; } |     CSS::ValueID id() const { return m_id; } | ||||||
| 
 | 
 | ||||||
|     virtual String to_string() const override; |     virtual String to_string() const override; | ||||||
|     virtual Color to_color(const Document&) const override; |     virtual Color to_color(const DOM::Document&) const override; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit IdentifierStyleValue(CSS::ValueID id) |     explicit IdentifierStyleValue(CSS::ValueID id) | ||||||
|  | @ -315,7 +315,7 @@ class ImageStyleValue final | ||||||
|     : public StyleValue |     : public StyleValue | ||||||
|     , public ImageResourceClient { |     , public ImageResourceClient { | ||||||
| public: | public: | ||||||
|     static NonnullRefPtr<ImageStyleValue> create(const URL& url, Document& document) { return adopt(*new ImageStyleValue(url, document)); } |     static NonnullRefPtr<ImageStyleValue> create(const URL& url, DOM::Document& document) { return adopt(*new ImageStyleValue(url, document)); } | ||||||
|     virtual ~ImageStyleValue() override { } |     virtual ~ImageStyleValue() override { } | ||||||
| 
 | 
 | ||||||
|     String to_string() const override { return String::format("Image{%s}", m_url.to_string().characters()); } |     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; } |     const Gfx::Bitmap* bitmap() const { return m_bitmap; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     ImageStyleValue(const URL&, Document&); |     ImageStyleValue(const URL&, DOM::Document&); | ||||||
| 
 | 
 | ||||||
|     // ^ResourceClient
 |     // ^ResourceClient
 | ||||||
|     virtual void resource_did_load() override; |     virtual void resource_did_load() override; | ||||||
| 
 | 
 | ||||||
|     URL m_url; |     URL m_url; | ||||||
|     WeakPtr<Document> m_document; |     WeakPtr<DOM::Document> m_document; | ||||||
|     RefPtr<Gfx::Bitmap> m_bitmap; |     RefPtr<Gfx::Bitmap> m_bitmap; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -26,6 +26,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <AK/ByteBuffer.h> | #include <AK/ByteBuffer.h> | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
|  | #include <AK/LexicalPath.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <LibCore/ArgsParser.h> | #include <LibCore/ArgsParser.h> | ||||||
| #include <LibCore/File.h> | #include <LibCore/File.h> | ||||||
|  | @ -108,6 +109,7 @@ struct Interface { | ||||||
|     // Added for convenience after parsing
 |     // Added for convenience after parsing
 | ||||||
|     String wrapper_class; |     String wrapper_class; | ||||||
|     String wrapper_base_class; |     String wrapper_base_class; | ||||||
|  |     String fully_qualified_name; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| OwnPtr<Interface> parse_interface(const StringView& input) | OwnPtr<Interface> parse_interface(const StringView& input) | ||||||
|  | @ -312,6 +314,9 @@ int main(int argc, char** argv) | ||||||
|         return 1; |         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 data = file_or_error.value()->read_all(); | ||||||
|     auto interface = IDL::parse_interface(data); |     auto interface = IDL::parse_interface(data); | ||||||
| 
 | 
 | ||||||
|  | @ -320,6 +325,17 @@ int main(int argc, char** argv) | ||||||
|         return 1; |         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 | #if 0 | ||||||
|     dbg() << "Attributes:"; |     dbg() << "Attributes:"; | ||||||
|     for (auto& attribute : interface->attributes) { |     for (auto& attribute : interface->attributes) { | ||||||
|  | @ -402,22 +418,21 @@ static void generate_header(const IDL::Interface& interface) | ||||||
|     if (wrapper_base_class != "Wrapper") |     if (wrapper_base_class != "Wrapper") | ||||||
|         out() << "#include <LibWeb/Bindings/" << wrapper_base_class << ".h>"; |         out() << "#include <LibWeb/Bindings/" << wrapper_base_class << ".h>"; | ||||||
| 
 | 
 | ||||||
|     out() << "namespace Web {"; |     out() << "namespace Web::Bindings {"; | ||||||
|     out() << "namespace Bindings {"; |  | ||||||
| 
 | 
 | ||||||
|     out() << "class " << wrapper_class << " : public " << wrapper_base_class << " {"; |     out() << "class " << wrapper_class << " : public " << wrapper_base_class << " {"; | ||||||
|     out() << "    JS_OBJECT(" << wrapper_class << ", " << wrapper_base_class << ");"; |     out() << "    JS_OBJECT(" << wrapper_class << ", " << wrapper_base_class << ");"; | ||||||
|     out() << "public:"; |     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 void initialize(JS::GlobalObject&) override;"; | ||||||
|     out() << "    virtual ~" << wrapper_class << "() override;"; |     out() << "    virtual ~" << wrapper_class << "() override;"; | ||||||
| 
 | 
 | ||||||
|     if (wrapper_base_class == "Wrapper") { |     if (wrapper_base_class == "Wrapper") { | ||||||
|         out() << "    " << interface.name << "& impl() { return *m_impl; }"; |         out() << "    " << interface.fully_qualified_name << "& impl() { return *m_impl; }"; | ||||||
|         out() << "    const " << interface.name << "& impl() const { return *m_impl; }"; |         out() << "    const " << interface.fully_qualified_name << "& impl() const { return *m_impl; }"; | ||||||
|     } else { |     } else { | ||||||
|         out() << "    " << interface.name << "& impl() { return static_cast<" << interface.name << "&>(" << wrapper_base_class << "::impl()); }"; |         out() << "    " << interface.fully_qualified_name << "& impl() { return static_cast<" << interface.fully_qualified_name << "&>(" << wrapper_base_class << "::impl()); }"; | ||||||
|         out() << "    const " << interface.name << "& impl() const { return static_cast<const " << interface.name << "&>(" << wrapper_base_class << "::impl()); }"; |         out() << "    const " << interface.fully_qualified_name << "& impl() const { return static_cast<const " << interface.fully_qualified_name << "&>(" << wrapper_base_class << "::impl()); }"; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     auto is_foo_wrapper_name = snake_name(String::format("Is%s", wrapper_class.characters())); |     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") { |     if (wrapper_base_class == "Wrapper") { | ||||||
|         out() << "    NonnullRefPtr<" << interface.name << "> m_impl;"; |         out() << "    NonnullRefPtr<" << interface.fully_qualified_name << "> m_impl;"; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     out() << "};"; |     out() << "};"; | ||||||
| 
 | 
 | ||||||
|     if (should_emit_wrapper_factory(interface)) { |     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() << "}"; | ||||||
|     out() << "}"; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void generate_implementation(const IDL::Interface& interface) | void generate_implementation(const IDL::Interface& interface) | ||||||
|  | @ -473,11 +487,17 @@ void generate_implementation(const IDL::Interface& interface) | ||||||
|     out() << "#include <LibWeb/Bindings/ImageDataWrapper.h>"; |     out() << "#include <LibWeb/Bindings/ImageDataWrapper.h>"; | ||||||
|     out() << "#include <LibWeb/Bindings/CanvasRenderingContext2DWrapper.h>"; |     out() << "#include <LibWeb/Bindings/CanvasRenderingContext2DWrapper.h>"; | ||||||
| 
 | 
 | ||||||
|     out() << "namespace Web {"; |     // FIXME: This is a total hack until we can figure out the namespace for a given type somehow.
 | ||||||
|     out() << "namespace Bindings {"; |     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
 |     // 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") { |     if (wrapper_base_class == "Wrapper") { | ||||||
|         out() << "    : Wrapper(*global_object.object_prototype())"; |         out() << "    : Wrapper(*global_object.object_prototype())"; | ||||||
|         out() << "    , m_impl(impl)"; |         out() << "    , m_impl(impl)"; | ||||||
|  | @ -510,13 +530,13 @@ void generate_implementation(const IDL::Interface& interface) | ||||||
| 
 | 
 | ||||||
|     // Implementation: impl_from()
 |     // Implementation: impl_from()
 | ||||||
|     if (!interface.attributes.is_empty() || !interface.functions.is_empty()) { |     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() << "{"; | ||||||
|         out() << "    auto* this_object = interpreter.this_value(global_object).to_object(interpreter, global_object);"; |         out() << "    auto* this_object = interpreter.this_value(global_object).to_object(interpreter, global_object);"; | ||||||
|         out() << "    if (!this_object)"; |         out() << "    if (!this_object)"; | ||||||
|         out() << "        return {};"; |         out() << "        return {};"; | ||||||
|         out() << "    if (!this_object->inherits(\"" << wrapper_class << "\")) {"; |         out() << "    if (!this_object->inherits(\"" << wrapper_class << "\")) {"; | ||||||
|         out() << "        interpreter.throw_exception<JS::TypeError>(JS::ErrorType::NotA, \"" << interface.name << "\");"; |         out() << "        interpreter.throw_exception<JS::TypeError>(JS::ErrorType::NotA, \"" << interface.fully_qualified_name << "\");"; | ||||||
|         out() << "        return nullptr;"; |         out() << "        return nullptr;"; | ||||||
|         out() << "    }"; |         out() << "    }"; | ||||||
|         out() << "    return &static_cast<" << wrapper_class << "*>(this_object)->impl();"; |         out() << "    return &static_cast<" << wrapper_class << "*>(this_object)->impl();"; | ||||||
|  | @ -676,12 +696,11 @@ void generate_implementation(const IDL::Interface& interface) | ||||||
| 
 | 
 | ||||||
|     // Implementation: Wrapper factory
 |     // Implementation: Wrapper factory
 | ||||||
|     if (should_emit_wrapper_factory(interface)) { |     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() << "{"; | ||||||
|         out() << "    return static_cast<" << wrapper_class << "*>(wrap_impl(global_object, impl));"; |         out() << "    return static_cast<" << wrapper_class << "*>(wrap_impl(global_object, impl));"; | ||||||
|         out() << "}"; |         out() << "}"; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     out() << "}"; |     out() << "}"; | ||||||
|     out() << "}"; |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibWeb/DOM/CharacterData.h> | #include <LibWeb/DOM/CharacterData.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| CharacterData::CharacterData(Document& document, NodeType type, const String& data) | CharacterData::CharacterData(Document& document, NodeType type, const String& data) | ||||||
|     : Node(document, type) |     : Node(document, type) | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
| #include <LibWeb/DOM/Node.h> | #include <LibWeb/DOM/Node.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| class CharacterData : public Node { | class CharacterData : public Node { | ||||||
| public: | public: | ||||||
|  | @ -49,6 +49,6 @@ private: | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::CharacterData) | AK_BEGIN_TYPE_TRAITS(Web::DOM::CharacterData) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_character_data(); } | static bool is_type(const Web::DOM::Node& node) { return node.is_character_data(); } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ | ||||||
| #include <LibWeb/DOM/Comment.h> | #include <LibWeb/DOM/Comment.h> | ||||||
| #include <LibWeb/Layout/LayoutText.h> | #include <LibWeb/Layout/LayoutText.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| Comment::Comment(Document& document, const String& data) | Comment::Comment(Document& document, const String& data) | ||||||
|     : CharacterData(document, NodeType::COMMENT_NODE, data) |     : CharacterData(document, NodeType::COMMENT_NODE, data) | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ | ||||||
| #include <AK/FlyString.h> | #include <AK/FlyString.h> | ||||||
| #include <LibWeb/DOM/CharacterData.h> | #include <LibWeb/DOM/CharacterData.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| class Comment final : public CharacterData { | class Comment final : public CharacterData { | ||||||
| public: | public: | ||||||
|  | @ -41,6 +41,6 @@ public: | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::Comment) | AK_BEGIN_TYPE_TRAITS(Web::DOM::Comment) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_comment(); } | static bool is_type(const Web::DOM::Node& node) { return node.is_comment(); } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -59,7 +59,7 @@ | ||||||
| #include <LibWeb/SVG/TagNames.h> | #include <LibWeb/SVG/TagNames.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| Document::Document(const URL& url) | Document::Document(const URL& url) | ||||||
|     : ParentNode(*this, NodeType::DOCUMENT_NODE) |     : ParentNode(*this, NodeType::DOCUMENT_NODE) | ||||||
|  | @ -433,7 +433,7 @@ JS::Value Document::run_javascript(const StringView& source) | ||||||
| 
 | 
 | ||||||
| NonnullRefPtr<Element> Document::create_element(const String& tag_name) | NonnullRefPtr<Element> Document::create_element(const String& tag_name) | ||||||
| { | { | ||||||
|     return Web::create_element(*this, tag_name); |     return DOM::create_element(*this, tag_name); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| NonnullRefPtr<Text> Document::create_text_node(const String& data) | NonnullRefPtr<Text> Document::create_text_node(const String& data) | ||||||
|  |  | ||||||
|  | @ -41,7 +41,7 @@ | ||||||
| #include <LibWeb/DOM/NonElementParentNode.h> | #include <LibWeb/DOM/NonElementParentNode.h> | ||||||
| #include <LibWeb/DOM/ParentNode.h> | #include <LibWeb/DOM/ParentNode.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| enum class QuirksMode { | enum class QuirksMode { | ||||||
|     No, |     No, | ||||||
|  | @ -190,7 +190,6 @@ private: | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::Document) | AK_BEGIN_TYPE_TRAITS(Web::DOM::Document) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_document(); } | static bool is_type(const Web::DOM::Node& node) { return node.is_document(); } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -30,7 +30,7 @@ | ||||||
| #include <LibWeb/DOM/NonElementParentNode.h> | #include <LibWeb/DOM/NonElementParentNode.h> | ||||||
| #include <LibWeb/DOM/ParentNode.h> | #include <LibWeb/DOM/ParentNode.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| class DocumentFragment | class DocumentFragment | ||||||
|     : public ParentNode |     : public ParentNode | ||||||
|  | @ -46,6 +46,6 @@ public: | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::DocumentFragment) | AK_BEGIN_TYPE_TRAITS(Web::DOM::DocumentFragment) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_document_fragment(); } | static bool is_type(const Web::DOM::Node& node) { return node.is_document_fragment(); } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibWeb/DOM/DocumentType.h> | #include <LibWeb/DOM/DocumentType.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| DocumentType::DocumentType(Document& document) | DocumentType::DocumentType(Document& document) | ||||||
|     : Node(document, NodeType::DOCUMENT_TYPE_NODE) |     : Node(document, NodeType::DOCUMENT_TYPE_NODE) | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ | ||||||
| #include <AK/FlyString.h> | #include <AK/FlyString.h> | ||||||
| #include <LibWeb/DOM/Node.h> | #include <LibWeb/DOM/Node.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| class DocumentType final : public Node { | class DocumentType final : public Node { | ||||||
| public: | public: | ||||||
|  | @ -57,6 +57,6 @@ private: | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::DocumentType) | AK_BEGIN_TYPE_TRAITS(Web::DOM::DocumentType) | ||||||
| static bool is_type(const Web::Node& node) { return node.type() == Web::NodeType::DOCUMENT_TYPE_NODE; } | static bool is_type(const Web::DOM::Node& node) { return node.type() == Web::DOM::NodeType::DOCUMENT_TYPE_NODE; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -43,7 +43,7 @@ | ||||||
| #include <LibWeb/Layout/LayoutTreeBuilder.h> | #include <LibWeb/Layout/LayoutTreeBuilder.h> | ||||||
| #include <LibWeb/Parser/HTMLDocumentParser.h> | #include <LibWeb/Parser/HTMLDocumentParser.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| Element::Element(Document& document, const FlyString& tag_name) | Element::Element(Document& document, const FlyString& tag_name) | ||||||
|     : ParentNode(document, NodeType::ELEMENT_NODE) |     : ParentNode(document, NodeType::ELEMENT_NODE) | ||||||
|  |  | ||||||
|  | @ -34,9 +34,7 @@ | ||||||
| #include <LibWeb/DOM/TagNames.h> | #include <LibWeb/DOM/TagNames.h> | ||||||
| #include <LibWeb/Layout/LayoutNode.h> | #include <LibWeb/Layout/LayoutNode.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 |  | ||||||
| class LayoutNodeWithStyle; |  | ||||||
| 
 | 
 | ||||||
| class Element : public ParentNode { | class Element : public ParentNode { | ||||||
| public: | public: | ||||||
|  | @ -101,6 +99,6 @@ private: | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::Element) | AK_BEGIN_TYPE_TRAITS(Web::DOM::Element) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_element(); } | static bool is_type(const Web::DOM::Node& node) { return node.is_element(); } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -51,7 +51,7 @@ | ||||||
| #include <LibWeb/SVG/SVGSVGElement.h> | #include <LibWeb/SVG/SVGSVGElement.h> | ||||||
| #include <LibWeb/SVG/TagNames.h> | #include <LibWeb/SVG/TagNames.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| NonnullRefPtr<Element> create_element(Document& document, const FlyString& tag_name) | NonnullRefPtr<Element> create_element(Document& document, const FlyString& tag_name) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibWeb/DOM/Element.h> | #include <LibWeb/DOM/Element.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| NonnullRefPtr<Element> create_element(Document&, const FlyString& tag_name); | NonnullRefPtr<Element> create_element(Document&, const FlyString& tag_name); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ | ||||||
| #include <AK/FlyString.h> | #include <AK/FlyString.h> | ||||||
| #include <LibWeb/Bindings/Wrappable.h> | #include <LibWeb/Bindings/Wrappable.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| class Event | class Event | ||||||
|     : public RefCounted<Event> |     : public RefCounted<Event> | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ | ||||||
| #include <LibJS/Runtime/Function.h> | #include <LibJS/Runtime/Function.h> | ||||||
| #include <LibWeb/DOM/EventListener.h> | #include <LibWeb/DOM/EventListener.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| JS::Function& EventListener::function() | JS::Function& EventListener::function() | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -30,7 +30,7 @@ | ||||||
| #include <LibJS/Heap/Handle.h> | #include <LibJS/Heap/Handle.h> | ||||||
| #include <LibWeb/Bindings/Wrappable.h> | #include <LibWeb/Bindings/Wrappable.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| class EventListener | class EventListener | ||||||
|     : public RefCounted<EventListener> |     : public RefCounted<EventListener> | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ | ||||||
| #include <LibWeb/DOM/EventListener.h> | #include <LibWeb/DOM/EventListener.h> | ||||||
| #include <LibWeb/DOM/EventTarget.h> | #include <LibWeb/DOM/EventTarget.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| EventTarget::EventTarget() | EventTarget::EventTarget() | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
| #include <LibWeb/Forward.h> | #include <LibWeb/Forward.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| class EventTarget { | class EventTarget { | ||||||
|     AK_MAKE_NONCOPYABLE(EventTarget); |     AK_MAKE_NONCOPYABLE(EventTarget); | ||||||
|  |  | ||||||
|  | @ -28,9 +28,9 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibWeb/DOM/Event.h> | #include <LibWeb/DOM/Event.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| class MouseEvent final : public Event { | class MouseEvent final : public DOM::Event { | ||||||
| public: | public: | ||||||
|     using WrapperType = Bindings::MouseEventWrapper; |     using WrapperType = Bindings::MouseEventWrapper; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -48,7 +48,7 @@ | ||||||
| 
 | 
 | ||||||
| //#define EVENT_DEBUG
 | //#define EVENT_DEBUG
 | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| Node::Node(Document& document, NodeType type) | Node::Node(Document& document, NodeType type) | ||||||
|     : m_document(&document) |     : m_document(&document) | ||||||
|  |  | ||||||
|  | @ -35,7 +35,7 @@ | ||||||
| #include <LibWeb/DOM/EventTarget.h> | #include <LibWeb/DOM/EventTarget.h> | ||||||
| #include <LibWeb/TreeNode.h> | #include <LibWeb/TreeNode.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| enum class NodeType : unsigned { | enum class NodeType : unsigned { | ||||||
|     INVALID = 0, |     INVALID = 0, | ||||||
|  | @ -47,15 +47,6 @@ enum class NodeType : unsigned { | ||||||
|     DOCUMENT_FRAGMENT_NODE = 11, |     DOCUMENT_FRAGMENT_NODE = 11, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| class Document; |  | ||||||
| class Element; |  | ||||||
| class HTMLElement; |  | ||||||
| class HTMLAnchorElement; |  | ||||||
| class ParentNode; |  | ||||||
| class LayoutNode; |  | ||||||
| class StyleResolver; |  | ||||||
| class StyleProperties; |  | ||||||
| 
 |  | ||||||
| class Node | class Node | ||||||
|     : public TreeNode<Node> |     : public TreeNode<Node> | ||||||
|     , public EventTarget |     , public EventTarget | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ | ||||||
| #include <LibWeb/Forward.h> | #include <LibWeb/Forward.h> | ||||||
| #include <LibWeb/TreeNode.h> | #include <LibWeb/TreeNode.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| template<typename NodeType> | template<typename NodeType> | ||||||
| class NonElementParentNode { | class NonElementParentNode { | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibWeb/DOM/ParentNode.h> | #include <LibWeb/DOM/ParentNode.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| void ParentNode::remove_all_children() | void ParentNode::remove_all_children() | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <LibWeb/DOM/Node.h> | #include <LibWeb/DOM/Node.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| class ParentNode : public Node { | class ParentNode : public Node { | ||||||
| public: | public: | ||||||
|  | @ -60,6 +60,6 @@ inline void ParentNode::for_each_child(Callback callback) | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::ParentNode) | AK_BEGIN_TYPE_TRAITS(Web::DOM::ParentNode) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_parent_node(); } | static bool is_type(const Web::DOM::Node& node) { return node.is_parent_node(); } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ | ||||||
| #include <LibWeb/DOM/Text.h> | #include <LibWeb/DOM/Text.h> | ||||||
| #include <LibWeb/Layout/LayoutText.h> | #include <LibWeb/Layout/LayoutText.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| Text::Text(Document& document, const String& data) | Text::Text(Document& document, const String& data) | ||||||
|     : CharacterData(document, NodeType::TEXT_NODE, data) |     : CharacterData(document, NodeType::TEXT_NODE, data) | ||||||
|  |  | ||||||
|  | @ -30,7 +30,7 @@ | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
| #include <LibWeb/DOM/CharacterData.h> | #include <LibWeb/DOM/CharacterData.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| class Text final : public CharacterData { | class Text final : public CharacterData { | ||||||
| public: | public: | ||||||
|  | @ -45,6 +45,6 @@ private: | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::Text) | AK_BEGIN_TYPE_TRAITS(Web::DOM::Text) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_text(); } | static bool is_type(const Web::DOM::Node& node) { return node.is_text(); } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -30,7 +30,7 @@ | ||||||
| #include <LibWeb/DOM/Timer.h> | #include <LibWeb/DOM/Timer.h> | ||||||
| #include <LibWeb/DOM/Window.h> | #include <LibWeb/DOM/Window.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| NonnullRefPtr<Timer> Timer::create_interval(Window& window, int milliseconds, JS::Function& callback) | NonnullRefPtr<Timer> Timer::create_interval(Window& window, int milliseconds, JS::Function& callback) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ | ||||||
| #include <LibJS/Heap/Handle.h> | #include <LibJS/Heap/Handle.h> | ||||||
| #include <LibWeb/Forward.h> | #include <LibWeb/Forward.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| class Timer final : public RefCounted<Timer> { | class Timer final : public RefCounted<Timer> { | ||||||
| public: | public: | ||||||
|  |  | ||||||
|  | @ -35,7 +35,7 @@ | ||||||
| #include <LibWeb/Frame/Frame.h> | #include <LibWeb/Frame/Frame.h> | ||||||
| #include <LibWeb/PageView.h> | #include <LibWeb/PageView.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| NonnullRefPtr<Window> Window::create_with_document(Document& document) | NonnullRefPtr<Window> Window::create_with_document(Document& document) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -33,7 +33,7 @@ | ||||||
| #include <LibWeb/Bindings/WindowObject.h> | #include <LibWeb/Bindings/WindowObject.h> | ||||||
| #include <LibWeb/Bindings/Wrappable.h> | #include <LibWeb/Bindings/Wrappable.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 | 
 | ||||||
| class Window : public RefCounted<Window> { | class Window : public RefCounted<Window> { | ||||||
| public: | public: | ||||||
|  |  | ||||||
|  | @ -38,7 +38,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| XMLHttpRequest::XMLHttpRequest(Window& window) | XMLHttpRequest::XMLHttpRequest(DOM::Window& window) | ||||||
|     : m_window(window) |     : m_window(window) | ||||||
| { | { | ||||||
| } | } | ||||||
|  | @ -78,22 +78,22 @@ void XMLHttpRequest::send() | ||||||
|                 return; |                 return; | ||||||
|             const_cast<XMLHttpRequest&>(*weak_this).m_response = data; |             const_cast<XMLHttpRequest&>(*weak_this).m_response = data; | ||||||
|             const_cast<XMLHttpRequest&>(*weak_this).set_ready_state(ReadyState::Done); |             const_cast<XMLHttpRequest&>(*weak_this).set_ready_state(ReadyState::Done); | ||||||
|             const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(Event::create("load")); |             const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(DOM::Event::create("load")); | ||||||
|         }, |         }, | ||||||
|         [weak_this = make_weak_ptr()](auto& error) { |         [weak_this = make_weak_ptr()](auto& error) { | ||||||
|             if (!weak_this) |             if (!weak_this) | ||||||
|                 return; |                 return; | ||||||
|             dbg() << "XHR failed to load: " << error; |             dbg() << "XHR failed to load: " << error; | ||||||
|             const_cast<XMLHttpRequest&>(*weak_this).set_ready_state(ReadyState::Done); |             const_cast<XMLHttpRequest&>(*weak_this).set_ready_state(ReadyState::Done); | ||||||
|             const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(Event::create("error")); |             const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(DOM::Event::create("error")); | ||||||
|         }); |         }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void XMLHttpRequest::dispatch_event(NonnullRefPtr<Event> event) | void XMLHttpRequest::dispatch_event(NonnullRefPtr<DOM::Event> event) | ||||||
| { | { | ||||||
|     for (auto& listener : listeners()) { |     for (auto& listener : listeners()) { | ||||||
|         if (listener.event_name == event->type()) { |         if (listener.event_name == event->type()) { | ||||||
|             auto& function = const_cast<EventListener&>(*listener.listener).function(); |             auto& function = const_cast<DOM::EventListener&>(*listener.listener).function(); | ||||||
|             auto& global_object = function.global_object(); |             auto& global_object = function.global_object(); | ||||||
|             auto* this_value = wrap(global_object, *this); |             auto* this_value = wrap(global_object, *this); | ||||||
|             JS::MarkedValueList arguments(global_object.heap()); |             JS::MarkedValueList arguments(global_object.heap()); | ||||||
|  |  | ||||||
|  | @ -37,7 +37,7 @@ namespace Web { | ||||||
| class XMLHttpRequest final | class XMLHttpRequest final | ||||||
|     : public RefCounted<XMLHttpRequest> |     : public RefCounted<XMLHttpRequest> | ||||||
|     , public Weakable<XMLHttpRequest> |     , public Weakable<XMLHttpRequest> | ||||||
|     , public EventTarget |     , public DOM::EventTarget | ||||||
|     , public Bindings::Wrappable { |     , public Bindings::Wrappable { | ||||||
| public: | public: | ||||||
|     enum class ReadyState { |     enum class ReadyState { | ||||||
|  | @ -50,7 +50,7 @@ public: | ||||||
| 
 | 
 | ||||||
|     using WrapperType = Bindings::XMLHttpRequestWrapper; |     using WrapperType = Bindings::XMLHttpRequestWrapper; | ||||||
| 
 | 
 | ||||||
|     static NonnullRefPtr<XMLHttpRequest> create(Window& window) { return adopt(*new XMLHttpRequest(window)); } |     static NonnullRefPtr<XMLHttpRequest> create(DOM::Window& window) { return adopt(*new XMLHttpRequest(window)); } | ||||||
| 
 | 
 | ||||||
|     virtual ~XMLHttpRequest() override; |     virtual ~XMLHttpRequest() override; | ||||||
| 
 | 
 | ||||||
|  | @ -65,13 +65,13 @@ public: | ||||||
| private: | private: | ||||||
|     virtual void ref_event_target() override { ref(); } |     virtual void ref_event_target() override { ref(); } | ||||||
|     virtual void unref_event_target() override { unref(); } |     virtual void unref_event_target() override { unref(); } | ||||||
|     virtual void dispatch_event(NonnullRefPtr<Event>) override; |     virtual void dispatch_event(NonnullRefPtr<DOM::Event>) override; | ||||||
| 
 | 
 | ||||||
|     void set_ready_state(ReadyState); |     void set_ready_state(ReadyState); | ||||||
| 
 | 
 | ||||||
|     explicit XMLHttpRequest(Window&); |     explicit XMLHttpRequest(DOM::Window&); | ||||||
| 
 | 
 | ||||||
|     NonnullRefPtr<Window> m_window; |     NonnullRefPtr<DOM::Window> m_window; | ||||||
| 
 | 
 | ||||||
|     ReadyState m_ready_state { ReadyState::Unsent }; |     ReadyState m_ready_state { ReadyState::Unsent }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| DOMTreeModel::DOMTreeModel(Document& document) | DOMTreeModel::DOMTreeModel(DOM::Document& document) | ||||||
|     : m_document(document) |     : m_document(document) | ||||||
| { | { | ||||||
|     m_document_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png")); |     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()) { |     if (!parent.is_valid()) { | ||||||
|         return create_index(row, column, m_document.ptr()); |         return create_index(row, column, m_document.ptr()); | ||||||
|     } |     } | ||||||
|     auto& parent_node = *static_cast<Node*>(parent.internal_data()); |     auto& parent_node = *static_cast<DOM::Node*>(parent.internal_data()); | ||||||
|     return create_index(row, column, parent_node.child_at_index(row)); |     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()) |     if (!index.is_valid()) | ||||||
|         return {}; |         return {}; | ||||||
|     auto& node = *static_cast<Node*>(index.internal_data()); |     auto& node = *static_cast<DOM::Node*>(index.internal_data()); | ||||||
|     if (!node.parent()) |     if (!node.parent()) | ||||||
|         return {}; |         return {}; | ||||||
| 
 | 
 | ||||||
|  | @ -85,7 +85,7 @@ int DOMTreeModel::row_count(const GUI::ModelIndex& index) const | ||||||
| { | { | ||||||
|     if (!index.is_valid()) |     if (!index.is_valid()) | ||||||
|         return 1; |         return 1; | ||||||
|     auto& node = *static_cast<Node*>(index.internal_data()); |     auto& node = *static_cast<DOM::Node*>(index.internal_data()); | ||||||
|     return node.child_count(); |     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 | GUI::Variant DOMTreeModel::data(const GUI::ModelIndex& index, Role role) const | ||||||
| { | { | ||||||
|     auto& node = *static_cast<Node*>(index.internal_data()); |     auto& node = *static_cast<DOM::Node*>(index.internal_data()); | ||||||
|     if (role == Role::Icon) { |     if (role == Role::Icon) { | ||||||
|         if (node.is_document()) |         if (node.is_document()) | ||||||
|             return m_document_icon; |             return m_document_icon; | ||||||
|  | @ -128,10 +128,10 @@ GUI::Variant DOMTreeModel::data(const GUI::ModelIndex& index, Role role) const | ||||||
|     } |     } | ||||||
|     if (role == Role::Display) { |     if (role == Role::Display) { | ||||||
|         if (node.is_text()) |         if (node.is_text()) | ||||||
|             return String::format("%s", with_whitespace_collapsed(downcast<Text>(node).data()).characters()); |             return String::format("%s", with_whitespace_collapsed(downcast<DOM::Text>(node).data()).characters()); | ||||||
|         if (!node.is_element()) |         if (!node.is_element()) | ||||||
|             return node.node_name(); |             return node.node_name(); | ||||||
|         auto& element = downcast<Element>(node); |         auto& element = downcast<DOM::Element>(node); | ||||||
|         StringBuilder builder; |         StringBuilder builder; | ||||||
|         builder.append('<'); |         builder.append('<'); | ||||||
|         builder.append(element.local_name()); |         builder.append(element.local_name()); | ||||||
|  |  | ||||||
|  | @ -27,14 +27,13 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/Model.h> | #include <LibGUI/Model.h> | ||||||
|  | #include <LibWeb/Forward.h> | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| class Document; |  | ||||||
| 
 |  | ||||||
| class DOMTreeModel final : public GUI::Model { | class DOMTreeModel final : public GUI::Model { | ||||||
| public: | public: | ||||||
|     static NonnullRefPtr<DOMTreeModel> create(Document& document) |     static NonnullRefPtr<DOMTreeModel> create(DOM::Document& document) | ||||||
|     { |     { | ||||||
|         return adopt(*new DOMTreeModel(document)); |         return adopt(*new DOMTreeModel(document)); | ||||||
|     } |     } | ||||||
|  | @ -49,9 +48,9 @@ public: | ||||||
|     virtual void update() override; |     virtual void update() override; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit DOMTreeModel(Document&); |     explicit DOMTreeModel(DOM::Document&); | ||||||
| 
 | 
 | ||||||
|     NonnullRefPtr<Document> m_document; |     NonnullRefPtr<DOM::Document> m_document; | ||||||
| 
 | 
 | ||||||
|     GUI::Icon m_document_icon; |     GUI::Icon m_document_icon; | ||||||
|     GUI::Icon m_element_icon; |     GUI::Icon m_element_icon; | ||||||
|  |  | ||||||
|  | @ -43,31 +43,31 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| void dump_tree(const Node& node) | void dump_tree(const DOM::Node& node) | ||||||
| { | { | ||||||
|     static int indent = 0; |     static int indent = 0; | ||||||
|     for (int i = 0; i < indent; ++i) |     for (int i = 0; i < indent; ++i) | ||||||
|         dbgprintf("  "); |         dbgprintf("  "); | ||||||
|     if (is<Document>(node)) { |     if (is<DOM::Document>(node)) { | ||||||
|         dbgprintf("*Document*\n"); |         dbgprintf("*Document*\n"); | ||||||
|     } else if (is<Element>(node)) { |     } else if (is<DOM::Element>(node)) { | ||||||
|         dbgprintf("<%s", downcast<Element>(node).local_name().characters()); |         dbgprintf("<%s", downcast<DOM::Element>(node).local_name().characters()); | ||||||
|         downcast<Element>(node).for_each_attribute([](auto& name, auto& value) { |         downcast<DOM::Element>(node).for_each_attribute([](auto& name, auto& value) { | ||||||
|             dbgprintf(" %s=%s", name.characters(), value.characters()); |             dbgprintf(" %s=%s", name.characters(), value.characters()); | ||||||
|         }); |         }); | ||||||
|         dbgprintf(">\n"); |         dbgprintf(">\n"); | ||||||
|     } else if (is<Text>(node)) { |     } else if (is<DOM::Text>(node)) { | ||||||
|         dbgprintf("\"%s\"\n", static_cast<const Text&>(node).data().characters()); |         dbgprintf("\"%s\"\n", downcast<DOM::Text>(node).data().characters()); | ||||||
|     } else if (is<DocumentType>(node)) { |     } else if (is<DOM::DocumentType>(node)) { | ||||||
|         dbgprintf("<!DOCTYPE html>\n"); |         dbgprintf("<!DOCTYPE html>\n"); | ||||||
|     } else if (is<Comment>(node)) { |     } else if (is<DOM::Comment>(node)) { | ||||||
|         dbgprintf("<!--%s-->\n", downcast<Comment>(node).data().characters()); |         dbgprintf("<!--%s-->\n", downcast<DOM::Comment>(node).data().characters()); | ||||||
|     } else if (is<DocumentFragment>(node)) { |     } else if (is<DOM::DocumentFragment>(node)) { | ||||||
|         dbgprintf("#document-fragment\n"); |         dbgprintf("#document-fragment\n"); | ||||||
|     } |     } | ||||||
|     ++indent; |     ++indent; | ||||||
|     if (is<ParentNode>(node)) { |     if (is<DOM::ParentNode>(node)) { | ||||||
|         static_cast<const ParentNode&>(node).for_each_child([](auto& child) { |         static_cast<const DOM::ParentNode&>(node).for_each_child([](auto& child) { | ||||||
|             dump_tree(child); |             dump_tree(child); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  | @ -83,18 +83,18 @@ void dump_tree(const LayoutNode& layout_node) | ||||||
|     FlyString tag_name; |     FlyString tag_name; | ||||||
|     if (layout_node.is_anonymous()) |     if (layout_node.is_anonymous()) | ||||||
|         tag_name = "(anonymous)"; |         tag_name = "(anonymous)"; | ||||||
|     else if (is<Text>(layout_node.node())) |     else if (is<DOM::Text>(layout_node.node())) | ||||||
|         tag_name = "#text"; |         tag_name = "#text"; | ||||||
|     else if (is<Document>(layout_node.node())) |     else if (is<DOM::Document>(layout_node.node())) | ||||||
|         tag_name = "#document"; |         tag_name = "#document"; | ||||||
|     else if (is<Element>(layout_node.node())) |     else if (is<DOM::Element>(layout_node.node())) | ||||||
|         tag_name = downcast<Element>(*layout_node.node()).local_name(); |         tag_name = downcast<DOM::Element>(*layout_node.node()).local_name(); | ||||||
|     else |     else | ||||||
|         tag_name = "???"; |         tag_name = "???"; | ||||||
| 
 | 
 | ||||||
|     String identifier = ""; |     String identifier = ""; | ||||||
|     if (layout_node.node() && is<Element>(*layout_node.node())) { |     if (layout_node.node() && is<DOM::Element>(*layout_node.node())) { | ||||||
|         auto& element = downcast<Element>(*layout_node.node()); |         auto& element = downcast<DOM::Element>(*layout_node.node()); | ||||||
|         StringBuilder builder; |         StringBuilder builder; | ||||||
|         auto id = element.attribute(HTML::AttributeNames::id); |         auto id = element.attribute(HTML::AttributeNames::id); | ||||||
|         if (!id.is_empty()) { |         if (!id.is_empty()) { | ||||||
|  |  | ||||||
|  | @ -30,7 +30,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| void dump_tree(const Node&); | void dump_tree(const DOM::Node&); | ||||||
| void dump_tree(const LayoutNode&); | void dump_tree(const LayoutNode&); | ||||||
| void dump_sheet(const StyleSheet&); | void dump_sheet(const StyleSheet&); | ||||||
| void dump_rule(const StyleRule&); | void dump_rule(const StyleRule&); | ||||||
|  |  | ||||||
|  | @ -26,9 +26,7 @@ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web::DOM { | ||||||
| 
 |  | ||||||
| class CanvasRenderingContext2D; |  | ||||||
| class Document; | class Document; | ||||||
| class DocumentType; | class DocumentType; | ||||||
| class Element; | class Element; | ||||||
|  | @ -36,7 +34,19 @@ class Event; | ||||||
| class EventHandler; | class EventHandler; | ||||||
| class EventListener; | class EventListener; | ||||||
| class EventTarget; | class EventTarget; | ||||||
|  | class MouseEvent; | ||||||
|  | class Node; | ||||||
|  | class ParentNode; | ||||||
|  | class Text; | ||||||
|  | class Timer; | ||||||
|  | class Window; | ||||||
|  | enum class QuirksMode; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | namespace Web { | ||||||
|  | class CanvasRenderingContext2D; | ||||||
| class Frame; | class Frame; | ||||||
|  | class HTMLAnchorElement; | ||||||
| class HTMLBodyElement; | class HTMLBodyElement; | ||||||
| class HTMLCanvasElement; | class HTMLCanvasElement; | ||||||
| class HTMLDocumentParser; | class HTMLDocumentParser; | ||||||
|  | @ -46,35 +56,29 @@ class HTMLHeadElement; | ||||||
| class HTMLHtmlElement; | class HTMLHtmlElement; | ||||||
| class HTMLImageElement; | class HTMLImageElement; | ||||||
| class HTMLScriptElement; | class HTMLScriptElement; | ||||||
| class PageView; |  | ||||||
| class ImageData; | class ImageData; | ||||||
| class LineBox; |  | ||||||
| class LineBoxFragment; |  | ||||||
| class LayoutBlock; | class LayoutBlock; | ||||||
| class LayoutDocument; | class LayoutDocument; | ||||||
| class LayoutNode; | class LayoutNode; | ||||||
| class LayoutNodeWithStyle; | class LayoutNodeWithStyle; | ||||||
| class LayoutReplaced; | class LayoutReplaced; | ||||||
|  | class LineBox; | ||||||
|  | class LineBoxFragment; | ||||||
| class LoadRequest; | class LoadRequest; | ||||||
| class MouseEvent; |  | ||||||
| class Node; |  | ||||||
| class Origin; | class Origin; | ||||||
| class Page; | class Page; | ||||||
| class PageClient; | class PageClient; | ||||||
|  | class PageView; | ||||||
| class PaintContext; | class PaintContext; | ||||||
| class Resource; | class Resource; | ||||||
| class ResourceLoader; | class ResourceLoader; | ||||||
| class Selector; | class Selector; | ||||||
| class StackingContext; | class StackingContext; | ||||||
|  | class StyleProperties; | ||||||
| class StyleResolver; | class StyleResolver; | ||||||
| class StyleRule; | class StyleRule; | ||||||
| class StyleSheet; | class StyleSheet; | ||||||
| class Text; |  | ||||||
| class Timer; |  | ||||||
| class Window; |  | ||||||
| class XMLHttpRequest; | class XMLHttpRequest; | ||||||
| enum class QuirksMode; |  | ||||||
| 
 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| namespace Web::Bindings { | namespace Web::Bindings { | ||||||
|  |  | ||||||
|  | @ -78,14 +78,14 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button | ||||||
| 
 | 
 | ||||||
|     auto result = layout_root()->hit_test(position); |     auto result = layout_root()->hit_test(position); | ||||||
|     if (result.layout_node && result.layout_node->node()) { |     if (result.layout_node && result.layout_node->node()) { | ||||||
|         RefPtr<Node> node = result.layout_node->node(); |         RefPtr<DOM::Node> node = result.layout_node->node(); | ||||||
|         if (is<HTMLIFrameElement>(*node)) { |         if (is<HTMLIFrameElement>(*node)) { | ||||||
|             if (auto* subframe = downcast<HTMLIFrameElement>(*node).hosted_frame()) |             if (auto* subframe = downcast<HTMLIFrameElement>(*node).hosted_frame()) | ||||||
|                 return subframe->event_handler().handle_mouseup(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers); |                 return subframe->event_handler().handle_mouseup(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers); | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|         auto offset = compute_mouse_event_offset(position, *result.layout_node); |         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; |         handled_event = true; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -107,7 +107,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt | ||||||
|     if (!result.layout_node) |     if (!result.layout_node) | ||||||
|         return false; |         return false; | ||||||
| 
 | 
 | ||||||
|     RefPtr<Node> node = result.layout_node->node(); |     RefPtr<DOM::Node> node = result.layout_node->node(); | ||||||
|     document->set_hovered_node(node); |     document->set_hovered_node(node); | ||||||
|     if (!node) |     if (!node) | ||||||
|         return false; |         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); |     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()) |     if (!layout_root()) | ||||||
|         return true; |         return true; | ||||||
| 
 | 
 | ||||||
|  | @ -173,7 +173,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt | ||||||
|     auto result = layout_root()->hit_test(position); |     auto result = layout_root()->hit_test(position); | ||||||
|     const HTMLAnchorElement* hovered_link_element = nullptr; |     const HTMLAnchorElement* hovered_link_element = nullptr; | ||||||
|     if (result.layout_node) { |     if (result.layout_node) { | ||||||
|         RefPtr<Node> node = result.layout_node->node(); |         RefPtr<DOM::Node> node = result.layout_node->node(); | ||||||
| 
 | 
 | ||||||
|         if (node && is<HTMLIFrameElement>(*node)) { |         if (node && is<HTMLIFrameElement>(*node)) { | ||||||
|             if (auto* subframe = downcast<HTMLIFrameElement>(*node).hosted_frame()) |             if (auto* subframe = downcast<HTMLIFrameElement>(*node).hosted_frame()) | ||||||
|  | @ -192,7 +192,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt | ||||||
|                 is_hovering_link = true; |                 is_hovering_link = true; | ||||||
|             } |             } | ||||||
|             auto offset = compute_mouse_event_offset(position, *result.layout_node); |             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()) |             if (!layout_root()) | ||||||
|                 return true; |                 return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -33,7 +33,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | 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_page(main_frame.page()) | ||||||
|     , m_main_frame(main_frame) |     , m_main_frame(main_frame) | ||||||
|     , m_loader(*this) |     , 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) |     if (m_document == document) | ||||||
|         return; |         return; | ||||||
|  |  | ||||||
|  | @ -41,16 +41,16 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class Frame : public TreeNode<Frame> { | class Frame : public TreeNode<Frame> { | ||||||
| public: | public: | ||||||
|     static NonnullRefPtr<Frame> create_subframe(Element& host_element, Frame& main_frame) { return adopt(*new Frame(host_element, main_frame)); } |     static NonnullRefPtr<Frame> create_subframe(DOM::Element& host_element, Frame& main_frame) { return adopt(*new Frame(host_element, main_frame)); } | ||||||
|     static NonnullRefPtr<Frame> create(Page& page) { return adopt(*new Frame(page)); } |     static NonnullRefPtr<Frame> create(Page& page) { return adopt(*new Frame(page)); } | ||||||
|     ~Frame(); |     ~Frame(); | ||||||
| 
 | 
 | ||||||
|     bool is_main_frame() const { return this == &m_main_frame; } |     bool is_main_frame() const { return this == &m_main_frame; } | ||||||
| 
 | 
 | ||||||
|     const Document* document() const { return m_document; } |     const DOM::Document* document() const { return m_document; } | ||||||
|     Document* document() { return m_document; } |     DOM::Document* document() { return m_document; } | ||||||
| 
 | 
 | ||||||
|     void set_document(Document*); |     void set_document(DOM::Document*); | ||||||
| 
 | 
 | ||||||
|     Page& page() { return m_page; } |     Page& page() { return m_page; } | ||||||
|     const Page& page() const { return m_page; } |     const Page& page() const { return m_page; } | ||||||
|  | @ -77,15 +77,15 @@ public: | ||||||
|     Frame& main_frame() { return m_main_frame; } |     Frame& main_frame() { return m_main_frame; } | ||||||
|     const Frame& main_frame() const { return m_main_frame; } |     const Frame& main_frame() const { return m_main_frame; } | ||||||
| 
 | 
 | ||||||
|     Element* host_element() { return m_host_element; } |     DOM::Element* host_element() { return m_host_element; } | ||||||
|     const Element* host_element() const { return m_host_element; } |     const DOM::Element* host_element() const { return m_host_element; } | ||||||
| 
 | 
 | ||||||
|     Gfx::IntPoint to_main_frame_position(const Gfx::IntPoint&); |     Gfx::IntPoint to_main_frame_position(const Gfx::IntPoint&); | ||||||
|     Gfx::IntRect to_main_frame_rect(const Gfx::IntRect&); |     Gfx::IntRect to_main_frame_rect(const Gfx::IntRect&); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit Frame(Element& host_element, Frame& main_frame); |     explicit Frame(DOM::Element& host_element, Frame& main_frame); | ||||||
|     explicit Frame(Page&); |     explicit Frame(Page&); | ||||||
| 
 | 
 | ||||||
|     Page& m_page; |     Page& m_page; | ||||||
|  | @ -94,8 +94,8 @@ private: | ||||||
|     FrameLoader m_loader; |     FrameLoader m_loader; | ||||||
|     EventHandler m_event_handler; |     EventHandler m_event_handler; | ||||||
| 
 | 
 | ||||||
|     WeakPtr<Element> m_host_element; |     WeakPtr<DOM::Element> m_host_element; | ||||||
|     RefPtr<Document> m_document; |     RefPtr<DOM::Document> m_document; | ||||||
|     Gfx::IntSize m_size; |     Gfx::IntSize m_size; | ||||||
|     Gfx::IntRect m_viewport_rect; |     Gfx::IntRect m_viewport_rect; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLAnchorElement::HTMLAnchorElement(Document& document, const FlyString& tag_name) | HTMLAnchorElement::HTMLAnchorElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class HTMLAnchorElement : public HTMLElement { | class HTMLAnchorElement : public HTMLElement { | ||||||
| public: | public: | ||||||
|     HTMLAnchorElement(Document&, const FlyString& local_name); |     HTMLAnchorElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLAnchorElement() override; |     virtual ~HTMLAnchorElement() override; | ||||||
| 
 | 
 | ||||||
|     String href() const { return attribute(HTML::AttributeNames::href); } |     String href() const { return attribute(HTML::AttributeNames::href); } | ||||||
|  | @ -42,5 +42,5 @@ public: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLAnchorElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLAnchorElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::a; } | static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::a; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLBRElement::HTMLBRElement(Document& document, const FlyString& tag_name) | HTMLBRElement::HTMLBRElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class HTMLBRElement final : public HTMLElement { | class HTMLBRElement final : public HTMLElement { | ||||||
| public: | public: | ||||||
|     HTMLBRElement(Document&, const FlyString& local_name); |     HTMLBRElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLBRElement() override; |     virtual ~HTMLBRElement() override; | ||||||
| 
 | 
 | ||||||
|     virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override; |     virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override; | ||||||
|  | @ -41,5 +41,5 @@ public: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLBRElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLBRElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::br; } | static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::br; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLBlinkElement::HTMLBlinkElement(Document& document, const FlyString& tag_name) | HTMLBlinkElement::HTMLBlinkElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
|     , m_timer(Core::Timer::construct()) |     , m_timer(Core::Timer::construct()) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -33,7 +33,7 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class HTMLBlinkElement : public HTMLElement { | class HTMLBlinkElement : public HTMLElement { | ||||||
| public: | public: | ||||||
|     HTMLBlinkElement(Document&, const FlyString& local_name); |     HTMLBlinkElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLBlinkElement() override; |     virtual ~HTMLBlinkElement() override; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|  | @ -45,5 +45,5 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLBlinkElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLBlinkElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::blink; } | static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::blink; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLBodyElement::HTMLBodyElement(Document& document, const FlyString& tag_name) | HTMLBodyElement::HTMLBodyElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
| } | } | ||||||
|  | @ -74,7 +74,7 @@ void HTMLBodyElement::parse_attribute(const FlyString& name, const String& value | ||||||
|         if (color.has_value()) |         if (color.has_value()) | ||||||
|             document().set_visited_link_color(color.value()); |             document().set_visited_link_color(color.value()); | ||||||
|     } else if (name.equals_ignoring_case("background")) { |     } else if (name.equals_ignoring_case("background")) { | ||||||
|         m_background_style_value = ImageStyleValue::create(document().complete_url(value), const_cast<Document&>(document())); |         m_background_style_value = ImageStyleValue::create(document().complete_url(value), const_cast<DOM::Document&>(document())); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class HTMLBodyElement : public HTMLElement { | class HTMLBodyElement : public HTMLElement { | ||||||
| public: | public: | ||||||
|     HTMLBodyElement(Document&, const FlyString& local_name); |     HTMLBodyElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLBodyElement() override; |     virtual ~HTMLBodyElement() override; | ||||||
| 
 | 
 | ||||||
|     virtual void parse_attribute(const FlyString&, const String&) override; |     virtual void parse_attribute(const FlyString&, const String&) override; | ||||||
|  | @ -45,5 +45,5 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLBodyElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLBodyElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::body; } | static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::body; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -36,7 +36,7 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| static constexpr auto max_canvas_area = 16384 * 16384; | 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) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -38,7 +38,7 @@ class HTMLCanvasElement : public HTMLElement { | ||||||
| public: | public: | ||||||
|     using WrapperType = Bindings::HTMLCanvasElementWrapper; |     using WrapperType = Bindings::HTMLCanvasElementWrapper; | ||||||
| 
 | 
 | ||||||
|     HTMLCanvasElement(Document&, const FlyString& local_name); |     HTMLCanvasElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLCanvasElement() override; |     virtual ~HTMLCanvasElement() override; | ||||||
| 
 | 
 | ||||||
|     const Gfx::Bitmap* bitmap() const { return m_bitmap; } |     const Gfx::Bitmap* bitmap() const { return m_bitmap; } | ||||||
|  | @ -60,5 +60,5 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLCanvasElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLCanvasElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::canvas; } | static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::canvas; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLElement::HTMLElement(Document& document, const FlyString& tag_name) | HTMLElement::HTMLElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : Element(document, tag_name) |     : Element(document, tag_name) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -30,11 +30,11 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| class HTMLElement : public Element { | class HTMLElement : public DOM::Element { | ||||||
| public: | public: | ||||||
|     using WrapperType = Bindings::HTMLElementWrapper; |     using WrapperType = Bindings::HTMLElementWrapper; | ||||||
| 
 | 
 | ||||||
|     HTMLElement(Document&, const FlyString& local_name); |     HTMLElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLElement() override; |     virtual ~HTMLElement() override; | ||||||
| 
 | 
 | ||||||
|     String title() const { return attribute(HTML::AttributeNames::title); } |     String title() const { return attribute(HTML::AttributeNames::title); } | ||||||
|  | @ -46,5 +46,5 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLElement) | 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() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -30,7 +30,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLFontElement::HTMLFontElement(Document& document, const FlyString& tag_name) | HTMLFontElement::HTMLFontElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class HTMLFontElement : public HTMLElement { | class HTMLFontElement : public HTMLElement { | ||||||
| public: | public: | ||||||
|     HTMLFontElement(Document&, const FlyString& local_name); |     HTMLFontElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLFontElement() override; |     virtual ~HTMLFontElement() override; | ||||||
| 
 | 
 | ||||||
|     virtual void apply_presentational_hints(StyleProperties&) const override; |     virtual void apply_presentational_hints(StyleProperties&) const override; | ||||||
|  | @ -41,5 +41,5 @@ public: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLFontElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLFontElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::font; } | static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::font; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -33,7 +33,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLFormElement::HTMLFormElement(Document& document, const FlyString& tag_name) | HTMLFormElement::HTMLFormElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -33,7 +33,7 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class HTMLFormElement : public HTMLElement { | class HTMLFormElement : public HTMLElement { | ||||||
| public: | public: | ||||||
|     HTMLFormElement(Document&, const FlyString& local_name); |     HTMLFormElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLFormElement() override; |     virtual ~HTMLFormElement() override; | ||||||
| 
 | 
 | ||||||
|     String action() const { return attribute(HTML::AttributeNames::action); } |     String action() const { return attribute(HTML::AttributeNames::action); } | ||||||
|  | @ -45,5 +45,5 @@ public: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLFormElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLFormElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::form; } | static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::form; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLHRElement::HTMLHRElement(Document& document, const FlyString& tag_name) | HTMLHRElement::HTMLHRElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -32,12 +32,12 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class HTMLHRElement : public HTMLElement { | class HTMLHRElement : public HTMLElement { | ||||||
| public: | public: | ||||||
|     HTMLHRElement(Document&, const FlyString& local_name); |     HTMLHRElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLHRElement() override; |     virtual ~HTMLHRElement() override; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLHRElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLHRElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::hr; } | static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::hr; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLHeadElement::HTMLHeadElement(Document& document, const FlyString& tag_name) | HTMLHeadElement::HTMLHeadElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -32,12 +32,12 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class HTMLHeadElement : public HTMLElement { | class HTMLHeadElement : public HTMLElement { | ||||||
| public: | public: | ||||||
|     HTMLHeadElement(Document&, const FlyString& local_name); |     HTMLHeadElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLHeadElement() override; |     virtual ~HTMLHeadElement() override; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLHeadElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLHeadElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::head; } | static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::head; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLHeadingElement::HTMLHeadingElement(Document& document, const FlyString& tag_name) | HTMLHeadingElement::HTMLHeadingElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class HTMLHeadingElement : public HTMLElement { | class HTMLHeadingElement : public HTMLElement { | ||||||
| public: | public: | ||||||
|     HTMLHeadingElement(Document&, const FlyString& local_name); |     HTMLHeadingElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLHeadingElement() override; |     virtual ~HTMLHeadingElement() override; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLHtmlElement::HTMLHtmlElement(Document& document, const FlyString& tag_name) | HTMLHtmlElement::HTMLHtmlElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -32,12 +32,12 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class HTMLHtmlElement : public HTMLElement { | class HTMLHtmlElement : public HTMLElement { | ||||||
| public: | public: | ||||||
|     HTMLHtmlElement(Document&, const FlyString& local_name); |     HTMLHtmlElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLHtmlElement() override; |     virtual ~HTMLHtmlElement() override; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLHtmlElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLHtmlElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::html; } | static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::html; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -41,7 +41,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLIFrameElement::HTMLIFrameElement(Document& document, const FlyString& tag_name) | HTMLIFrameElement::HTMLIFrameElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, 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); |     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; |     return m_hosted_frame ? m_hosted_frame->document() : nullptr; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class HTMLIFrameElement final : public HTMLElement { | class HTMLIFrameElement final : public HTMLElement { | ||||||
| public: | public: | ||||||
|     HTMLIFrameElement(Document&, const FlyString& local_name); |     HTMLIFrameElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLIFrameElement() override; |     virtual ~HTMLIFrameElement() override; | ||||||
| 
 | 
 | ||||||
|     virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override; |     virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override; | ||||||
|  | @ -40,7 +40,7 @@ public: | ||||||
|     Frame* hosted_frame() { return m_hosted_frame; } |     Frame* hosted_frame() { return m_hosted_frame; } | ||||||
|     const Frame* hosted_frame() const { 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: | private: | ||||||
|     virtual void document_did_attach_to_frame(Frame&) override; |     virtual void document_did_attach_to_frame(Frame&) override; | ||||||
|  | @ -54,5 +54,5 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLIFrameElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLIFrameElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::iframe; } | static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::iframe; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -37,18 +37,18 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLImageElement::HTMLImageElement(Document& document, const FlyString& tag_name) | HTMLImageElement::HTMLImageElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
|     m_image_loader.on_load = [this] { |     m_image_loader.on_load = [this] { | ||||||
|         this->document().update_layout(); |         this->document().update_layout(); | ||||||
|         dispatch_event(Event::create("load")); |         dispatch_event(DOM::Event::create("load")); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_image_loader.on_fail = [this] { |     m_image_loader.on_fail = [this] { | ||||||
|         dbg() << "HTMLImageElement: Resource did fail: " << this->src(); |         dbg() << "HTMLImageElement: Resource did fail: " << this->src(); | ||||||
|         this->document().update_layout(); |         this->document().update_layout(); | ||||||
|         dispatch_event(Event::create("error")); |         dispatch_event(DOM::Event::create("error")); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_image_loader.on_animate = [this] { |     m_image_loader.on_animate = [this] { | ||||||
|  |  | ||||||
|  | @ -40,7 +40,7 @@ class HTMLImageElement final : public HTMLElement { | ||||||
| public: | public: | ||||||
|     using WrapperType = Bindings::HTMLImageElementWrapper; |     using WrapperType = Bindings::HTMLImageElementWrapper; | ||||||
| 
 | 
 | ||||||
|     HTMLImageElement(Document&, const FlyString& local_name); |     HTMLImageElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLImageElement() override; |     virtual ~HTMLImageElement() override; | ||||||
| 
 | 
 | ||||||
|     virtual void parse_attribute(const FlyString& name, const String& value) override; |     virtual void parse_attribute(const FlyString& name, const String& value) override; | ||||||
|  | @ -63,5 +63,5 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLImageElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLImageElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::img; } | static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::img; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -37,7 +37,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLInputElement::HTMLInputElement(Document& document, const FlyString& tag_name) | HTMLInputElement::HTMLInputElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
| } | } | ||||||
|  | @ -76,7 +76,7 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties* p | ||||||
|         int text_width = Gfx::Font::default_font().width(value()); |         int text_width = Gfx::Font::default_font().width(value()); | ||||||
|         button.set_relative_rect(0, 0, text_width + 20, 20); |         button.set_relative_rect(0, 0, text_width + 20, 20); | ||||||
|         button.on_click = [this](auto) { |         button.on_click = [this](auto) { | ||||||
|             const_cast<HTMLInputElement*>(this)->dispatch_event(Event::create("click")); |             const_cast<HTMLInputElement*>(this)->dispatch_event(DOM::Event::create("click")); | ||||||
|         }; |         }; | ||||||
|         widget = button; |         widget = button; | ||||||
|     } else { |     } else { | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ namespace Web { | ||||||
| 
 | 
 | ||||||
| class HTMLInputElement : public HTMLElement { | class HTMLInputElement : public HTMLElement { | ||||||
| public: | public: | ||||||
|     HTMLInputElement(Document&, const FlyString& local_name); |     HTMLInputElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLInputElement() override; |     virtual ~HTMLInputElement() override; | ||||||
| 
 | 
 | ||||||
|     virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override; |     virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override; | ||||||
|  | @ -45,5 +45,5 @@ public: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLInputElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLInputElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::input; } | static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::input; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLLinkElement::HTMLLinkElement(Document& document, const FlyString& tag_name) | HTMLLinkElement::HTMLLinkElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -35,7 +35,7 @@ class HTMLLinkElement final | ||||||
|     : public HTMLElement |     : public HTMLElement | ||||||
|     , public ResourceClient { |     , public ResourceClient { | ||||||
| public: | public: | ||||||
|     HTMLLinkElement(Document&, const FlyString& local_name); |     HTMLLinkElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLLinkElement() override; |     virtual ~HTMLLinkElement() override; | ||||||
| 
 | 
 | ||||||
|     virtual void inserted_into(Node&) override; |     virtual void inserted_into(Node&) override; | ||||||
|  | @ -67,5 +67,5 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLLinkElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLLinkElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::link; } | static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::link; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
|  | @ -35,7 +35,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace Web { | namespace Web { | ||||||
| 
 | 
 | ||||||
| HTMLObjectElement::HTMLObjectElement(Document& document, const FlyString& tag_name) | HTMLObjectElement::HTMLObjectElement(DOM::Document& document, const FlyString& tag_name) | ||||||
|     : HTMLElement(document, tag_name) |     : HTMLElement(document, tag_name) | ||||||
| { | { | ||||||
|     m_image_loader.on_load = [this] { |     m_image_loader.on_load = [this] { | ||||||
|  |  | ||||||
|  | @ -37,7 +37,7 @@ class LayoutDocument; | ||||||
| 
 | 
 | ||||||
| class HTMLObjectElement final : public HTMLElement { | class HTMLObjectElement final : public HTMLElement { | ||||||
| public: | public: | ||||||
|     HTMLObjectElement(Document&, const FlyString& local_name); |     HTMLObjectElement(DOM::Document&, const FlyString& local_name); | ||||||
|     virtual ~HTMLObjectElement() override; |     virtual ~HTMLObjectElement() override; | ||||||
| 
 | 
 | ||||||
|     virtual void parse_attribute(const FlyString& name, const String& value) override; |     virtual void parse_attribute(const FlyString& name, const String& value) override; | ||||||
|  | @ -55,5 +55,5 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| AK_BEGIN_TYPE_TRAITS(Web::HTMLObjectElement) | AK_BEGIN_TYPE_TRAITS(Web::HTMLObjectElement) | ||||||
| static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::object; } | static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::object; } | ||||||
| AK_END_TYPE_TRAITS() | AK_END_TYPE_TRAITS() | ||||||
|  |  | ||||||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling