Prevent speculative RWHVAs from handling input meant for existing views
Currently, when we create a RenderWidgetHostViewAndroid, we attach
its corresponding native view to the hierarchy. However, RWHVAs
may be created for a speculative RenderFrameHost for a cross-site
navigation, and would not replace the old RWHVA until the navigation
commits. This gives us two RWHVAs in the hierarchy. In this state,
input events are targeted to the speculative RWHVA.
Moreover, if the cross-site navigation is canceled before it commits,
then we stay in this state where input events are sent to the unused
RWHVA, causing the page to be seemingly unresponsive to input.
We now move new RWHVAs behind any existing ones in the view hierarchy.
Bug: 867932
Change-Id: I845d99ecbde7f721f6fa4b6e1b0243abb89a97fc
Reviewed-on: https://chromium-review.googlesource.com/1165482
Reviewed-by: Bo <[email protected]>
Commit-Queue: Kevin McNee <[email protected]>
Cr-Commit-Position: refs/heads/master@{#582206}
diff --git a/ui/android/view_android_unittests.cc b/ui/android/view_android_unittests.cc
index 71c758d..2a72742 100644
--- a/ui/android/view_android_unittests.cc
+++ b/ui/android/view_android_unittests.cc
@@ -118,6 +118,11 @@
root_.MoveToFront(&view2_);
GenerateTouchEventAt(100.f, 100.f);
ExpectHit(handler2_);
+
+ // View 2 moves back to the bottom, and events should hit View 1 again.
+ root_.MoveToBack(&view2_);
+ GenerateTouchEventAt(100.f, 100.f);
+ ExpectHit(handler1_);
}
TEST_F(ViewAndroidBoundsTest, MatchesViewArea) {