Source/WebKit2/ChangeLog

 12011-06-06 Eunmi Lee <eunmi15.lee@samsung.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 [EFL][WK2] add WebKit2 EFL port's NativeWebMouseEvent and NativeWebWheelEvent
 6 https://bugs.webkit.org/show_bug.cgi?id=61993
 7
 8 Add WebKit2 EFL port's NativeWebMouseEvent and NativeWebWheelEvent
 9
 10 * Shared/NativeWebMouseEvent.h:
 11 (WebKit::NativeWebMouseEvent::nativeEvent):
 12 * Shared/NativeWebWheelEvent.h:
 13 (WebKit::NativeWebWheelEvent::nativeEvent):
 14 * Shared/efl/NativeWebMouseEventEfl.cpp: Added.
 15 (WebKit::NativeWebMouseEvent::NativeWebMouseEvent):
 16 * Shared/efl/NativeWebWheelEventEfl.cpp: Added.
 17 (WebKit::NativeWebWheelEvent::NativeWebWheelEvent):
 18 * Shared/efl/WebEventFactory.cpp: Added.
 19 (WebKit::modifiersForEvent):
 20 (WebKit::buttonForEvent):
 21 (WebKit::clickCountForEvent):
 22 (WebKit::WebEventFactory::createWebMouseEvent):
 23 (WebKit::WebEventFactory::createWebWheelEvent):
 24 * Shared/efl/WebEventFactory.h: Added.
 25
1262011-06-06 John Sullivan <sullivan@apple.com>
227
328 Reviewed by Dan Bernstein.

Source/WebKit2/Shared/NativeWebMouseEvent.h

@@OBJC_CLASS NSView;
3636#elif PLATFORM(GTK)
3737#include <GOwnPtrGtk.h>
3838typedef union _GdkEvent GdkEvent;
 39#elif PLATFORM(EFL)
 40#include <Evas.h>
3941#endif
4042
4143namespace WebKit {

@@public:
5153#elif PLATFORM(GTK)
5254 NativeWebMouseEvent(const NativeWebMouseEvent&);
5355 NativeWebMouseEvent(GdkEvent*, int);
 56#elif PLATFORM(EFL)
 57 NativeWebMouseEvent(const Evas_Event_Mouse_Down*, const Evas_Point*);
 58 NativeWebMouseEvent(const Evas_Event_Mouse_Up*, const Evas_Point*);
 59 NativeWebMouseEvent(const Evas_Event_Mouse_Move*, const Evas_Point*);
5460#endif
5561
5662#if PLATFORM(MAC)

@@public:
6167 const QGraphicsSceneMouseEvent* nativeEvent() const { return m_nativeEvent; }
6268#elif PLATFORM(GTK)
6369 const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
 70#elif PLATFORM(EFL)
 71 const void* nativeEvent() const { return m_nativeEvent; }
6472#endif
6573
6674private:

@@private:
7280 QGraphicsSceneMouseEvent* m_nativeEvent;
7381#elif PLATFORM(GTK)
7482 GOwnPtr<GdkEvent> m_nativeEvent;
 83#elif PLATFORM(EFL)
 84 const void* m_nativeEvent;
7585#endif
7686};
7787

Source/WebKit2/Shared/NativeWebWheelEvent.h

@@OBJC_CLASS NSView;
3636#elif PLATFORM(GTK)
3737#include <GOwnPtrGtk.h>
3838typedef union _GdkEvent GdkEvent;
 39#elif PLATFORM(EFL)
 40#include <Evas.h>
3941#endif
4042
4143namespace WebKit {

@@public:
5153#elif PLATFORM(GTK)
5254 NativeWebWheelEvent(const NativeWebWheelEvent&);
5355 NativeWebWheelEvent(GdkEvent*);
 56#elif PLATFORM(EFL)
 57 NativeWebWheelEvent(const Evas_Event_Mouse_Wheel*, const Evas_Point*);
5458#endif
5559
5660#if PLATFORM(MAC)

@@public:
6165 const QGraphicsSceneWheelEvent* nativeEvent() const { return m_nativeEvent; }
6266#elif PLATFORM(GTK)
6367 const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
 68#elif PLATFORM(EFL)
 69 const Evas_Event_Mouse_Wheel* nativeEvent() const { return m_nativeEvent; }
6470#endif
6571
6672private:

@@private:
7278 QGraphicsSceneWheelEvent* m_nativeEvent;
7379#elif PLATFORM(GTK)
7480 GOwnPtr<GdkEvent> m_nativeEvent;
 81#elif PLATFORM(EFL)
 82 const Evas_Event_Mouse_Wheel* m_nativeEvent;
7583#endif
7684};
7785

Source/WebKit2/Shared/efl/NativeWebMouseEventEfl.cpp

 1/*
 2 * Copyright (C) 2011 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "NativeWebMouseEvent.h"
 28
 29#include "WebEventFactory.h"
 30
 31namespace WebKit {
 32
 33NativeWebMouseEvent::NativeWebMouseEvent(const Evas_Event_Mouse_Down* event, const Evas_Point* position)
 34 : WebMouseEvent(WebEventFactory::createWebMouseEvent(event, position))
 35 , m_nativeEvent(event)
 36{
 37}
 38
 39NativeWebMouseEvent::NativeWebMouseEvent(const Evas_Event_Mouse_Up* event, const Evas_Point* position)
 40 : WebMouseEvent(WebEventFactory::createWebMouseEvent(event, position))
 41 , m_nativeEvent(event)
 42{
 43}
 44
 45NativeWebMouseEvent::NativeWebMouseEvent(const Evas_Event_Mouse_Move* event, const Evas_Point* position)
 46 : WebMouseEvent(WebEventFactory::createWebMouseEvent(event, position))
 47 , m_nativeEvent(event)
 48{
 49}
 50
 51} // namespace WebKit

Source/WebKit2/Shared/efl/NativeWebWheelEventEfl.cpp

 1/*
 2 * Copyright (C) 2011 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "NativeWebWheelEvent.h"
 28
 29#include "WebEventFactory.h"
 30
 31namespace WebKit {
 32
 33NativeWebWheelEvent::NativeWebWheelEvent(const Evas_Event_Mouse_Wheel* event, const Evas_Point* position)
 34 : WebWheelEvent(WebEventFactory::createWebWheelEvent(event, position))
 35 , m_nativeEvent(event)
 36{
 37}
 38
 39} // namespace WebKit

Source/WebKit2/Shared/efl/WebEventFactory.cpp

 1/*
 2 * Copyright (C) 2011 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "WebEventFactory.h"
 28
 29#include <WebCore/NotImplemented.h>
 30#include <WebCore/Scrollbar.h>
 31
 32using namespace WebCore;
 33
 34namespace WebKit {
 35
 36enum {
 37 VerticalScrollDirection = 0,
 38 HorizontalScrollDirection = 1
 39};
 40
 41static inline WebEvent::Modifiers modifiersForEvent(const Evas_Modifier* modifiers)
 42{
 43 unsigned result = 0;
 44
 45 if (evas_key_modifier_is_set(modifiers, "Shift"))
 46 result |= WebEvent::ShiftKey;
 47 if (evas_key_modifier_is_set(modifiers, "Control"))
 48 result |= WebEvent::ControlKey;
 49 if (evas_key_modifier_is_set(modifiers, "Alt"))
 50 result |= WebEvent::AltKey;
 51 if (evas_key_modifier_is_set(modifiers, "Meta"))
 52 result |= WebEvent::MetaKey;
 53
 54 return static_cast<WebEvent::Modifiers>(result);
 55}
 56
 57static inline WebMouseEvent::Button buttonForEvent(int button)
 58{
 59 if (button == 1)
 60 return WebMouseEvent::LeftButton;
 61 if (button == 2)
 62 return WebMouseEvent::MiddleButton;
 63 if (button == 3)
 64 return WebMouseEvent::RightButton;
 65
 66 return WebMouseEvent::NoButton;
 67}
 68
 69static inline int clickCountForEvent(const Evas_Button_Flags flags)
 70{
 71 if (flags & EVAS_BUTTON_TRIPLE_CLICK)
 72 return 3;
 73 if (flags & EVAS_BUTTON_DOUBLE_CLICK)
 74 return 2;
 75
 76 return 1;
 77}
 78
 79WebMouseEvent WebEventFactory::createWebMouseEvent(const Evas_Event_Mouse_Down* event, const Evas_Point* position)
 80{
 81 return WebMouseEvent(WebEvent::MouseDown,
 82 buttonForEvent(event->button),
 83 IntPoint(event->canvas.x - position->x, event->canvas.y - position->y),
 84 IntPoint(event->canvas.x, event->canvas.y),
 85 0 /* deltaX */,
 86 0 /* deltaY */,
 87 0 /* deltaZ */,
 88 clickCountForEvent(event->flags),
 89 modifiersForEvent(event->modifiers),
 90 event->timestamp);
 91}
 92
 93WebMouseEvent WebEventFactory::createWebMouseEvent(const Evas_Event_Mouse_Up* event, const Evas_Point* position)
 94{
 95 return WebMouseEvent(WebEvent::MouseUp,
 96 buttonForEvent(event->button),
 97 IntPoint(event->canvas.x - position->x, event->canvas.y - position->y),
 98 IntPoint(event->canvas.x, event->canvas.y),
 99 0 /* deltaX */,
 100 0 /* deltaY */,
 101 0 /* deltaZ */,
 102 clickCountForEvent(event->flags),
 103 modifiersForEvent(event->modifiers),
 104 event->timestamp);
 105}
 106
 107WebMouseEvent WebEventFactory::createWebMouseEvent(const Evas_Event_Mouse_Move* event, const Evas_Point* position)
 108{
 109 return WebMouseEvent(WebEvent::MouseMove,
 110 buttonForEvent(event->buttons),
 111 IntPoint(event->cur.canvas.x - position->x, event->cur.canvas.y - position->y),
 112 IntPoint(event->cur.canvas.x, event->cur.canvas.y),
 113 0 /* deltaX */,
 114 0 /* deltaY */,
 115 0 /* deltaZ */,
 116 0 /* clickCount */,
 117 modifiersForEvent(event->modifiers),
 118 event->timestamp);
 119}
 120
 121WebWheelEvent WebEventFactory::createWebWheelEvent(const Evas_Event_Mouse_Wheel* event, const Evas_Point* position)
 122{
 123 float deltaX = 0;
 124 float deltaY = 0;
 125 float wheelTicksX = 0;
 126 float wheelTicksY = 0;
 127
 128 // A negative z value means (in EFL) that we are scrolling down, so we need
 129 // to invert the value.
 130 if (event->direction == VerticalScrollDirection) {
 131 deltaX = 0;
 132 deltaY = - event->z;
 133 } else if (event->direction == HorizontalScrollDirection) {
 134 deltaX = - event->z;
 135 deltaY = 0;
 136 }
 137
 138 wheelTicksX = deltaX;
 139 wheelTicksY = deltaY;
 140 deltaX *= static_cast<float>(Scrollbar::pixelsPerLineStep());
 141 deltaY *= static_cast<float>(Scrollbar::pixelsPerLineStep());
 142
 143 return WebWheelEvent(WebEvent::Wheel,
 144 IntPoint(event->canvas.x - position->x, event->canvas.y - position->y),
 145 IntPoint(event->canvas.x, event->canvas.y),
 146 FloatSize(deltaX, deltaY),
 147 FloatSize(wheelTicksX, wheelTicksY),
 148 WebWheelEvent::ScrollByPixelWheelEvent,
 149 modifiersForEvent(event->modifiers),
 150 event->timestamp);
 151}
 152
 153} // namespace WebKit

Source/WebKit2/Shared/efl/WebEventFactory.h

 1/*
 2 * Copyright (C) 2011 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef WebEventFactory_h
 27#define WebEventFactory_h
 28
 29#include "WebEvent.h"
 30#include <Evas.h>
 31
 32namespace WebKit {
 33
 34class WebEventFactory {
 35public:
 36 static WebMouseEvent createWebMouseEvent(const Evas_Event_Mouse_Down*, const Evas_Point*);
 37 static WebMouseEvent createWebMouseEvent(const Evas_Event_Mouse_Up*, const Evas_Point*);
 38 static WebMouseEvent createWebMouseEvent(const Evas_Event_Mouse_Move*, const Evas_Point*);
 39 static WebWheelEvent createWebWheelEvent(const Evas_Event_Mouse_Wheel*, const Evas_Point*);
 40};
 41
 42} // namespace WebKit
 43
 44#endif // WebEventFactory_h