Commit 59dc4be5 authored by sahel's avatar sahel Committed by Commit bot

Drop-down closes via tap/touch again.

The drop-down list closes on a GestureTapDown, and the next GestureTap
cannot open the same list. The regression was because of the following
cl: https://codereview.chromium.org/2517253002/

BUG=670185, 569092
Test=LayoutTests/fast/forms/select-popup/popup-menu-touch-operations.html

Review-Url: https://codereview.chromium.org/2558113002
Cr-Commit-Position: refs/heads/master@{#437650}
parent 841a6a86
...@@ -21,6 +21,12 @@ PASS window.internals.pagePopupWindow is not null ...@@ -21,6 +21,12 @@ PASS window.internals.pagePopupWindow is not null
PASS menuElement2.value is "2" PASS menuElement2.value is "2"
==> Test popup closes on outside GestureTapDawn ==> Test popup closes on outside GestureTapDawn
PASS window.internals.pagePopupWindow is null PASS window.internals.pagePopupWindow is null
==> Test popup doesn't reopen immediately after closing
PASS window.internals.pagePopupWindow is null
PASS window.internals.pagePopupWindow is null
PASS window.internals.pagePopupWindow is not null
PASS window.internals.pagePopupWindow is null
PASS window.internals.pagePopupWindow is null
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -155,13 +155,35 @@ function test3() { ...@@ -155,13 +155,35 @@ function test3() {
openPicker(menuElement, function () { openPicker(menuElement, function () {
eventSender.gestureTapDown(300, 300); eventSender.gestureTapDown(300, 300);
shouldBeNull('window.internals.pagePopupWindow'); shouldBeNull('window.internals.pagePopupWindow');
finishJSTest(); test4();
}, function () { }, function () {
testFailed('picker didn\'t open') testFailed('picker didn\'t open')
finishJSTest(); finishJSTest();
}); });
} }
function test4() {
debug("==> Test popup doesn't reopen immediately after closing");
eventSender.clearTouchPoints();
shouldBeNull('window.internals.pagePopupWindow');
// Open the popup with a GestureTap.
var position = elementCenterPosition(menuElement);
eventSender.gestureTapDown(position[0], position[1]);
shouldBeNull('window.internals.pagePopupWindow');
eventSender.gestureTap(position[0], position[1]);
shouldNotBe('window.internals.pagePopupWindow', 'null');
// GestureTapDown on an open popup closes it.
eventSender.gestureTapDown(position[0], position[1]);
shouldBeNull('window.internals.pagePopupWindow');
// The next GestureTap on the recently closed popup shouldn't open it.
eventSender.gestureTap(position[0], position[1]);
shouldBeNull('window.internals.pagePopupWindow');
finishJSTest();
}
</script> </script>
</body> </body>
......
...@@ -816,13 +816,6 @@ WebInputEventResult WebViewImpl::handleGestureEvent( ...@@ -816,13 +816,6 @@ WebInputEventResult WebViewImpl::handleGestureEvent(
switch (event.type) { switch (event.type) {
case WebInputEvent::GestureTap: { case WebInputEvent::GestureTap: {
// If there is a popup open, close it as the user is clicking on the page
// (outside of the popup). We also save it so we can prevent a tap on an
// element from immediately reopening the same popup.
RefPtr<WebPagePopupImpl> pagePopup = m_pagePopup;
hidePopups();
DCHECK(!m_pagePopup);
m_client->cancelScheduledContentIntents(); m_client->cancelScheduledContentIntents();
if (detectContentOnTouch(targetedEvent)) { if (detectContentOnTouch(targetedEvent)) {
eventResult = WebInputEventResult::HandledSystem; eventResult = WebInputEventResult::HandledSystem;
...@@ -874,13 +867,13 @@ WebInputEventResult WebViewImpl::handleGestureEvent( ...@@ -874,13 +867,13 @@ WebInputEventResult WebViewImpl::handleGestureEvent(
eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent( eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(
targetedEvent); targetedEvent);
if (m_pagePopup && m_lastHiddenPagePopup &&
if (m_pagePopup && pagePopup && m_pagePopup->hasSamePopupClient(m_lastHiddenPagePopup.get())) {
m_pagePopup->hasSamePopupClient(pagePopup.get())) {
// The tap triggered a page popup that is the same as the one we just // The tap triggered a page popup that is the same as the one we just
// closed. It needs to be closed. // closed. It needs to be closed.
cancelPagePopup(); cancelPagePopup();
} }
m_lastHiddenPagePopup = nullptr;
break; break;
} }
case WebInputEvent::GestureTwoFingerTap: case WebInputEvent::GestureTwoFingerTap:
...@@ -900,21 +893,38 @@ WebInputEventResult WebViewImpl::handleGestureEvent( ...@@ -900,21 +893,38 @@ WebInputEventResult WebViewImpl::handleGestureEvent(
break; break;
} }
case WebInputEvent::GestureShowPress: case WebInputEvent::GestureTapDown: {
m_client->cancelScheduledContentIntents(); // Touch pinch zoom and scroll on the page (outside of a popup) must hide
case WebInputEvent::GestureTapDown: // the popup. In case of a touch scroll or pinch zoom, this function is
// Touch pinch zoom and scroll must hide the popup. In case of a touch // called with GestureTapDown rather than a GSB/GSU/GSE or GPB/GPU/GPE.
// scroll or pinch zoom, this function is called with GestureTapDown // When we close a popup because of a GestureTapDown, we also save it so
// rather than a GSB/GSU/GSE or GPB/GPU/GPE. // we can prevent the following GestureTap from immediately reopening the
// same popup.
m_lastHiddenPagePopup = m_pagePopup;
hidePopups(); hidePopups();
case WebInputEvent::GestureTapCancel: DCHECK(!m_pagePopup);
eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(
targetedEvent);
break;
}
case WebInputEvent::GestureTapCancel: {
m_lastHiddenPagePopup = nullptr;
eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(
targetedEvent);
break;
}
case WebInputEvent::GestureShowPress: {
m_client->cancelScheduledContentIntents();
eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(
targetedEvent);
break;
}
case WebInputEvent::GestureTapUnconfirmed: { case WebInputEvent::GestureTapUnconfirmed: {
eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent( eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(
targetedEvent); targetedEvent);
break; break;
} }
default: default: { NOTREACHED(); }
NOTREACHED();
} }
m_client->didHandleGestureEvent(event, eventCancelled); m_client->didHandleGestureEvent(event, eventCancelled);
return eventResult; return eventResult;
......
...@@ -667,6 +667,11 @@ class WEB_EXPORT WebViewImpl final ...@@ -667,6 +667,11 @@ class WEB_EXPORT WebViewImpl final
// The popup associated with an input/select element. // The popup associated with an input/select element.
RefPtr<WebPagePopupImpl> m_pagePopup; RefPtr<WebPagePopupImpl> m_pagePopup;
// This stores the last hidden page popup. If a GestureTap attempts to open
// the popup that is closed by its previous GestureTapDown, the popup remains
// closed.
RefPtr<WebPagePopupImpl> m_lastHiddenPagePopup;
Persistent<DevToolsEmulator> m_devToolsEmulator; Persistent<DevToolsEmulator> m_devToolsEmulator;
std::unique_ptr<PageOverlay> m_pageColorOverlay; std::unique_ptr<PageOverlay> m_pageColorOverlay;
......
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