From f5ab9e91229d12ffc1f8ca1dab1f87730098c9d1 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Wed, 4 Nov 2020 03:16:17 +0000 Subject: [PATCH] Bug 1663000 - Handle the event as if it's consumed in the root APZC in InputQueue::ReceiveTouchInput() if there's contents covered by the dynamic toolbar. r=geckoview-reviewers,botond,snorp Differential Revision: https://phabricator.services.mozilla.com/D93917 --- gfx/layers/apz/src/AsyncPanZoomController.cpp | 11 +++-- gfx/layers/apz/src/InputQueue.cpp | 5 ++ .../geckoview/test/PanZoomControllerTest.kt | 47 +++++++++---------- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index ab7fcd72f6f0..2adff0bd62f3 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -856,9 +856,14 @@ bool AsyncPanZoomController::ArePointerEventsConsumable( bool pannableX = aBlock->TouchActionAllowsPanningX() && aBlock->GetOverscrollHandoffChain()->CanScrollInDirection( this, ScrollDirection::eHorizontal); - bool pannableY = aBlock->TouchActionAllowsPanningY() && - aBlock->GetOverscrollHandoffChain()->CanScrollInDirection( - this, ScrollDirection::eVertical); + bool pannableY = + (aBlock->TouchActionAllowsPanningY() && + (aBlock->GetOverscrollHandoffChain()->CanScrollInDirection( + this, ScrollDirection::eVertical) || + // In the case of the root APZC with any dynamic toolbar, it + // shoule be pannable if there is room moving the dynamic + // toolbar. + (IsRootContent() && CanScrollDownwardsWithDynamicToolbar()))); bool pannable; diff --git a/gfx/layers/apz/src/InputQueue.cpp b/gfx/layers/apz/src/InputQueue.cpp index 9edffb793a82..3e79c9bd13da 100644 --- a/gfx/layers/apz/src/InputQueue.cpp +++ b/gfx/layers/apz/src/InputQueue.cpp @@ -178,6 +178,11 @@ nsEventStatus InputQueue::ReceiveTouchInput( INPQ_LOG("dropping event due to block %p being in slop\n", block); result = nsEventStatus_eConsumeNoDefault; } else { + // FIXME: Even if the event is consumed in a non-root APZC, if scroll + // positions in all relevant APZCs are at the bottom edge and if there are + // contents covered by the dynamic toolbar, we need to handle the event as + // if it's consumed in the root APZC so that GeckoView can tel the + // dynamic toolbar needs to move. result = nsEventStatus_eConsumeDoDefault; } } else if (block->UpdateSlopState(aEvent, false)) { diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PanZoomControllerTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PanZoomControllerTest.kt index 6bec0bd5beca..99411e2fb75f 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PanZoomControllerTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PanZoomControllerTest.kt @@ -354,34 +354,31 @@ class PanZoomControllerTest : BaseSessionTest() { assertThat("The input result should be HANDLED_CONTENT in iframe_100_percent_height_scrollable.html", value, equalTo(PanZoomController.INPUT_RESULT_HANDLED_CONTENT)) - // Below cases don't work yet without event handlers - if (withEventHandler) { - // The content height is greater than "screen height - the dynamic toolbar height". - setupTouchEventDocument(ROOT_98VH_HTML_PATH, withEventHandler) - value = sessionRule.waitForResult(sendDownEvent(50f, 50f)) - assertThat("The input result should be HANDLED in root_98vh.html", - value, equalTo(PanZoomController.INPUT_RESULT_HANDLED)) + // The content height is greater than "screen height - the dynamic toolbar height". + setupTouchEventDocument(ROOT_98VH_HTML_PATH, withEventHandler) + value = sessionRule.waitForResult(sendDownEvent(50f, 50f)) + assertThat("The input result should be HANDLED in root_98vh.html", + value, equalTo(PanZoomController.INPUT_RESULT_HANDLED)) - // The content height is equal to "screen height". - setupTouchEventDocument(ROOT_100VH_HTML_PATH, withEventHandler) - value = sessionRule.waitForResult(sendDownEvent(50f, 50f)) - assertThat("The input result should be HANDLED in root_100vh.html", - value, equalTo(PanZoomController.INPUT_RESULT_HANDLED)) + // The content height is equal to "screen height". + setupTouchEventDocument(ROOT_100VH_HTML_PATH, withEventHandler) + value = sessionRule.waitForResult(sendDownEvent(50f, 50f)) + assertThat("The input result should be HANDLED in root_100vh.html", + value, equalTo(PanZoomController.INPUT_RESULT_HANDLED)) - // There is a 98vh iframe which is not scrollable. - setupTouchEventDocument(IFRAME_98VH_NO_SCROLLABLE_HTML_PATH, withEventHandler) - value = sessionRule.waitForResult(sendDownEvent(50f, 50f)) - // The input result should NOT be handled in the iframe content. - assertThat("The input result should be HANDLED in iframe_98vh_no_scrollable.html", - value, equalTo(PanZoomController.INPUT_RESULT_HANDLED)) + // There is a 98vh iframe which is not scrollable. + setupTouchEventDocument(IFRAME_98VH_NO_SCROLLABLE_HTML_PATH, withEventHandler) + value = sessionRule.waitForResult(sendDownEvent(50f, 50f)) + // The input result should NOT be handled in the iframe content. + assertThat("The input result should be HANDLED in iframe_98vh_no_scrollable.html", + value, equalTo(PanZoomController.INPUT_RESULT_HANDLED)) - // There is a 98vh iframe which is scrollable. - setupTouchEventDocument(IFRAME_98VH_SCROLLABLE_HTML_PATH, withEventHandler) - value = sessionRule.waitForResult(sendDownEvent(50f, 50f)) - // The input result should be handled in the iframe content initially. - assertThat("The input result should be HANDLED_CONTENT initially in iframe_98vh_scrollable.html", - value, equalTo(PanZoomController.INPUT_RESULT_HANDLED_CONTENT)) - } + // There is a 98vh iframe which is scrollable. + setupTouchEventDocument(IFRAME_98VH_SCROLLABLE_HTML_PATH, withEventHandler) + value = sessionRule.waitForResult(sendDownEvent(50f, 50f)) + // The input result should be handled in the iframe content initially. + assertThat("The input result should be HANDLED_CONTENT initially in iframe_98vh_scrollable.html", + value, equalTo(PanZoomController.INPUT_RESULT_HANDLED_CONTENT)) // The following test doesn't work either with/without event handlers. if (false) {