diff options
author | Leon Scroggins <scroggo@google.com> | 2010-03-05 11:39:01 -0500 |
---|---|---|
committer | Grace Kloba <klobag@google.com> | 2010-03-09 11:33:41 -0800 |
commit | 6ed4a4e9a23ead7c910239171daf02b8fbecc17b (patch) | |
tree | 481f3029333ec03e0f3952cdc1088f46f2c64242 | |
parent | fa26a8dd531dff44d6cad0700ff32c0bb949392c (diff) | |
download | external_webkit-6ed4a4e9a23ead7c910239171daf02b8fbecc17b.zip external_webkit-6ed4a4e9a23ead7c910239171daf02b8fbecc17b.tar.gz external_webkit-6ed4a4e9a23ead7c910239171daf02b8fbecc17b.tar.bz2 |
Only call plugin touch code if it is in full screen
mode or it is the document focused node.
Remove Android special code added to support prevent
default for double tap and long press. Long press
and double tap needs to call preventDefault if it
is needed.
Remove Android special code added to pass event time.
Need a separate CL for android_npapi.
-rw-r--r-- | WebCore/dom/Event.h | 4 | ||||
-rw-r--r-- | WebCore/dom/TouchEvent.cpp | 4 | ||||
-rw-r--r-- | WebCore/dom/TouchEvent.h | 15 | ||||
-rw-r--r-- | WebCore/page/EventHandler.cpp | 41 | ||||
-rw-r--r-- | WebCore/page/EventHandler.h | 15 | ||||
-rw-r--r-- | WebCore/platform/PlatformTouchEvent.h | 9 | ||||
-rw-r--r-- | WebCore/platform/android/PlatformTouchEventAndroid.cpp | 5 | ||||
-rw-r--r-- | WebCore/plugins/android/PluginViewAndroid.cpp | 35 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 12 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 2 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginDebugAndroid.cpp | 6 | ||||
-rw-r--r-- | WebKit/android/plugins/SkANP.cpp | 7 | ||||
-rw-r--r-- | WebKit/android/plugins/SkANP.h | 1 |
13 files changed, 22 insertions, 134 deletions
diff --git a/WebCore/dom/Event.h b/WebCore/dom/Event.h index 1ba5e3d..0a05863 100644 --- a/WebCore/dom/Event.h +++ b/WebCore/dom/Event.h @@ -154,10 +154,6 @@ namespace WebCore { bool createdByDOM() const { return m_createdByDOM; } void setCreatedByDOM(bool createdByDOM) { m_createdByDOM = createdByDOM; } -#if PLATFORM(ANDROID) - void setCreateTime(DOMTimeStamp time) { m_createTime = time; } -#endif - protected: Event(); Event(const AtomicString& type, bool canBubble, bool cancelable); diff --git a/WebCore/dom/TouchEvent.cpp b/WebCore/dom/TouchEvent.cpp index 1fbba6c..bcc395f 100644 --- a/WebCore/dom/TouchEvent.cpp +++ b/WebCore/dom/TouchEvent.cpp @@ -40,10 +40,6 @@ TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches, , m_touches(touches) , m_targetTouches(targetTouches) , m_changedTouches(changedTouches) -#if PLATFORM(ANDROID) - , m_longPressPrevented(false) - , m_doubleTapPrevented(false) -#endif { } diff --git a/WebCore/dom/TouchEvent.h b/WebCore/dom/TouchEvent.h index abc1ee2..080a495 100644 --- a/WebCore/dom/TouchEvent.h +++ b/WebCore/dom/TouchEvent.h @@ -60,16 +60,6 @@ public: 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, @@ -83,11 +73,6 @@ private: 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/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp index 4d7f123..233fd05 100644 --- a/WebCore/page/EventHandler.cpp +++ b/WebCore/page/EventHandler.cpp @@ -2562,14 +2562,7 @@ static PassRefPtr<TouchList> assembleTargetTouches(Touch* touchTarget, TouchList return targetTouches.release(); } -#if PLATFORM(ANDROID) -// TODO(benm): On Android we return an int back to Java to signify whether the default actions -// for longpress/doubletap in the Browser should be prevented. I think that before upstreaming -// to webkit.org we can refactor the Java side to not require this. -int EventHandler::handleTouchEvent(const PlatformTouchEvent& event) -#else bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) -#endif { RefPtr<TouchList> touches = TouchList::create(); RefPtr<TouchList> pressedTouches = TouchList::create(); @@ -2643,13 +2636,6 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) Touch* changedTouch = 0; EventTarget* touchEventTarget = 0; -#if PLATFORM(ANDROID) - // TODO (benm): We should be able to remove this prior to upstreaming once Java side refactorings to make - // preventDeault work better are complete. - bool longPressPrevented = false; - bool doubleTapPrevented = false; -#endif - if (cancelTouches->length() > 0) { // We dispatch the event to the target of the touch that caused this touch event to be generated, i.e. // we take it from the list that will be used as the changedTouches property of the event. @@ -2668,9 +2654,6 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()); -#if PLATFORM(ANDROID) - cancelEv->setCreateTime(static_cast<DOMTimeStamp>(event.eventTime())); -#endif ExceptionCode ec = 0; touchEventTarget->dispatchEvent(cancelEv.get(), ec); defaultPrevented |= cancelEv->defaultPrevented(); @@ -2690,9 +2673,6 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) *eventName, touchEventTarget->toNode()->document()->defaultView(), 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()); -#if PLATFORM(ANDROID) - endEv->setCreateTime(static_cast<DOMTimeStamp>(event.eventTime())); -#endif ExceptionCode ec = 0; touchEventTarget->dispatchEvent(endEv.get(), ec); defaultPrevented |= endEv->defaultPrevented(); @@ -2713,7 +2693,6 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) *eventName, touchEventTarget->toNode()->document()->defaultView(), 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()); - longpressEv->setCreateTime(static_cast<DOMTimeStamp>(event.eventTime())); ExceptionCode ec = 0; touchEventTarget->dispatchEvent(longpressEv.get(), ec); @@ -2725,7 +2704,6 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) *eventName, touchEventTarget->toNode()->document()->defaultView(), 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()); - doubleTapEv->setCreateTime(static_cast<DOMTimeStamp>(event.eventTime())); ExceptionCode ec = 0; touchEventTarget->dispatchEvent(doubleTapEv.get(), ec); @@ -2738,15 +2716,10 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) *eventName, touchEventTarget->toNode()->document()->defaultView(), 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()); -#if PLATFORM(ANDROID) - startEv->setCreateTime(static_cast<DOMTimeStamp>(event.eventTime())); -#endif ExceptionCode ec = 0; touchEventTarget->dispatchEvent(startEv.get(), ec); defaultPrevented |= startEv->defaultPrevented(); #if PLATFORM(ANDROID) - longPressPrevented |= startEv->longPressPrevented(); - doubleTapPrevented |= startEv->doubleTapPrevented(); } #endif } @@ -2765,26 +2738,12 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) *eventName, touchEventTarget->toNode()->document()->defaultView(), 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()); -#if PLATFORM(ANDROID) - moveEv->setCreateTime(static_cast<DOMTimeStamp>(event.eventTime())); -#endif ExceptionCode ec = 0; touchEventTarget->dispatchEvent(moveEv.get(), ec); defaultPrevented |= moveEv->defaultPrevented(); } -#if PLATFORM(ANDROID) - // TODO (benm): We should be able to remove this prior to upstreaming once Java side refactorings to make - // preventDefault work better are complete. - if (event.type() == TouchLongPress || event.type() == TouchDoubleTap) - return 0; - - return (defaultPrevented ? preventTouch : 0) - | (longPressPrevented ? preventLongPress : 0) - | (doubleTapPrevented ? preventDoubleTap : 0); -#else return defaultPrevented; -#endif } #endif diff --git a/WebCore/page/EventHandler.h b/WebCore/page/EventHandler.h index aeed356..a268adb 100644 --- a/WebCore/page/EventHandler.h +++ b/WebCore/page/EventHandler.h @@ -78,17 +78,6 @@ extern const int GeneralDragHysteresis; enum HitTestScrollbars { ShouldHitTestScrollbars, DontHitTestScrollbars }; -#if PLATFORM(ANDROID) -// TODO (benm): I think with some Java refactoring we can remove this before upstreaming to webkit.org. -#if ENABLE(TOUCH_EVENTS) -enum TouchResultMask { - preventTouch = 1 << 0, - preventLongPress = 1 << 1, - preventDoubleTap = 1 << 2, -}; -#endif -#endif - class EventHandler : public Noncopyable { public: EventHandler(Frame*); @@ -211,12 +200,8 @@ public: #endif #if ENABLE(TOUCH_EVENTS) -#if PLATFORM(ANDROID) - int handleTouchEvent(const PlatformTouchEvent&); -#else bool handleTouchEvent(const PlatformTouchEvent&); #endif -#endif private: #if ENABLE(DRAG_SUPPORT) diff --git a/WebCore/platform/PlatformTouchEvent.h b/WebCore/platform/PlatformTouchEvent.h index 56d1020..7e2ac84 100644 --- a/WebCore/platform/PlatformTouchEvent.h +++ b/WebCore/platform/PlatformTouchEvent.h @@ -61,7 +61,7 @@ public: PlatformTouchEvent(QTouchEvent*); #elif PLATFORM(ANDROID) // TODO (benm): eventTime and metaState are new and need to be upstreamed. - PlatformTouchEvent(const IntPoint& windowPos, TouchEventType, PlatformTouchPoint::State, long eventTime, int metaState); + PlatformTouchEvent(const IntPoint& windowPos, TouchEventType, PlatformTouchPoint::State, int metaState); #endif TouchEventType type() const { return m_type; } @@ -72,10 +72,6 @@ public: bool shiftKey() const { return m_shiftKey; } bool metaKey() const { return m_metaKey; } -#if PLATFORM(ANDROID) - long eventTime() const { return m_eventTime; } -#endif - private: TouchEventType m_type; Vector<PlatformTouchPoint> m_touchPoints; @@ -83,9 +79,6 @@ private: bool m_altKey; bool m_shiftKey; bool m_metaKey; -#if PLATFORM(ANDROID) - long m_eventTime; -#endif }; } diff --git a/WebCore/platform/android/PlatformTouchEventAndroid.cpp b/WebCore/platform/android/PlatformTouchEventAndroid.cpp index 085eb0a..0b3ac13 100644 --- a/WebCore/platform/android/PlatformTouchEventAndroid.cpp +++ b/WebCore/platform/android/PlatformTouchEventAndroid.cpp @@ -38,11 +38,10 @@ enum AndroidMetaKeyState { META_SYM_ON = 0x04 }; -// TODO (benm): eventTime and metaState are new and needs to be upstreamed. -PlatformTouchEvent::PlatformTouchEvent(const IntPoint& windowPos, TouchEventType type, PlatformTouchPoint::State state, long eventTime, int metaState) +// TODO (benm): metaState are new and needs to be upstreamed. +PlatformTouchEvent::PlatformTouchEvent(const IntPoint& windowPos, TouchEventType type, PlatformTouchPoint::State state, int metaState) : m_type(type) , m_metaKey(false) - , m_eventTime(eventTime) { m_touchPoints.append(PlatformTouchPoint(windowPos, state)); diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp index c91b480..cd86556 100644 --- a/WebCore/plugins/android/PluginViewAndroid.cpp +++ b/WebCore/plugins/android/PluginViewAndroid.cpp @@ -190,10 +190,12 @@ void PluginView::handleTouchEvent(TouchEvent* event) if (!m_window->isAcceptingEvent(kTouch_ANPEventFlag)) return; + if (!m_window->inFullScreen() && m_parentFrame->document()->focusedNode() != m_element) + return; + ANPEvent evt; - SkANP::InitEvent(&evt, kTouch_ANPEventType, event->timeStamp()); + SkANP::InitEvent(&evt, kTouch_ANPEventType); - bool ignoreRet = false; const AtomicString& type = event->type(); if (eventNames().touchstartEvent == type) evt.data.touch.action = kDown_ANPTouchAction; @@ -203,13 +205,11 @@ void PluginView::handleTouchEvent(TouchEvent* event) evt.data.touch.action = kMove_ANPTouchAction; else if (eventNames().touchcancelEvent == type) evt.data.touch.action = kCancel_ANPTouchAction; - else if (eventNames().touchlongpressEvent == type) { + else if (eventNames().touchlongpressEvent == type) evt.data.touch.action = kLongPress_ANPTouchAction; - ignoreRet = true; - } else if (eventNames().touchdoubletapEvent == type) { + else if (eventNames().touchdoubletapEvent == type) evt.data.touch.action = kDoubleTap_ANPTouchAction; - ignoreRet = true; - } else + else return; evt.data.touch.modifiers = 0; // todo @@ -225,23 +225,8 @@ void PluginView::handleTouchEvent(TouchEvent* event) evt.data.touch.x = localPos.x(); evt.data.touch.y = localPos.y(); - int16 ret = m_window->sendEvent(evt); - if (ignoreRet) - return; - if (ret & kHandleTouch_ANPTouchResult) { - // The plugin needs focus to receive keyboard events - if (evt.data.touch.action == kDown_ANPTouchAction) { - if (Page* page = m_parentFrame->page()) - page->focusController()->setFocusedFrame(m_parentFrame); - m_parentFrame->document()->setFocusedNode(m_element); - } + if (m_window->sendEvent(evt)) event->preventDefault(); - } else { - if (ret & kHandleLongPress_ANPTouchResult) - event->preventLongPress(); - if (ret & kHandleDoubleTap_ANPTouchResult) - event->preventDoubleTap(); - } } void PluginView::handleMouseEvent(MouseEvent* event) @@ -253,7 +238,7 @@ void PluginView::handleMouseEvent(MouseEvent* event) ANPEvent evt; if (isUp || isDown) { - SkANP::InitEvent(&evt, kMouse_ANPEventType, event->timeStamp()); + SkANP::InitEvent(&evt, kMouse_ANPEventType); evt.data.mouse.action = isUp ? kUp_ANPMouseAction : kDown_ANPMouseAction; // Convert to coordinates that are relative to the plugin. @@ -315,7 +300,7 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event) bool ignoreEvent = false; ANPEvent evt; - SkANP::InitEvent(&evt, kKey_ANPEventType, event->timeStamp()); + SkANP::InitEvent(&evt, kKey_ANPEventType); switch (pke->type()) { case PlatformKeyboardEvent::KeyDown: diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 53f2b24..9cbeb71 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -1962,9 +1962,9 @@ void WebViewCore::click(WebCore::Frame* frame, WebCore::Node* node) { } } -int WebViewCore::handleTouchEvent(int action, int x, int y, long time, int metaState) +bool WebViewCore::handleTouchEvent(int action, int x, int y, int metaState) { - int preventDefault = 0; + bool preventDefault = false; #if USE(ACCELERATED_COMPOSITING) RenderView* contentRenderer = m_mainFrame->contentRenderer(); @@ -2018,7 +2018,7 @@ int WebViewCore::handleTouchEvent(int action, int x, int y, long time, int metaS m_lastTouchPoint = pt; - WebCore::PlatformTouchEvent te(pt, type, touchState, time, metaState); + WebCore::PlatformTouchEvent te(pt, type, touchState, metaState); preventDefault = m_mainFrame->eventHandler()->handleTouchEvent(te); #endif @@ -2711,14 +2711,14 @@ static jstring FindAddress(JNIEnv *env, jobject obj, jstring addr, return ret; } -static jint HandleTouchEvent(JNIEnv *env, jobject obj, jint action, jint x, jint y, jlong time, jint metaState) +static jboolean HandleTouchEvent(JNIEnv *env, jobject obj, jint action, jint x, jint y, jint metaState) { #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); #endif WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__); - return viewImpl->handleTouchEvent(action, x, y, time, metaState); + return viewImpl->handleTouchEvent(action, x, y, metaState); } static void TouchUp(JNIEnv *env, jobject obj, jint touchGeneration, @@ -3121,7 +3121,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) SaveDocumentState }, { "nativeFindAddress", "(Ljava/lang/String;Z)Ljava/lang/String;", (void*) FindAddress }, - { "nativeHandleTouchEvent", "(IIIJI)I", + { "nativeHandleTouchEvent", "(IIII)Z", (void*) HandleTouchEvent }, { "nativeTouchUp", "(IIIII)V", (void*) TouchUp }, diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index b7b931d..7883cdd 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -290,7 +290,7 @@ namespace android { /** * Handle touch event */ - int handleTouchEvent(int action, int x, int y, long time, int metaState); + bool handleTouchEvent(int action, int x, int y, int metaState); /** * Handle motionUp event from the UI thread (called touchUp in the diff --git a/WebKit/android/plugins/PluginDebugAndroid.cpp b/WebKit/android/plugins/PluginDebugAndroid.cpp index e783419..e13e928 100644 --- a/WebKit/android/plugins/PluginDebugAndroid.cpp +++ b/WebKit/android/plugins/PluginDebugAndroid.cpp @@ -93,10 +93,8 @@ void anp_logPluginEvent(void* npp, const ANPEvent* evt, int16 returnVal, int ela case kTouch_ANPEventType: if(evt->data.touch.action < ARRAY_COUNT(inputActions)) { - uint32_t totalTime = android::uptimeMillis() - evt->timeStamp; - - anp_logPlugin("%p EVENT::TOUCH[%d] delay=%d time=%d action=%s [%d %d]", - npp, returnVal, totalTime - elapsedTime, elapsedTime, + anp_logPlugin("%p EVENT::TOUCH[%d] time=%d action=%s [%d %d]", + npp, returnVal, elapsedTime, inputActions[evt->data.touch.action], evt->data.touch.x, evt->data.touch.y); } else { diff --git a/WebKit/android/plugins/SkANP.cpp b/WebKit/android/plugins/SkANP.cpp index bb3fe45..720387d 100644 --- a/WebKit/android/plugins/SkANP.cpp +++ b/WebKit/android/plugins/SkANP.cpp @@ -103,11 +103,4 @@ bool SkANP::SetBitmap(ANPBitmap* dst, const SkBitmap& src) { void SkANP::InitEvent(ANPEvent* event, ANPEventType et) { event->inSize = sizeof(ANPEvent); event->eventType = et; - event->timeStamp = currentTime() * 1000.0; -} - -void SkANP::InitEvent(ANPEvent* event, ANPEventType et, long time) { - event->inSize = sizeof(ANPEvent); - event->eventType = et; - event->timeStamp = time; } diff --git a/WebKit/android/plugins/SkANP.h b/WebKit/android/plugins/SkANP.h index 8590e10..5c2a936 100644 --- a/WebKit/android/plugins/SkANP.h +++ b/WebKit/android/plugins/SkANP.h @@ -74,7 +74,6 @@ public: static bool SetBitmap(ANPBitmap* dst, const SkBitmap& src); static void InitEvent(ANPEvent* event, ANPEventType et); - static void InitEvent(ANPEvent* event, ANPEventType et, long time); }; #endif |