mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:12:45 +00:00 
			
		
		
		
	LibWeb: Remove more hand-rolled type information :^)
Hoo boy, we've really accumulated a lot of this stuff.
This commit is contained in:
		
							parent
							
								
									d2613403e0
								
							
						
					
					
						commit
						3bb0cb2202
					
				
					 15 changed files with 5 additions and 40 deletions
				
			
		|  | @ -33,7 +33,7 @@ namespace Bindings { | |||
| 
 | ||||
| EventWrapper* wrap(JS::GlobalObject& global_object, DOM::Event& event) | ||||
| { | ||||
|     if (event.is_mouse_event()) | ||||
|     if (is<UIEvents::MouseEvent>(event)) | ||||
|         return static_cast<MouseEventWrapper*>(wrap_impl(global_object, static_cast<UIEvents::MouseEvent&>(event))); | ||||
|     return static_cast<EventWrapper*>(wrap_impl(global_object, event)); | ||||
| } | ||||
|  |  | |||
|  | @ -29,6 +29,7 @@ | |||
| #include <LibWeb/DOM/Element.h> | ||||
| #include <LibWeb/DOM/Text.h> | ||||
| #include <LibWeb/HTML/AttributeNames.h> | ||||
| #include <LibWeb/HTML/HTMLElement.h> | ||||
| 
 | ||||
| namespace Web::SelectorEngine { | ||||
| 
 | ||||
|  | @ -86,7 +87,7 @@ static bool matches(const CSS::Selector::SimpleSelector& component, const DOM::E | |||
|             return false; | ||||
|         break; | ||||
|     case CSS::Selector::SimpleSelector::PseudoClass::Root: | ||||
|         if (!element.is_html_element()) | ||||
|         if (!is<HTML::HTMLElement>(element)) | ||||
|             return false; | ||||
|         break; | ||||
|     } | ||||
|  |  | |||
|  | @ -39,7 +39,7 @@ void Event::append_to_path(EventTarget& invocation_target, RefPtr<EventTarget> s | |||
| 
 | ||||
|     if (is<Node>(invocation_target)) { | ||||
|         auto& invocation_target_node = downcast<Node>(invocation_target); | ||||
|         if (invocation_target_node.root()->is_shadow_root()) | ||||
|         if (is<ShadowRoot>(invocation_target_node.root())) | ||||
|             invocation_target_in_shadow_tree = true; | ||||
|         if (is<ShadowRoot>(invocation_target_node)) { | ||||
|             auto& invocation_target_shadow_root = downcast<ShadowRoot>(invocation_target_node); | ||||
|  |  | |||
|  | @ -149,9 +149,6 @@ public: | |||
|         m_stop_immediate_propagation = true; | ||||
|     } | ||||
| 
 | ||||
|     virtual bool is_ui_event() const { return false; } | ||||
|     virtual bool is_mouse_event() const { return false; } | ||||
| 
 | ||||
| protected: | ||||
|     explicit Event(const FlyString& type) | ||||
|         : m_type(type) | ||||
|  |  | |||
|  | @ -57,7 +57,7 @@ static EventTarget* retarget(EventTarget* left, [[maybe_unused]] EventTarget* ri | |||
| 
 | ||||
|         auto* left_node = downcast<Node>(left); | ||||
|         auto* left_root = left_node->root(); | ||||
|         if (!left_root->is_shadow_root()) | ||||
|         if (!is<ShadowRoot>(left_root)) | ||||
|             return left; | ||||
| 
 | ||||
|         // FIXME: If right is a node and left’s root is a shadow-including inclusive ancestor of right, return left.
 | ||||
|  |  | |||
|  | @ -63,9 +63,6 @@ public: | |||
| 
 | ||||
|     const Vector<EventListenerRegistration>& listeners() const { return m_listeners; } | ||||
| 
 | ||||
|     virtual bool is_node() const { return false; } | ||||
|     virtual bool is_window() const { return false; } | ||||
| 
 | ||||
|     Function<void(const Event&)> activation_behaviour; | ||||
| 
 | ||||
|     // NOTE: These only exist for checkbox and radio input elements.
 | ||||
|  |  | |||
|  | @ -77,10 +77,6 @@ public: | |||
|     bool is_document_fragment() const { return type() == NodeType::DOCUMENT_FRAGMENT_NODE; } | ||||
|     bool is_parent_node() const { return is_element() || is_document() || is_document_fragment(); } | ||||
|     bool is_slottable() const { return is_element() || is_text(); } | ||||
|     virtual bool is_svg_element() const { return false; } | ||||
|     virtual bool is_shadow_root() const { return false; } | ||||
| 
 | ||||
|     virtual bool is_node() const final { return true; } | ||||
| 
 | ||||
|     virtual bool is_editable() const; | ||||
| 
 | ||||
|  | @ -103,9 +99,6 @@ public: | |||
| 
 | ||||
|     String child_text_content() const; | ||||
| 
 | ||||
|     virtual bool is_html_element() const { return false; } | ||||
|     virtual bool is_unknown_html_element() const { return false; } | ||||
| 
 | ||||
|     Node* root(); | ||||
|     const Node* root() const | ||||
|     { | ||||
|  |  | |||
|  | @ -42,9 +42,6 @@ public: | |||
|     bool available_to_element_internals() const { return m_available_to_element_internals; } | ||||
|     void set_available_to_element_internals(bool available_to_element_internals) { m_available_to_element_internals = available_to_element_internals; } | ||||
| 
 | ||||
|     // ^Node
 | ||||
|     virtual bool is_shadow_root() const override { return true; } | ||||
| 
 | ||||
|     // ^EventTarget
 | ||||
|     virtual EventTarget* get_parent(const Event&) override; | ||||
| 
 | ||||
|  |  | |||
|  | @ -79,8 +79,6 @@ public: | |||
| 
 | ||||
|     HighResolutionTime::Performance& performance() { return *m_performance; } | ||||
| 
 | ||||
|     virtual bool is_window() const override { return true; } | ||||
| 
 | ||||
|     const Event* current_event() const { return m_current_event; } | ||||
|     void set_current_event(Event* event) { m_current_event = event; } | ||||
| 
 | ||||
|  |  | |||
|  | @ -49,8 +49,6 @@ public: | |||
|     bool cannot_navigate() const; | ||||
| 
 | ||||
| private: | ||||
|     virtual bool is_html_element() const final { return true; } | ||||
| 
 | ||||
|     enum class ContentEditableState { | ||||
|         True, | ||||
|         False, | ||||
|  |  | |||
|  | @ -36,9 +36,6 @@ public: | |||
| 
 | ||||
|     HTMLUnknownElement(DOM::Document&, const QualifiedName& qualified_name); | ||||
|     virtual ~HTMLUnknownElement() override; | ||||
| 
 | ||||
| private: | ||||
|     virtual bool is_unknown_html_element() const final { return true; } | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -34,13 +34,8 @@ class SVGElement : public DOM::Element { | |||
| public: | ||||
|     using WrapperType = Bindings::SVGElementWrapper; | ||||
| 
 | ||||
|     virtual bool is_graphics_element() const { return false; } | ||||
| 
 | ||||
| protected: | ||||
|     SVGElement(DOM::Document&, const QualifiedName& qualified_name); | ||||
| 
 | ||||
| private: | ||||
|     virtual bool is_svg_element() const final { return true; } | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -49,9 +49,6 @@ protected: | |||
|     Optional<Gfx::Color> m_fill_color; | ||||
|     Optional<Gfx::Color> m_stroke_color; | ||||
|     Optional<float> m_stroke_width; | ||||
| 
 | ||||
| private: | ||||
|     virtual bool is_graphics_element() const final { return true; } | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -49,8 +49,6 @@ protected: | |||
|     MouseEvent(const FlyString& event_name, i32 offset_x, i32 offset_y); | ||||
| 
 | ||||
| private: | ||||
|     virtual bool is_mouse_event() const override { return true; } | ||||
| 
 | ||||
|     void set_event_characteristics(); | ||||
| 
 | ||||
|     i32 m_offset_x { 0 }; | ||||
|  |  | |||
|  | @ -41,9 +41,6 @@ protected: | |||
|         : Event(event_name) | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
| private: | ||||
|     virtual bool is_ui_event() const final { return true; } | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling