OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "modules/screen_orientation/ScreenOrientation.h" | 6 #include "modules/screen_orientation/ScreenOrientation.h" |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 supplement = new ScreenOrientation(screen); | 109 supplement = new ScreenOrientation(screen); |
110 provideTo(screen, supplementName(), adoptPtrWillBeNoop(supplement)); | 110 provideTo(screen, supplementName(), adoptPtrWillBeNoop(supplement)); |
111 } | 111 } |
112 return *supplement; | 112 return *supplement; |
113 } | 113 } |
114 | 114 |
115 ScreenOrientation::~ScreenOrientation() | 115 ScreenOrientation::~ScreenOrientation() |
116 { | 116 { |
117 } | 117 } |
118 | 118 |
119 const AtomicString& ScreenOrientation::orientation(Screen& screen) | 119 OrientationInformation* ScreenOrientation::orientation(Screen& screen) |
120 { | 120 { |
121 ScreenOrientation& screenOrientation = ScreenOrientation::from(screen); | 121 ScreenOrientation& screenOrientation = ScreenOrientation::from(screen); |
122 if (!screenOrientation.frame()) { | 122 if (!screenOrientation.frame()) { |
123 // FIXME: we should try to return a better guess, like the latest known
value. | 123 return 0; |
124 return orientationTypeToString(blink::WebScreenOrientationPortraitPrimar
y); | |
125 } | 124 } |
126 ScreenOrientationController& controller = ScreenOrientationController::from(
*screenOrientation.frame()); | 125 return ScreenOrientationController::from(*screenOrientation.frame()).orienta
tion(); |
127 return orientationTypeToString(controller.orientation()); | |
128 } | 126 } |
129 | 127 |
130 ScriptPromise ScreenOrientation::lockOrientation(ScriptState* state, Screen& scr
een, const AtomicString& lockString) | 128 ScriptPromise ScreenOrientation::lockOrientation(ScriptState* state, Screen& scr
een, const AtomicString& lockString) |
131 { | 129 { |
132 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(state
); | 130 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(state
); |
133 ScriptPromise promise = resolver->promise(); | 131 ScriptPromise promise = resolver->promise(); |
134 | 132 |
135 ScreenOrientation& screenOrientation = ScreenOrientation::from(screen); | 133 ScreenOrientation& screenOrientation = ScreenOrientation::from(screen); |
136 Document* document = screenOrientation.document(); | 134 Document* document = screenOrientation.document(); |
137 | 135 |
(...skipping 16 matching lines...) Expand all Loading... |
154 void ScreenOrientation::unlockOrientation(Screen& screen) | 152 void ScreenOrientation::unlockOrientation(Screen& screen) |
155 { | 153 { |
156 ScreenOrientation& screenOrientation = ScreenOrientation::from(screen); | 154 ScreenOrientation& screenOrientation = ScreenOrientation::from(screen); |
157 if (!screenOrientation.frame()) | 155 if (!screenOrientation.frame()) |
158 return; | 156 return; |
159 | 157 |
160 ScreenOrientationController::from(*screenOrientation.frame()).unlockOrientat
ion(); | 158 ScreenOrientationController::from(*screenOrientation.frame()).unlockOrientat
ion(); |
161 } | 159 } |
162 | 160 |
163 } // namespace WebCore | 161 } // namespace WebCore |
OLD | NEW |