diff options
Diffstat (limited to 'WebCore/dom')
| -rw-r--r-- | WebCore/dom/Document.cpp | 65 | ||||
| -rw-r--r-- | WebCore/dom/Document.h | 22 | ||||
| -rw-r--r-- | WebCore/dom/Document.idl | 12 | ||||
| -rw-r--r-- | WebCore/dom/Element.h | 7 | ||||
| -rw-r--r-- | WebCore/dom/Element.idl | 12 | ||||
| -rw-r--r-- | WebCore/dom/Event.cpp | 10 | ||||
| -rw-r--r-- | WebCore/dom/Event.h | 6 | ||||
| -rw-r--r-- | WebCore/dom/EventNames.h | 17 | ||||
| -rw-r--r-- | WebCore/dom/Node.cpp | 32 | ||||
| -rw-r--r-- | WebCore/dom/Node.h | 7 | ||||
| -rw-r--r-- | WebCore/dom/Touch.cpp | 6 | ||||
| -rw-r--r-- | WebCore/dom/Touch.h | 64 | ||||
| -rw-r--r-- | WebCore/dom/TouchEvent.cpp | 16 | ||||
| -rw-r--r-- | WebCore/dom/TouchEvent.h | 106 | ||||
| -rw-r--r-- | WebCore/dom/TouchEvent.idl | 10 | ||||
| -rw-r--r-- | WebCore/dom/TouchList.cpp | 2 | ||||
| -rw-r--r-- | WebCore/dom/TouchList.h | 28 |
17 files changed, 205 insertions, 217 deletions
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp index 13c2fae..d031853 100644 --- a/WebCore/dom/Document.cpp +++ b/WebCore/dom/Document.cpp @@ -171,12 +171,10 @@ #include "SVGStyleElement.h" #endif -#if ENABLE(TOUCH_EVENTS) // Android -#include "TouchEvent.h" #if PLATFORM(ANDROID) +// FIXME: We shouldn't be including this from WebCore! #include "WebViewCore.h" #endif -#endif #ifdef ANDROID_META_SUPPORT #include "Settings.h" @@ -191,6 +189,11 @@ #include "TimeCounter.h" #endif +#if ENABLE(TOUCH_EVENTS) +#include "ChromeClient.h" +#include "TouchEvent.h" +#endif + #if ENABLE(WML) #include "WMLDocument.h" #include "WMLElement.h" @@ -1484,17 +1487,6 @@ void Document::detach() FrameView* view = m_frame->view(); if (view) view->detachCustomScrollbars(); - -#if ENABLE(TOUCH_EVENTS) // Android - // clean up for the top document - if (!m_frame->ownerElement()) { - m_touchEventListeners.clear(); -#if PLATFORM(ANDROID) - if (view) - android::WebViewCore::getWebViewCore(view)->needTouchEvents(false); -#endif - } -#endif } // indicate destruction mode, i.e. attached() but renderer == 0 @@ -2257,7 +2249,8 @@ void Document::processMetadataSettings(const String& content) String key(buffer.substring(keyBegin, keyEnd - keyBegin)); String value(buffer.substring(valueBegin, valueEnd - valueBegin)); - frame()->settings()->setMetadataSettings(key, value); + if (frame()) + frame()->settings()->setMetadataSettings(key, value); } } #endif @@ -3061,7 +3054,7 @@ PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionCode& else if (eventType == "SVGZoomEvents") event = SVGZoomEvent::create(); #endif -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) else if (eventType == "TouchEvent") event = TouchEvent::create(); #endif @@ -3101,6 +3094,14 @@ void Document::addListenerTypeIfNeeded(const AtomicString& eventType) addListenerType(TRANSITIONEND_LISTENER); else if (eventType == eventNames().beforeloadEvent) addListenerType(BEFORELOAD_LISTENER); + else if (eventType == eventNames().touchstartEvent + || eventType == eventNames().touchmoveEvent + || eventType == eventNames().touchendEvent + || eventType == eventNames().touchcancelEvent) { + addListenerType(TOUCH_LISTENER); + if (Page* page = this->page()) + page->chrome()->client()->needTouchEvents(true); + } } CSSStyleDeclaration* Document::getOverrideStyle(Element*, const String&) @@ -4672,38 +4673,6 @@ void Document::parseDNSPrefetchControlHeader(const String& dnsPrefetchControl) m_haveExplicitlyDisabledDNSPrefetch = true; } -#if ENABLE(TOUCH_EVENTS) // Android -void Document::addTouchEventListener(Node* node) -{ - // Note: we only keep track of touch listener in the top frame - if (m_frame && m_frame->tree()->parent()) { - m_frame->page()->mainFrame()->document()->addTouchEventListener(node); - } else { -#if PLATFORM(ANDROID) - if (m_frame && m_frame->view() && m_touchEventListeners.isEmpty()) - android::WebViewCore::getWebViewCore(m_frame->view())->needTouchEvents(true); -#endif - m_touchEventListeners.add(node, 0); - } -} - -void Document::removeTouchEventListener(Node* node) -{ - // Note: we only keep track of touch listener in the top frame - if (m_frame && m_frame->tree()->parent()) { - m_frame->page()->mainFrame()->document()->removeTouchEventListener(node); - } else { -#if PLATFORM(ANDROID) - if (m_frame && m_frame->view() && m_touchEventListeners.size() == 1 && - m_touchEventListeners.contains(node)) - android::WebViewCore::getWebViewCore(m_frame->view())->needTouchEvents(false); -#endif - m_touchEventListeners.remove(node); - } -} - -#endif - void Document::reportException(const String& errorMessage, int lineNumber, const String& sourceURL) { if (DOMWindow* window = domWindow()) diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h index f2125b1..b24063a 100644 --- a/WebCore/dom/Document.h +++ b/WebCore/dom/Document.h @@ -252,6 +252,12 @@ public: DEFINE_ATTRIBUTE_EVENT_LISTENER(reset); DEFINE_ATTRIBUTE_EVENT_LISTENER(search); DEFINE_ATTRIBUTE_EVENT_LISTENER(selectstart); +#if ENABLE(TOUCH_EVENTS) + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart); + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove); + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend); + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel); +#endif DocumentType* doctype() const { return m_docType.get(); } @@ -624,7 +630,8 @@ public: ANIMATIONSTART_LISTENER = 0x200, ANIMATIONITERATION_LISTENER = 0x400, TRANSITIONEND_LISTENER = 0x800, - BEFORELOAD_LISTENER = 0x1000 + BEFORELOAD_LISTENER = 0x1000, + TOUCH_LISTENER = 0x2000 }; bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); } @@ -937,17 +944,6 @@ protected: void clearXMLVersion() { m_xmlVersion = String(); } -#if ENABLE(TOUCH_EVENTS) // Android -public: - typedef HashMap<Node*, unsigned > TouchListenerMap; - - void addTouchEventListener(Node*); - void removeTouchEventListener(Node*); - const TouchListenerMap& touchEventListeners() const { return m_touchEventListeners; } - -private: - TouchListenerMap m_touchEventListeners; -#endif // ENABLE(TOUCH_EVENTS) private: virtual bool isDocument() const { return true; } @@ -1120,7 +1116,7 @@ private: #if ENABLE(XBL) OwnPtr<XBLBindingManager> m_bindingManager; // The access point through which documents and elements communicate with XBL. #endif - + typedef HashMap<AtomicStringImpl*, HTMLMapElement*> ImageMapsByName; ImageMapsByName m_imageMapsByName; diff --git a/WebCore/dom/Document.idl b/WebCore/dom/Document.idl index e54add0..69417c8 100644 --- a/WebCore/dom/Document.idl +++ b/WebCore/dom/Document.idl @@ -284,12 +284,6 @@ module core { attribute [DontEnum] EventListener onscroll; attribute [DontEnum] EventListener onselect; attribute [DontEnum] EventListener onsubmit; -#if ENABLE_TOUCH_EVENTS - attribute [DontEnum] EventListener ontouchstart; - attribute [DontEnum] EventListener ontouchend; - attribute [DontEnum] EventListener ontouchmove; - attribute [DontEnum] EventListener ontouchcancel; -#endif // attribute [DontEnum] EventListener oncanplay; // attribute [DontEnum] EventListener oncanplaythrough; @@ -326,6 +320,12 @@ module core { attribute [DontEnum] EventListener onreset; attribute [DontEnum] EventListener onsearch; attribute [DontEnum] EventListener onselectstart; +#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS + attribute [DontEnum] EventListener ontouchstart; + attribute [DontEnum] EventListener ontouchmove; + attribute [DontEnum] EventListener ontouchend; + attribute [DontEnum] EventListener ontouchcancel; +#endif #endif #endif }; diff --git a/WebCore/dom/Element.h b/WebCore/dom/Element.h index 97d3eb4..ce25d70 100644 --- a/WebCore/dom/Element.h +++ b/WebCore/dom/Element.h @@ -88,7 +88,12 @@ public: DEFINE_ATTRIBUTE_EVENT_LISTENER(reset); DEFINE_ATTRIBUTE_EVENT_LISTENER(search); DEFINE_ATTRIBUTE_EVENT_LISTENER(selectstart); - +#if ENABLE(TOUCH_EVENTS) + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart); + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove); + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend); + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel); +#endif const AtomicString& getIDAttribute() const; bool hasAttribute(const QualifiedName&) const; const AtomicString& getAttribute(const QualifiedName&) const; diff --git a/WebCore/dom/Element.idl b/WebCore/dom/Element.idl index c24ef65..4a223bb 100644 --- a/WebCore/dom/Element.idl +++ b/WebCore/dom/Element.idl @@ -167,12 +167,6 @@ module core { attribute [DontEnum] EventListener onscroll; attribute [DontEnum] EventListener onselect; attribute [DontEnum] EventListener onsubmit; -#if ENABLE_TOUCH_EVENTS - attribute [DontEnum] EventListener ontouchstart; - attribute [DontEnum] EventListener ontouchend; - attribute [DontEnum] EventListener ontouchmove; - attribute [DontEnum] EventListener ontouchcancel; -#endif // attribute [DontEnum] EventListener oncanplay; // attribute [DontEnum] EventListener oncanplaythrough; @@ -209,6 +203,12 @@ module core { attribute [DontEnum] EventListener onreset; attribute [DontEnum] EventListener onsearch; attribute [DontEnum] EventListener onselectstart; +#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS + attribute [DontEnum] EventListener ontouchstart; + attribute [DontEnum] EventListener ontouchmove; + attribute [DontEnum] EventListener ontouchend; + attribute [DontEnum] EventListener ontouchcancel; +#endif #endif #endif }; diff --git a/WebCore/dom/Event.cpp b/WebCore/dom/Event.cpp index eda44b0..be2b37b 100644 --- a/WebCore/dom/Event.cpp +++ b/WebCore/dom/Event.cpp @@ -180,20 +180,20 @@ bool Event::isStorageEvent() const } #endif -#if ENABLE(TOUCH_EVENTS) // Android -bool Event::isTouchEvent() const +#if ENABLE(WORKERS) +bool Event::isErrorEvent() const { return false; } #endif -#if ENABLE(WORKERS) -bool Event::isErrorEvent() const +#if ENABLE(TOUCH_EVENTS) +bool Event::isTouchEvent() const { return false; } #endif - + bool Event::storesResultAsString() const { return false; diff --git a/WebCore/dom/Event.h b/WebCore/dom/Event.h index 7ec85a7..4624663 100644 --- a/WebCore/dom/Event.h +++ b/WebCore/dom/Event.h @@ -123,12 +123,12 @@ namespace WebCore { #if ENABLE(DOM_STORAGE) virtual bool isStorageEvent() const; #endif -#if ENABLE(TOUCH_EVENTS) // Android - virtual bool isTouchEvent() const; -#endif #if ENABLE(WORKERS) virtual bool isErrorEvent() const; #endif +#if ENABLE(TOUCH_EVENTS) + virtual bool isTouchEvent() const; +#endif bool propagationStopped() const { return m_propagationStopped; } diff --git a/WebCore/dom/EventNames.h b/WebCore/dom/EventNames.h index 63460a5..c8c3291 100644 --- a/WebCore/dom/EventNames.h +++ b/WebCore/dom/EventNames.h @@ -95,14 +95,6 @@ namespace WebCore { macro(storage) \ macro(submit) \ macro(textInput) \ -/* #if ENABLE(TOUCH_EVENTS) // Android */ \ - macro(touchstart) \ - macro(touchmove) \ - macro(touchend) \ - macro(touchcancel) \ - macro(touchlongpress) \ - macro(touchdoubletap) \ -/* #endif */ \ macro(unload) \ macro(updateready) \ macro(zoom) \ @@ -154,6 +146,15 @@ namespace WebCore { \ macro(orientationchange) \ \ + macro(touchstart) \ + macro(touchmove) \ + macro(touchend) \ + macro(touchcancel) \ +/* #if PLATFORM(ANDROID) */ \ + macro(touchlongpress) \ + macro(touchdoubletap) \ +/* #endif */ \ + \ // end of DOM_EVENT_NAMES_FOR_EACH class EventNames : public Noncopyable { diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp index 4ae83de..c2d5281 100644 --- a/WebCore/dom/Node.cpp +++ b/WebCore/dom/Node.cpp @@ -101,6 +101,10 @@ #include "HTMLNoScriptElement.h" #endif +#if ENABLE(TOUCH_EVENTS) +#include "ChromeClient.h" +#endif + #define DUMP_NODE_STATISTICS 0 using namespace std; @@ -2422,16 +2426,8 @@ bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe if (Document* document = this->document()) document->addListenerTypeIfNeeded(eventType); - updateSVGElementInstancesAfterEventListenerChange(this); -#if ENABLE(TOUCH_EVENTS) // Android - if (this->document() && - (eventType == eventNames().touchstartEvent || - eventType == eventNames().touchendEvent || - eventType == eventNames().touchmoveEvent || - eventType == eventNames().touchcancelEvent)) - this->document()->addTouchEventListener(this); -#endif + updateSVGElementInstancesAfterEventListenerChange(this); return true; } @@ -2442,13 +2438,17 @@ bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis updateSVGElementInstancesAfterEventListenerChange(this); -#if ENABLE(TOUCH_EVENTS) // Android - if (this->document() && - (eventType == eventNames().touchstartEvent || - eventType == eventNames().touchendEvent || - eventType == eventNames().touchmoveEvent || - eventType == eventNames().touchcancelEvent)) - this->document()->removeTouchEventListener(this); +#if ENABLE(TOUCH_EVENTS) + if (Document* document = this->document()) { + if (document->page() + && (eventType == eventNames().touchstartEvent + || eventType == eventNames().touchmoveEvent + || eventType == eventNames().touchendEvent + || eventType == eventNames().touchcancelEvent)) + // Note the corresponding needTouchEvents(true) is called in Document::addListenerTypeIfNeeded(). + document->page()->chrome()->client()->needTouchEvents(false); + + } #endif return true; } diff --git a/WebCore/dom/Node.h b/WebCore/dom/Node.h index 7da8634..ebf275a 100644 --- a/WebCore/dom/Node.h +++ b/WebCore/dom/Node.h @@ -565,13 +565,6 @@ public: */ virtual bool disabled() const; -#if ENABLE(TOUCH_EVENTS) // Android - DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart); - DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend); - DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove); - DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel); -#endif - using TreeShared<Node>::ref; using TreeShared<Node>::deref; diff --git a/WebCore/dom/Touch.cpp b/WebCore/dom/Touch.cpp index 561a786..41d5c19 100644 --- a/WebCore/dom/Touch.cpp +++ b/WebCore/dom/Touch.cpp @@ -25,7 +25,7 @@ #include "config.h" -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) #include "Touch.h" @@ -40,7 +40,7 @@ static int contentsX(Frame* frame) FrameView* frameView = frame->view(); if (!frameView) return 0; - return frameView->scrollX(); + return frameView->scrollX() / frame->pageZoomFactor(); } static int contentsY(Frame* frame) @@ -50,7 +50,7 @@ static int contentsY(Frame* frame) FrameView* frameView = frame->view(); if (!frameView) return 0; - return frameView->scrollY(); + return frameView->scrollY() / frame->pageZoomFactor(); } Touch::Touch(Frame* frame, EventTarget* target, unsigned identifier, diff --git a/WebCore/dom/Touch.h b/WebCore/dom/Touch.h index 62822fb..cf39faf 100644 --- a/WebCore/dom/Touch.h +++ b/WebCore/dom/Touch.h @@ -26,7 +26,7 @@ #ifndef TOUCH_H_ #define TOUCH_H_ -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) #include "EventTarget.h" #include "Frame.h" @@ -36,41 +36,41 @@ namespace WebCore { - class Touch : public RefCounted<Touch> { - public: - static PassRefPtr<Touch> create(Frame* frame, EventTarget* target, - unsigned identifier, int screenX, int screenY, int pageX, int pageY) - { - return adoptRef(new Touch(frame, target, identifier, screenX, - screenY, pageX, pageY)); - } +class Touch : public RefCounted<Touch> { +public: + static PassRefPtr<Touch> create(Frame* frame, EventTarget* target, + unsigned identifier, int screenX, int screenY, int pageX, int pageY) + { + return adoptRef(new Touch(frame, target, identifier, screenX, + screenY, pageX, pageY)); + } - void updateLocation(int screenX, int screenY, int pageX, int pageY); + void updateLocation(int screenX, int screenY, int pageX, int pageY); - Frame* frame() const { return m_frame.get(); } - EventTarget* target() const { return m_target.get(); } - unsigned identifier() const { return m_identifier; } - int clientX() const { return m_clientX; } - int clientY() const { return m_clientY; } - int screenX() const { return m_screenX; } - int screenY() const { return m_screenY; } - int pageX() const { return m_pageX; } - int pageY() const { return m_pageY; } + Frame* frame() const { return m_frame.get(); } + EventTarget* target() const { return m_target.get(); } + unsigned identifier() const { return m_identifier; } + int clientX() const { return m_clientX; } + int clientY() const { return m_clientY; } + int screenX() const { return m_screenX; } + int screenY() const { return m_screenY; } + int pageX() const { return m_pageX; } + int pageY() const { return m_pageY; } - private: - Touch(Frame* frame, EventTarget* target, unsigned identifier, - int screenX, int screenY, int pageX, int pageY); +private: + Touch(Frame* frame, EventTarget* target, unsigned identifier, + int screenX, int screenY, int pageX, int pageY); - RefPtr<Frame> m_frame; - RefPtr<EventTarget> m_target; - unsigned m_identifier; - int m_clientX; - int m_clientY; - int m_screenX; - int m_screenY; - int m_pageX; - int m_pageY; - }; + RefPtr<Frame> m_frame; + RefPtr<EventTarget> m_target; + unsigned m_identifier; + int m_clientX; + int m_clientY; + int m_screenX; + int m_screenY; + int m_pageX; + int m_pageY; +}; } // namespace WebCore diff --git a/WebCore/dom/TouchEvent.cpp b/WebCore/dom/TouchEvent.cpp index 7ce856f..1fbba6c 100644 --- a/WebCore/dom/TouchEvent.cpp +++ b/WebCore/dom/TouchEvent.cpp @@ -25,7 +25,7 @@ #include "config.h" -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) #include "TouchEvent.h" @@ -33,20 +33,24 @@ namespace WebCore { TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches, TouchList* changedTouches, const AtomicString& type, - PassRefPtr<AbstractView> view, int screenX, int screenY, int pageX, int pageY) + PassRefPtr<AbstractView> view, int screenX, int screenY, int pageX, int pageY, + bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) : MouseRelatedEvent(type, true, true, view, 0, screenX, screenY, pageX, pageY, - false, false, false, false) + ctrlKey, altKey, shiftKey, metaKey) , m_touches(touches) , m_targetTouches(targetTouches) , m_changedTouches(changedTouches) +#if PLATFORM(ANDROID) , m_longPressPrevented(false) , m_doubleTapPrevented(false) +#endif { } void TouchEvent::initTouchEvent(TouchList* touches, TouchList* targetTouches, TouchList* changedTouches, const AtomicString& type, - PassRefPtr<AbstractView> view, int screenX, int screenY, int clientX, int clientY) + PassRefPtr<AbstractView> view, int screenX, int screenY, int clientX, int clientY, + bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) { if (dispatched()) return; @@ -55,6 +59,10 @@ void TouchEvent::initTouchEvent(TouchList* touches, TouchList* targetTouches, m_screenX = screenX; m_screenY = screenY; + m_ctrlKey = ctrlKey; + m_altKey = altKey; + m_shiftKey = shiftKey; + m_metaKey = metaKey; initCoordinates(clientX, clientY); } diff --git a/WebCore/dom/TouchEvent.h b/WebCore/dom/TouchEvent.h index 6b7d384..abc1ee2 100644 --- a/WebCore/dom/TouchEvent.h +++ b/WebCore/dom/TouchEvent.h @@ -26,61 +26,69 @@ #ifndef TouchEvent_h #define TouchEvent_h -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) #include "MouseRelatedEvent.h" #include "TouchList.h" namespace WebCore { - class TouchEvent : public MouseRelatedEvent { - public: - static PassRefPtr<TouchEvent> create() - { - return adoptRef(new TouchEvent); - } - static PassRefPtr<TouchEvent> create(TouchList* touches, - TouchList* targetTouches, TouchList* changedTouches, - const AtomicString& type, PassRefPtr<AbstractView> view, - int screenX, int screenY, int pageX, int pageY) - { - return adoptRef(new TouchEvent(touches, targetTouches, changedTouches, - type, view, screenX, screenY, pageX, pageY)); - } - - void initTouchEvent(TouchList* touches, TouchList* targetTouches, - TouchList* changedTouches, const AtomicString& type, - PassRefPtr<AbstractView> view, int screenX, int screenY, - int clientX, int clientY); - - TouchList* touches() const {return m_touches.get();} - TouchList* targetTouches() const {return m_targetTouches.get();} - TouchList* changedTouches() const {return m_changedTouches.get();} - - bool longPressPrevented() const { return m_longPressPrevented; } - void preventLongPress() { m_longPressPrevented = true; } - void setLongPressPrevented(bool prevented) { m_longPressPrevented = prevented; } - - bool doubleTapPrevented() const { return m_doubleTapPrevented; } - void preventDoubleTap() { m_doubleTapPrevented = true; } - void setDoubleTapPrevented(bool prevented) { m_doubleTapPrevented = prevented; } - - private: - TouchEvent() {} - TouchEvent(TouchList* touches, TouchList* targetTouches, - TouchList* changedTouches, const AtomicString& type, - PassRefPtr<AbstractView>, int screenX, int screenY, int pageX, - int pageY); - - virtual bool isTouchEvent() const {return true;} - - RefPtr<TouchList> m_touches; - RefPtr<TouchList> m_targetTouches; - RefPtr<TouchList> m_changedTouches; - - bool m_longPressPrevented; - bool m_doubleTapPrevented; - }; +class TouchEvent : public MouseRelatedEvent { +public: + static PassRefPtr<TouchEvent> create() + { + return adoptRef(new TouchEvent); + } + static PassRefPtr<TouchEvent> create(TouchList* touches, + TouchList* targetTouches, TouchList* changedTouches, + const AtomicString& type, PassRefPtr<AbstractView> view, + int screenX, int screenY, int pageX, int pageY, + bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) + { + return adoptRef(new TouchEvent(touches, targetTouches, changedTouches, + type, view, screenX, screenY, pageX, pageY, + ctrlKey, altKey, shiftKey, metaKey)); + } + + void initTouchEvent(TouchList* touches, TouchList* targetTouches, + TouchList* changedTouches, const AtomicString& type, + PassRefPtr<AbstractView> view, int screenX, int screenY, + int clientX, int clientY, + bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); + + TouchList* touches() const { return m_touches.get(); } + TouchList* targetTouches() const { return m_targetTouches.get(); } + TouchList* changedTouches() const { return m_changedTouches.get(); } + +#if PLATFORM(ANDROID) + bool longPressPrevented() const { return m_longPressPrevented; } + void preventLongPress() { m_longPressPrevented = true; } + void setLongPressPrevented(bool prevented) { m_longPressPrevented = prevented; } + + bool doubleTapPrevented() const { return m_doubleTapPrevented; } + void preventDoubleTap() { m_doubleTapPrevented = true; } + void setDoubleTapPrevented(bool prevented) { m_doubleTapPrevented = prevented; } +#endif + +private: + TouchEvent() {} + TouchEvent(TouchList* touches, TouchList* targetTouches, + TouchList* changedTouches, const AtomicString& type, + PassRefPtr<AbstractView>, int screenX, int screenY, int pageX, + int pageY, + bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); + + virtual bool isTouchEvent() const { return true; } + + RefPtr<TouchList> m_touches; + RefPtr<TouchList> m_targetTouches; + RefPtr<TouchList> m_changedTouches; + +#if PLATFORM(ANDROID) + bool m_longPressPrevented; + bool m_doubleTapPrevented; +#endif +}; } // namespace WebCore diff --git a/WebCore/dom/TouchEvent.idl b/WebCore/dom/TouchEvent.idl index b7148b0..010c36f 100644 --- a/WebCore/dom/TouchEvent.idl +++ b/WebCore/dom/TouchEvent.idl @@ -32,6 +32,10 @@ module events { readonly attribute TouchList touches; readonly attribute TouchList targetTouches; readonly attribute TouchList changedTouches; + readonly attribute boolean ctrlKey; + readonly attribute boolean shiftKey; + readonly attribute boolean altKey; + readonly attribute boolean metaKey; void initTouchEvent(in TouchList touches, in TouchList targetTouches, @@ -41,6 +45,10 @@ module events { in long screenX, in long screenY, in long clientX, - in long clientY); + in long clientY, + in boolean ctrlKey, + in boolean altKey, + in boolean shiftKey, + in boolean metaKey); }; } diff --git a/WebCore/dom/TouchList.cpp b/WebCore/dom/TouchList.cpp index 78b588e..4167e42 100644 --- a/WebCore/dom/TouchList.cpp +++ b/WebCore/dom/TouchList.cpp @@ -25,7 +25,7 @@ #include "config.h" -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) #include "TouchList.h" diff --git a/WebCore/dom/TouchList.h b/WebCore/dom/TouchList.h index fa5fc80..f5033c9 100644 --- a/WebCore/dom/TouchList.h +++ b/WebCore/dom/TouchList.h @@ -26,7 +26,7 @@ #ifndef TOUCHLIST_H_ #define TOUCHLIST_H_ -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) #include <wtf/RefCounted.h> #include <wtf/Vector.h> @@ -34,24 +34,24 @@ namespace WebCore { - class TouchList : public RefCounted<TouchList> { - public: - static PassRefPtr<TouchList> create() - { - return adoptRef(new TouchList); - } +class TouchList : public RefCounted<TouchList> { +public: + static PassRefPtr<TouchList> create() + { + return adoptRef(new TouchList); + } - unsigned length() const { return m_values.size(); } + unsigned length() const { return m_values.size(); } - Touch* item (unsigned); + Touch* item(unsigned); - void append(const PassRefPtr<Touch> touch) { m_values.append(touch); } + void append(const PassRefPtr<Touch> touch) { m_values.append(touch); } - private: - TouchList() {} +private: + TouchList() {} - Vector<RefPtr<Touch> > m_values; - }; + Vector<RefPtr<Touch> > m_values; +}; } // namespace WebCore |
