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" |
11 #include "core/dom/Document.h" | 11 #include "core/dom/Document.h" |
12 #include "core/dom/ExceptionCode.h" | 12 #include "core/dom/ExceptionCode.h" |
13 #include "core/frame/LocalFrame.h" | 13 #include "core/frame/LocalFrame.h" |
14 #include "modules/EventTargetModules.h" | 14 #include "modules/EventTargetModules.h" |
15 #include "modules/screen_orientation/LockOrientationCallback.h" | 15 #include "modules/screen_orientation/LockOrientationCallback.h" |
16 #include "modules/screen_orientation/ScreenOrientationController.h" | 16 #include "modules/screen_orientation/ScreenOrientationController.h" |
17 #include "public/platform/Platform.h" | |
17 #include "public/platform/WebScreenOrientationType.h" | 18 #include "public/platform/WebScreenOrientationType.h" |
18 | 19 |
19 // This code assumes that WebScreenOrientationType values are included in WebScr eenOrientationLockType. | 20 // This code assumes that WebScreenOrientationType values are included in WebScr eenOrientationLockType. |
20 #define COMPILE_ASSERT_MATCHING_ENUM(enum1, enum2) \ | 21 #define COMPILE_ASSERT_MATCHING_ENUM(enum1, enum2) \ |
21 COMPILE_ASSERT(static_cast<unsigned>(blink::enum1) == static_cast<unsigned>( blink::enum2), mismatching_types) | 22 COMPILE_ASSERT(static_cast<unsigned>(blink::enum1) == static_cast<unsigned>( blink::enum2), mismatching_types) |
22 COMPILE_ASSERT_MATCHING_ENUM(WebScreenOrientationPortraitPrimary, WebScreenOrien tationLockPortraitPrimary); | 23 COMPILE_ASSERT_MATCHING_ENUM(WebScreenOrientationPortraitPrimary, WebScreenOrien tationLockPortraitPrimary); |
23 COMPILE_ASSERT_MATCHING_ENUM(WebScreenOrientationPortraitSecondary, WebScreenOri entationLockPortraitSecondary); | 24 COMPILE_ASSERT_MATCHING_ENUM(WebScreenOrientationPortraitSecondary, WebScreenOri entationLockPortraitSecondary); |
24 COMPILE_ASSERT_MATCHING_ENUM(WebScreenOrientationLandscapePrimary, WebScreenOrie ntationLockLandscapePrimary); | 25 COMPILE_ASSERT_MATCHING_ENUM(WebScreenOrientationLandscapePrimary, WebScreenOrie ntationLockLandscapePrimary); |
25 COMPILE_ASSERT_MATCHING_ENUM(WebScreenOrientationLandscapeSecondary, WebScreenOr ientationLockLandscapeSecondary); | 26 COMPILE_ASSERT_MATCHING_ENUM(WebScreenOrientationLandscapeSecondary, WebScreenOr ientationLockLandscapeSecondary); |
26 | 27 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 orientation->controller()->setOrientation(orientation); | 101 orientation->controller()->setOrientation(orientation); |
101 return orientation; | 102 return orientation; |
102 } | 103 } |
103 | 104 |
104 ScreenOrientation::ScreenOrientation(LocalFrame* frame) | 105 ScreenOrientation::ScreenOrientation(LocalFrame* frame) |
105 : DOMWindowProperty(frame) | 106 : DOMWindowProperty(frame) |
106 , m_type(blink::WebScreenOrientationUndefined) | 107 , m_type(blink::WebScreenOrientationUndefined) |
107 , m_angle(0) | 108 , m_angle(0) |
108 { | 109 { |
109 ScriptWrappable::init(this); | 110 ScriptWrappable::init(this); |
111 | |
112 blink::Platform::current()->startScreenOrientationListening(); | |
110 } | 113 } |
111 | 114 |
112 ScreenOrientation::~ScreenOrientation() | 115 ScreenOrientation::~ScreenOrientation() |
113 { | 116 { |
117 blink::Platform::current()->stopScreenOrientationListening(); | |
Michael van Ouwerkerk
2014/07/17 10:36:27
Shouldn't this also be called when page visibility
| |
114 } | 118 } |
115 | 119 |
116 const WTF::AtomicString& ScreenOrientation::interfaceName() const | 120 const WTF::AtomicString& ScreenOrientation::interfaceName() const |
117 { | 121 { |
118 return EventTargetNames::ScreenOrientation; | 122 return EventTargetNames::ScreenOrientation; |
119 } | 123 } |
120 | 124 |
121 ExecutionContext* ScreenOrientation::executionContext() const | 125 ExecutionContext* ScreenOrientation::executionContext() const |
122 { | 126 { |
123 if (!m_frame) | 127 if (!m_frame) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 | 187 |
184 return ScreenOrientationController::from(*m_frame); | 188 return ScreenOrientationController::from(*m_frame); |
185 } | 189 } |
186 | 190 |
187 void ScreenOrientation::trace(Visitor* visitor) | 191 void ScreenOrientation::trace(Visitor* visitor) |
188 { | 192 { |
189 EventTargetWithInlineData::trace(visitor); | 193 EventTargetWithInlineData::trace(visitor); |
190 } | 194 } |
191 | 195 |
192 } // namespace WebCore | 196 } // namespace WebCore |
OLD | NEW |