Chromium Code Reviews| 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) |