| 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 "modules/screen_orientation/ScreenOrientationController.h" | 5 #include "modules/screen_orientation/ScreenOrientationController.h" |
| 6 | 6 |
| 7 #include "core/events/Event.h" | 7 #include "core/events/Event.h" |
| 8 #include "core/frame/FrameHost.h" | 8 #include "core/frame/FrameHost.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| 11 #include "core/page/ChromeClient.h" | 11 #include "core/page/ChromeClient.h" |
| 12 #include "core/page/Page.h" | 12 #include "core/page/Page.h" |
| 13 #include "modules/screen_orientation/ScreenOrientation.h" | 13 #include "modules/screen_orientation/ScreenOrientation.h" |
| 14 #include "modules/screen_orientation/ScreenOrientationDispatcher.h" | 14 #include "modules/screen_orientation/ScreenOrientationDispatcher.h" |
| 15 #include "platform/LayoutTestSupport.h" | 15 #include "platform/LayoutTestSupport.h" |
| 16 #include "public/platform/WebScreenInfo.h" | 16 #include "public/platform/WebScreenInfo.h" |
| 17 #include "public/platform/modules/screen_orientation/WebScreenOrientationClient.
h" | 17 #include "public/platform/modules/screen_orientation/WebScreenOrientationClient.
h" |
| 18 | 18 |
| 19 namespace blink { | 19 namespace blink { |
| 20 | 20 |
| 21 ScreenOrientationController::~ScreenOrientationController() | 21 ScreenOrientationController::~ScreenOrientationController() |
| 22 { | 22 { |
| 23 } | 23 } |
| 24 | 24 |
| 25 void ScreenOrientationController::provideTo(LocalFrame& frame, WebScreenOrientat
ionClient* client) | 25 void ScreenOrientationController::provideTo(LocalFrame& frame, WebScreenOrientat
ionClient* client) |
| 26 { | 26 { |
| 27 ASSERT(RuntimeEnabledFeatures::screenOrientationEnabled()); | 27 ASSERT(RuntimeEnabledFeatures::screenOrientationEnabled()); |
| 28 | 28 |
| 29 ScreenOrientationController* controller = new ScreenOrientationController(fr
ame, client); | 29 ScreenOrientationController* controller = new ScreenOrientationController(fr
ame, client); |
| 30 WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), adoptPt
rWillBeNoop(controller)); | 30 HeapSupplement<LocalFrame>::provideTo(frame, supplementName(), (controller))
; |
| 31 } | 31 } |
| 32 | 32 |
| 33 ScreenOrientationController* ScreenOrientationController::from(LocalFrame& frame
) | 33 ScreenOrientationController* ScreenOrientationController::from(LocalFrame& frame
) |
| 34 { | 34 { |
| 35 return static_cast<ScreenOrientationController*>(WillBeHeapSupplement<LocalF
rame>::from(frame, supplementName())); | 35 return static_cast<ScreenOrientationController*>(HeapSupplement<LocalFrame>:
:from(frame, supplementName())); |
| 36 } | 36 } |
| 37 | 37 |
| 38 ScreenOrientationController::ScreenOrientationController(LocalFrame& frame, WebS
creenOrientationClient* client) | 38 ScreenOrientationController::ScreenOrientationController(LocalFrame& frame, WebS
creenOrientationClient* client) |
| 39 : LocalFrameLifecycleObserver(&frame) | 39 : LocalFrameLifecycleObserver(&frame) |
| 40 , PlatformEventController(frame.page()) | 40 , PlatformEventController(frame.page()) |
| 41 , m_client(client) | 41 , m_client(client) |
| 42 , m_dispatchEventTimer(this, &ScreenOrientationController::dispatchEventTime
rFired) | 42 , m_dispatchEventTimer(this, &ScreenOrientationController::dispatchEventTime
rFired) |
| 43 , m_override(false) | 43 , m_override(false) |
| 44 , m_overrideType(WebScreenOrientationUndefined) | 44 , m_overrideType(WebScreenOrientationUndefined) |
| 45 , m_overrideAngle(0) | 45 , m_overrideAngle(0) |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 ASSERT(RuntimeEnabledFeatures::screenOrientationEnabled()); | 134 ASSERT(RuntimeEnabledFeatures::screenOrientationEnabled()); |
| 135 | 135 |
| 136 if (!isActiveAndVisible()) | 136 if (!isActiveAndVisible()) |
| 137 return; | 137 return; |
| 138 | 138 |
| 139 updateOrientation(); | 139 updateOrientation(); |
| 140 | 140 |
| 141 // Keep track of the frames that need to be notified before notifying the | 141 // Keep track of the frames that need to be notified before notifying the |
| 142 // current frame as it will prevent side effects from the change event | 142 // current frame as it will prevent side effects from the change event |
| 143 // handlers. | 143 // handlers. |
| 144 WillBeHeapVector<RefPtrWillBeMember<LocalFrame>> childFrames; | 144 HeapVector<Member<LocalFrame>> childFrames; |
| 145 for (Frame* child = frame()->tree().firstChild(); child; child = child->tree
().nextSibling()) { | 145 for (Frame* child = frame()->tree().firstChild(); child; child = child->tree
().nextSibling()) { |
| 146 if (child->isLocalFrame()) | 146 if (child->isLocalFrame()) |
| 147 childFrames.append(toLocalFrame(child)); | 147 childFrames.append(toLocalFrame(child)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 // Notify current orientation object. | 150 // Notify current orientation object. |
| 151 if (!m_dispatchEventTimer.isActive()) | 151 if (!m_dispatchEventTimer.isActive()) |
| 152 m_dispatchEventTimer.startOneShot(0, BLINK_FROM_HERE); | 152 m_dispatchEventTimer.startOneShot(0, BLINK_FROM_HERE); |
| 153 | 153 |
| 154 // ... and child frames, if they have a ScreenOrientationController. | 154 // ... and child frames, if they have a ScreenOrientationController. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 if (m_orientation && page()->isPageVisible()) | 233 if (m_orientation && page()->isPageVisible()) |
| 234 startUpdating(); | 234 startUpdating(); |
| 235 else | 235 else |
| 236 stopUpdating(); | 236 stopUpdating(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 DEFINE_TRACE(ScreenOrientationController) | 239 DEFINE_TRACE(ScreenOrientationController) |
| 240 { | 240 { |
| 241 visitor->trace(m_orientation); | 241 visitor->trace(m_orientation); |
| 242 LocalFrameLifecycleObserver::trace(visitor); | 242 LocalFrameLifecycleObserver::trace(visitor); |
| 243 WillBeHeapSupplement<LocalFrame>::trace(visitor); | 243 HeapSupplement<LocalFrame>::trace(visitor); |
| 244 PlatformEventController::trace(visitor); | 244 PlatformEventController::trace(visitor); |
| 245 } | 245 } |
| 246 | 246 |
| 247 } // namespace blink | 247 } // namespace blink |
| OLD | NEW |