 Chromium Code Reviews
 Chromium Code Reviews Issue 1752833002:
  Implement Gesture event hit testing/forwarding for OOPIF.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@wjmCFTouch.v2
    
  
    Issue 1752833002:
  Implement Gesture event hit testing/forwarding for OOPIF.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@wjmCFTouch.v2| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" | 
| 6 | 6 | 
| 7 #include <stddef.h> | 7 #include <stddef.h> | 
| 8 #include <stdint.h> | 8 #include <stdint.h> | 
| 9 | 9 | 
| 10 #include <algorithm> | 10 #include <algorithm> | 
| 11 #include <vector> | 11 #include <vector> | 
| 12 | 12 | 
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" | 
| 14 #include "base/location.h" | 14 #include "base/location.h" | 
| 15 #include "base/macros.h" | 15 #include "base/macros.h" | 
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" | 
| 17 #include "base/strings/pattern.h" | 17 #include "base/strings/pattern.h" | 
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" | 
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" | 
| 20 #include "base/test/test_timeouts.h" | 20 #include "base/test/test_timeouts.h" | 
| 21 #include "base/thread_task_runner_handle.h" | 21 #include "base/thread_task_runner_handle.h" | 
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" | 
| 23 #include "content/browser/frame_host/cross_process_frame_connector.h" | 23 #include "content/browser/frame_host/cross_process_frame_connector.h" | 
| 24 #include "content/browser/frame_host/frame_tree.h" | 24 #include "content/browser/frame_host/frame_tree.h" | 
| 25 #include "content/browser/frame_host/navigator.h" | 25 #include "content/browser/frame_host/navigator.h" | 
| 26 #include "content/browser/frame_host/render_frame_proxy_host.h" | 26 #include "content/browser/frame_host/render_frame_proxy_host.h" | 
| 27 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 27 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 
| 28 #include "content/browser/gpu/compositor_util.h" | 28 #include "content/browser/gpu/compositor_util.h" | 
| 29 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" | |
| 29 #include "content/browser/renderer_host/render_view_host_impl.h" | 30 #include "content/browser/renderer_host/render_view_host_impl.h" | 
| 30 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 31 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 
| 31 #include "content/browser/web_contents/web_contents_impl.h" | 32 #include "content/browser/web_contents/web_contents_impl.h" | 
| 32 #include "content/common/frame_messages.h" | 33 #include "content/common/frame_messages.h" | 
| 34 #include "content/common/input/synthetic_tap_gesture_params.h" | |
| 33 #include "content/common/view_messages.h" | 35 #include "content/common/view_messages.h" | 
| 34 #include "content/public/browser/notification_observer.h" | 36 #include "content/public/browser/notification_observer.h" | 
| 35 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" | 
| 36 #include "content/public/browser/notification_types.h" | 38 #include "content/public/browser/notification_types.h" | 
| 37 #include "content/public/browser/resource_dispatcher_host.h" | 39 #include "content/public/browser/resource_dispatcher_host.h" | 
| 38 #include "content/public/common/browser_side_navigation_policy.h" | 40 #include "content/public/common/browser_side_navigation_policy.h" | 
| 39 #include "content/public/common/content_switches.h" | 41 #include "content/public/common/content_switches.h" | 
| 40 #include "content/public/test/browser_test_utils.h" | 42 #include "content/public/test/browser_test_utils.h" | 
| 41 #include "content/public/test/content_browser_test_utils.h" | 43 #include "content/public/test/content_browser_test_utils.h" | 
| 42 #include "content/public/test/test_navigation_observer.h" | 44 #include "content/public/test/test_navigation_observer.h" | 
| (...skipping 4427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4470 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); | 4472 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); | 
| 4471 rwhv->OnTouchEvent(&touch_event); | 4473 rwhv->OnTouchEvent(&touch_event); | 
| 4472 | 4474 | 
| 4473 // Verify touch handler in subframe was invoked | 4475 // Verify touch handler in subframe was invoked | 
| 4474 std::string result; | 4476 std::string result; | 
| 4475 EXPECT_TRUE(ExecuteScriptAndExtractString( | 4477 EXPECT_TRUE(ExecuteScriptAndExtractString( | 
| 4476 root->child_at(0)->current_frame_host(), | 4478 root->child_at(0)->current_frame_host(), | 
| 4477 "window.domAutomationController.send(getLastTouchEvent());", &result)); | 4479 "window.domAutomationController.send(getLastTouchEvent());", &result)); | 
| 4478 EXPECT_EQ("touchstart", result); | 4480 EXPECT_EQ("touchstart", result); | 
| 4479 } | 4481 } | 
| 4482 | |
| 4483 namespace { | |
| 4484 | |
| 4485 // Declared here to be close to the SubframeGestureEventRouting test. | |
| 4486 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner, | |
| 4487 SyntheticGesture::Result result) { | |
| 4488 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); | |
| 4489 runner->Quit(); | |
| 4490 } | |
| 4491 | |
| 4492 } // namespace anonymous | |
| 4493 | |
| 4494 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
| 4495 SubframeGestureEventRouting) { | |
| 4496 GURL main_url(embedded_test_server()->GetURL( | |
| 4497 "a.com", "/frame_tree/page_with_one_frame.html")); | |
| 4498 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | |
| 4499 | |
| 4500 WebContentsImpl* web_contents = | |
| 4501 static_cast<WebContentsImpl*>(shell()->web_contents()); | |
| 4502 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | |
| 4503 | |
| 4504 GURL frame_url( | |
| 4505 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html")); | |
| 4506 NavigateFrameToURL(root->child_at(0), frame_url); | |
| 4507 EXPECT_TRUE(WaitForRenderFrameReady(root->child_at(0)->current_frame_host())); | |
| 4508 | |
| 4509 // Synchronize with the child and parent renderers to guarantee that the | |
| 4510 // surface information required for event hit testing is ready. | |
| 4511 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( | |
| 4512 root->child_at(0)->current_frame_host()->GetView()); | |
| 4513 SurfaceHitTestReadyNotifier notifier( | |
| 4514 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv)); | |
| 4515 notifier.WaitForSurfaceReady(); | |
| 4516 | |
| 4517 // There have been no GestureTaps send yet. | |
| 
kenrb
2016/03/02 16:23:13
nit: s/send/sent
 | |
| 4518 { | |
| 4519 std::string result; | |
| 4520 EXPECT_TRUE(ExecuteScriptAndExtractString( | |
| 4521 root->child_at(0)->current_frame_host(), | |
| 4522 "window.domAutomationController.send(getClickStatus());", &result)); | |
| 4523 EXPECT_EQ("0 clicks received", result); | |
| 4524 } | |
| 4525 | |
| 4526 // Simulate touch sequence to send GestureTap to sub-frame. | |
| 4527 SyntheticTapGestureParams params; | |
| 4528 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | |
| 4529 gfx::Point center = child_rwhv->GetBoundsInRootWindow().CenterPoint(); | |
| 4530 params.position = gfx::PointF(center.x(), center.y()); | |
| 4531 params.duration_ms = 100; | |
| 4532 scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); | |
| 4533 | |
| 4534 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner(); | |
| 4535 | |
| 4536 RenderWidgetHostImpl* render_widget_host = | |
| 4537 root->current_frame_host()->GetRenderWidgetHost(); | |
| 4538 //TODO(wjmaclean): Convert the call to base::Bind() to a lambda someday. | |
| 4539 render_widget_host->QueueSyntheticGesture( | |
| 4540 std::move(gesture), base::Bind(OnSyntheticGestureCompleted, runner)); | |
| 4541 | |
| 4542 runner->Run(); | |
| 4543 runner = nullptr; | |
| 4544 | |
| 4545 // Verify click handler in subframe was invoked | |
| 4546 { | |
| 4547 std::string result; | |
| 4548 EXPECT_TRUE(ExecuteScriptAndExtractString( | |
| 4549 root->child_at(0)->current_frame_host(), | |
| 4550 "window.domAutomationController.send(getClickStatus());", &result)); | |
| 4551 EXPECT_EQ("1 clicks received", result); | |
| 4552 } | |
| 4553 } | |
| 4480 #endif // defined(USE_AURA) | 4554 #endif // defined(USE_AURA) | 
| 4481 | 4555 | 
| 4482 // Ensure that a cross-process subframe can receive keyboard events when in | 4556 // Ensure that a cross-process subframe can receive keyboard events when in | 
| 4483 // focus. | 4557 // focus. | 
| 4484 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 4558 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 
| 4485 SubframeKeyboardEventRouting) { | 4559 SubframeKeyboardEventRouting) { | 
| 4486 GURL main_url(embedded_test_server()->GetURL( | 4560 GURL main_url(embedded_test_server()->GetURL( | 
| 4487 "a.com", "/frame_tree/page_with_one_frame.html")); | 4561 "a.com", "/frame_tree/page_with_one_frame.html")); | 
| 4488 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 4562 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 
| 4489 | 4563 | 
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5397 | 5471 | 
| 5398 // Force the renderer to generate a new frame. | 5472 // Force the renderer to generate a new frame. | 
| 5399 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), | 5473 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), | 
| 5400 "document.body.style.background = 'black'")); | 5474 "document.body.style.background = 'black'")); | 
| 5401 | 5475 | 
| 5402 // Waits for the next frame. | 5476 // Waits for the next frame. | 
| 5403 observer->Wait(); | 5477 observer->Wait(); | 
| 5404 } | 5478 } | 
| 5405 | 5479 | 
| 5406 } // namespace content | 5480 } // namespace content | 
| OLD | NEW |