Changeset 51981 in webkit


Ignore:
Timestamp:
Dec 11, 2009 6:07:49 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-11 Simon Hausmann <Simon Hausmann>, Kim Grönholm <kim.gronholm@nomovok.com>

Reviewed by Antti Koivisto.

Added interfaces for touch event support in JavaScript.

https://bugs.webkit.org/show_bug.cgi?id=32114

The Touch, TouchEvent and TouchList interfaces come straight from
Android's copy of WebKit (eclaire branch).

The PlatformTouchEvent and PlatformTouchPoint code was written by
us.

No new tests added, we are just adding interfaces
with this patch.

  • WebCore.pro:
  • bindings/js/JSEventCustom.cpp: (WebCore::toJS):
  • dom/Document.cpp: (WebCore::Document::addListenerTypeIfNeeded):
  • dom/Document.h: (WebCore::Document::):
  • dom/Document.idl:
  • dom/Element.h:
  • dom/Element.idl:
  • dom/Event.cpp: (WebCore::Event::isTouchEvent):
  • dom/Event.h:
  • dom/EventNames.h:
  • dom/Touch.cpp: Added. (WebCore::contentsX): (WebCore::contentsY): (WebCore::Touch::Touch): (WebCore::Touch::updateLocation):
  • dom/Touch.h: Added. (WebCore::Touch::create): (WebCore::Touch::frame): (WebCore::Touch::target): (WebCore::Touch::identifier): (WebCore::Touch::clientX): (WebCore::Touch::clientY): (WebCore::Touch::screenX): (WebCore::Touch::screenY): (WebCore::Touch::pageX): (WebCore::Touch::pageY):
  • dom/Touch.idl: Added.
  • dom/TouchEvent.cpp: Added. (WebCore::TouchEvent::TouchEvent): (WebCore::TouchEvent::initTouchEvent):
  • dom/TouchEvent.h: Added. (WebCore::TouchEvent::create): (WebCore::TouchEvent::touches): (WebCore::TouchEvent::targetTouches): (WebCore::TouchEvent::changedTouches): (WebCore::TouchEvent::TouchEvent): (WebCore::TouchEvent::isTouchEvent):
  • dom/TouchEvent.idl: Added.
  • dom/TouchList.cpp: Added. (WebCore::TouchList::item):
  • dom/TouchList.h: Added. (WebCore::TouchList::create): (WebCore::TouchList::length): (WebCore::TouchList::append): (WebCore::TouchList::TouchList):
  • dom/TouchList.idl: Added.
  • html/HTMLAttributeNames.in:
  • html/HTMLElement.cpp: (WebCore::HTMLElement::parseMappedAttribute):
  • page/DOMWindow.h:
  • page/DOMWindow.idl:
  • platform/PlatformTouchEvent.h: Added. (WebCore::PlatformTouchEvent::PlatformTouchEvent): (WebCore::PlatformTouchEvent::touchPoints):
  • platform/PlatformTouchPoint.h: Added. (WebCore::PlatformTouchPoint::): (WebCore::PlatformTouchPoint::id): (WebCore::PlatformTouchPoint::state): (WebCore::PlatformTouchPoint::screenPos): (WebCore::PlatformTouchPoint::pos):
  • platform/qt/PlatformTouchEventQt.cpp: Added. (WebCore::PlatformTouchEvent::PlatformTouchEvent):
  • platform/qt/PlatformTouchPointQt.cpp: Added. (WebCore::PlatformTouchPoint::PlatformTouchPoint):
Location:
trunk/WebCore
Files:
13 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r51980 r51981  
     12009-12-11  Simon Hausmann  <hausmann@webkit.org>, Kim Grönholm  <kim.gronholm@nomovok.com>
     2
     3        Reviewed by Antti Koivisto.
     4
     5        Added interfaces for touch event support in JavaScript.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=32114
     8
     9        The Touch, TouchEvent and TouchList interfaces come straight from
     10        Android's copy of WebKit (eclaire branch).
     11
     12        The PlatformTouchEvent and PlatformTouchPoint code was written by
     13        us.
     14
     15        No new tests added, we are just adding interfaces
     16        with this patch.
     17
     18        * WebCore.pro:
     19        * bindings/js/JSEventCustom.cpp:
     20        (WebCore::toJS):
     21        * dom/Document.cpp:
     22        (WebCore::Document::addListenerTypeIfNeeded):
     23        * dom/Document.h:
     24        (WebCore::Document::):
     25        * dom/Document.idl:
     26        * dom/Element.h:
     27        * dom/Element.idl:
     28        * dom/Event.cpp:
     29        (WebCore::Event::isTouchEvent):
     30        * dom/Event.h:
     31        * dom/EventNames.h:
     32        * dom/Touch.cpp: Added.
     33        (WebCore::contentsX):
     34        (WebCore::contentsY):
     35        (WebCore::Touch::Touch):
     36        (WebCore::Touch::updateLocation):
     37        * dom/Touch.h: Added.
     38        (WebCore::Touch::create):
     39        (WebCore::Touch::frame):
     40        (WebCore::Touch::target):
     41        (WebCore::Touch::identifier):
     42        (WebCore::Touch::clientX):
     43        (WebCore::Touch::clientY):
     44        (WebCore::Touch::screenX):
     45        (WebCore::Touch::screenY):
     46        (WebCore::Touch::pageX):
     47        (WebCore::Touch::pageY):
     48        * dom/Touch.idl: Added.
     49        * dom/TouchEvent.cpp: Added.
     50        (WebCore::TouchEvent::TouchEvent):
     51        (WebCore::TouchEvent::initTouchEvent):
     52        * dom/TouchEvent.h: Added.
     53        (WebCore::TouchEvent::create):
     54        (WebCore::TouchEvent::touches):
     55        (WebCore::TouchEvent::targetTouches):
     56        (WebCore::TouchEvent::changedTouches):
     57        (WebCore::TouchEvent::TouchEvent):
     58        (WebCore::TouchEvent::isTouchEvent):
     59        * dom/TouchEvent.idl: Added.
     60        * dom/TouchList.cpp: Added.
     61        (WebCore::TouchList::item):
     62        * dom/TouchList.h: Added.
     63        (WebCore::TouchList::create):
     64        (WebCore::TouchList::length):
     65        (WebCore::TouchList::append):
     66        (WebCore::TouchList::TouchList):
     67        * dom/TouchList.idl: Added.
     68        * html/HTMLAttributeNames.in:
     69        * html/HTMLElement.cpp:
     70        (WebCore::HTMLElement::parseMappedAttribute):
     71        * page/DOMWindow.h:
     72        * page/DOMWindow.idl:
     73        * platform/PlatformTouchEvent.h: Added.
     74        (WebCore::PlatformTouchEvent::PlatformTouchEvent):
     75        (WebCore::PlatformTouchEvent::touchPoints):
     76        * platform/PlatformTouchPoint.h: Added.
     77        (WebCore::PlatformTouchPoint::):
     78        (WebCore::PlatformTouchPoint::id):
     79        (WebCore::PlatformTouchPoint::state):
     80        (WebCore::PlatformTouchPoint::screenPos):
     81        (WebCore::PlatformTouchPoint::pos):
     82        * platform/qt/PlatformTouchEventQt.cpp: Added.
     83        (WebCore::PlatformTouchEvent::PlatformTouchEvent):
     84        * platform/qt/PlatformTouchPointQt.cpp: Added.
     85        (WebCore::PlatformTouchPoint::PlatformTouchPoint):
     86
    1872009-12-11  Grace Kloba  <klobag@gmail.com>
    288
  • trunk/WebCore/WebCore.pro

    r51922 r51981  
    181181
    182182DEFINES += WTF_CHANGES=1
     183
     184# Enable touch event support with Qt 4.6
     185!lessThan(QT_MINOR_VERSION, 6): DEFINES += ENABLE_TOUCH_EVENTS=1
    183186
    184187# Used to compute defaults for the build-webkit script
     
    368371    dom/Text.idl \
    369372    dom/TextEvent.idl \
     373    dom/Touch.idl \
     374    dom/TouchEvent.idl \
     375    dom/TouchList.idl \
    370376    dom/TreeWalker.idl \
    371377    dom/UIEvent.idl \
     
    922928    dom/Text.cpp \
    923929    dom/TextEvent.cpp \
     930    dom/Touch.cpp \
     931    dom/TouchEvent.cpp \
     932    dom/TouchList.cpp \
    924933    dom/Traversal.cpp \
    925934    dom/TreeWalker.cpp \
     
    16061615    dom/TextEvent.h \
    16071616    dom/Text.h \
     1617    dom/Touch.h \
     1618    dom/TouchEvent.h \
     1619    dom/TouchList.h \
    16081620    dom/TransformSource.h \
    16091621    dom/Traversal.h \
     
    19501962    platform/network/ResourceRequestBase.h \
    19511963    platform/network/ResourceResponseBase.h \
     1964    platform/PlatformTouchEvent.h \
     1965    platform/PlatformTouchPoint.h \
    19521966    platform/qt/ClipboardQt.h \
    19531967    platform/qt/QWebPageClient.h \
     
    24082422    platform/qt/PlatformMouseEventQt.cpp \
    24092423    platform/qt/PlatformScreenQt.cpp \
     2424    platform/qt/PlatformTouchEventQt.cpp \
     2425    platform/qt/PlatformTouchPointQt.cpp \
    24102426    platform/qt/PopupMenuQt.cpp \
    24112427    platform/qt/QWebPopup.cpp \
     
    25542570contains(DEFINES, ENABLE_EVENTSOURCE=1) {
    25552571    FEATURE_DEFINES_JAVASCRIPT += ENABLE_EVENTSOURCE=1
     2572}
     2573
     2574contains(DEFINES, ENABLE_TOUCH_EVENTS=1) {
     2575    FEATURE_DEFINES_JAVASCRIPT += ENABLE_TOUCH_EVENTS=1
    25562576}
    25572577
  • trunk/WebCore/bindings/js/JSEventCustom.cpp

    r51644 r51981  
    7979#endif
    8080
     81#if ENABLE(TOUCH_EVENTS)
     82#include "JSTouchEvent.h"
     83#include "TouchEvent.h"
     84#endif
     85
    8186using namespace JSC;
    8287
     
    114119        else if (event->isCompositionEvent())
    115120            wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CompositionEvent, event);
     121#if ENABLE(TOUCH_EVENTS)
     122        else if (event->isTouchEvent())
     123            wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, TouchEvent, event);
     124#endif
    116125        else
    117126            wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, UIEvent, event);
  • trunk/WebCore/dom/Document.cpp

    r51793 r51981  
    29782978    else if (eventType == eventNames().beforeloadEvent)
    29792979        addListenerType(BEFORELOAD_LISTENER);
     2980    else if (eventType == eventNames().touchstartEvent
     2981             || eventType == eventNames().touchmoveEvent
     2982             || eventType == eventNames().touchendEvent)
     2983        addListenerType(TOUCH_LISTENER);
    29802984}
    29812985
  • trunk/WebCore/dom/Document.h

    r51680 r51981  
    253253    DEFINE_ATTRIBUTE_EVENT_LISTENER(search);
    254254    DEFINE_ATTRIBUTE_EVENT_LISTENER(selectstart);
     255#if ENABLE(TOUCH_EVENTS)
     256    DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart);
     257    DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove);
     258    DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend);
     259#endif
    255260
    256261    DocumentType* doctype() const { return m_docType.get(); }
     
    621626        ANIMATIONITERATION_LISTENER          = 0x400,
    622627        TRANSITIONEND_LISTENER               = 0x800,
    623         BEFORELOAD_LISTENER                  = 0x1000
     628        BEFORELOAD_LISTENER                  = 0x1000,
     629        TOUCH_LISTENER                       = 0x2000
    624630    };
    625631
  • trunk/WebCore/dom/Document.idl

    r51577 r51981  
    321321        attribute [DontEnum] EventListener onsearch;
    322322        attribute [DontEnum] EventListener onselectstart;
     323#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
     324        attribute [DontEnum] EventListener ontouchstart;
     325        attribute [DontEnum] EventListener ontouchmove;
     326        attribute [DontEnum] EventListener ontouchend;
     327#endif
    323328#endif
    324329#endif
  • trunk/WebCore/dom/Element.h

    r51566 r51981  
    8989    DEFINE_ATTRIBUTE_EVENT_LISTENER(search);
    9090    DEFINE_ATTRIBUTE_EVENT_LISTENER(selectstart);
     91#if ENABLE(TOUCH_EVENTS)
     92    DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart);
     93    DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove);
     94    DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend);
     95#endif
    9196
    9297    const AtomicString& getIDAttribute() const;
  • trunk/WebCore/dom/Element.idl

    r48728 r51981  
    204204        attribute [DontEnum] EventListener onsearch;
    205205        attribute [DontEnum] EventListener onselectstart;
     206#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
     207        attribute [DontEnum] EventListener ontouchstart;
     208        attribute [DontEnum] EventListener ontouchmove;
     209        attribute [DontEnum] EventListener ontouchend;
     210#endif
    206211#endif
    207212#endif
  • trunk/WebCore/dom/Event.cpp

    r51644 r51981  
    187187}
    188188#endif
    189    
     189
     190#if ENABLE(TOUCH_EVENTS)
     191bool Event::isTouchEvent() const
     192{
     193    return false;
     194}
     195#endif
     196
    190197bool Event::storesResultAsString() const
    191198{
  • trunk/WebCore/dom/Event.h

    r51644 r51981  
    127127        virtual bool isErrorEvent() const;
    128128#endif
     129#if ENABLE(TOUCH_EVENTS)
     130        virtual bool isTouchEvent() const;
     131#endif
    129132       
    130133        bool propagationStopped() const { return m_propagationStopped; }
  • trunk/WebCore/dom/EventNames.h

    r51644 r51981  
    147147    macro(orientationchange) \
    148148    \
     149    macro(touchstart) \
     150    macro(touchmove) \
     151    macro(touchend) \
     152    \
    149153// end of DOM_EVENT_NAMES_FOR_EACH
    150154
  • trunk/WebCore/html/HTMLAttributeNames.in

    r51669 r51981  
    200200onsubmit
    201201ontimeupdate
     202ontouchstart
     203ontouchmove
     204ontouchend
    202205onunload
    203206onvolumechange
  • trunk/WebCore/html/HTMLElement.cpp

    r49798 r51981  
    223223    } else if (attr->name() == oninvalidAttr) {
    224224        setAttributeEventListener(eventNames().invalidEvent, createAttributeEventListener(this, attr));
     225    } else if (attr->name() == ontouchstartAttr) {
     226        setAttributeEventListener(eventNames().touchstartEvent, createAttributeEventListener(this, attr));
     227    } else if (attr->name() == ontouchmoveAttr) {
     228        setAttributeEventListener(eventNames().touchmoveEvent, createAttributeEventListener(this, attr));
     229    } else if (attr->name() == ontouchendAttr) {
     230        setAttributeEventListener(eventNames().touchendEvent, createAttributeEventListener(this, attr));
    225231    }
    226232}
  • trunk/WebCore/page/DOMWindow.h

    r51644 r51981  
    323323        DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(webkittransitionend, webkitTransitionEnd);
    324324
     325#if ENABLE(TOUCH_EVENTS)
     326        DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart);
     327        DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove);
     328        DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend);
     329#endif
    325330        void captureEvents();
    326331        void releaseEvents();
  • trunk/WebCore/page/DOMWindow.idl

    r51971 r51981  
    290290        attribute EventListener onorientationchange;
    291291#endif
     292 #if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
     293        attribute [DontEnum] EventListener ontouchstart;
     294        attribute [DontEnum] EventListener ontouchmove;
     295        attribute [DontEnum] EventListener ontouchend;
     296 #endif
    292297
    293298        // EventTarget interface
     
    567572#endif
    568573
     574#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
     575        attribute TouchEventConstructor TouchEvent;
     576#endif
     577
    569578#endif // defined(LANGUAGE_JAVASCRIPT)
    570579
Note: See TracChangeset for help on using the changeset viewer.