summaryrefslogtreecommitdiff
path: root/Source/WebCore/page/EventHandler.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-09-18 15:53:33 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-09-18 15:53:33 +0200
commit6bbb7fbbac94d0f511a7bd0cbd50854ab643bfb2 (patch)
treed9c68d1cca0b3e352f1e438561f3e504e641a08f /Source/WebCore/page/EventHandler.cpp
parentd0424a769059c84ae20beb3c217812792ea6726b (diff)
downloadqtwebkit-6bbb7fbbac94d0f511a7bd0cbd50854ab643bfb2.tar.gz
Imported WebKit commit c7503cef7ecb236730d1309676ab9fc723fd061d (http://svn.webkit.org/repository/webkit/trunk@128886)
New snapshot with various build fixes
Diffstat (limited to 'Source/WebCore/page/EventHandler.cpp')
-rw-r--r--Source/WebCore/page/EventHandler.cpp66
1 files changed, 59 insertions, 7 deletions
diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp
index f102e856d..919f8e45c 100644
--- a/Source/WebCore/page/EventHandler.cpp
+++ b/Source/WebCore/page/EventHandler.cpp
@@ -264,6 +264,20 @@ static inline bool scrollNode(float delta, ScrollGranularity granularity, Scroll
return enclosingBox->scroll(delta < 0 ? negativeDirection : positiveDirection, granularity, absDelta, stopNode);
}
+#if ENABLE(GESTURE_EVENTS)
+static inline bool shouldGesturesTriggerActive()
+{
+ // If the platform we're on supports GestureTapDown and GestureTapCancel then we'll
+ // rely on them to set the active state. Unfortunately there's no generic way to
+ // know in advance what event types are supported.
+#if PLATFORM(CHROMIUM) && !OS(ANDROID)
+ return true;
+#else
+ return false;
+#endif
+}
+#endif
+
#if !PLATFORM(MAC)
inline bool EventHandler::eventLoopHandleMouseUp(const MouseEventWithHitTestResults&)
@@ -1049,13 +1063,33 @@ HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, bool
hitType |= HitTestRequest::IgnoreClipping;
if (allowShadowContent)
hitType |= HitTestRequest::AllowShadowContent;
- if (testScrollbars == ShouldHitTestScrollbars)
- hitType |= HitTestRequest::TestChildFrameScrollBars;
- // We always need to handle child frame content.
- hitType |= HitTestRequest::AllowChildFrameContent;
-
m_frame->contentRenderer()->hitTest(HitTestRequest(hitType), result);
+ while (true) {
+ Node* n = result.innerNode();
+ if (!result.isOverWidget() || !n || !n->renderer() || !n->renderer()->isWidget())
+ break;
+ RenderWidget* renderWidget = toRenderWidget(n->renderer());
+ Widget* widget = renderWidget->widget();
+ if (!widget || !widget->isFrameView())
+ break;
+ Frame* frame = static_cast<HTMLFrameElementBase*>(n)->contentFrame();
+ if (!frame || !frame->contentRenderer())
+ break;
+ FrameView* view = static_cast<FrameView*>(widget);
+ LayoutPoint widgetPoint(result.localPoint().x() + view->scrollX() - renderWidget->borderLeft() - renderWidget->paddingLeft(),
+ result.localPoint().y() + view->scrollY() - renderWidget->borderTop() - renderWidget->paddingTop());
+ HitTestResult widgetHitTestResult(widgetPoint, padding.height(), padding.width(), padding.height(), padding.width());
+ frame->contentRenderer()->hitTest(HitTestRequest(hitType), widgetHitTestResult);
+ result = widgetHitTestResult;
+
+ if (testScrollbars == ShouldHitTestScrollbars) {
+ Scrollbar* eventScrollbar = view->scrollbarAtPoint(roundedIntPoint(point));
+ if (eventScrollbar)
+ result.setScrollbar(eventScrollbar);
+ }
+ }
+
// If our HitTestResult is not visible, then we started hit testing too far down the frame chain.
// Another hit test at the main frame level should get us the correct visible result.
Frame* resultFrame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document()->frame() : 0;
@@ -2380,8 +2414,20 @@ bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
if (gestureEvent.type() == PlatformEvent::GestureScrollEnd || gestureEvent.type() == PlatformEvent::GestureScrollUpdate)
eventTarget = m_scrollGestureHandlingNode.get();
- if (!eventTarget) {
- HitTestResult result = hitTestResultAtPoint(gestureEvent.position(), false, false, DontHitTestScrollbars, HitTestRequest::ReadOnly | HitTestRequest::Active);
+ HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent;
+ if (gestureEvent.type() == PlatformEvent::GestureTapDown)
+ hitType |= HitTestRequest::Active;
+ else if (gestureEvent.type() == PlatformEvent::GestureTap || gestureEvent.type() == PlatformEvent::GestureTapDownCancel)
+ hitType |= HitTestRequest::Release;
+ else
+ hitType |= HitTestRequest::Active | HitTestRequest::ReadOnly;
+
+ if (!shouldGesturesTriggerActive())
+ hitType |= HitTestRequest::ReadOnly;
+
+ if (!eventTarget || !(hitType & HitTestRequest::ReadOnly)) {
+ IntPoint hitTestPoint = m_frame->view()->windowToContents(gestureEvent.position());
+ HitTestResult result = hitTestResultAtPoint(hitTestPoint, false, false, DontHitTestScrollbars, hitType);
eventTarget = result.targetNode();
}
@@ -2419,6 +2465,7 @@ bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
case PlatformEvent::GesturePinchBegin:
case PlatformEvent::GesturePinchEnd:
case PlatformEvent::GesturePinchUpdate:
+ case PlatformEvent::GestureTapDownCancel:
break;
default:
ASSERT_NOT_REACHED();
@@ -3553,6 +3600,11 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
break;
}
+#if ENABLE(GESTURE_EVENTS)
+ if (shouldGesturesTriggerActive())
+ hitType |= HitTestRequest::ReadOnly;
+#endif
+
// Increment the platform touch id by 1 to avoid storing a key of 0 in the hashmap.
unsigned touchPointTargetKey = point.id() + 1;
RefPtr<EventTarget> touchTarget;