summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-25 13:52:30 +0000
committermlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-25 13:52:30 +0000
commit6131fe6d36d160340926091f4daf7d64bffdd5c5 (patch)
treeec285eb7f40cefef4437a930731de6ac6732819c
parent88f666c4e84a6ba47557f3fd8582b4aa0610db6f (diff)
downloadchromium_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
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.cc2
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.cc3
-rw-r--r--content/browser/renderer_host/render_widget_host_view_base.cc34
-rw-r--r--content/browser/renderer_host/render_widget_host_view_base.h5
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.mm2
5 files changed, 45 insertions, 1 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index 51ac5fc..e830e65 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -1444,6 +1444,8 @@ void RenderWidgetHostViewBase::GetDefaultScreenInfo(
results->availableRect = display.work_area();
results->deviceScaleFactor = display.device_scale_factor();
results->orientationAngle = display.RotationAsDegree();
+ results->orientationType =
+ RenderWidgetHostViewBase::GetOrientationTypeFromDisplay(display);
gfx::DeviceDisplayInfo info;
results->depth = info.GetBitsPerPixel();
results->depthPerComponent = info.GetBitsPerComponent();
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 16a4e76..77d0800 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -316,6 +316,9 @@ void GetScreenInfoForWindow(WebScreenInfo* results, aura::Window* window) {
results->orientationAngle = 270;
else if (results->orientationAngle == 270)
results->orientationAngle = 90;
+
+ results->orientationType =
+ RenderWidgetHostViewBase::GetOrientationTypeFromDisplay(display);
}
bool PointerEventActivates(const ui::Event& event) {
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
diff --git a/content/browser/renderer_host/render_widget_host_view_base.h b/content/browser/renderer_host/render_widget_host_view_base.h
index 9bf2e60..8ff1c75 100644
--- a/content/browser/renderer_host/render_widget_host_view_base.h
+++ b/content/browser/renderer_host/render_widget_host_view_base.h
@@ -22,6 +22,7 @@
#include "content/common/input/input_event_ack_state.h"
#include "content/public/browser/render_widget_host_view.h"
#include "ipc/ipc_listener.h"
+#include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
#include "third_party/WebKit/public/web/WebPopupType.h"
#include "third_party/WebKit/public/web/WebTextDirection.h"
#include "ui/base/ime/text_input_mode.h"
@@ -308,6 +309,10 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
// returned only if the accelerated surface size matches.
virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) = 0;
+ // Returns the orientation type based on the current display state.
+ static blink::WebScreenOrientationType GetOrientationTypeFromDisplay(
+ const gfx::Display& display);
+
virtual void GetScreenInfo(blink::WebScreenInfo* results) = 0;
// Gets the bounds of the window, in screen coordinates.
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index bb24a63..34ff9bf 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -376,6 +376,8 @@ blink::WebScreenInfo GetWebScreenInfo(NSView* view) {
results.rect = display.bounds();
results.availableRect = display.work_area();
results.orientationAngle = display.RotationAsDegree();
+ results.orientationType =
+ content::RenderWidgetHostViewBase::GetOrientationTypeFromDisplay(display);
return results;
}