Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 1926173002: Erase LinkDisambiguation code on desktop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix include Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 1273
1274 gfx::NativeViewAccessible 1274 gfx::NativeViewAccessible
1275 RenderWidgetHostViewAura::AccessibilityGetNativeViewAccessible() { 1275 RenderWidgetHostViewAura::AccessibilityGetNativeViewAccessible() {
1276 #if defined(OS_WIN) 1276 #if defined(OS_WIN)
1277 if (legacy_render_widget_host_HWND_) 1277 if (legacy_render_widget_host_HWND_)
1278 return legacy_render_widget_host_HWND_->window_accessible(); 1278 return legacy_render_widget_host_HWND_->window_accessible();
1279 #endif 1279 #endif
1280 return NULL; 1280 return NULL;
1281 } 1281 }
1282 1282
1283 void RenderWidgetHostViewAura::ShowDisambiguationPopup(
1284 const gfx::Rect& rect_pixels,
1285 const SkBitmap& zoomed_bitmap) {
1286 RenderViewHost* rvh = RenderViewHost::From(host_);
1287 if (rvh) {
1288 RenderViewHostDelegate* delegate = rvh->GetDelegate();
1289 // Suppress the link disambiguation popup if the virtual keyboard is
1290 // currently requested, as it doesn't interact well with the keyboard.
1291 if (delegate && delegate->IsVirtualKeyboardRequested())
1292 return;
1293 }
1294
1295 // |target_rect| is provided in pixels, not DIPs. So we convert it to DIPs
1296 // by scaling it by the inverse of the device scale factor.
1297 gfx::RectF screen_target_rect_f(rect_pixels);
1298 screen_target_rect_f.Scale(1.0f / current_device_scale_factor_);
1299 disambiguation_target_rect_ = gfx::ToEnclosingRect(screen_target_rect_f);
1300
1301 float scale = static_cast<float>(zoomed_bitmap.width()) /
1302 static_cast<float>(rect_pixels.width());
1303 gfx::Size zoomed_size =
1304 gfx::ScaleToCeiledSize(disambiguation_target_rect_.size(), scale);
1305
1306 // Save of a copy of the |last_scroll_offset_| for comparison when the copy
1307 // callback fires, to ensure that we haven't scrolled.
1308 disambiguation_scroll_offset_ = last_scroll_offset_;
1309
1310 CopyFromCompositingSurface(
1311 disambiguation_target_rect_,
1312 zoomed_size,
1313 base::Bind(&RenderWidgetHostViewAura::DisambiguationPopupRendered,
1314 weak_ptr_factory_.GetWeakPtr()),
1315 kN32_SkColorType);
1316 }
1317
1318 void RenderWidgetHostViewAura::DisambiguationPopupRendered(
1319 const SkBitmap& result,
1320 ReadbackResponse response) {
1321 if ((response != READBACK_SUCCESS) ||
1322 disambiguation_scroll_offset_ != last_scroll_offset_)
1323 return;
1324
1325 // Use RenderViewHostDelegate to get to the WebContentsViewAura, which will
1326 // actually show the disambiguation popup.
1327 RenderViewHost* rvh = RenderViewHost::From(host_);
1328 if (!rvh)
1329 return;
1330
1331 RenderViewHostDelegate* delegate = rvh->GetDelegate();
1332 if (!delegate)
1333 return;
1334
1335 if (delegate->IsVirtualKeyboardRequested())
1336 return;
1337
1338 RenderViewHostDelegateView* delegate_view = delegate->GetDelegateView();
1339 if (delegate_view) {
1340 delegate_view->ShowDisambiguationPopup(
1341 disambiguation_target_rect_,
1342 result,
1343 base::Bind(&RenderWidgetHostViewAura::ProcessDisambiguationGesture,
1344 weak_ptr_factory_.GetWeakPtr()),
1345 base::Bind(&RenderWidgetHostViewAura::ProcessDisambiguationMouse,
1346 weak_ptr_factory_.GetWeakPtr()));
1347 }
1348 }
1349
1350 void RenderWidgetHostViewAura::HideDisambiguationPopup() {
1351 RenderViewHost* rvh = RenderViewHost::From(host_);
1352 if (!rvh)
1353 return;
1354
1355 RenderViewHostDelegate* delegate = rvh->GetDelegate();
1356 if (!delegate)
1357 return;
1358
1359 RenderViewHostDelegateView* delegate_view = delegate->GetDelegateView();
1360 if (delegate_view)
1361 delegate_view->HideDisambiguationPopup();
1362 }
1363
1364 void RenderWidgetHostViewAura::ProcessDisambiguationGesture(
1365 ui::GestureEvent* event) {
1366 blink::WebGestureEvent web_gesture = content::MakeWebGestureEvent(*event);
1367 // If we fail to make a WebGestureEvent that is a Tap from the provided event,
1368 // don't forward it to Blink.
1369 if (web_gesture.type < blink::WebInputEvent::Type::GestureTap ||
1370 web_gesture.type > blink::WebInputEvent::Type::GestureTapCancel)
1371 return;
1372
1373 host_->ForwardGestureEvent(web_gesture);
1374 }
1375
1376 void RenderWidgetHostViewAura::ProcessDisambiguationMouse(
1377 ui::MouseEvent* event) {
1378 blink::WebMouseEvent web_mouse = content::MakeWebMouseEvent(*event);
1379 host_->ForwardMouseEvent(web_mouse);
1380 }
1381
1382 bool RenderWidgetHostViewAura::LockMouse() { 1283 bool RenderWidgetHostViewAura::LockMouse() {
1383 aura::Window* root_window = window_->GetRootWindow(); 1284 aura::Window* root_window = window_->GetRootWindow();
1384 if (!root_window) 1285 if (!root_window)
1385 return false; 1286 return false;
1386 1287
1387 if (mouse_locked_) 1288 if (mouse_locked_)
1388 return true; 1289 return true;
1389 1290
1390 mouse_locked_ = true; 1291 mouse_locked_ = true;
1391 #if !defined(OS_WIN) 1292 #if !defined(OS_WIN)
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 // dismiss them. 1882 // dismiss them.
1982 aura::WindowTreeHost* host = window_->GetHost(); 1883 aura::WindowTreeHost* host = window_->GetHost();
1983 if (host) { 1884 if (host) {
1984 HWND parent = host->GetAcceleratedWidget(); 1885 HWND parent = host->GetAcceleratedWidget();
1985 HWND toplevel_hwnd = ::GetAncestor(parent, GA_ROOT); 1886 HWND toplevel_hwnd = ::GetAncestor(parent, GA_ROOT);
1986 EnumThreadWindows(GetCurrentThreadId(), 1887 EnumThreadWindows(GetCurrentThreadId(),
1987 DismissOwnedPopups, 1888 DismissOwnedPopups,
1988 reinterpret_cast<LPARAM>(toplevel_hwnd)); 1889 reinterpret_cast<LPARAM>(toplevel_hwnd));
1989 } 1890 }
1990 #endif 1891 #endif
1991 // The Disambiguation popup does not parent itself from this window, so we
1992 // manually dismiss it.
1993 HideDisambiguationPopup();
1994
1995 blink::WebMouseWheelEvent mouse_wheel_event = 1892 blink::WebMouseWheelEvent mouse_wheel_event =
1996 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); 1893 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event));
1997 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { 1894 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) {
1998 if (ShouldRouteEvent(event)) { 1895 if (ShouldRouteEvent(event)) {
1999 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( 1896 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent(
2000 this, &mouse_wheel_event); 1897 this, &mouse_wheel_event);
2001 } else { 1898 } else {
2002 ProcessMouseWheelEvent(mouse_wheel_event); 1899 ProcessMouseWheelEvent(mouse_wheel_event);
2003 } 1900 }
2004 } 1901 }
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
2952 2849
2953 //////////////////////////////////////////////////////////////////////////////// 2850 ////////////////////////////////////////////////////////////////////////////////
2954 // RenderWidgetHostViewBase, public: 2851 // RenderWidgetHostViewBase, public:
2955 2852
2956 // static 2853 // static
2957 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2854 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2958 GetScreenInfoForWindow(results, NULL); 2855 GetScreenInfoForWindow(results, NULL);
2959 } 2856 }
2960 2857
2961 } // namespace content 2858 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698