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

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

Issue 1195793008: [DevTools] Implement screen orientation override. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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: Source/modules/screen_orientation/ScreenOrientationController.cpp
diff --git a/Source/modules/screen_orientation/ScreenOrientationController.cpp b/Source/modules/screen_orientation/ScreenOrientationController.cpp
index 0820474f073e7db10f66ec4a4058887cf10b4a33..873d3bf9a600716cba65c336626aeca0519d5ffe 100644
--- a/Source/modules/screen_orientation/ScreenOrientationController.cpp
+++ b/Source/modules/screen_orientation/ScreenOrientationController.cpp
@@ -41,6 +41,9 @@ ScreenOrientationController::ScreenOrientationController(LocalFrame& frame, WebS
, PlatformEventController(frame.page())
, m_client(client)
, m_dispatchEventTimer(this, &ScreenOrientationController::dispatchEventTimerFired)
+ , m_override(false)
+ , m_overrideType(WebScreenOrientationUndefined)
+ , m_overrideAngle(0)
{
}
@@ -83,7 +86,8 @@ void ScreenOrientationController::updateOrientation()
ASSERT(frame()->host());
ChromeClient& chromeClient = frame()->host()->chromeClient();
- WebScreenOrientationType orientationType = chromeClient.screenInfo().orientationType;
+ unsigned short orientationAngle = m_override ? m_overrideAngle : chromeClient.screenInfo().orientationAngle;
+ WebScreenOrientationType orientationType = m_override ? m_overrideType : chromeClient.screenInfo().orientationType;
if (orientationType == WebScreenOrientationUndefined) {
// The embedder could not provide us with an orientation, deduce it ourselves.
orientationType = computeOrientation(chromeClient);
@@ -91,7 +95,7 @@ void ScreenOrientationController::updateOrientation()
ASSERT(orientationType != WebScreenOrientationUndefined);
m_orientation->setType(orientationType);
- m_orientation->setAngle(chromeClient.screenInfo().orientationAngle);
+ m_orientation->setAngle(orientationAngle);
}
bool ScreenOrientationController::isActiveAndVisible() const
@@ -108,7 +112,7 @@ void ScreenOrientationController::pageVisibilityChanged()
// 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 = m_override ? m_overrideAngle : frame()->host()->chromeClient().screenInfo().orientationAngle;
mlamouri (slow - plz ping) 2015/06/24 16:51:06 nit: could you have in internal method that does t
dgozman 2015/06/25 12:21:26 Done.
// FIXME: sendOrientationChangeEvent() currently send an event all the
// children of the frame, so it should only be called on the frame on
@@ -172,6 +176,20 @@ void ScreenOrientationController::unlock()
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