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

Unified Diff: third_party/WebKit/Source/modules/screen_orientation/ScreenOrientationController.cpp

Issue 1727083002: Revert of [DevTools] Move screen orientation override to RenderWidgetScreenMetricsEmulator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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: third_party/WebKit/Source/modules/screen_orientation/ScreenOrientationController.cpp
diff --git a/third_party/WebKit/Source/modules/screen_orientation/ScreenOrientationController.cpp b/third_party/WebKit/Source/modules/screen_orientation/ScreenOrientationController.cpp
index de25e2c7aa258ac10f793bb8d080c3164e22f9a6..8e3c8624cf8f2ca630895aeb18f1751132880b92 100644
--- a/third_party/WebKit/Source/modules/screen_orientation/ScreenOrientationController.cpp
+++ b/third_party/WebKit/Source/modules/screen_orientation/ScreenOrientationController.cpp
@@ -40,6 +40,9 @@
, PlatformEventController(frame.page())
, m_client(client)
, m_dispatchEventTimer(this, &ScreenOrientationController::dispatchEventTimerFired)
+ , m_override(false)
+ , m_overrideType(WebScreenOrientationUndefined)
+ , m_overrideAngle(0)
{
}
@@ -73,6 +76,16 @@
}
}
+unsigned short ScreenOrientationController::effectiveAngle(ChromeClient& chromeClient)
+{
+ return m_override ? m_overrideAngle : chromeClient.screenInfo().orientationAngle;
+}
+
+WebScreenOrientationType ScreenOrientationController::effectiveType(ChromeClient& chromeClient)
+{
+ return m_override ? m_overrideType : chromeClient.screenInfo().orientationType;
+}
+
void ScreenOrientationController::updateOrientation()
{
ASSERT(m_orientation);
@@ -80,16 +93,15 @@
ASSERT(frame()->host());
ChromeClient& chromeClient = frame()->host()->chromeClient();
- WebScreenInfo screenInfo = chromeClient.screenInfo();
- WebScreenOrientationType orientationType = screenInfo.orientationType;
+ WebScreenOrientationType orientationType = effectiveType(chromeClient);
if (orientationType == WebScreenOrientationUndefined) {
// The embedder could not provide us with an orientation, deduce it ourselves.
- orientationType = computeOrientation(chromeClient.screenInfo().rect, screenInfo.orientationAngle);
+ orientationType = computeOrientation(chromeClient.screenInfo().rect, effectiveAngle(chromeClient));
}
ASSERT(orientationType != WebScreenOrientationUndefined);
m_orientation->setType(orientationType);
- m_orientation->setAngle(screenInfo.orientationAngle);
+ m_orientation->setAngle(effectiveAngle(chromeClient));
}
bool ScreenOrientationController::isActiveAndVisible() const
@@ -106,7 +118,7 @@
// The orientation type and angle are tied in a way that if the angle has
// changed, the type must have changed.
- unsigned short currentAngle = frame()->host()->chromeClient().screenInfo().orientationAngle;
+ unsigned short currentAngle = effectiveAngle(frame()->host()->chromeClient());
// FIXME: sendOrientationChangeEvent() currently send an event all the
// children of the frame, so it should only be called on the frame on
@@ -170,6 +182,20 @@
m_client->unlockOrientation();
}
+void ScreenOrientationController::setOverride(WebScreenOrientationType type, unsigned short angle)
+{
+ m_override = true;
+ m_overrideType = type;
+ m_overrideAngle = angle;
+ notifyOrientationChanged();
+}
+
+void ScreenOrientationController::clearOverride()
+{
+ m_override = false;
+ notifyOrientationChanged();
+}
+
void ScreenOrientationController::dispatchEventTimerFired(Timer<ScreenOrientationController>*)
{
if (!m_orientation)

Powered by Google App Engine
This is Rietveld 408576698