Chromium Code Reviews| Index: Source/modules/screen_orientation/ScreenOrientationController.cpp |
| diff --git a/Source/modules/screen_orientation/ScreenOrientationController.cpp b/Source/modules/screen_orientation/ScreenOrientationController.cpp |
| index 9ea7c471dd53915318dc6d82c784382414c527a7..0d0a0d0396143418cf56f3a977e499a0db74149f 100644 |
| --- a/Source/modules/screen_orientation/ScreenOrientationController.cpp |
| +++ b/Source/modules/screen_orientation/ScreenOrientationController.cpp |
| @@ -5,6 +5,8 @@ |
| #include "config.h" |
| #include "modules/screen_orientation/ScreenOrientationController.h" |
| +#include "core/dom/Document.h" |
| +#include "core/dom/ExecutionContextTask.h" |
| #include "core/events/Event.h" |
| #include "core/frame/FrameView.h" |
| #include "core/frame/LocalFrame.h" |
| @@ -38,7 +40,7 @@ ScreenOrientationController::ScreenOrientationController(LocalFrame& frame, WebS |
| : LocalFrameLifecycleObserver(&frame) |
| , PlatformEventController(frame.page()) |
| , m_client(client) |
| - , m_dispatchEventTimer(this, &ScreenOrientationController::dispatchEventTimerFired) |
| + , m_isDispatchingEvent(false) |
| { |
| } |
| @@ -135,8 +137,12 @@ void ScreenOrientationController::notifyOrientationChanged() |
| } |
| // Notify current orientation object. |
| - if (!m_dispatchEventTimer.isActive()) |
| - m_dispatchEventTimer.startOneShot(0, FROM_HERE); |
| + if (!m_isDispatchingEvent) { |
| + if (Document* document = frame()->document()) { |
| + document->postTask(FROM_HERE, createSameThreadTask(&ScreenOrientationController::dispatchChangeEvent, this)); |
|
alex clarke (OOO till 29th)
2015/04/15 09:27:32
FYI the blink scheduler team are thinking of addin
|
| + m_isDispatchingEvent = true; |
| + } |
| + } |
| // ... and child frames, if they have a ScreenOrientationController. |
| for (size_t i = 0; i < childFrames.size(); ++i) { |
| @@ -169,8 +175,9 @@ void ScreenOrientationController::unlock() |
| m_client->unlockOrientation(); |
| } |
| -void ScreenOrientationController::dispatchEventTimerFired(Timer<ScreenOrientationController>*) |
| +void ScreenOrientationController::dispatchChangeEvent() |
| { |
| + m_isDispatchingEvent = false; |
| if (!m_orientation) |
| return; |
| m_orientation->dispatchEvent(Event::create(EventTypeNames::change)); |