| 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_base.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "content/browser/accessibility/browser_accessibility_manager.h" | 9 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 10 #include "content/browser/gpu/gpu_data_manager_impl.h" | 10 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 11 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" | 11 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" |
| 12 #include "content/browser/renderer_host/render_process_host_impl.h" | 12 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 13 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 13 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 14 #include "content/browser/renderer_host/render_widget_host_impl.h" | 14 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 15 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" | 15 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" |
| 16 #include "content/common/content_switches_internal.h" | 16 #include "content/common/content_switches_internal.h" |
| 17 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 17 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 18 #include "ui/gfx/display.h" | 18 #include "ui/display/display.h" |
| 19 #include "ui/display/screen.h" |
| 19 #include "ui/gfx/geometry/point_conversions.h" | 20 #include "ui/gfx/geometry/point_conversions.h" |
| 20 #include "ui/gfx/geometry/size_conversions.h" | 21 #include "ui/gfx/geometry/size_conversions.h" |
| 21 #include "ui/gfx/geometry/size_f.h" | 22 #include "ui/gfx/geometry/size_f.h" |
| 22 #include "ui/gfx/screen.h" | |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // How many microseconds apart input events should be flushed. | 28 // How many microseconds apart input events should be flushed. |
| 29 const int kFlushInputRateInUs = 16666; | 29 const int kFlushInputRateInUs = 16666; |
| 30 | 30 |
| 31 } | 31 } |
| 32 | 32 |
| 33 RenderWidgetHostViewBase::RenderWidgetHostViewBase() | 33 RenderWidgetHostViewBase::RenderWidgetHostViewBase() |
| 34 : popup_type_(blink::WebPopupTypeNone), | 34 : popup_type_(blink::WebPopupTypeNone), |
| 35 background_color_(SK_ColorWHITE), | 35 background_color_(SK_ColorWHITE), |
| 36 mouse_locked_(false), | 36 mouse_locked_(false), |
| 37 showing_context_menu_(false), | 37 showing_context_menu_(false), |
| 38 selection_text_offset_(0), | 38 selection_text_offset_(0), |
| 39 selection_range_(gfx::Range::InvalidRange()), | 39 selection_range_(gfx::Range::InvalidRange()), |
| 40 current_device_scale_factor_(0), | 40 current_device_scale_factor_(0), |
| 41 current_display_rotation_(gfx::Display::ROTATE_0), | 41 current_display_rotation_(display::Display::ROTATE_0), |
| 42 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), | 42 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), |
| 43 renderer_frame_number_(0), | 43 renderer_frame_number_(0), |
| 44 weak_factory_(this) {} | 44 weak_factory_(this) {} |
| 45 | 45 |
| 46 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { | 46 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { |
| 47 DCHECK(!mouse_locked_); | 47 DCHECK(!mouse_locked_); |
| 48 // We call this here to guarantee that observers are notified before we go | 48 // We call this here to guarantee that observers are notified before we go |
| 49 // away. However, some subclasses may wish to call this earlier in their | 49 // away. However, some subclasses may wish to call this earlier in their |
| 50 // shutdown process, e.g. to force removal from | 50 // shutdown process, e.g. to force removal from |
| 51 // RenderWidgetHostInputEventRouter's surface map before relinquishing a | 51 // RenderWidgetHostInputEventRouter's surface map before relinquishing a |
| (...skipping 23 matching lines...) Expand all Loading... |
| 75 | 75 |
| 76 void RenderWidgetHostViewBase::SetBackgroundColorToDefault() { | 76 void RenderWidgetHostViewBase::SetBackgroundColorToDefault() { |
| 77 SetBackgroundColor(SK_ColorWHITE); | 77 SetBackgroundColor(SK_ColorWHITE); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool RenderWidgetHostViewBase::GetBackgroundOpaque() { | 80 bool RenderWidgetHostViewBase::GetBackgroundOpaque() { |
| 81 return SkColorGetA(background_color_) == SK_AlphaOPAQUE; | 81 return SkColorGetA(background_color_) == SK_AlphaOPAQUE; |
| 82 } | 82 } |
| 83 | 83 |
| 84 gfx::Size RenderWidgetHostViewBase::GetPhysicalBackingSize() const { | 84 gfx::Size RenderWidgetHostViewBase::GetPhysicalBackingSize() const { |
| 85 gfx::Display display = | 85 display::Display display = |
| 86 gfx::Screen::GetScreen()->GetDisplayNearestWindow(GetNativeView()); | 86 display::Screen::GetScreen()->GetDisplayNearestWindow(GetNativeView()); |
| 87 return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), | 87 return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), |
| 88 display.device_scale_factor()); | 88 display.device_scale_factor()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool RenderWidgetHostViewBase::DoTopControlsShrinkBlinkSize() const { | 91 bool RenderWidgetHostViewBase::DoTopControlsShrinkBlinkSize() const { |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| 94 | 94 |
| 95 float RenderWidgetHostViewBase::GetTopControlsHeight() const { | 95 float RenderWidgetHostViewBase::GetTopControlsHeight() const { |
| 96 return 0.f; | 96 return 0.f; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 impl = RenderWidgetHostImpl::From(GetRenderWidgetHost()); | 207 impl = RenderWidgetHostImpl::From(GetRenderWidgetHost()); |
| 208 | 208 |
| 209 if (impl && impl->delegate()) | 209 if (impl && impl->delegate()) |
| 210 impl->delegate()->SendScreenRects(); | 210 impl->delegate()->SendScreenRects(); |
| 211 | 211 |
| 212 if (HasDisplayPropertyChanged(view) && impl) | 212 if (HasDisplayPropertyChanged(view) && impl) |
| 213 impl->NotifyScreenInfoChanged(); | 213 impl->NotifyScreenInfoChanged(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 bool RenderWidgetHostViewBase::HasDisplayPropertyChanged(gfx::NativeView view) { | 216 bool RenderWidgetHostViewBase::HasDisplayPropertyChanged(gfx::NativeView view) { |
| 217 gfx::Display display = | 217 display::Display display = |
| 218 gfx::Screen::GetScreen()->GetDisplayNearestWindow(view); | 218 display::Screen::GetScreen()->GetDisplayNearestWindow(view); |
| 219 if (current_display_area_ == display.work_area() && | 219 if (current_display_area_ == display.work_area() && |
| 220 current_device_scale_factor_ == display.device_scale_factor() && | 220 current_device_scale_factor_ == display.device_scale_factor() && |
| 221 current_display_rotation_ == display.rotation()) { | 221 current_display_rotation_ == display.rotation()) { |
| 222 return false; | 222 return false; |
| 223 } | 223 } |
| 224 | 224 |
| 225 current_display_area_ = display.work_area(); | 225 current_display_area_ = display.work_area(); |
| 226 current_device_scale_factor_ = display.device_scale_factor(); | 226 current_device_scale_factor_ = display.device_scale_factor(); |
| 227 current_display_rotation_ = display.rotation(); | 227 current_display_rotation_ = display.rotation(); |
| 228 return true; | 228 return true; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 return GetViewBounds().size(); | 284 return GetViewBounds().size(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void RenderWidgetHostViewBase::SetInsets(const gfx::Insets& insets) { | 287 void RenderWidgetHostViewBase::SetInsets(const gfx::Insets& insets) { |
| 288 NOTIMPLEMENTED(); | 288 NOTIMPLEMENTED(); |
| 289 } | 289 } |
| 290 | 290 |
| 291 // static | 291 // static |
| 292 blink::WebScreenOrientationType | 292 blink::WebScreenOrientationType |
| 293 RenderWidgetHostViewBase::GetOrientationTypeForMobile( | 293 RenderWidgetHostViewBase::GetOrientationTypeForMobile( |
| 294 const gfx::Display& display) { | 294 const display::Display& display) { |
| 295 int angle = display.RotationAsDegree(); | 295 int angle = display.RotationAsDegree(); |
| 296 const gfx::Rect& bounds = display.bounds(); | 296 const gfx::Rect& bounds = display.bounds(); |
| 297 | 297 |
| 298 // Whether the device's natural orientation is portrait. | 298 // Whether the device's natural orientation is portrait. |
| 299 bool natural_portrait = false; | 299 bool natural_portrait = false; |
| 300 if (angle == 0 || angle == 180) // The device is in its natural orientation. | 300 if (angle == 0 || angle == 180) // The device is in its natural orientation. |
| 301 natural_portrait = bounds.height() >= bounds.width(); | 301 natural_portrait = bounds.height() >= bounds.width(); |
| 302 else | 302 else |
| 303 natural_portrait = bounds.height() <= bounds.width(); | 303 natural_portrait = bounds.height() <= bounds.width(); |
| 304 | 304 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 317 : blink::WebScreenOrientationPortraitPrimary; | 317 : blink::WebScreenOrientationPortraitPrimary; |
| 318 default: | 318 default: |
| 319 NOTREACHED(); | 319 NOTREACHED(); |
| 320 return blink::WebScreenOrientationPortraitPrimary; | 320 return blink::WebScreenOrientationPortraitPrimary; |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 | 323 |
| 324 // static | 324 // static |
| 325 blink::WebScreenOrientationType | 325 blink::WebScreenOrientationType |
| 326 RenderWidgetHostViewBase::GetOrientationTypeForDesktop( | 326 RenderWidgetHostViewBase::GetOrientationTypeForDesktop( |
| 327 const gfx::Display& display) { | 327 const display::Display& display) { |
| 328 static int primary_landscape_angle = -1; | 328 static int primary_landscape_angle = -1; |
| 329 static int primary_portrait_angle = -1; | 329 static int primary_portrait_angle = -1; |
| 330 | 330 |
| 331 int angle = display.RotationAsDegree(); | 331 int angle = display.RotationAsDegree(); |
| 332 const gfx::Rect& bounds = display.bounds(); | 332 const gfx::Rect& bounds = display.bounds(); |
| 333 bool is_portrait = bounds.height() >= bounds.width(); | 333 bool is_portrait = bounds.height() >= bounds.width(); |
| 334 | 334 |
| 335 if (is_portrait && primary_portrait_angle == -1) | 335 if (is_portrait && primary_portrait_angle == -1) |
| 336 primary_portrait_angle = angle; | 336 primary_portrait_angle = angle; |
| 337 | 337 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 | 394 |
| 395 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { | 395 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { |
| 396 return false; | 396 return false; |
| 397 } | 397 } |
| 398 | 398 |
| 399 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { | 399 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { |
| 400 return cc::SurfaceId(); | 400 return cc::SurfaceId(); |
| 401 } | 401 } |
| 402 | 402 |
| 403 } // namespace content | 403 } // namespace content |
| OLD | NEW |