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 "core/frame/DOMWindow.h" | 8 #include "core/frame/DOMWindow.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "core/frame/Screen.h" | 10 #include "core/frame/Screen.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 const AtomicString& ScreenOrientation::orientation(Screen& screen) | 124 const AtomicString& ScreenOrientation::orientation(Screen& screen) |
125 { | 125 { |
126 ScreenOrientation& screenOrientation = ScreenOrientation::from(screen); | 126 ScreenOrientation& screenOrientation = ScreenOrientation::from(screen); |
127 if (!screenOrientation.document()) | 127 if (!screenOrientation.document()) |
128 return emptyAtom; | 128 return emptyAtom; |
129 ScreenOrientationController& controller = ScreenOrientationController::from(
*screenOrientation.document()); | 129 ScreenOrientationController& controller = ScreenOrientationController::from(
*screenOrientation.document()); |
130 return orientationToString(controller.orientation()); | 130 return orientationToString(controller.orientation()); |
131 } | 131 } |
132 | 132 |
133 bool ScreenOrientation::lockOrientation(Screen& screen, const Vector<String>& or
ientationsVector) | |
134 { | |
135 blink::WebScreenOrientations orientations = 0; | |
136 for (size_t i = 0; i < orientationsVector.size(); ++i) { | |
137 blink::WebScreenOrientations currentOrientation = stringToOrientations(A
tomicString(orientationsVector[i])); | |
138 if (!currentOrientation) | |
139 return false; | |
140 orientations |= currentOrientation; | |
141 } | |
142 if (!orientations) | |
143 return false; | |
144 ScreenOrientation::from(screen).lockOrientationAsync(orientations); | |
145 return true; | |
146 } | |
147 | |
148 bool ScreenOrientation::lockOrientation(Screen& screen, const AtomicString& orie
ntationString) | 133 bool ScreenOrientation::lockOrientation(Screen& screen, const AtomicString& orie
ntationString) |
149 { | 134 { |
150 blink::WebScreenOrientations orientations = stringToOrientations(orientation
String); | 135 blink::WebScreenOrientations orientations = stringToOrientations(orientation
String); |
151 if (!orientations) | 136 if (!orientations) |
152 return false; | 137 return false; |
153 ScreenOrientation::from(screen).lockOrientationAsync(orientations); | 138 ScreenOrientation::from(screen).lockOrientationAsync(orientations); |
154 return true; | 139 return true; |
155 } | 140 } |
156 | 141 |
157 void ScreenOrientation::unlockOrientation(Screen& screen) | 142 void ScreenOrientation::unlockOrientation(Screen& screen) |
158 { | 143 { |
159 ScreenOrientation::from(screen).lockOrientationAsync(WebScreenOrientationDef
ault); | 144 ScreenOrientation::from(screen).lockOrientationAsync(WebScreenOrientationDef
ault); |
160 } | 145 } |
161 | 146 |
162 } // namespace WebCore | 147 } // namespace WebCore |
OLD | NEW |