Skip to content

Commit

Permalink
Use gpuBenchmarking.smoothScrollByXY for wheel scroll in event-dispat…
Browse files Browse the repository at this point in the history
…ching.js

In dom/shadow/resources/event-dispatching.js, there is a function that
simulates mouse wheel scroll, it used eventSender.mouseScrollBy, now we
change to use wheelTick which uses gpuBenchmarking.smoothScrollByXY,
this will simulate wheel scroll from compositor.

Bug: 1047176
Change-Id: Ic4aa5cd4b5d4ba97c99e7ea340c5760f4204f81d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2181228
Reviewed-by: David Bokan <bokan@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#787366}
  • Loading branch information
LanWei22 authored and Commit Bot committed Jul 10, 2020
1 parent f1bc441 commit 99cd974
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 64 deletions.
Expand Up @@ -46,15 +46,6 @@ function dragMouse(node)
eventSender.mouseMoveTo(x, y);
}

function scrollMouseWheel(node)
{
var rect = node.getBoundingClientRect();
var x = rect.left + 5;
var y = rect.top + defaultPaddingSize + 5;
eventSender.mouseMoveTo(x, y);
eventSender.mouseScrollBy(0, 120);
}

var eventRecords = {};

function clearEventRecords()
Expand Down
Expand Up @@ -2,42 +2,49 @@
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../../../resources/gesture-util.js"></script>
<script src="resources/shadow-dom.js"></script>
<script src="resources/event-dispatching.js"></script>
</head>
<body>
<body onload="runTest();">
<p id="description"></p>
<div id="sandbox"></div>
<pre id="console"></pre>
<script>
var sandbox = document.getElementById('sandbox');
jsTestIsAsync = true;

sandbox.appendChild(
createDOM('div', {'id': 'top'},
createDOM('div', {'id': 'shadow-host'},
createShadowRoot({'id': 'shadow-root'}))));
var shadowRoot = getNodeInComposedTree('shadow-host/');
shadowRoot.innerHTML = 'Text Nodes';
addEventListeners(['top', 'shadow-host', 'shadow-host/']);
showSandboxTree();
async function runTest() {
var sandbox = document.getElementById('sandbox');

// Calculates the position of the text node in the shadow root.
var host = document.getElementById('shadow-host');
var x = host.offsetLeft + 5;
var y = host.offsetTop + defaultPaddingSize + 5;
debug('\n' + 'Moving mouse from a direct child text node of the shadow root to top');
eventSender.mouseMoveTo(x, y);
clearEventRecords();
sandbox.appendChild(
createDOM('div', {'id': 'top'},
createDOM('div', {'id': 'shadow-host'},
attachShadow({mode: 'open', 'id': 'shadow-root'}))));
var shadowRoot = getNodeInComposedTree('shadow-host/');
shadowRoot.innerHTML = 'Text Nodes';
addEventListeners(['top', 'shadow-host', 'shadow-host/']);
showSandboxTree();

moveMouseOver(document.getElementById('top'));
debugDispatchedEvent('mouseout');
debugDispatchedEvent('mouseover');
// Calculates the position of the text node in the shadow root.
var host = document.getElementById('shadow-host');
var x = host.offsetLeft + 5;
var y = host.offsetTop + defaultPaddingSize + 5;
debug('\n' + 'Moving mouse from a direct child text node of the shadow root to top');
eventSender.mouseMoveTo(x, y);
clearEventRecords();

touchLocation(host);
debugDispatchedEvent('touchstart');
moveMouseOver(document.getElementById('top'));
debugDispatchedEvent('mouseout');
debugDispatchedEvent('mouseover');

scrollMouseWheel(host);
debugDispatchedEvent('mousewheel');
touchLocation(host);
debugDispatchedEvent('touchstart');

var host_center = elementCenter(host);
await wheelTick(0, 1, host_center);
debugDispatchedEvent('mousewheel');
finishJSTest();
}
</script>
</body>
</html>
Expand Up @@ -46,15 +46,6 @@ function dragMouse(node)
eventSender.mouseMoveTo(x, y);
}

function scrollMouseWheel(node)
{
var rect = node.getBoundingClientRect();
var x = rect.left + 5;
var y = rect.top + defaultPaddingSize + 5;
eventSender.mouseMoveTo(x, y);
eventSender.mouseScrollBy(0, 120);
}

var eventRecords = {};

function clearEventRecords()
Expand Down
Expand Up @@ -2,46 +2,53 @@
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../../../resources/gesture-util.js"></script>
<script src="resources/shadow-dom.js"></script>
<script src="resources/event-dispatching.js"></script>
</head>
<body>
<body onload="runTest();">
<p id="description"></p>
<div id="sandbox"></div>
<pre id="console"></pre>
<script>
var sandbox = document.getElementById('sandbox');
jsTestIsAsync = true;

// Makes sure the parent of the insertion point can receive an event when a distributed text node is clicked.
sandbox.appendChild(
async function runTest() {
var sandbox = document.getElementById('sandbox');

// Makes sure the parent of the insertion point can receive an event when a distributed text node is clicked.
sandbox.appendChild(
createDOM('div', {'id': 'top'},
createDOM('div', {'id': 'shadow-host'},
createShadowRoot({'id': 'shadow-root'},
createDOM('div', {'id': 'content-parent'},
createDOM('content', {'id': 'content'}))),
document.createTextNode('Text Node'))));
addEventListeners(['top', 'shadow-host', 'shadow-host/', 'shadow-host/content-parent', 'shadow-host/content']);
showSandboxTree();
addEventListeners(['top', 'shadow-host', 'shadow-host/', 'shadow-host/content-parent', 'shadow-host/content']);
showSandboxTree();

// Calculates the position of the text node.
var host = document.getElementById('shadow-host');
var x = host.offsetLeft + 5;
var y = host.offsetTop + defaultPaddingSize + 5;
debug('\n' + 'Moving mouse from a distributed text node to top');
eventSender.mouseMoveTo(x, y);
clearEventRecords();
// Calculates the position of the text node.
var host = document.getElementById('shadow-host');
var x = host.offsetLeft + 5;
var y = host.offsetTop + defaultPaddingSize + 5;
debug('\n' + 'Moving mouse from a distributed text node to top');
eventSender.mouseMoveTo(x, y);
clearEventRecords();

moveMouseOver(document.getElementById('top'));
debugDispatchedEvent('mouseout');
debugDispatchedEvent('mouseover');
moveMouseOver(document.getElementById('top'));
debugDispatchedEvent('mouseout');
debugDispatchedEvent('mouseover');

clearEventRecords();
scrollMouseWheel(host);
debugDispatchedEvent('mousewheel');
clearEventRecords();
var host_center = elementCenter(host);
await wheelTick(0, 1, host_center);
debugDispatchedEvent('mousewheel');

clearEventRecords();
touchLocation(host);
debugDispatchedEvent('touchstart');
clearEventRecords();
touchLocation(host);
debugDispatchedEvent('touchstart');
finishJSTest();
}
</script>
</body>
</html>

0 comments on commit 99cd974

Please sign in to comment.