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

Side by Side Diff: LayoutTests/fast/events/hit-test-counts.html

Issue 1177123003: Revert "Implement a Hit Test Cache for same point hits." (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <meta name="viewport" content="width=device-width, initial-scale=1"> 2 <meta name="viewport" content="width=device-width, initial-scale=1">
3 <style> 3 <style>
4 html { 4 html {
5 font-family: Ahem; 5 font-family: Ahem;
6 font-size: 10px; 6 font-size: 10px;
7 } 7 }
8 #testArea { 8 #testArea {
9 position: absolute; 9 position: absolute;
10 right: 50px; 10 right: 50px;
11 top: 50px; 11 top: 50px;
12 } 12 }
13 #target { 13 #target {
14 width: 10px; 14 width: 10px;
15 height: 10px; 15 height: 10px;
16 } 16 }
17 #frame { 17 #frame {
18 width: 100px; 18 width: 100px;
19 height: 100px; 19 height: 100px;
20 margin-top: 30px; 20 margin-top: 30px;
21 } 21 }
22 </style> 22 </style>
23 <div id=testArea> 23 <div id=testArea>
24 <div id=target></div> 24 <div id=target></div>
25 <iframe id=frame srcdoc='<iframe width=75 height=75></iframe>'></iframe> 25 <iframe id=frame srcdoc='<iframe width=75 height=75></iframe>'></iframe>
26 </div> 26 </div>
27 <script src="../../resources/js-test.js"></script> 27 <script src="../../resources/js-test.js"></script>
28 <script> 28 <script>
29 setPrintTestResultsLazily();
30 if (window.internals) { 29 if (window.internals) {
31 window.internals.settings.setViewportEnabled(true); 30 window.internals.settings.setViewportEnabled(true);
32 window.internals.settings.setMockScrollbarsEnabled(true); 31 window.internals.settings.setMockScrollbarsEnabled(true);
33 } 32 }
34 33
35 description("Count how many hit tests are required for various event scenarios. Hit tests can be expensive and it's often tempting to add more. These values s hould only ever be changed to go down, not up."); 34 description("Count how many hit tests are required for various event scenarios. Hit tests can be expensive and it's often tempting to add more. These values s hould only ever be changed to go down, not up.");
36 35
37 function hitTestCountDelta(doc) 36 function hitTestCountDelta(doc)
38 { 37 {
39 var lastCount = 0; 38 var lastCount = 0;
40 if ('lastHitTestCount' in doc) 39 if ('lastHitTestCount' in doc)
41 lastCount = doc.lastHitTestCount; 40 lastCount = doc.lastHitTestCount;
42 var newCount = internals.hitTestCount(doc); 41 var newCount = internals.hitTestCount(doc);
43 doc.lastHitTestCount = newCount; 42 doc.lastHitTestCount = newCount;
44 return newCount - lastCount; 43 return newCount - lastCount;
45 } 44 }
46 45
47 function hitTestCacheHitsDelta(doc)
48 {
49 var lastCount = 0;
50 if ('lastHitTestCacheHits' in doc)
51 lastCount = doc.lastHitTestCacheHits;
52 var newCount = internals.hitTestCacheHits(doc);
53 doc.lastHitTestCacheHits = newCount;
54 return newCount - lastCount;
55 }
56
57 function logCounts(label, documents, multiTapNotification, eventSenderFunction) 46 function logCounts(label, documents, multiTapNotification, eventSenderFunction)
58 { 47 {
59 if (eventSenderFunction) 48 if (eventSenderFunction)
60 eventSenderFunction(); 49 eventSenderFunction();
61 50
62 var countStr = ''; 51 var countStr = '';
63 for(var i = 0; i < documents.length; i++) { 52 for(var i = 0; i < documents.length; i++)
64 var hits = hitTestCountDelta(documents[i]); 53 countStr += ' ' + hitTestCountDelta(documents[i]);
65 var cacheHits = hitTestCacheHitsDelta(documents[i]);
66 countStr += ' ' + (hits - cacheHits) + "+" + cacheHits;
67 }
68 54
69 if (multiTapNotification) { 55 if (multiTapNotification) {
70 debug(label + ':' + eventCounts[label] 56 debug(label + ':' + eventCounts[label]
71 + ((countStr == eventCounts[label])? '': ' [with multiTargetTapNotificat ion:' + countStr + ']')); 57 + ((countStr == eventCounts[label])? '': ' [with multiTargetTapNotificat ion:' + countStr + ']'));
72 } else { 58 } else {
73 // store the count for later; to be compared when the 59 // store the count for later; to be compared when the
74 // multiTapNotification test is run. 60 // multiTapNotification test is run.
75 eventCounts[label] = countStr; 61 eventCounts[label] = countStr;
76 } 62 }
77 } 63 }
78 64
79 function clearCounts(documents) 65 function clearCounts(documents)
80 { 66 {
81 for(var i = 0; i < documents.length; i++) { 67 for(var i = 0; i < documents.length; i++)
82 documents[i].lastHitTestCount = internals.hitTestCount(documents[i]); 68 documents[i].lastHitTestCount = internals.hitTestCount(documents[i]);
83 documents[i].lastHitTestCacheHits = internals.hitTestCacheHits(documents [i]);
84 }
85 } 69 }
86 70
87 function sendEvents(targetX, targetY, documents, multiTapNotification) 71 function sendEvents(targetX, targetY, documents, multiTapNotification)
88 { 72 {
89 logCounts('Initial', documents, multiTapNotification); 73 logCounts('Initial', documents, multiTapNotification);
90 74
91 logCounts('MouseMove', documents, multiTapNotification, function() { 75 logCounts('MouseMove', documents, multiTapNotification, function() {
92 eventSender.mouseMoveTo(targetX, targetY); 76 eventSender.mouseMoveTo(targetX, targetY);
93 }); 77 });
94 78
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 130
147 logCounts('GestureScrollEnd', documents, multiTapNotification, function() { 131 logCounts('GestureScrollEnd', documents, multiTapNotification, function() {
148 eventSender.gestureScrollEnd(0, 5); 132 eventSender.gestureScrollEnd(0, 5);
149 }); 133 });
150 } 134 }
151 135
152 function runTestForDocuments(targetX, targetY, documents) 136 function runTestForDocuments(targetX, targetY, documents)
153 { 137 {
154 sendEvents(targetX, targetY, documents, false); 138 sendEvents(targetX, targetY, documents, false);
155 window.internals.settings.setMultiTargetTapNotificationEnabled(true); 139 window.internals.settings.setMultiTargetTapNotificationEnabled(true);
156 for(var i = 0; i < documents.length; i++) {
157 internals.clearHitTestCache(documents[i]);
158 }
159 sendEvents(targetX, targetY, documents, true); 140 sendEvents(targetX, targetY, documents, true);
160 window.internals.settings.setMultiTargetTapNotificationEnabled(false); 141 window.internals.settings.setMultiTargetTapNotificationEnabled(false);
161 } 142 }
162 143
163 function centerOf(element) { 144 function centerOf(element) {
164 var targetRect = element.getBoundingClientRect(); 145 var targetRect = element.getBoundingClientRect();
165 return { 146 return {
166 x: targetRect.left + targetRect.width / 2, 147 x: targetRect.left + targetRect.width / 2,
167 y: targetRect.top + targetRect.height / 2 148 y: targetRect.top + targetRect.height / 2
168 }; 149 };
(...skipping 24 matching lines...) Expand all
193 runTestForDocuments(rect.left + 3, rect.top + 3, [document, doc2, doc3]); 174 runTestForDocuments(rect.left + 3, rect.top + 3, [document, doc2, doc3]);
194 debug(''); 175 debug('');
195 176
196 window.internals.settings.setViewportEnabled(false); 177 window.internals.settings.setViewportEnabled(false);
197 debug('Event on a simple div (desktop viewport)'); 178 debug('Event on a simple div (desktop viewport)');
198 debug('---------------------'); 179 debug('---------------------');
199 var point = centerOf(document.getElementById('target')); 180 var point = centerOf(document.getElementById('target'));
200 runTestForDocuments(point.x, point.y, [document]); 181 runTestForDocuments(point.x, point.y, [document]);
201 debug(''); 182 debug('');
202 window.internals.settings.setViewportEnabled(true); 183 window.internals.settings.setViewportEnabled(true);
203 finishJSTest();
204 } 184 }
205 </script> 185 </script>
OLDNEW
« no previous file with comments | « LayoutTests/fast/events/hit-test-cache-expected.txt ('k') | LayoutTests/fast/events/hit-test-counts-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698