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

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

Issue 879423003: Move Location to DOMWindow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
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 "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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 { 112 {
113 } 113 }
114 114
115 const WTF::AtomicString& ScreenOrientation::interfaceName() const 115 const WTF::AtomicString& ScreenOrientation::interfaceName() const
116 { 116 {
117 return EventTargetNames::ScreenOrientation; 117 return EventTargetNames::ScreenOrientation;
118 } 118 }
119 119
120 ExecutionContext* ScreenOrientation::executionContext() const 120 ExecutionContext* ScreenOrientation::executionContext() const
121 { 121 {
122 if (!m_frame) 122 if (!localFrame())
123 return 0; 123 return 0;
124 return m_frame->document(); 124 return localFrame()->document();
125 } 125 }
126 126
127 String ScreenOrientation::type() const 127 String ScreenOrientation::type() const
128 { 128 {
129 return orientationTypeToString(m_type); 129 return orientationTypeToString(m_type);
130 } 130 }
131 131
132 unsigned short ScreenOrientation::angle() const 132 unsigned short ScreenOrientation::angle() const
133 { 133 {
134 return m_angle; 134 return m_angle;
135 } 135 }
136 136
137 void ScreenOrientation::setType(WebScreenOrientationType type) 137 void ScreenOrientation::setType(WebScreenOrientationType type)
138 { 138 {
139 m_type = type; 139 m_type = type;
140 } 140 }
141 141
142 void ScreenOrientation::setAngle(unsigned short angle) 142 void ScreenOrientation::setAngle(unsigned short angle)
143 { 143 {
144 m_angle = angle; 144 m_angle = angle;
145 } 145 }
146 146
147 ScriptPromise ScreenOrientation::lock(ScriptState* state, const AtomicString& lo ckString) 147 ScriptPromise ScreenOrientation::lock(ScriptState* state, const AtomicString& lo ckString)
148 { 148 {
149 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(state); 149 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(state);
150 ScriptPromise promise = resolver->promise(); 150 ScriptPromise promise = resolver->promise();
151 151
152 Document* document = m_frame ? m_frame->document() : 0; 152 Document* document = localFrame() ? localFrame()->document() : 0;
153 153
154 if (!document || !controller()) { 154 if (!document || !controller()) {
155 RefPtrWillBeRawPtr<DOMException> exception = DOMException::create(Invali dStateError, "The object is no longer associated to a document."); 155 RefPtrWillBeRawPtr<DOMException> exception = DOMException::create(Invali dStateError, "The object is no longer associated to a document.");
156 resolver->reject(exception); 156 resolver->reject(exception);
157 return promise; 157 return promise;
158 } 158 }
159 159
160 if (document->isSandboxed(SandboxOrientationLock)) { 160 if (document->isSandboxed(SandboxOrientationLock)) {
161 RefPtrWillBeRawPtr<DOMException> exception = DOMException::create(Securi tyError, "The document is sandboxed and lacks the 'allow-orientation-lock' flag. "); 161 RefPtrWillBeRawPtr<DOMException> exception = DOMException::create(Securi tyError, "The document is sandboxed and lacks the 'allow-orientation-lock' flag. ");
162 resolver->reject(exception); 162 resolver->reject(exception);
163 return promise; 163 return promise;
164 } 164 }
165 165
166 controller()->lock(stringToOrientationLock(lockString), new LockOrientationC allback(resolver)); 166 controller()->lock(stringToOrientationLock(lockString), new LockOrientationC allback(resolver));
167 return promise; 167 return promise;
168 } 168 }
169 169
170 void ScreenOrientation::unlock() 170 void ScreenOrientation::unlock()
171 { 171 {
172 if (!controller()) 172 if (!controller())
173 return; 173 return;
174 174
175 controller()->unlock(); 175 controller()->unlock();
176 } 176 }
177 177
178 ScreenOrientationController* ScreenOrientation::controller() 178 ScreenOrientationController* ScreenOrientation::controller()
179 { 179 {
180 if (!m_frame) 180 if (!localFrame())
181 return 0; 181 return 0;
182 182
183 return ScreenOrientationController::from(*m_frame); 183 return ScreenOrientationController::from(*localFrame());
184 } 184 }
185 185
186 void ScreenOrientation::trace(Visitor* visitor) 186 void ScreenOrientation::trace(Visitor* visitor)
187 { 187 {
188 RefCountedGarbageCollectedEventTargetWithInlineData<ScreenOrientation>::trac e(visitor); 188 RefCountedGarbageCollectedEventTargetWithInlineData<ScreenOrientation>::trac e(visitor);
189 DOMWindowProperty::trace(visitor); 189 DOMWindowProperty::trace(visitor);
190 } 190 }
191 191
192 } // namespace blink 192 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698