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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 #include "ui/compositor/compositor_vsync_manager.h" | 73 #include "ui/compositor/compositor_vsync_manager.h" |
| 74 #include "ui/compositor/dip_util.h" | 74 #include "ui/compositor/dip_util.h" |
| 75 #include "ui/events/blink/blink_event_util.h" | 75 #include "ui/events/blink/blink_event_util.h" |
| 76 #include "ui/events/event.h" | 76 #include "ui/events/event.h" |
| 77 #include "ui/events/event_utils.h" | 77 #include "ui/events/event_utils.h" |
| 78 #include "ui/events/gesture_detection/gesture_configuration.h" | 78 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 79 #include "ui/events/gestures/gesture_recognizer.h" | 79 #include "ui/events/gestures/gesture_recognizer.h" |
| 80 #include "ui/gfx/canvas.h" | 80 #include "ui/gfx/canvas.h" |
| 81 #include "ui/gfx/color_profile.h" | 81 #include "ui/gfx/color_profile.h" |
| 82 #include "ui/gfx/display.h" | 82 #include "ui/gfx/display.h" |
| 83 #include "ui/gfx/geometry/dip_util.h" | |
| 83 #include "ui/gfx/geometry/rect_conversions.h" | 84 #include "ui/gfx/geometry/rect_conversions.h" |
| 84 #include "ui/gfx/geometry/size_conversions.h" | 85 #include "ui/gfx/geometry/size_conversions.h" |
| 85 #include "ui/gfx/screen.h" | 86 #include "ui/gfx/screen.h" |
| 86 #include "ui/gfx/skia_util.h" | 87 #include "ui/gfx/skia_util.h" |
| 87 #include "ui/touch_selection/touch_selection_controller.h" | 88 #include "ui/touch_selection/touch_selection_controller.h" |
| 88 #include "ui/wm/public/activation_client.h" | 89 #include "ui/wm/public/activation_client.h" |
| 89 #include "ui/wm/public/scoped_tooltip_disabler.h" | 90 #include "ui/wm/public/scoped_tooltip_disabler.h" |
| 90 #include "ui/wm/public/tooltip_client.h" | 91 #include "ui/wm/public/tooltip_client.h" |
| 91 #include "ui/wm/public/transient_window_client.h" | 92 #include "ui/wm/public/transient_window_client.h" |
| 92 #include "ui/wm/public/window_types.h" | 93 #include "ui/wm/public/window_types.h" |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 GetSurfaceIdNamespace(), this); | 496 GetSurfaceIdNamespace(), this); |
| 496 } | 497 } |
| 497 | 498 |
| 498 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> | 499 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> |
| 499 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; | 500 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; |
| 500 SetOverscrollControllerEnabled(overscroll_enabled); | 501 SetOverscrollControllerEnabled(overscroll_enabled); |
| 501 | 502 |
| 502 selection_controller_client_.reset( | 503 selection_controller_client_.reset( |
| 503 new TouchSelectionControllerClientAura(this)); | 504 new TouchSelectionControllerClientAura(this)); |
| 504 CreateSelectionController(); | 505 CreateSelectionController(); |
| 506 | |
| 507 const gfx::Display display = | |
| 508 gfx::Screen::GetScreenFor(window_)->GetDisplayNearestWindow(window_); | |
| 509 device_scale_factor_ = display.device_scale_factor(); | |
|
sadrul
2015/11/03 18:00:00
Note that at this point, |window_| hasn't been att
lfg
2015/11/03 20:49:15
Done. I've also added a DCHECK to make sure it's i
| |
| 505 } | 510 } |
| 506 | 511 |
| 507 //////////////////////////////////////////////////////////////////////////////// | 512 //////////////////////////////////////////////////////////////////////////////// |
| 508 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 513 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
| 509 | 514 |
| 510 bool RenderWidgetHostViewAura::OnMessageReceived( | 515 bool RenderWidgetHostViewAura::OnMessageReceived( |
| 511 const IPC::Message& message) { | 516 const IPC::Message& message) { |
| 512 bool handled = true; | 517 bool handled = true; |
| 513 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) | 518 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) |
| 514 IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames, | 519 IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames, |
| (...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1876 NOTREACHED(); | 1881 NOTREACHED(); |
| 1877 } | 1882 } |
| 1878 | 1883 |
| 1879 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( | 1884 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( |
| 1880 float device_scale_factor) { | 1885 float device_scale_factor) { |
| 1881 if (!host_ || !window_->GetRootWindow()) | 1886 if (!host_ || !window_->GetRootWindow()) |
| 1882 return; | 1887 return; |
| 1883 | 1888 |
| 1884 UpdateScreenInfo(window_); | 1889 UpdateScreenInfo(window_); |
| 1885 | 1890 |
| 1891 device_scale_factor_ = device_scale_factor; | |
| 1886 const gfx::Display display = gfx::Screen::GetScreenFor(window_)-> | 1892 const gfx::Display display = gfx::Screen::GetScreenFor(window_)-> |
| 1887 GetDisplayNearestWindow(window_); | 1893 GetDisplayNearestWindow(window_); |
| 1888 DCHECK_EQ(device_scale_factor, display.device_scale_factor()); | 1894 DCHECK_EQ(device_scale_factor, display.device_scale_factor()); |
| 1889 current_cursor_.SetDisplayInfo(display); | 1895 current_cursor_.SetDisplayInfo(display); |
| 1890 SnapToPhysicalPixelBoundary(); | 1896 SnapToPhysicalPixelBoundary(); |
| 1891 } | 1897 } |
| 1892 | 1898 |
| 1893 void RenderWidgetHostViewAura::OnWindowDestroying(aura::Window* window) { | 1899 void RenderWidgetHostViewAura::OnWindowDestroying(aura::Window* window) { |
| 1894 #if defined(OS_WIN) | 1900 #if defined(OS_WIN) |
| 1895 HWND parent = NULL; | 1901 HWND parent = NULL; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2167 window_->parent()->delegate()->OnMouseEvent(event); | 2173 window_->parent()->delegate()->OnMouseEvent(event); |
| 2168 } | 2174 } |
| 2169 | 2175 |
| 2170 if (!IsXButtonUpEvent(event)) | 2176 if (!IsXButtonUpEvent(event)) |
| 2171 event->SetHandled(); | 2177 event->SetHandled(); |
| 2172 } | 2178 } |
| 2173 | 2179 |
| 2174 uint32_t RenderWidgetHostViewAura::SurfaceIdNamespaceAtPoint( | 2180 uint32_t RenderWidgetHostViewAura::SurfaceIdNamespaceAtPoint( |
| 2175 const gfx::Point& point, | 2181 const gfx::Point& point, |
| 2176 gfx::Point* transformed_point) { | 2182 gfx::Point* transformed_point) { |
| 2177 cc::SurfaceId id = | 2183 gfx::Point point_in_pixels = |
| 2178 delegated_frame_host_->SurfaceIdAtPoint(point, transformed_point); | 2184 gfx::ConvertPointToPixel(device_scale_factor_, point); |
| 2185 cc::SurfaceId id = delegated_frame_host_->SurfaceIdAtPoint(point_in_pixels, | |
| 2186 transformed_point); | |
| 2187 *transformed_point = | |
| 2188 gfx::ConvertPointToDIP(device_scale_factor_, *transformed_point); | |
|
sadrul
2015/11/03 18:00:00
Add a comment here to clarify that surface-hittest
lfg
2015/11/03 20:49:16
Done.
| |
| 2189 | |
| 2179 // It is possible that the renderer has not yet produced a surface, in which | 2190 // It is possible that the renderer has not yet produced a surface, in which |
| 2180 // case we return our current namespace. | 2191 // case we return our current namespace. |
| 2181 if (id.is_null()) | 2192 if (id.is_null()) |
| 2182 return GetSurfaceIdNamespace(); | 2193 return GetSurfaceIdNamespace(); |
| 2183 return cc::SurfaceIdAllocator::NamespaceForId(id); | 2194 return cc::SurfaceIdAllocator::NamespaceForId(id); |
| 2184 } | 2195 } |
| 2185 | 2196 |
| 2186 void RenderWidgetHostViewAura::ProcessMouseEvent( | 2197 void RenderWidgetHostViewAura::ProcessMouseEvent( |
| 2187 const blink::WebMouseEvent& event) { | 2198 const blink::WebMouseEvent& event) { |
| 2188 host_->ForwardMouseEvent(event); | 2199 host_->ForwardMouseEvent(event); |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2899 | 2910 |
| 2900 //////////////////////////////////////////////////////////////////////////////// | 2911 //////////////////////////////////////////////////////////////////////////////// |
| 2901 // RenderWidgetHostViewBase, public: | 2912 // RenderWidgetHostViewBase, public: |
| 2902 | 2913 |
| 2903 // static | 2914 // static |
| 2904 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2915 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2905 GetScreenInfoForWindow(results, NULL); | 2916 GetScreenInfoForWindow(results, NULL); |
| 2906 } | 2917 } |
| 2907 | 2918 |
| 2908 } // namespace content | 2919 } // namespace content |
| OLD | NEW |