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

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

Issue 398003002: Add start/stop listening Platform methods for Screen Orientation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | public/platform/Platform.h » ('j') | public/platform/Platform.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
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
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
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
OLDNEW
« no previous file with comments | « no previous file | public/platform/Platform.h » ('j') | public/platform/Platform.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698