Commit 9b46ae85 authored by jochen@chromium.org's avatar jochen@chromium.org

Share a user gesture indicator across touch event sequences

BUG=379271
R=rbyers@chromium.org

Review URL: https://codereview.chromium.org/329393006

git-svn-id: svn://svn.chromium.org/blink/trunk@176059 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 116871b1
Test that only a single popup is allowed in response to a single touch sequence. The test passes if only one popup is created when you touch and move around on this page.
touchstart event
touchstart event
touchmove event
touchmove event
touchend event
<!DOCTYPE html>
<html>
<body>
<p>
Test that only a single popup is allowed in response to a single
touch sequence. The test passes if only one popup is created when
you touch and move around on this page.
</p>
<div id="console"></div>
<script>
function log(msg)
{
document.querySelector("#console").innerHTML += msg + "<br>";
}
function popup()
{
window.open("about:blank");
if (window.testRunner) {
if (testRunner.windowCount() > windowCount + 1)
log("FAIL: too many popups");
else if (testRunner.windowCount() == windowCount)
log("FAIL: could not open popup at all");
}
}
function touchStart(e)
{
log("touchstart event");
e.preventDefault();
popup();
}
function touchMove(e)
{
log("touchmove event");
e.preventDefault();
popup();
}
function touchEnd(e)
{
log("touchend event");
e.preventDefault();
popup();
if (window.testRunner)
testRunner.notifyDone();
}
document.addEventListener("touchstart", touchStart);
document.addEventListener("touchmove", touchMove);
document.addEventListener("touchend", touchEnd);
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.setCanOpenWindows();
testRunner.setPopupBlockingEnabled(true);
testRunner.setCloseRemainingWindowsWhenComplete(true);
testRunner.waitUntilDone();
gc();
windowCount = testRunner.windowCount();
if (window.eventSender) {
eventSender.clearTouchPoints();
eventSender.addTouchPoint(50, 50);
eventSender.touchStart();
eventSender.addTouchPoint(75, 50);
eventSender.touchStart();
eventSender.updateTouchPoint(0, 100, 100);
eventSender.updateTouchPoint(1, 125, 100);
eventSender.touchMove();
eventSender.updateTouchPoint(0, 100, 50);
eventSender.updateTouchPoint(1, 200, 50);
eventSender.touchMove();
eventSender.releaseTouchPoint(0);
eventSender.releaseTouchPoint(1);
eventSender.touchEnd();
}
}
</script>
</body>
</html>
...@@ -295,6 +295,7 @@ void EventHandler::clear() ...@@ -295,6 +295,7 @@ void EventHandler::clear()
m_previousWheelScrolledNode = nullptr; m_previousWheelScrolledNode = nullptr;
m_targetForTouchID.clear(); m_targetForTouchID.clear();
m_touchSequenceDocument.clear(); m_touchSequenceDocument.clear();
m_touchSequenceUserGestureToken.clear();
m_scrollGestureHandlingNode = nullptr; m_scrollGestureHandlingNode = nullptr;
m_lastHitTestResultOverWidget = false; m_lastHitTestResultOverWidget = false;
m_previousGestureScrolledNode = nullptr; m_previousGestureScrolledNode = nullptr;
...@@ -3403,8 +3404,6 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) ...@@ -3403,8 +3404,6 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
const Vector<PlatformTouchPoint>& points = event.touchPoints(); const Vector<PlatformTouchPoint>& points = event.touchPoints();
UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
unsigned i; unsigned i;
bool freshTouchEvents = true; bool freshTouchEvents = true;
bool allTouchReleased = true; bool allTouchReleased = true;
...@@ -3422,8 +3421,18 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) ...@@ -3422,8 +3421,18 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
// there may be cases where the browser doesn't reliably release all // there may be cases where the browser doesn't reliably release all
// touches. http://crbug.com/345372 tracks this. // touches. http://crbug.com/345372 tracks this.
m_touchSequenceDocument.clear(); m_touchSequenceDocument.clear();
m_touchSequenceUserGestureToken.clear();
} }
OwnPtr<UserGestureIndicator> gestureIndicator;
if (m_touchSequenceUserGestureToken)
gestureIndicator = adoptPtr(new UserGestureIndicator(m_touchSequenceUserGestureToken.release()));
else
gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessingUserGesture));
m_touchSequenceUserGestureToken = gestureIndicator->currentToken();
ASSERT(m_frame->view()); ASSERT(m_frame->view());
if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touchSequenceDocument->frame()->view())) { if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touchSequenceDocument->frame()->view())) {
// If the active touch document has no frame or view, it's probably being destroyed // If the active touch document has no frame or view, it's probably being destroyed
...@@ -3486,8 +3495,10 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) ...@@ -3486,8 +3495,10 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
// document set to receive the events, then we can skip all the rest of // document set to receive the events, then we can skip all the rest of
// this work. // this work.
if (!m_touchSequenceDocument || !m_touchSequenceDocument->hasTouchEventHandlers() || !m_touchSequenceDocument->frame()) { if (!m_touchSequenceDocument || !m_touchSequenceDocument->hasTouchEventHandlers() || !m_touchSequenceDocument->frame()) {
if (allTouchReleased) if (allTouchReleased) {
m_touchSequenceDocument.clear(); m_touchSequenceDocument.clear();
m_touchSequenceUserGestureToken.clear();
}
return false; return false;
} }
...@@ -3601,8 +3612,10 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) ...@@ -3601,8 +3612,10 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
changedTouches[pointState].m_targets.add(touchTarget); changedTouches[pointState].m_targets.add(touchTarget);
} }
} }
if (allTouchReleased) if (allTouchReleased) {
m_touchSequenceDocument.clear(); m_touchSequenceDocument.clear();
m_touchSequenceUserGestureToken.clear();
}
// Now iterate the changedTouches list and m_targets within it, sending // Now iterate the changedTouches list and m_targets within it, sending
// events to the targets as required. // events to the targets as required.
......
...@@ -373,6 +373,7 @@ private: ...@@ -373,6 +373,7 @@ private:
// If set, the document of the active touch sequence. Unset if no touch sequence active. // If set, the document of the active touch sequence. Unset if no touch sequence active.
RefPtrWillBeMember<Document> m_touchSequenceDocument; RefPtrWillBeMember<Document> m_touchSequenceDocument;
RefPtr<UserGestureToken> m_touchSequenceUserGestureToken;
bool m_touchPressed; bool m_touchPressed;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment