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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_view_base.cc
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 d5f58e0aab794c88a9a82862b5737799eb894116..fda352846838c3d3666af40aaf26588ba5dc62be 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

Powered by Google App Engine
This is Rietveld 408576698