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

Unified Diff: LayoutTests/fast/events/hit-test-cache.html

Issue 1142283004: Implement a Hit Test Cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix git cl format mangling Created 5 years, 7 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: LayoutTests/fast/events/hit-test-cache.html
diff --git a/LayoutTests/fast/events/hit-test-cache.html b/LayoutTests/fast/events/hit-test-cache.html
new file mode 100644
index 0000000000000000000000000000000000000000..e98d2a5ea3ff3f72465eeb890770e2a77e7cd659
--- /dev/null
+++ b/LayoutTests/fast/events/hit-test-cache.html
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+html {
+ font-family: Ahem;
+ font-size: 10px;
+}
+#testArea {
+ height: 6000px;
+ width: 500px;
+ background: red;
+}
+#target {
+ position: fixed;
+ left: 10px;
+ top: 10px;
+ width: 40px;
+ height: 40px;
+ background: yellow;
+}
+</style>
+<div id=testArea>
+ <div id=target></div>
+</div>
+<p id="description"></p>
+<div id="console"></div>
+<script src="../../resources/js-test.js"></script>
+<script>
+if (window.internals) {
+ window.internals.settings.setViewportEnabled(true);
+ window.internals.settings.setMockScrollbarsEnabled(true);
+}
+
+description("Ensure hit test cache works in correct scenarios of scrolling, dom and style changes.");
+
+function hitTestCountDelta()
+{
+ var lastCount = 0;
+ if ('lastHitTestCount' in document)
+ lastCount = document.lastHitTestCount;
+ var newCount = internals.hitTestCount(document);
+ document.lastHitTestCount = newCount;
+ return newCount - lastCount;
+}
+
+function hitTestCacheHitsDelta()
+{
+ var lastCount = 0;
+ if ('lastHitTestCacheHits' in document)
+ lastCount = document.lastHitTestCacheHits;
+ var newCount = internals.hitTestCacheHits(document);
+ document.lastHitTestCacheHits = newCount;
+ return newCount - lastCount;
+}
+
+function clearCounts()
+{
+ document.lastHitTestCount = internals.hitTestCount(document);
+ document.lastHitTestCacheHits = internals.hitTestCacheHits(document);
+}
+
+function reportElementAt(x, y)
+{
+ var element = document.elementFromPoint(x, y);
+ debug("Element is " + element.nodeName + ", " + element.id);
+ element = internals.elementFromPointNoCache(document, x, y);
+ debug("Element (no cache) is " + element.nodeName + ", " + element.id);
+ debug("Hit Test " + hitTestCountDelta() + "/" + hitTestCacheHitsDelta());
+}
+
+onload = function() {
+ clearCounts();
+ debug('Hit test fixed div after scroll');
Rick Byers 2015/06/05 20:48:58 please add at least one simple test case where the
dtapuska 2015/06/09 18:21:23 Done.
+ debug('---------------------');
+
+ reportElementAt(12, 12);
+ reportElementAt(10, 60);
+ window.scrollTo(0, 50);
+ reportElementAt(12, 12);
+
Rick Byers 2015/06/05 20:48:59 nit: debug('') here to make the output more readab
dtapuska 2015/06/09 18:21:23 Done.
+ debug('Hit test after style change');
+ debug('---------------------');
+ reportElementAt(12, 12);
+ document.getElementById('target').style.background = "blue";
+ reportElementAt(12, 12);
Rick Byers 2015/06/05 20:48:58 I'd prefer if the test code indicated what the exp
dtapuska 2015/06/09 18:21:23 Done.
+}
+</script>
« no previous file with comments | « no previous file | LayoutTests/fast/events/hit-test-cache-expected.txt » ('j') | LayoutTests/fast/events/hit-test-counts.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698