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

Side by Side Diff: Source/web/tests/LinkHighlightTest.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 unified diff | Download patch | Annotate | Revision Log
« Source/web/WebViewImpl.cpp ('K') | « Source/web/WebViewImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 11 matching lines...) Expand all
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25 #include "config.h" 25 #include "config.h"
26 26
27 #include "web/LinkHighlight.h" 27 #include "web/LinkHighlight.h"
28 28
29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
30 #include "core/dom/Node.h" 30 #include "core/dom/Node.h"
31 #include "core/frame/FrameView.h" 31 #include "core/frame/FrameView.h"
32 #include "core/page/EventHandler.h"
33 #include "core/page/Page.h"
32 #include "core/page/TouchDisambiguation.h" 34 #include "core/page/TouchDisambiguation.h"
33 #include "core/testing/URLTestHelpers.h" 35 #include "core/testing/URLTestHelpers.h"
34 #include "platform/geometry/IntRect.h" 36 #include "platform/geometry/IntRect.h"
35 #include "public/platform/Platform.h" 37 #include "public/platform/Platform.h"
36 #include "public/platform/WebContentLayer.h" 38 #include "public/platform/WebContentLayer.h"
37 #include "public/platform/WebFloatPoint.h" 39 #include "public/platform/WebFloatPoint.h"
38 #include "public/platform/WebSize.h" 40 #include "public/platform/WebSize.h"
39 #include "public/platform/WebUnitTestSupport.h" 41 #include "public/platform/WebUnitTestSupport.h"
40 #include "public/web/WebFrame.h" 42 #include "public/web/WebFrame.h"
41 #include "public/web/WebFrameClient.h" 43 #include "public/web/WebFrameClient.h"
(...skipping 27 matching lines...) Expand all
69 71
70 WebGestureEvent touchEvent; 72 WebGestureEvent touchEvent;
71 touchEvent.type = WebInputEvent::GestureShowPress; 73 touchEvent.type = WebInputEvent::GestureShowPress;
72 74
73 // The coordinates below are linked to absolute positions in the referenced .html file. 75 // The coordinates below are linked to absolute positions in the referenced .html file.
74 touchEvent.x = 20; 76 touchEvent.x = 20;
75 touchEvent.y = 20; 77 touchEvent.y = 20;
76 78
77 { 79 {
78 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent); 80 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent);
79 Node* touchNode = webViewImpl->bestTapNode(platformEvent); 81 GestureEventWithHitTestResults targetedEvent =
82 webViewImpl->page()->deprecatedLocalMainFrame()->eventHandler().targ etGestureEvent(platformEvent, true);
Rick Byers 2014/08/20 23:59:33 Factor these couple lines into a little helper fun
Zeeshan Qureshi 2014/08/21 04:59:25 Done.
83 Node* touchNode = webViewImpl->bestTapNode(targetedEvent);
80 ASSERT_TRUE(touchNode); 84 ASSERT_TRUE(touchNode);
81 } 85 }
82 86
83 touchEvent.y = 40; 87 touchEvent.y = 40;
84 { 88 {
85 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent); 89 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent);
86 EXPECT_FALSE(webViewImpl->bestTapNode(platformEvent)); 90 GestureEventWithHitTestResults targetedEvent =
91 webViewImpl->page()->deprecatedLocalMainFrame()->eventHandler().targ etGestureEvent(platformEvent, true);
92 EXPECT_FALSE(webViewImpl->bestTapNode(targetedEvent));
87 } 93 }
88 94
89 touchEvent.y = 20; 95 touchEvent.y = 20;
90 // Shouldn't crash. 96 // Shouldn't crash.
91 97
92 { 98 {
93 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent); 99 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent);
94 webViewImpl->enableTapHighlightAtPoint(platformEvent); 100 GestureEventWithHitTestResults targetedEvent =
101 webViewImpl->page()->deprecatedLocalMainFrame()->eventHandler().targ etGestureEvent(platformEvent, true);
102 webViewImpl->enableTapHighlightAtPoint(targetedEvent);
95 } 103 }
96 104
97 EXPECT_TRUE(webViewImpl->linkHighlight(0)); 105 EXPECT_TRUE(webViewImpl->linkHighlight(0));
98 EXPECT_TRUE(webViewImpl->linkHighlight(0)->contentLayer()); 106 EXPECT_TRUE(webViewImpl->linkHighlight(0)->contentLayer());
99 EXPECT_TRUE(webViewImpl->linkHighlight(0)->clipLayer()); 107 EXPECT_TRUE(webViewImpl->linkHighlight(0)->clipLayer());
100 108
101 // Find a target inside a scrollable div 109 // Find a target inside a scrollable div
102 110
103 touchEvent.y = 100; 111 touchEvent.y = 100;
104 { 112 {
105 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent); 113 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent);
106 webViewImpl->enableTapHighlightAtPoint(platformEvent); 114 GestureEventWithHitTestResults targetedEvent =
115 webViewImpl->page()->deprecatedLocalMainFrame()->eventHandler().targ etGestureEvent(platformEvent, true);
116 webViewImpl->enableTapHighlightAtPoint(targetedEvent);
107 } 117 }
108 118
109 ASSERT_TRUE(webViewImpl->linkHighlight(0)); 119 ASSERT_TRUE(webViewImpl->linkHighlight(0));
110 120
111 // Don't highlight if no "hand cursor" 121 // Don't highlight if no "hand cursor"
112 touchEvent.y = 220; // An A-link with cross-hair cursor. 122 touchEvent.y = 220; // An A-link with cross-hair cursor.
113 { 123 {
114 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent); 124 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent);
115 webViewImpl->enableTapHighlightAtPoint(platformEvent); 125 GestureEventWithHitTestResults targetedEvent =
126 webViewImpl->page()->deprecatedLocalMainFrame()->eventHandler().targ etGestureEvent(platformEvent, true);
127 webViewImpl->enableTapHighlightAtPoint(targetedEvent);
116 } 128 }
117 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); 129 ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
118 130
119 touchEvent.y = 260; // A text input box. 131 touchEvent.y = 260; // A text input box.
120 { 132 {
121 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent); 133 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent);
122 webViewImpl->enableTapHighlightAtPoint(platformEvent); 134 GestureEventWithHitTestResults targetedEvent =
135 webViewImpl->page()->deprecatedLocalMainFrame()->eventHandler().targ etGestureEvent(platformEvent, true);
136 webViewImpl->enableTapHighlightAtPoint(targetedEvent);
123 } 137 }
124 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); 138 ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
125 139
126 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 140 Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
127 } 141 }
128 142
129 class FakeWebFrameClient : public WebFrameClient { 143 class FakeWebFrameClient : public WebFrameClient {
130 // To make the destructor public. 144 // To make the destructor public.
131 }; 145 };
132 146
(...skipping 21 matching lines...) Expand all
154 int pageHeight = 480; 168 int pageHeight = 480;
155 webViewImpl->resize(WebSize(pageWidth, pageHeight)); 169 webViewImpl->resize(WebSize(pageWidth, pageHeight));
156 webViewImpl->layout(); 170 webViewImpl->layout();
157 171
158 WebGestureEvent touchEvent; 172 WebGestureEvent touchEvent;
159 touchEvent.type = WebInputEvent::GestureShowPress; 173 touchEvent.type = WebInputEvent::GestureShowPress;
160 touchEvent.x = 20; 174 touchEvent.x = 20;
161 touchEvent.y = 20; 175 touchEvent.y = 20;
162 176
163 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->fram eView(), touchEvent); 177 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->fram eView(), touchEvent);
164 Node* touchNode = webViewImpl->bestTapNode(platformEvent); 178 GestureEventWithHitTestResults targetedEvent =
179 webViewImpl->page()->deprecatedLocalMainFrame()->eventHandler().targetGe stureEvent(platformEvent, true);
180 Node* touchNode = webViewImpl->bestTapNode(targetedEvent);
165 ASSERT_TRUE(touchNode); 181 ASSERT_TRUE(touchNode);
166 182
167 webViewImpl->enableTapHighlightAtPoint(platformEvent); 183 webViewImpl->enableTapHighlightAtPoint(targetedEvent);
168 ASSERT_TRUE(webViewImpl->linkHighlight(0)); 184 ASSERT_TRUE(webViewImpl->linkHighlight(0));
169 185
170 GraphicsLayer* highlightLayer = webViewImpl->linkHighlight(0)->currentGraphi csLayerForTesting(); 186 GraphicsLayer* highlightLayer = webViewImpl->linkHighlight(0)->currentGraphi csLayerForTesting();
171 ASSERT_TRUE(highlightLayer); 187 ASSERT_TRUE(highlightLayer);
172 EXPECT_TRUE(highlightLayer->linkHighlight(0)); 188 EXPECT_TRUE(highlightLayer->linkHighlight(0));
173 189
174 touchNode->remove(IGNORE_EXCEPTION); 190 touchNode->remove(IGNORE_EXCEPTION);
175 webViewImpl->layout(); 191 webViewImpl->layout();
176 ASSERT_EQ(0U, highlightLayer->numLinkHighlights()); 192 ASSERT_EQ(0U, highlightLayer->numLinkHighlights());
177 193
(...skipping 25 matching lines...) Expand all
203 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, touchEvent .y - touchEvent.data.tap.height / 2, touchEvent.data.tap.width, touchEvent.data. tap.height); 219 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, touchEvent .y - touchEvent.data.tap.height / 2, touchEvent.data.tap.width, touchEvent.data. tap.height);
204 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), goo dTargets, highlightNodes); 220 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), goo dTargets, highlightNodes);
205 221
206 webViewImpl->enableTapHighlights(highlightNodes); 222 webViewImpl->enableTapHighlights(highlightNodes);
207 EXPECT_EQ(2U, webViewImpl->numLinkHighlights()); 223 EXPECT_EQ(2U, webViewImpl->numLinkHighlights());
208 224
209 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 225 Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
210 } 226 }
211 227
212 } // namespace 228 } // namespace
OLDNEW
« Source/web/WebViewImpl.cpp ('K') | « Source/web/WebViewImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698