diff options
author | Andreas Kling <kling@serenityos.org> | 2020-07-28 19:38:25 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-28 19:39:17 +0200 |
commit | c95a1fe3a35228f997937ca17223a942a54f14aa (patch) | |
tree | 1f0f028253720db66903466f1eba874f3fd55e7d | |
parent | ef711f501e786852642ad8f99af3a42912f9bc95 (diff) | |
download | serenity-c95a1fe3a35228f997937ca17223a942a54f14aa.zip |
LibWeb: Add UIEvent class (base of MouseEvent, and others)
-rw-r--r-- | Libraries/LibWeb/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Libraries/LibWeb/DOM/Event.h | 3 | ||||
-rw-r--r-- | Libraries/LibWeb/UIEvents/MouseEvent.h | 8 | ||||
-rw-r--r-- | Libraries/LibWeb/UIEvents/UIEvent.h | 49 | ||||
-rw-r--r-- | Libraries/LibWeb/UIEvents/UIEvent.idl | 3 |
5 files changed, 59 insertions, 5 deletions
diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index ecaabe504e..2e9101f56a 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -191,6 +191,7 @@ libweb_js_wrapper(HTML/HTMLTableRowElement) libweb_js_wrapper(HTML/HTMLTitleElement) libweb_js_wrapper(HTML/ImageData) libweb_js_wrapper(UIEvents/MouseEvent) +libweb_js_wrapper(UIEvents/UIEvent) get_property(WRAPPER_SOURCES GLOBAL PROPERTY wrapper_sources) set(SOURCES ${SOURCES} ${WRAPPER_SOURCES}) diff --git a/Libraries/LibWeb/DOM/Event.h b/Libraries/LibWeb/DOM/Event.h index 4755b35b4d..5e09c16ddd 100644 --- a/Libraries/LibWeb/DOM/Event.h +++ b/Libraries/LibWeb/DOM/Event.h @@ -42,10 +42,11 @@ public: return adopt(*new Event(event_name)); } - virtual ~Event() {} + virtual ~Event() { } const FlyString& type() const { return m_type; } + virtual bool is_ui_event() const { return false; } virtual bool is_mouse_event() const { return false; } protected: diff --git a/Libraries/LibWeb/UIEvents/MouseEvent.h b/Libraries/LibWeb/UIEvents/MouseEvent.h index 0121c2eef6..a84a88fe4e 100644 --- a/Libraries/LibWeb/UIEvents/MouseEvent.h +++ b/Libraries/LibWeb/UIEvents/MouseEvent.h @@ -26,11 +26,11 @@ #pragma once -#include <LibWeb/DOM/Event.h> +#include <LibWeb/UIEvents/UIEvent.h> namespace Web::UIEvents { -class MouseEvent final : public DOM::Event { +class MouseEvent final : public UIEvents::UIEvent { public: using WrapperType = Bindings::MouseEventWrapper; @@ -39,14 +39,14 @@ public: return adopt(*new MouseEvent(event_name, offset_x, offset_y)); } - virtual ~MouseEvent() override {} + virtual ~MouseEvent() override { } i32 offset_x() const { return m_offset_x; } i32 offset_y() const { return m_offset_y; } protected: MouseEvent(const FlyString& event_name, i32 offset_x, i32 offset_y) - : Event(event_name) + : UIEvent(event_name) , m_offset_x(offset_x) , m_offset_y(offset_y) { diff --git a/Libraries/LibWeb/UIEvents/UIEvent.h b/Libraries/LibWeb/UIEvents/UIEvent.h new file mode 100644 index 0000000000..83e15688e7 --- /dev/null +++ b/Libraries/LibWeb/UIEvents/UIEvent.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include <LibWeb/DOM/Event.h> + +namespace Web::UIEvents { + +class UIEvent : public DOM::Event { +public: + using WrapperType = Bindings::MouseEventWrapper; + + virtual ~UIEvent() override { } + +protected: + explicit UIEvent(const FlyString& event_name) + : Event(event_name) + { + } + +private: + virtual bool is_ui_event() const final { return true; } +}; + +} diff --git a/Libraries/LibWeb/UIEvents/UIEvent.idl b/Libraries/LibWeb/UIEvents/UIEvent.idl new file mode 100644 index 0000000000..641b96d650 --- /dev/null +++ b/Libraries/LibWeb/UIEvents/UIEvent.idl @@ -0,0 +1,3 @@ +interface UIEvent : Event { + +} |