1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:38:10 +00:00

LibWeb: Move MouseEvent into the UIEvents namespace

Named after the UIEvents specification that houses MouseEvent.
This commit is contained in:
Andreas Kling 2020-07-28 17:21:23 +02:00
parent c99a3efc5b
commit 8b55d3d86e
7 changed files with 17 additions and 16 deletions

View file

@ -33,7 +33,7 @@ namespace Bindings {
EventWrapper* wrap(JS::GlobalObject& global_object, DOM::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<DOM::MouseEvent&>(event))); return static_cast<MouseEventWrapper*>(wrap_impl(global_object, static_cast<UIEvents::MouseEvent&>(event)));
return static_cast<EventWrapper*>(wrap_impl(global_object, event)); return static_cast<EventWrapper*>(wrap_impl(global_object, event));
} }

View file

@ -166,7 +166,6 @@ libweb_js_wrapper(DOM/DocumentType)
libweb_js_wrapper(DOM/Element) libweb_js_wrapper(DOM/Element)
libweb_js_wrapper(DOM/Event) libweb_js_wrapper(DOM/Event)
libweb_js_wrapper(DOM/EventTarget) libweb_js_wrapper(DOM/EventTarget)
libweb_js_wrapper(DOM/MouseEvent)
libweb_js_wrapper(DOM/Node) libweb_js_wrapper(DOM/Node)
libweb_js_wrapper(HTML/CanvasRenderingContext2D) libweb_js_wrapper(HTML/CanvasRenderingContext2D)
libweb_js_wrapper(HTML/HTMLAnchorElement) libweb_js_wrapper(HTML/HTMLAnchorElement)
@ -191,6 +190,7 @@ libweb_js_wrapper(HTML/HTMLTableElement)
libweb_js_wrapper(HTML/HTMLTableRowElement) libweb_js_wrapper(HTML/HTMLTableRowElement)
libweb_js_wrapper(HTML/HTMLTitleElement) libweb_js_wrapper(HTML/HTMLTitleElement)
libweb_js_wrapper(HTML/ImageData) libweb_js_wrapper(HTML/ImageData)
libweb_js_wrapper(UIEvents/MouseEvent)
get_property(WRAPPER_SOURCES GLOBAL PROPERTY wrapper_sources) get_property(WRAPPER_SOURCES GLOBAL PROPERTY wrapper_sources)
set(SOURCES ${SOURCES} ${WRAPPER_SOURCES}) set(SOURCES ${SOURCES} ${WRAPPER_SOURCES})

View file

@ -325,7 +325,7 @@ int main(int argc, char** argv)
return 1; return 1;
} }
if (namespace_ == "DOM") { if (namespace_ == "DOM" || namespace_ == "UIEvents") {
StringBuilder builder; StringBuilder builder;
builder.append(namespace_); builder.append(namespace_);
builder.append("::"); builder.append("::");
@ -411,8 +411,10 @@ static void generate_header(const IDL::Interface& interface)
// FIXME: This is very strange. // FIXME: This is very strange.
out() << "#if __has_include(<LibWeb/DOM/" << interface.name << ".h>)"; out() << "#if __has_include(<LibWeb/DOM/" << interface.name << ".h>)";
out() << "#include <LibWeb/DOM/" << interface.name << ".h>"; out() << "#include <LibWeb/DOM/" << interface.name << ".h>";
out() << "#else"; out() << "#elif __has_include(<LibWeb/HTML/" << interface.name << ".h>)";
out() << "#include <LibWeb/HTML/" << interface.name << ".h>"; out() << "#include <LibWeb/HTML/" << interface.name << ".h>";
out() << "#elif __has_include(<LibWeb/UIEvents/" << interface.name << ".h>)";
out() << "#include <LibWeb/UIEvents/" << interface.name << ".h>";
out() << "#endif"; out() << "#endif";
if (wrapper_base_class != "Wrapper") if (wrapper_base_class != "Wrapper")

View file

@ -28,13 +28,13 @@
#include <LibGUI/Window.h> #include <LibGUI/Window.h>
#include <LibJS/Runtime/Value.h> #include <LibJS/Runtime/Value.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLIFrameElement.h>
#include <LibWeb/DOM/MouseEvent.h>
#include <LibWeb/Frame/EventHandler.h> #include <LibWeb/Frame/EventHandler.h>
#include <LibWeb/Frame/Frame.h> #include <LibWeb/Frame/Frame.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLIFrameElement.h>
#include <LibWeb/Layout/LayoutDocument.h> #include <LibWeb/Layout/LayoutDocument.h>
#include <LibWeb/PageView.h> #include <LibWeb/PageView.h>
#include <LibWeb/UIEvents/MouseEvent.h>
namespace Web { namespace Web {
@ -85,7 +85,7 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button
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(DOM::MouseEvent::create("mouseup", offset.x(), offset.y())); node->dispatch_event(UIEvents::MouseEvent::create("mouseup", offset.x(), offset.y()));
handled_event = true; handled_event = true;
} }
@ -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(DOM::MouseEvent::create("mousedown", offset.x(), offset.y())); node->dispatch_event(UIEvents::MouseEvent::create("mousedown", offset.x(), offset.y()));
if (!layout_root()) if (!layout_root())
return true; return true;
@ -153,8 +153,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
layout_root()->selection().set({ result.layout_node, result.index_in_node }, {}); layout_root()->selection().set({ result.layout_node, result.index_in_node }, {});
dump_selection("MouseDown"); dump_selection("MouseDown");
m_in_mouse_selection = true; m_in_mouse_selection = true;
} } else if (button == GUI::MouseButton::Right) {
else if (button == GUI::MouseButton::Right) {
page_client.page_did_request_context_menu(m_frame.to_main_frame_position(position)); page_client.page_did_request_context_menu(m_frame.to_main_frame_position(position));
} }
} }
@ -192,7 +191,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(DOM::MouseEvent::create("mousemove", offset.x(), offset.y())); node->dispatch_event(UIEvents::MouseEvent::create("mousemove", offset.x(), offset.y()));
if (!layout_root()) if (!layout_root())
return true; return true;
} }

View file

@ -38,13 +38,12 @@
#include <LibJS/Runtime/Value.h> #include <LibJS/Runtime/Value.h>
#include <LibWeb/DOM/Element.h> #include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/ElementFactory.h> #include <LibWeb/DOM/ElementFactory.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLImageElement.h>
#include <LibWeb/DOM/MouseEvent.h>
#include <LibWeb/DOM/Text.h> #include <LibWeb/DOM/Text.h>
#include <LibWeb/Dump.h> #include <LibWeb/Dump.h>
#include <LibWeb/Frame/EventHandler.h> #include <LibWeb/Frame/EventHandler.h>
#include <LibWeb/Frame/Frame.h> #include <LibWeb/Frame/Frame.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLImageElement.h>
#include <LibWeb/Layout/LayoutBreak.h> #include <LibWeb/Layout/LayoutBreak.h>
#include <LibWeb/Layout/LayoutDocument.h> #include <LibWeb/Layout/LayoutDocument.h>
#include <LibWeb/Layout/LayoutNode.h> #include <LibWeb/Layout/LayoutNode.h>
@ -53,6 +52,7 @@
#include <LibWeb/PageView.h> #include <LibWeb/PageView.h>
#include <LibWeb/Painting/PaintContext.h> #include <LibWeb/Painting/PaintContext.h>
#include <LibWeb/Parser/HTMLDocumentParser.h> #include <LibWeb/Parser/HTMLDocumentParser.h>
#include <LibWeb/UIEvents/MouseEvent.h>
#include <stdio.h> #include <stdio.h>
//#define SELECTION_DEBUG //#define SELECTION_DEBUG

View file

@ -28,7 +28,7 @@
#include <LibWeb/DOM/Event.h> #include <LibWeb/DOM/Event.h>
namespace Web::DOM { namespace Web::UIEvents {
class MouseEvent final : public DOM::Event { class MouseEvent final : public DOM::Event {
public: public: