Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: Source/modules/screen_orientation/ScreenOrientation.cpp

Issue 207833003: Update screen.orientation to follow the latest version of the specs. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@partial_enum_callback
Patch Set: ... and mac expected results Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 return *supplement; 117 return *supplement;
118 } 118 }
119 119
120 ScreenOrientation::~ScreenOrientation() 120 ScreenOrientation::~ScreenOrientation()
121 { 121 {
122 } 122 }
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 // FIXME: we should try to return a better guess, like the latest known value.
129 return orientationToString(blink::WebScreenOrientationPortraitPrimary);
130 }
129 ScreenOrientationController& controller = ScreenOrientationController::from( *screenOrientation.document()); 131 ScreenOrientationController& controller = ScreenOrientationController::from( *screenOrientation.document());
130 return orientationToString(controller.orientation()); 132 return orientationToString(controller.orientation());
131 } 133 }
132 134
133 bool ScreenOrientation::lockOrientation(Screen& screen, const AtomicString& orie ntationString) 135 bool ScreenOrientation::lockOrientation(Screen& screen, const AtomicString& orie ntationString)
134 { 136 {
135 blink::WebScreenOrientations orientations = stringToOrientations(orientation String); 137 blink::WebScreenOrientations orientations = stringToOrientations(orientation String);
136 if (!orientations) 138 if (!orientations)
137 return false; 139 return false;
138 ScreenOrientation::from(screen).lockOrientationAsync(orientations); 140 ScreenOrientation::from(screen).lockOrientationAsync(orientations);
139 return true; 141 return true;
140 } 142 }
141 143
142 void ScreenOrientation::unlockOrientation(Screen& screen) 144 void ScreenOrientation::unlockOrientation(Screen& screen)
143 { 145 {
144 ScreenOrientation::from(screen).lockOrientationAsync(WebScreenOrientationDef ault); 146 ScreenOrientation::from(screen).lockOrientationAsync(WebScreenOrientationDef ault);
145 } 147 }
146 148
147 } // namespace WebCore 149 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698