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

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

Issue 351683002: Adds link disambiguation popup support to Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: making interface changes windows-only Created 6 years, 4 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 "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 11 matching lines...) Expand all
22 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 22 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
23 #include "content/browser/frame_host/frame_tree.h" 23 #include "content/browser/frame_host/frame_tree.h"
24 #include "content/browser/frame_host/frame_tree_node.h" 24 #include "content/browser/frame_host/frame_tree_node.h"
25 #include "content/browser/frame_host/render_frame_host_impl.h" 25 #include "content/browser/frame_host/render_frame_host_impl.h"
26 #include "content/browser/gpu/compositor_util.h" 26 #include "content/browser/gpu/compositor_util.h"
27 #include "content/browser/renderer_host/compositor_resize_lock_aura.h" 27 #include "content/browser/renderer_host/compositor_resize_lock_aura.h"
28 #include "content/browser/renderer_host/dip_util.h" 28 #include "content/browser/renderer_host/dip_util.h"
29 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" 29 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h"
30 #include "content/browser/renderer_host/overscroll_controller.h" 30 #include "content/browser/renderer_host/overscroll_controller.h"
31 #include "content/browser/renderer_host/render_view_host_delegate.h" 31 #include "content/browser/renderer_host/render_view_host_delegate.h"
32 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
32 #include "content/browser/renderer_host/render_view_host_impl.h" 33 #include "content/browser/renderer_host/render_view_host_impl.h"
33 #include "content/browser/renderer_host/render_widget_host_impl.h" 34 #include "content/browser/renderer_host/render_widget_host_impl.h"
34 #include "content/browser/renderer_host/ui_events_helper.h" 35 #include "content/browser/renderer_host/ui_events_helper.h"
35 #include "content/browser/renderer_host/web_input_event_aura.h" 36 #include "content/browser/renderer_host/web_input_event_aura.h"
36 #include "content/common/gpu/client/gl_helper.h" 37 #include "content/common/gpu/client/gl_helper.h"
37 #include "content/common/gpu/gpu_messages.h" 38 #include "content/common/gpu/gpu_messages.h"
38 #include "content/common/view_messages.h" 39 #include "content/common/view_messages.h"
39 #include "content/public/browser/content_browser_client.h" 40 #include "content/public/browser/content_browser_client.h"
40 #include "content/public/browser/overscroll_configuration.h" 41 #include "content/public/browser/overscroll_configuration.h"
41 #include "content/public/browser/render_view_host.h" 42 #include "content/public/browser/render_view_host.h"
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 return legacy_render_widget_host_HWND_->window_accessible(); 1218 return legacy_render_widget_host_HWND_->window_accessible();
1218 #endif 1219 #endif
1219 return NULL; 1220 return NULL;
1220 1221
1221 } 1222 }
1222 1223
1223 gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() { 1224 gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() {
1224 return ImageTransportFactory::GetInstance()->GetSharedSurfaceHandle(); 1225 return ImageTransportFactory::GetInstance()->GetSharedSurfaceHandle();
1225 } 1226 }
1226 1227
1228 #if defined(OS_WIN)
1229 void RenderWidgetHostViewAura::ShowDisambiguationPopup(
1230 const gfx::Rect& target_rect,
1231 const SkBitmap& zoomed_bitmap) {
1232 // |target_rect| is provided in pixels, not DIPs. So we convert it to DIPs
1233 // by scaling it by the inverse of the device scale factor.
1234 gfx::RectF screen_target_rect_f(target_rect);
1235 screen_target_rect_f.Scale(1.0f / current_device_scale_factor_);
1236 disambiguation_target_rect_ = gfx::ToEnclosingRect(screen_target_rect_f);
1237
1238 float scale = static_cast<float>(zoomed_bitmap.width()) /
1239 static_cast<float>(target_rect.width());
1240 scale = std::min(scale, 3.0f);
1241 scale = std::max(scale, 1.0f);
1242 gfx::Size zoomed_size(gfx::ToCeiledSize(
1243 gfx::ScaleSize(disambiguation_target_rect_.size(), scale)));
1244
1245 CopyFromCompositingSurface(
1246 disambiguation_target_rect_,
1247 zoomed_size,
1248 base::Bind(&RenderWidgetHostViewAura::DisambiguationPopupRendered,
1249 base::Unretained(this)),
1250 kN32_SkColorType);
1251 }
1252
1253 void RenderWidgetHostViewAura::DisambiguationPopupRendered(
1254 bool success,
1255 const SkBitmap& result) {
1256 if (!success)
1257 return;
1258
1259 // Use RenderViewHostDelegate to get to the WebContentsViewAura, which will
1260 // actually show the delegate.
1261 RenderViewHostDelegate* delegate = NULL;
1262 if (host_->IsRenderView())
1263 delegate = RenderViewHost::From(host_)->GetDelegate();
1264 RenderViewHostDelegateView* delegate_view = NULL;
1265 if (delegate)
1266 delegate_view = delegate->GetDelegateView();
1267 if (delegate_view)
1268 delegate_view->ShowDisambiguationPopup(disambiguation_target_rect_, result);
1269 }
1270 #endif
1271
1227 bool RenderWidgetHostViewAura::LockMouse() { 1272 bool RenderWidgetHostViewAura::LockMouse() {
1228 aura::Window* root_window = window_->GetRootWindow(); 1273 aura::Window* root_window = window_->GetRootWindow();
1229 if (!root_window) 1274 if (!root_window)
1230 return false; 1275 return false;
1231 1276
1232 if (mouse_locked_) 1277 if (mouse_locked_)
1233 return true; 1278 return true;
1234 1279
1235 mouse_locked_ = true; 1280 mouse_locked_ = true;
1236 #if !defined(OS_WIN) 1281 #if !defined(OS_WIN)
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 2538
2494 //////////////////////////////////////////////////////////////////////////////// 2539 ////////////////////////////////////////////////////////////////////////////////
2495 // RenderWidgetHostViewBase, public: 2540 // RenderWidgetHostViewBase, public:
2496 2541
2497 // static 2542 // static
2498 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2543 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2499 GetScreenInfoForWindow(results, NULL); 2544 GetScreenInfoForWindow(results, NULL);
2500 } 2545 }
2501 2546
2502 } // namespace content 2547 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698