Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2528)

Unified Diff: Source/web/WebViewImpl.cpp

Issue 490783003: Reduce hit test on ShowPress by moving event targeting to WebViewImpl (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update hit test counts Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index 7f6775e22c3486d7aa8d72b3b8f70bf9e34103d0..ea59192fa1cc827a913b410c755b6191eea694e0 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -71,7 +71,6 @@
#include "core/page/DragData.h"
#include "core/page/DragSession.h"
#include "core/page/EventHandler.h"
-#include "core/page/EventWithHitTestResults.h"
#include "core/page/FocusController.h"
#include "core/page/FrameTree.h"
#include "core/page/InjectedStyleSheets.h"
@@ -658,15 +657,18 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
- // FIXME: Remove redundant hit tests by pushing the call to EventHandler::targetGestureEvent
- // up to this point and pass GestureEventWithHitTestResults around.
+ HitTestResult emptyResult;
Rick Byers 2014/08/20 23:59:33 As discussed, having this "sometimes targetted but
Zeeshan Qureshi 2014/08/21 04:59:25 Done.
+ GestureEventWithHitTestResults targetedEvent(platformEvent, emptyResult);
+ // Hit test across all frames and do touch adjustment as necessary for the event type.
+ if (!platformEvent.isScrollEvent())
+ targetedEvent = m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(platformEvent);
// Handle link highlighting outside the main switch to avoid getting lost in the
// complicated set of cases handled below.
switch (event.type) {
case WebInputEvent::GestureShowPress:
// Queue a highlight animation, then hand off to regular handler.
- enableTapHighlightAtPoint(platformEvent);
+ enableTapHighlightAtPoint(targetedEvent);
break;
case WebInputEvent::GestureTapCancel:
case WebInputEvent::GestureTap:
@@ -681,7 +683,7 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
switch (event.type) {
case WebInputEvent::GestureTap: {
m_client->cancelScheduledContentIntents();
- if (detectContentOnTouch(platformEvent.position())) {
+ if (detectContentOnTouch(targetedEvent.event().position())) {
Rick Byers 2014/08/20 23:59:32 Add FIXME to use the targeted event here.
Zeeshan Qureshi 2014/08/21 04:59:25 Done.
eventSwallowed = true;
break;
}
@@ -717,7 +719,7 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
}
}
- eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(platformEvent);
+ eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(targetedEvent);
if (m_selectPopup && m_selectPopup == selectPopup) {
// That tap triggered a select popup which is the same as the one that
@@ -738,20 +740,20 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
m_client->cancelScheduledContentIntents();
m_page->contextMenuController().clearContextMenu();
m_contextMenuAllowed = true;
- eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(platformEvent);
+ eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(targetedEvent);
m_contextMenuAllowed = false;
break;
}
case WebInputEvent::GestureShowPress: {
m_client->cancelScheduledContentIntents();
- eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(platformEvent);
+ eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(targetedEvent);
break;
}
case WebInputEvent::GestureDoubleTap:
if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor() != maximumPageScaleFactor()) {
m_client->cancelScheduledContentIntents();
- animateDoubleTapZoom(platformEvent.position());
+ animateDoubleTapZoom(targetedEvent.event().position());
}
// GestureDoubleTap is currently only used by Android for zooming. For WebCore,
// GestureTap with tap count = 2 is used instead. So we drop GestureDoubleTap here.
@@ -769,7 +771,7 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
case WebInputEvent::GesturePinchEnd:
case WebInputEvent::GesturePinchUpdate:
case WebInputEvent::GestureFlingStart: {
- eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(platformEvent);
+ eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(targetedEvent);
break;
}
default:
@@ -1189,17 +1191,14 @@ static bool showsHandCursor(Node* node, LocalFrame* frame)
|| (cursor == CURSOR_AUTO && frame->eventHandler().useHandCursor(node, node->isLink()));
}
-Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent)
+Node* WebViewImpl::bestTapNode(const GestureEventWithHitTestResults& targetedTapEvent)
{
TRACE_EVENT0("input", "WebViewImpl::bestTapNode");
if (!m_page || !m_page->mainFrame())
return 0;
- // FIXME: Rely on earlier hit test instead of hit testing again.
- GestureEventWithHitTestResults targetedEvent =
- m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(tapEvent, true);
- Node* bestTouchNode = targetedEvent.hitTestResult().targetNode();
+ Node* bestTouchNode = targetedTapEvent.hitTestResult().targetNode();
// We might hit something like an image map that has no renderer on it
// Walk up the tree until we have a node with an attached renderer
@@ -1225,9 +1224,9 @@ Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent)
return bestTouchNode;
}
-void WebViewImpl::enableTapHighlightAtPoint(const PlatformGestureEvent& tapEvent)
+void WebViewImpl::enableTapHighlightAtPoint(const GestureEventWithHitTestResults& targetedTapEvent)
{
- Node* touchNode = bestTapNode(tapEvent);
+ Node* touchNode = bestTapNode(targetedTapEvent);
WillBeHeapVector<RawPtrWillBeMember<Node> > highlightNodes;
highlightNodes.append(touchNode);

Powered by Google App Engine
This is Rietveld 408576698