Chromium Code Reviews| 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/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 Loading... | |
| 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 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1223 return legacy_render_widget_host_HWND_->window_accessible(); | 1224 return legacy_render_widget_host_HWND_->window_accessible(); |
| 1224 #endif | 1225 #endif |
| 1225 return NULL; | 1226 return NULL; |
| 1226 | 1227 |
| 1227 } | 1228 } |
| 1228 | 1229 |
| 1229 gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() { | 1230 gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() { |
| 1230 return ImageTransportFactory::GetInstance()->GetSharedSurfaceHandle(); | 1231 return ImageTransportFactory::GetInstance()->GetSharedSurfaceHandle(); |
| 1231 } | 1232 } |
| 1232 | 1233 |
| 1234 void RenderWidgetHostViewAura::ShowDisambiguationPopup( | |
| 1235 const gfx::Rect& target_rect, | |
| 1236 const SkBitmap& zoomed_bitmap) { | |
| 1237 // |target_rect| is provided in pixels, not DIPs. So we convert it to DIPs | |
| 1238 // by scaling it by the inverse of the device scale factor. | |
| 1239 gfx::RectF screen_target_rect_f(target_rect); | |
| 1240 screen_target_rect_f.Scale(1.0f / current_device_scale_factor_); | |
| 1241 disambiguation_target_rect_ = gfx::ToEnclosingRect(screen_target_rect_f); | |
|
sky
2014/09/11 14:53:43
Won't this conversion be losing? Will it matter?
luken
2014/09/17 00:00:48
Yes, it loses accuracy. No, it doesn't seem to mat
| |
| 1242 | |
| 1243 float scale = static_cast<float>(zoomed_bitmap.width()) / | |
| 1244 static_cast<float>(target_rect.width()); | |
| 1245 gfx::Size zoomed_size(gfx::ToCeiledSize( | |
| 1246 gfx::ScaleSize(disambiguation_target_rect_.size(), scale))); | |
| 1247 | |
| 1248 CopyFromCompositingSurface( | |
| 1249 disambiguation_target_rect_, | |
| 1250 zoomed_size, | |
| 1251 base::Bind(&RenderWidgetHostViewAura::DisambiguationPopupRendered, | |
|
sky
2014/09/11 14:53:43
How do you know by the time this is returned that
luken
2014/09/17 00:00:48
I've added code to save the last_scroll_offset_ fo
sky
2014/09/19 15:19:23
Is that really enough? Might the dom or other rand
luken
2014/09/19 19:27:41
AFAICT we are already doing more than what this fe
sky
2014/09/22 15:01:30
Have you talked with any of the guys on the Androi
| |
| 1252 base::internal::SupportsWeakPtrBase::StaticAsWeakPtr | |
| 1253 <RenderWidgetHostViewAura>(this)), | |
| 1254 kN32_SkColorType); | |
| 1255 } | |
| 1256 | |
| 1257 void RenderWidgetHostViewAura::DisambiguationPopupRendered( | |
| 1258 bool success, | |
| 1259 const SkBitmap& result) { | |
| 1260 if (!success) | |
| 1261 return; | |
| 1262 | |
| 1263 // Use RenderViewHostDelegate to get to the WebContentsViewAura, which will | |
| 1264 // actually show the delegate. | |
| 1265 RenderViewHostDelegate* delegate = NULL; | |
| 1266 if (host_->IsRenderView()) | |
| 1267 delegate = RenderViewHost::From(host_)->GetDelegate(); | |
| 1268 RenderViewHostDelegateView* delegate_view = NULL; | |
| 1269 if (delegate) | |
| 1270 delegate_view = delegate->GetDelegateView(); | |
| 1271 if (delegate_view) | |
| 1272 delegate_view->ShowDisambiguationPopup(disambiguation_target_rect_, result); | |
| 1273 } | |
| 1274 | |
| 1275 void RenderWidgetHostViewAura::HideDisambiguationPopup() { | |
| 1276 RenderViewHostDelegate* delegate = NULL; | |
| 1277 if (host_->IsRenderView()) | |
| 1278 delegate = RenderViewHost::From(host_)->GetDelegate(); | |
| 1279 RenderViewHostDelegateView* delegate_view = NULL; | |
| 1280 if (delegate) | |
| 1281 delegate_view = delegate->GetDelegateView(); | |
| 1282 if (delegate_view) | |
| 1283 delegate_view->HideDisambiguationPopup(); | |
| 1284 } | |
| 1285 | |
| 1233 bool RenderWidgetHostViewAura::LockMouse() { | 1286 bool RenderWidgetHostViewAura::LockMouse() { |
| 1234 aura::Window* root_window = window_->GetRootWindow(); | 1287 aura::Window* root_window = window_->GetRootWindow(); |
| 1235 if (!root_window) | 1288 if (!root_window) |
| 1236 return false; | 1289 return false; |
| 1237 | 1290 |
| 1238 if (mouse_locked_) | 1291 if (mouse_locked_) |
| 1239 return true; | 1292 return true; |
| 1240 | 1293 |
| 1241 mouse_locked_ = true; | 1294 mouse_locked_ = true; |
| 1242 #if !defined(OS_WIN) | 1295 #if !defined(OS_WIN) |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1838 // So here we check if we have any owned popup windows in the foreground and | 1891 // So here we check if we have any owned popup windows in the foreground and |
| 1839 // dismiss them. | 1892 // dismiss them. |
| 1840 aura::WindowTreeHost* host = window_->GetHost(); | 1893 aura::WindowTreeHost* host = window_->GetHost(); |
| 1841 if (host) { | 1894 if (host) { |
| 1842 HWND parent = host->GetAcceleratedWidget(); | 1895 HWND parent = host->GetAcceleratedWidget(); |
| 1843 HWND toplevel_hwnd = ::GetAncestor(parent, GA_ROOT); | 1896 HWND toplevel_hwnd = ::GetAncestor(parent, GA_ROOT); |
| 1844 EnumThreadWindows(GetCurrentThreadId(), | 1897 EnumThreadWindows(GetCurrentThreadId(), |
| 1845 DismissOwnedPopups, | 1898 DismissOwnedPopups, |
| 1846 reinterpret_cast<LPARAM>(toplevel_hwnd)); | 1899 reinterpret_cast<LPARAM>(toplevel_hwnd)); |
| 1847 } | 1900 } |
| 1901 // The Disambiguation popup does not parent itself from this window, so we | |
| 1902 // manually dismiss it. | |
| 1903 HideDisambiguationPopup(); | |
|
sky
2014/09/11 14:53:43
Why is this in the ifdef? Also, it seems like the
luken
2014/09/17 00:00:48
I moved it outside of the ifdef. I wasn't able to
| |
| 1848 #endif | 1904 #endif |
| 1849 blink::WebMouseWheelEvent mouse_wheel_event = | 1905 blink::WebMouseWheelEvent mouse_wheel_event = |
| 1850 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); | 1906 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); |
| 1851 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) | 1907 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) |
| 1852 host_->ForwardWheelEvent(mouse_wheel_event); | 1908 host_->ForwardWheelEvent(mouse_wheel_event); |
| 1853 } else if (CanRendererHandleEvent(event) && | 1909 } else if (CanRendererHandleEvent(event) && |
| 1854 !(event->flags() & ui::EF_FROM_TOUCH)) { | 1910 !(event->flags() & ui::EF_FROM_TOUCH)) { |
| 1855 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(event); | 1911 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(event); |
| 1856 ModifyEventMovementAndCoords(&mouse_event); | 1912 ModifyEventMovementAndCoords(&mouse_event); |
| 1857 host_->ForwardMouseEvent(mouse_event); | 1913 host_->ForwardMouseEvent(mouse_event); |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2494 | 2550 |
| 2495 //////////////////////////////////////////////////////////////////////////////// | 2551 //////////////////////////////////////////////////////////////////////////////// |
| 2496 // RenderWidgetHostViewBase, public: | 2552 // RenderWidgetHostViewBase, public: |
| 2497 | 2553 |
| 2498 // static | 2554 // static |
| 2499 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2555 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2500 GetScreenInfoForWindow(results, NULL); | 2556 GetScreenInfoForWindow(results, NULL); |
| 2501 } | 2557 } |
| 2502 | 2558 |
| 2503 } // namespace content | 2559 } // namespace content |
| OLD | NEW |