Chromium Code Reviews| Index: Source/modules/screen_orientation/ScreenOrientation.cpp |
| diff --git a/Source/modules/screen_orientation/ScreenOrientation.cpp b/Source/modules/screen_orientation/ScreenOrientation.cpp |
| index 504fda15eaa2df75458e48db0fe92d019ee14df8..d16efd4523ade3db22ccb8c6b65e61d42b21d01a 100644 |
| --- a/Source/modules/screen_orientation/ScreenOrientation.cpp |
| +++ b/Source/modules/screen_orientation/ScreenOrientation.cpp |
| @@ -13,9 +13,9 @@ |
| #include "core/frame/DOMWindow.h" |
| #include "core/frame/LocalFrame.h" |
| #include "core/frame/Screen.h" |
| +#include "core/page/Page.h" |
| #include "modules/screen_orientation/LockOrientationCallback.h" |
| #include "modules/screen_orientation/ScreenOrientationController.h" |
| -#include "public/platform/Platform.h" |
| #include "public/platform/WebScreenOrientationType.h" |
| // This code assumes that WebScreenOrientationType values are included in WebScreenOrientationLockType. |
| @@ -101,6 +101,12 @@ Document* ScreenOrientation::document() const |
| return m_associatedDOMWindow->document(); |
| } |
| +Page* ScreenOrientation::page() const |
| +{ |
| + ASSERT(document()->page()); |
|
Inactive
2014/06/03 18:04:53
This seems unsafe. We should probably return 0 if
mlamouri (slow - plz ping)
2014/06/03 19:49:30
Done.
|
| + return document()->page(); |
|
Inactive
2014/06/03 18:04:53
We should be able to use frame()->page() since thi
mlamouri (slow - plz ping)
2014/06/03 19:49:30
Done.
|
| +} |
| + |
| ScreenOrientation& ScreenOrientation::from(Screen& screen) |
| { |
| ScreenOrientation* supplement = static_cast<ScreenOrientation*>(WillBeHeapSupplement<Screen>::from(screen, supplementName())); |
| @@ -122,7 +128,7 @@ const AtomicString& ScreenOrientation::orientation(Screen& screen) |
| // FIXME: we should try to return a better guess, like the latest known value. |
| return orientationTypeToString(blink::WebScreenOrientationPortraitPrimary); |
| } |
| - ScreenOrientationController& controller = ScreenOrientationController::from(*screenOrientation.document()); |
| + ScreenOrientationController& controller = ScreenOrientationController::from(*screenOrientation.page()); |
| return orientationTypeToString(controller.orientation()); |
| } |
| @@ -146,13 +152,17 @@ ScriptPromise ScreenOrientation::lockOrientation(ScriptState* state, Screen& scr |
| return promise; |
| } |
| - blink::Platform::current()->lockOrientation(stringToOrientationLock(lockString), new LockOrientationCallback(resolver)); |
| + ScreenOrientationController::from(*document->page()).lockOrientation(stringToOrientationLock(lockString), new LockOrientationCallback(resolver)); |
|
Inactive
2014/06/03 18:04:53
I think it is possible for page() to return null i
mlamouri (slow - plz ping)
2014/06/03 19:49:30
Done.
|
| return promise; |
| } |
| void ScreenOrientation::unlockOrientation(Screen& screen) |
| { |
| - blink::Platform::current()->unlockOrientation(); |
| + ScreenOrientation& screenOrientation = ScreenOrientation::from(screen); |
| + if (!screenOrientation.page()) |
|
Inactive
2014/06/03 18:04:53
That method currently has an assertion making sure
mlamouri (slow - plz ping)
2014/06/03 19:49:30
Done.
|
| + return; |
| + |
| + ScreenOrientationController::from(*screenOrientation.page()).unlockOrientation(); |
| } |
| } // namespace WebCore |