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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 return orientationMap[i].name; | 46 return orientationMap[i].name; |
47 } | 47 } |
48 // We do no handle OrientationInvalid and OrientationAny but this is fine be
cause screen.orientation | 48 // We do no handle OrientationInvalid and OrientationAny but this is fine be
cause screen.orientation |
49 // should never return these and WebScreenOrientation does not define those
values. | 49 // should never return these and WebScreenOrientation does not define those
values. |
50 ASSERT_NOT_REACHED(); | 50 ASSERT_NOT_REACHED(); |
51 return nullAtom; | 51 return nullAtom; |
52 } | 52 } |
53 | 53 |
54 static blink::WebScreenOrientations stringToOrientations(const AtomicString& ori
entationString) | 54 static blink::WebScreenOrientations stringToOrientations(const AtomicString& ori
entationString) |
55 { | 55 { |
| 56 DEFINE_STATIC_LOCAL(const AtomicString, any, ("any", AtomicString::Construct
FromLiteral)); |
56 DEFINE_STATIC_LOCAL(const AtomicString, portrait, ("portrait", AtomicString:
:ConstructFromLiteral)); | 57 DEFINE_STATIC_LOCAL(const AtomicString, portrait, ("portrait", AtomicString:
:ConstructFromLiteral)); |
57 DEFINE_STATIC_LOCAL(const AtomicString, landscape, ("landscape", AtomicStrin
g::ConstructFromLiteral)); | 58 DEFINE_STATIC_LOCAL(const AtomicString, landscape, ("landscape", AtomicStrin
g::ConstructFromLiteral)); |
58 | 59 |
| 60 if (orientationString == any) { |
| 61 return blink::WebScreenOrientationPortraitPrimary | blink::WebScreenOrie
ntationPortraitSecondary | |
| 62 blink::WebScreenOrientationLandscapePrimary | blink::WebScreenOrient
ationLandscapeSecondary; |
| 63 } |
59 if (orientationString == portrait) | 64 if (orientationString == portrait) |
60 return blink::WebScreenOrientationPortraitPrimary | blink::WebScreenOrie
ntationPortraitSecondary; | 65 return blink::WebScreenOrientationPortraitPrimary | blink::WebScreenOrie
ntationPortraitSecondary; |
61 if (orientationString == landscape) | 66 if (orientationString == landscape) |
62 return blink::WebScreenOrientationLandscapePrimary | blink::WebScreenOri
entationLandscapeSecondary; | 67 return blink::WebScreenOrientationLandscapePrimary | blink::WebScreenOri
entationLandscapeSecondary; |
63 | 68 |
64 unsigned length = 0; | 69 unsigned length = 0; |
65 ScreenOrientationInfo* orientationMap = orientationsMap(length); | 70 ScreenOrientationInfo* orientationMap = orientationsMap(length); |
66 for (unsigned i = 0; i < length; ++i) { | 71 for (unsigned i = 0; i < length; ++i) { |
67 if (orientationMap[i].name == orientationString) | 72 if (orientationMap[i].name == orientationString) |
68 return orientationMap[i].orientation; | 73 return orientationMap[i].orientation; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 ScreenOrientation::from(screen).lockOrientationAsync(orientations); | 145 ScreenOrientation::from(screen).lockOrientationAsync(orientations); |
141 return true; | 146 return true; |
142 } | 147 } |
143 | 148 |
144 void ScreenOrientation::unlockOrientation(Screen& screen) | 149 void ScreenOrientation::unlockOrientation(Screen& screen) |
145 { | 150 { |
146 ScreenOrientation::from(screen).lockOrientationAsync(WebScreenOrientationDef
ault); | 151 ScreenOrientation::from(screen).lockOrientationAsync(WebScreenOrientationDef
ault); |
147 } | 152 } |
148 | 153 |
149 } // namespace WebCore | 154 } // namespace WebCore |
OLD | NEW |