| Index: third_party/WebKit/Source/web/FullscreenController.cpp
|
| diff --git a/third_party/WebKit/Source/web/FullscreenController.cpp b/third_party/WebKit/Source/web/FullscreenController.cpp
|
| index c139da43cda4d5410e0653d25ccd86930ec70feb..fd9b2dbbc6af7911d4d8593027b08c202022ba72 100644
|
| --- a/third_party/WebKit/Source/web/FullscreenController.cpp
|
| +++ b/third_party/WebKit/Source/web/FullscreenController.cpp
|
| @@ -32,6 +32,7 @@
|
|
|
| #include "core/dom/Document.h"
|
| #include "core/dom/Fullscreen.h"
|
| +#include "core/dom/FullscreenCallbacks.h"
|
| #include "core/frame/FrameView.h"
|
| #include "core/frame/LocalFrame.h"
|
| #include "core/frame/PageScaleConstraintsSet.h"
|
| @@ -78,16 +79,11 @@ void FullscreenController::didEnterFullscreen() {
|
|
|
| m_state = State::Fullscreen;
|
|
|
| - // Notify all local frames that we have entered fullscreen.
|
| - for (Frame* frame = m_webViewImpl->page()->mainFrame(); frame;
|
| - frame = frame->tree().traverseNext()) {
|
| - if (!frame->isLocalFrame())
|
| - continue;
|
| - if (Document* document = toLocalFrame(frame)->document()) {
|
| - if (Fullscreen* fullscreen = Fullscreen::fromIfExists(*document))
|
| - fullscreen->didEnterFullscreen();
|
| - }
|
| - }
|
| + DCHECK(!m_callbacksList.isEmpty());
|
| + CallbacksList callbacksList;
|
| + callbacksList.swap(m_callbacksList);
|
| + for (auto& callbacks : callbacksList)
|
| + callbacks->onSuccess();
|
| }
|
|
|
| void FullscreenController::didExitFullscreen() {
|
| @@ -107,6 +103,17 @@ void FullscreenController::didExitFullscreen() {
|
| // with animation frames. https://crbug.com/402376
|
| m_state = State::ExitingFullscreen;
|
|
|
| + // If we were transitioning into fullscreen, invoke the error callbacks.
|
| + if (m_state == State::EnteringFullscreen) {
|
| + DCHECK(!m_callbacksList.isEmpty());
|
| + CallbacksList callbacksList;
|
| + callbacksList.swap(m_callbacksList);
|
| + for (auto& callbacks : callbacksList)
|
| + callbacks->onError();
|
| + } else {
|
| + DCHECK(m_callbacksList.isEmpty());
|
| + }
|
| +
|
| // Notify all local frames that we have exited fullscreen.
|
| // TODO(foolip): This should only need to notify the topmost local roots. That
|
| // doesn't currently work because |Fullscreen::m_currentFullScreenElement|
|
| @@ -129,14 +136,16 @@ void FullscreenController::didExitFullscreen() {
|
| m_state = State::NeedsScrollAndScaleRestore;
|
| }
|
|
|
| -void FullscreenController::enterFullscreen(LocalFrame& frame) {
|
| - // If already fullscreen or exiting fullscreen, synchronously call
|
| - // |didEnterFullscreen()|. When exiting, the coming |didExitFullscren()| call
|
| - // will again notify all frames.
|
| +void FullscreenController::enterFullscreen(
|
| + LocalFrame& frame,
|
| + std::unique_ptr<FullscreenCallbacks> callbacks) {
|
| + // If already fullscreen or exiting fullscreen, synchronously invoke the
|
| + // success callback. When exiting, the coming |didExitFullscren()| call will
|
| + // again notify all frames.
|
| if (m_state == State::Fullscreen || m_state == State::ExitingFullscreen) {
|
| State oldState = m_state;
|
| m_state = State::EnteringFullscreen;
|
| - didEnterFullscreen();
|
| + callbacks->onSuccess();
|
| m_state = oldState;
|
| return;
|
| }
|
| @@ -154,6 +163,8 @@ void FullscreenController::enterFullscreen(LocalFrame& frame) {
|
| m_initialVisualViewportOffset = m_webViewImpl->visualViewportOffset();
|
| }
|
|
|
| + m_callbacksList.append(std::move(callbacks));
|
| +
|
| // If already entering fullscreen, just wait.
|
| if (m_state == State::EnteringFullscreen)
|
| return;
|
|
|