diff options
Diffstat (limited to 'WebCore/platform')
-rw-r--r-- | WebCore/platform/PlatformTouchEvent.h | 127 | ||||
-rw-r--r-- | WebCore/platform/PlatformTouchPoint.h | 69 | ||||
-rw-r--r-- | WebCore/platform/android/PlatformTouchEventAndroid.cpp | 39 | ||||
-rw-r--r-- | WebCore/platform/android/PlatformTouchPointAndroid.cpp | 37 |
4 files changed, 218 insertions, 54 deletions
diff --git a/WebCore/platform/PlatformTouchEvent.h b/WebCore/platform/PlatformTouchEvent.h index 6c8629c..78de894 100644 --- a/WebCore/platform/PlatformTouchEvent.h +++ b/WebCore/platform/PlatformTouchEvent.h @@ -1,67 +1,86 @@ /* - * Copyright 2008, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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 ``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 APPLE COMPUTER, INC. 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. - */ + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ #ifndef PlatformTouchEvent_h #define PlatformTouchEvent_h -#if ENABLE(TOUCH_EVENTS) // Android +#include "PlatformTouchPoint.h" +#include <wtf/Vector.h> + +#if ENABLE(TOUCH_EVENTS) + +#if PLATFORM(QT) +QT_BEGIN_NAMESPACE +class QTouchEvent; +QT_END_NAMESPACE +#endif +#if PLATFORM(ANDROID) #include "IntPoint.h" +#endif namespace WebCore { - enum TouchEventType {TouchEventStart, TouchEventMove, TouchEventEnd, TouchEventCancel, TouchEventLongPress, TouchEventDoubleTap}; - - class PlatformTouchEvent { - public: - PlatformTouchEvent() - : m_eventType(TouchEventCancel) - { - } - - PlatformTouchEvent(const IntPoint& pos, const IntPoint& globalPos, TouchEventType eventType) - : m_position(pos) - , m_globalPosition(globalPos) - , m_eventType(eventType) - { - } - - const IntPoint& pos() const { return m_position; } - int x() const { return m_position.x(); } - int y() const { return m_position.y(); } - int globalX() const { return m_globalPosition.x(); } - int globalY() const { return m_globalPosition.y(); } - TouchEventType eventType() const { return m_eventType; } - - private: - IntPoint m_position; - IntPoint m_globalPosition; - TouchEventType m_eventType; - }; - -} // namespace WebCore +enum TouchEventType { + TouchStart + , TouchMove + , TouchEnd + , TouchCancel +#if PLATFORM(ANDROID) + , TouchLongPress + , TouchDoubleTap +#endif +}; + +class PlatformTouchEvent { +public: + PlatformTouchEvent() + : m_type(TouchStart) + , m_ctrlKey(false) + , m_altKey(false) + , m_shiftKey(false) + , m_metaKey(false) + {} +#if PLATFORM(QT) + PlatformTouchEvent(QTouchEvent*); +#elif PLATFORM(ANDROID) + PlatformTouchEvent(const IntPoint&, const IntPoint&, TouchEventType, PlatformTouchPoint::State); +#endif + + TouchEventType type() const { return m_type; } + const Vector<PlatformTouchPoint>& touchPoints() const { return m_touchPoints; } + + bool ctrlKey() const { return m_ctrlKey; } + bool altKey() const { return m_altKey; } + bool shiftKey() const { return m_shiftKey; } + bool metaKey() const { return m_metaKey; } + +private: + TouchEventType m_type; + Vector<PlatformTouchPoint> m_touchPoints; + bool m_ctrlKey; + bool m_altKey; + bool m_shiftKey; + bool m_metaKey; +}; + +} #endif // ENABLE(TOUCH_EVENTS) diff --git a/WebCore/platform/PlatformTouchPoint.h b/WebCore/platform/PlatformTouchPoint.h new file mode 100644 index 0000000..339fe73 --- /dev/null +++ b/WebCore/platform/PlatformTouchPoint.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef PlatformTouchPoint_h +#define PlatformTouchPoint_h + +#include "IntPoint.h" +#include <wtf/Platform.h> +#include <wtf/Vector.h> + +#if ENABLE(TOUCH_EVENTS) + +#if PLATFORM(QT) +#include <QTouchEvent> +#endif + +namespace WebCore { + +class PlatformTouchEvent; + +class PlatformTouchPoint { +public: + enum State { + TouchReleased, + TouchPressed, + TouchMoved, + TouchStationary, + TouchCancelled + }; + +#if PLATFORM(QT) + PlatformTouchPoint(const QTouchEvent::TouchPoint&); +#elif PLATFORM(ANDROID) + PlatformTouchPoint(const IntPoint&, const IntPoint&, State); +#endif + + int id() const { return m_id; } + State state() const { return m_state; } + IntPoint screenPos() const { return m_screenPos; } + IntPoint pos() const { return m_pos; } + +private: + int m_id; + State m_state; + IntPoint m_screenPos; + IntPoint m_pos; +}; + +} + +#endif // ENABLE(TOUCH_EVENTS) + +#endif // PlatformTouchPoint_h diff --git a/WebCore/platform/android/PlatformTouchEventAndroid.cpp b/WebCore/platform/android/PlatformTouchEventAndroid.cpp new file mode 100644 index 0000000..46d5c6f --- /dev/null +++ b/WebCore/platform/android/PlatformTouchEventAndroid.cpp @@ -0,0 +1,39 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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 ``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 OWNER 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. + */ + +#include "config.h" +#include "PlatformTouchEvent.h" + +#if ENABLE(TOUCH_EVENTS) + +namespace WebCore { + +PlatformTouchEvent::PlatformTouchEvent(const IntPoint& pos, const IntPoint& globalPos, TouchEventType type, PlatformTouchPoint::State state) : m_type(type) { + m_touchPoints.append(PlatformTouchPoint(pos, globalPos, state)); +} + +} + +#endif diff --git a/WebCore/platform/android/PlatformTouchPointAndroid.cpp b/WebCore/platform/android/PlatformTouchPointAndroid.cpp new file mode 100644 index 0000000..cb22f5f --- /dev/null +++ b/WebCore/platform/android/PlatformTouchPointAndroid.cpp @@ -0,0 +1,37 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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 ``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 OWNER 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. + */ + +#include "config.h" +#include "PlatformTouchPoint.h" + +#if ENABLE(TOUCH_EVENTS) + +namespace WebCore { + +PlatformTouchPoint::PlatformTouchPoint(const IntPoint& pos, const IntPoint& globalPos, State state) :m_id(0), m_state(state), m_screenPos(pos), m_pos(globalPos) {} + +} + +#endif |