diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
commit | 284837daa07b29d6a63a748544a90b1f5842ac5c (patch) | |
tree | ecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/WebCore/page/EventHandler.cpp | |
parent | 2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff) | |
download | qtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz |
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/WebCore/page/EventHandler.cpp')
-rw-r--r-- | Source/WebCore/page/EventHandler.cpp | 76 |
1 files changed, 23 insertions, 53 deletions
diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp index 04f636eae..3807c5597 100644 --- a/Source/WebCore/page/EventHandler.cpp +++ b/Source/WebCore/page/EventHandler.cpp @@ -308,7 +308,6 @@ EventHandler::EventHandler(Frame* frame) , m_eventHandlerWillResetCapturingMouseEventsNode(0) , m_clickCount(0) , m_mouseDownTimestamp(0) - , m_useLatchedWheelEventNode(false) , m_widgetIsLatched(false) #if PLATFORM(MAC) , m_mouseDownView(nil) @@ -1008,7 +1007,7 @@ void EventHandler::updateAutoscrollRenderer() if (!m_autoscrollRenderer) return; - HitTestResult hitTest = hitTestResultAtPoint(m_panScrollStartPos, true); + HitTestResult hitTest = hitTestResultAtPoint(m_panScrollStartPos, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent); if (Node* nodeAtPoint = hitTest.innerNode()) m_autoscrollRenderer = nodeAtPoint->renderer(); @@ -1040,42 +1039,18 @@ DragSourceAction EventHandler::updateDragSourceActionsAllowed() const } #endif // ENABLE(DRAG_SUPPORT) -HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, bool allowShadowContent, bool ignoreClipping, HitTestScrollbars testScrollbars, HitTestRequest::HitTestRequestType hitType, const LayoutSize& padding) +HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTestRequest::HitTestRequestType hitType, const LayoutSize& padding) { - enum ShadowContentFilterPolicy shadowContentFilterPolicy = allowShadowContent ? AllowShadowContent : DoNotAllowShadowContent; - HitTestResult result(point, padding.height(), padding.width(), padding.height(), padding.width(), shadowContentFilterPolicy); + HitTestResult result(point, padding.height(), padding.width(), padding.height(), padding.width()); if (!m_frame->contentRenderer()) return result; - if (ignoreClipping) - hitType |= HitTestRequest::IgnoreClipping; - m_frame->contentRenderer()->hitTest(HitTestRequest(hitType), result); + // We always need to handle child frame content. + hitType |= HitTestRequest::AllowChildFrameContent; + + HitTestRequest request(hitType); + m_frame->contentRenderer()->hitTest(request, 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(), shadowContentFilterPolicy); - 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; @@ -1086,12 +1061,12 @@ HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, bool FrameView* mainView = mainFrame->view(); if (resultView && mainView) { IntPoint mainFramePoint = mainView->rootViewToContents(resultView->contentsToRootView(roundedIntPoint(result.point()))); - result = mainFrame->eventHandler()->hitTestResultAtPoint(mainFramePoint, allowShadowContent, ignoreClipping, testScrollbars, hitType, padding); + result = mainFrame->eventHandler()->hitTestResultAtPoint(mainFramePoint, hitType, padding); } } } - if (!allowShadowContent) + if (!request.allowsShadowContent()) result.setToNonShadowAncestor(); return result; @@ -1501,7 +1476,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) m_mouseDownWasInSubframe = false; HitTestRequest request(HitTestRequest::Active); - // Save the document point we generate in case the window coordinate is invalidated by what happens + // Save the document point we generate in case the window coordinate is invalidated by what happens // when we dispatch the event. LayoutPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.position()); MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent); @@ -2299,11 +2274,9 @@ bool EventHandler::handleWheelEvent(const PlatformWheelEvent& e) HitTestResult result(vPoint); doc->renderView()->hitTest(request, result); -#if PLATFORM(MAC) - m_useLatchedWheelEventNode = e.momentumPhase() == PlatformWheelEventPhaseBegan || e.momentumPhase() == PlatformWheelEventPhaseChanged; -#endif + bool useLatchedWheelEventNode = e.useLatchedEventNode(); - if (m_useLatchedWheelEventNode) { + if (useLatchedWheelEventNode) { if (!m_latchedWheelEventNode) { m_latchedWheelEventNode = result.innerNode(); m_widgetIsLatched = result.isOverWidget(); @@ -2367,7 +2340,7 @@ void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv if (scrollNode(wheelEvent->rawDeltaY(), granularity, ScrollUp, ScrollDown, startNode, &stopNode)) wheelEvent->setDefaultHandled(); - if (!m_useLatchedWheelEventNode) + if (!m_latchedWheelEventNode) m_previousWheelScrolledNode = stopNode; } @@ -2403,7 +2376,7 @@ bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) eventTarget = m_scrollGestureHandlingNode.get(); if (!eventTarget) { - HitTestResult result = hitTestResultAtPoint(gestureEvent.position(), false, false, DontHitTestScrollbars, HitTestRequest::ReadOnly | HitTestRequest::Active); + HitTestResult result = hitTestResultAtPoint(gestureEvent.position()); eventTarget = result.targetNode(); } @@ -2454,8 +2427,8 @@ bool EventHandler::handleGestureTap(const PlatformGestureEvent& gestureEvent) // FIXME: Refactor this code to not hit test multiple times. We use the adjusted position to ensure that the correct node is targeted by the later redundant hit tests. IntPoint adjustedPoint = gestureEvent.position(); #if ENABLE(TOUCH_ADJUSTMENT) - if (!gestureEvent.area().isEmpty() && !adjustGesturePosition(gestureEvent, adjustedPoint)) - return false; + if (!gestureEvent.area().isEmpty()) + adjustGesturePosition(gestureEvent, adjustedPoint); #endif PlatformMouseEvent fakeMouseMove(adjustedPoint, gestureEvent.globalPosition(), @@ -2490,7 +2463,6 @@ bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture bool EventHandler::handleGestureScrollCore(const PlatformGestureEvent& gestureEvent, PlatformWheelEventGranularity granularity, bool latchedWheel) { - TemporaryChange<bool> latched(m_useLatchedWheelEventNode, latchedWheel); const float tickDivisor = (float)WheelEvent::tickMultiplier; IntPoint point(gestureEvent.position().x(), gestureEvent.position().y()); IntPoint globalPoint(gestureEvent.globalPosition().x(), gestureEvent.globalPosition().y()); @@ -2498,6 +2470,7 @@ bool EventHandler::handleGestureScrollCore(const PlatformGestureEvent& gestureEv gestureEvent.deltaX(), gestureEvent.deltaY(), gestureEvent.deltaX() / tickDivisor, gestureEvent.deltaY() / tickDivisor, granularity, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey()); + syntheticWheelEvent.setUseLatchedEventNode(latchedWheel); return handleWheelEvent(syntheticWheelEvent); } #endif @@ -2505,9 +2478,8 @@ bool EventHandler::handleGestureScrollCore(const PlatformGestureEvent& gestureEv #if ENABLE(TOUCH_ADJUSTMENT) bool EventHandler::bestClickableNodeForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntPoint& targetPoint, Node*& targetNode) { - HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active; IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter); - HitTestResult result = hitTestResultAtPoint(hitTestPoint, /*allowShadowContent*/ true, /*ignoreClipping*/ false, DontHitTestScrollbars, hitType, touchRadius); + HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent, touchRadius); IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); RefPtr<StaticHashSetNodeList> nodeList = StaticHashSetNodeList::adopt(result.rectBasedTestResult()); @@ -2524,9 +2496,8 @@ bool EventHandler::bestClickableNodeForTouchPoint(const IntPoint& touchCenter, c bool EventHandler::bestContextMenuNodeForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntPoint& targetPoint, Node*& targetNode) { - HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active; IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter); - HitTestResult result = hitTestResultAtPoint(hitTestPoint, /*allowShadowContent*/ true, /*ignoreClipping*/ false, DontHitTestScrollbars, hitType, touchRadius); + HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent, touchRadius); IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); RefPtr<StaticHashSetNodeList> nodeList = StaticHashSetNodeList::adopt(result.rectBasedTestResult()); @@ -2535,9 +2506,8 @@ bool EventHandler::bestContextMenuNodeForTouchPoint(const IntPoint& touchCenter, bool EventHandler::bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntRect& targetArea, Node*& targetNode) { - HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active; IntPoint hitTestPoint = m_frame->view()->windowToContents(touchCenter); - HitTestResult result = hitTestResultAtPoint(hitTestPoint, /*allowShadowContent*/ false, /*ignoreClipping*/ false, DontHitTestScrollbars, hitType, touchRadius); + HitTestResult result = hitTestResultAtPoint(hitTestPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, touchRadius); IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); RefPtr<StaticHashSetNodeList> nodeList = StaticHashSetNodeList::adopt(result.rectBasedTestResult()); @@ -3579,7 +3549,7 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) unsigned touchPointTargetKey = point.id() + 1; RefPtr<EventTarget> touchTarget; if (pointState == PlatformTouchPoint::TouchPressed) { - HitTestResult result = hitTestResultAtPoint(pagePoint, /*allowShadowContent*/ false, false, DontHitTestScrollbars, hitType); + HitTestResult result = hitTestResultAtPoint(pagePoint, hitType); Node* node = result.innerNode(); ASSERT(node); @@ -3597,7 +3567,7 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) touchTarget = node; } else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) { // We only perform a hittest on release or cancel to unset :active or :hover state. - hitTestResultAtPoint(pagePoint, /*allowShadowContent*/ false, false, DontHitTestScrollbars, hitType); + hitTestResultAtPoint(pagePoint, hitType); // The target should be the original target for this touch, so get it from the hashmap. As it's a release or cancel // we also remove it from the map. touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKey); |