diff options
author | mlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-25 13:52:30 +0000 |
---|---|---|
committer | mlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-25 13:52:30 +0000 |
commit | 6131fe6d36d160340926091f4daf7d64bffdd5c5 (patch) | |
tree | ec285eb7f40cefef4437a930731de6ac6732819c /content/browser/renderer_host/render_widget_host_view_base.cc | |
parent | 88f666c4e84a6ba47557f3fd8582b4aa0610db6f (diff) | |
download | chromium_src-6131fe6d36d160340926091f4daf7d64bffdd5c5.zip chromium_src-6131fe6d36d160340926091f4daf7d64bffdd5c5.tar.gz chromium_src-6131fe6d36d160340926091f4daf7d64bffdd5c5.tar.bz2 |
Android: compute screen orientation type in the RWHV.
BUG=162827
Review URL: https://codereview.chromium.org/336313011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279709 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host/render_widget_host_view_base.cc')
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_base.cc | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc index d5f58e0..fda35284 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.cc +++ b/content/browser/renderer_host/render_widget_host_view_base.cc @@ -12,7 +12,6 @@ #include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/common/content_switches_internal.h" #include "content/public/browser/render_widget_host_view_frame_subscriber.h" -#include "third_party/WebKit/public/platform/WebScreenInfo.h" #include "ui/gfx/display.h" #include "ui/gfx/screen.h" #include "ui/gfx/size_conversions.h" @@ -608,4 +607,37 @@ void RenderWidgetHostViewBase::SetInsets(const gfx::Insets& insets) { NOTIMPLEMENTED(); } +// static +blink::WebScreenOrientationType +RenderWidgetHostViewBase::GetOrientationTypeFromDisplay( + const gfx::Display& display) { + int angle = display.RotationAsDegree(); + const gfx::Rect& bounds = display.bounds(); + + // Whether the device's natural orientation is portrait. + bool naturalPortrait = false; + if (angle == 0 || angle == 180) // The device is in its natural orientation. + naturalPortrait = bounds.height() > bounds.width(); + else + naturalPortrait = bounds.height() < bounds.width(); + + switch (angle) { + case 0: + return naturalPortrait ? blink::WebScreenOrientationPortraitPrimary + : blink::WebScreenOrientationLandscapePrimary; + case 90: + return naturalPortrait ? blink::WebScreenOrientationLandscapePrimary + : blink::WebScreenOrientationPortraitSecondary; + case 180: + return naturalPortrait ? blink::WebScreenOrientationPortraitSecondary + : blink::WebScreenOrientationLandscapeSecondary; + case 270: + return naturalPortrait ? blink::WebScreenOrientationLandscapeSecondary + : blink::WebScreenOrientationPortraitPrimary; + default: + NOTREACHED(); + return blink::WebScreenOrientationPortraitPrimary; + } +} + } // namespace content |