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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 ASSERT_NOT_REACHED(); | 82 ASSERT_NOT_REACHED(); |
83 return WebScreenOrientationLockDefault; | 83 return WebScreenOrientationLockDefault; |
84 } | 84 } |
85 | 85 |
86 // static | 86 // static |
87 ScreenOrientation* ScreenOrientation::create(LocalFrame* frame) | 87 ScreenOrientation* ScreenOrientation::create(LocalFrame* frame) |
88 { | 88 { |
89 ASSERT(frame); | 89 ASSERT(frame); |
90 | 90 |
| 91 // Check if the ScreenOrientationController is supported for the |
| 92 // frame. It will not be for all LocalFrames, or the frame may |
| 93 // have been detached. |
| 94 if (!ScreenOrientationController::from(*frame)) |
| 95 return nullptr; |
| 96 |
91 ScreenOrientation* orientation = new ScreenOrientation(frame); | 97 ScreenOrientation* orientation = new ScreenOrientation(frame); |
92 ASSERT(orientation->controller()); | 98 ASSERT(orientation->controller()); |
93 // FIXME: ideally, we would like to provide the ScreenOrientationController | 99 // FIXME: ideally, we would like to provide the ScreenOrientationController |
94 // the case where it is not defined but for the moment, it is eagerly | 100 // the case where it is not defined but for the moment, it is eagerly |
95 // created when the LocalFrame is created so we shouldn't be in that | 101 // created when the LocalFrame is created so we shouldn't be in that |
96 // situation. | 102 // situation. |
97 // In order to create the ScreenOrientationController lazily, we would need | 103 // In order to create the ScreenOrientationController lazily, we would need |
98 // to be able to access WebFrameClient from modules/. | 104 // to be able to access WebFrameClient from modules/. |
99 | 105 |
100 orientation->controller()->setOrientation(orientation); | 106 orientation->controller()->setOrientation(orientation); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 return ScreenOrientationController::from(*m_frame); | 189 return ScreenOrientationController::from(*m_frame); |
184 } | 190 } |
185 | 191 |
186 DEFINE_TRACE(ScreenOrientation) | 192 DEFINE_TRACE(ScreenOrientation) |
187 { | 193 { |
188 RefCountedGarbageCollectedEventTargetWithInlineData<ScreenOrientation>::trac
e(visitor); | 194 RefCountedGarbageCollectedEventTargetWithInlineData<ScreenOrientation>::trac
e(visitor); |
189 DOMWindowProperty::trace(visitor); | 195 DOMWindowProperty::trace(visitor); |
190 } | 196 } |
191 | 197 |
192 } // namespace blink | 198 } // namespace blink |
OLD | NEW |