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

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

Issue 336313011: Android: compute screen orientation type in the RWHV. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lock_fullscreen
Patch Set: fix mac build Created 6 years, 6 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_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 "content/browser/accessibility/browser_accessibility_manager.h" 8 #include "content/browser/accessibility/browser_accessibility_manager.h"
9 #include "content/browser/gpu/gpu_data_manager_impl.h" 9 #include "content/browser/gpu/gpu_data_manager_impl.h"
10 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" 10 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h"
11 #include "content/browser/renderer_host/render_process_host_impl.h" 11 #include "content/browser/renderer_host/render_process_host_impl.h"
12 #include "content/browser/renderer_host/render_widget_host_impl.h" 12 #include "content/browser/renderer_host/render_widget_host_impl.h"
13 #include "content/common/content_switches_internal.h" 13 #include "content/common/content_switches_internal.h"
14 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 14 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
15 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
16 #include "ui/gfx/display.h" 15 #include "ui/gfx/display.h"
17 #include "ui/gfx/screen.h" 16 #include "ui/gfx/screen.h"
18 #include "ui/gfx/size_conversions.h" 17 #include "ui/gfx/size_conversions.h"
19 #include "ui/gfx/size_f.h" 18 #include "ui/gfx/size_f.h"
20 19
21 #if defined(OS_WIN) 20 #if defined(OS_WIN)
22 #include "base/command_line.h" 21 #include "base/command_line.h"
23 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
24 #include "base/win/wrapped_window_proc.h" 23 #include "base/win/wrapped_window_proc.h"
25 #include "content/browser/plugin_process_host.h" 24 #include "content/browser/plugin_process_host.h"
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } 600 }
602 601
603 gfx::Size RenderWidgetHostViewBase::GetVisibleViewportSize() const { 602 gfx::Size RenderWidgetHostViewBase::GetVisibleViewportSize() const {
604 return GetViewBounds().size(); 603 return GetViewBounds().size();
605 } 604 }
606 605
607 void RenderWidgetHostViewBase::SetInsets(const gfx::Insets& insets) { 606 void RenderWidgetHostViewBase::SetInsets(const gfx::Insets& insets) {
608 NOTIMPLEMENTED(); 607 NOTIMPLEMENTED();
609 } 608 }
610 609
610 // static
611 blink::WebScreenOrientationType
612 RenderWidgetHostViewBase::GetOrientationTypeFromDisplay(
613 const gfx::Display& display) {
614 int angle = display.RotationAsDegree();
615 const gfx::Rect& bounds = display.bounds();
616
617 // Whether the device's natural orientation is portrait.
618 bool naturalPortrait = false;
619 if (angle == 0 || angle == 180) // The device is in its natural orientation.
620 naturalPortrait = bounds.height() > bounds.width();
621 else
622 naturalPortrait = bounds.height() < bounds.width();
623
624 switch (angle) {
625 case 0:
626 return naturalPortrait ? blink::WebScreenOrientationPortraitPrimary
627 : blink::WebScreenOrientationLandscapePrimary;
628 case 90:
629 return naturalPortrait ? blink::WebScreenOrientationLandscapePrimary
630 : blink::WebScreenOrientationPortraitSecondary;
631 case 180:
632 return naturalPortrait ? blink::WebScreenOrientationPortraitSecondary
633 : blink::WebScreenOrientationLandscapeSecondary;
634 case 270:
635 return naturalPortrait ? blink::WebScreenOrientationLandscapeSecondary
636 : blink::WebScreenOrientationPortraitPrimary;
637 default:
638 NOTREACHED();
639 return blink::WebScreenOrientationPortraitPrimary;
640 }
641 }
642
611 } // namespace content 643 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698