| Index: third_party/WebKit/Source/core/dom/Fullscreen.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/Fullscreen.cpp b/third_party/WebKit/Source/core/dom/Fullscreen.cpp
|
| index c168a417617edd87a6e25b1ce2aabfeda4e6ecce..acbd89c43566f47c868748fb13a61818abfb85ac 100644
|
| --- a/third_party/WebKit/Source/core/dom/Fullscreen.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/Fullscreen.cpp
|
| @@ -32,6 +32,7 @@
|
| #include "bindings/core/v8/ConditionalFeatures.h"
|
| #include "core/dom/Document.h"
|
| #include "core/dom/ElementTraversal.h"
|
| +#include "core/dom/FullscreenCallbacks.h"
|
| #include "core/dom/StyleEngine.h"
|
| #include "core/events/Event.h"
|
| #include "core/frame/HostsUsingFeatures.h"
|
| @@ -313,6 +314,36 @@ void Fullscreen::contextDestroyed() {
|
| m_fullscreenElementStack.clear();
|
| }
|
|
|
| +// RequestFullscreenCallbacks hold the data for a pending request.
|
| +// FullscreenController invokes the success or error callback.
|
| +class RequestFullscreenCallbacks final : public FullscreenCallbacks {
|
| + USING_FAST_MALLOC(RequestFullscreenCallbacks);
|
| + WTF_MAKE_NONCOPYABLE(RequestFullscreenCallbacks);
|
| +
|
| + public:
|
| + static std::unique_ptr<FullscreenCallbacks>
|
| + create(Document& document, Element& element, Fullscreen::RequestType type) {
|
| + return wrapUnique(new RequestFullscreenCallbacks(document, element, type));
|
| + }
|
| +
|
| + void onSuccess() override {
|
| + Fullscreen::from(*m_document).didEnterFullscreen(*m_element);
|
| + }
|
| +
|
| + void onError() override {
|
| + Fullscreen::from(*m_document).enqueueErrorEvent(*m_element, m_type);
|
| + }
|
| +
|
| + private:
|
| + RequestFullscreenCallbacks(Document& document,
|
| + Element& element,
|
| + Fullscreen::RequestType type)
|
| + : m_document(document), m_element(element), m_type(type) {}
|
| + Persistent<Document> m_document;
|
| + Persistent<Element> m_element;
|
| + Fullscreen::RequestType m_type;
|
| +};
|
| +
|
| // https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen
|
| void Fullscreen::requestFullscreen(Element& element,
|
| RequestType requestType,
|
| @@ -432,8 +463,9 @@ void Fullscreen::requestFullscreen(Element& element,
|
|
|
| // 5. Return, and run the remaining steps asynchronously.
|
| // 6. Optionally, perform some animation.
|
| - from(document).m_pendingFullscreenElement = &element;
|
| - document.frame()->chromeClient().enterFullscreen(*document.frame());
|
| + document.frame()->chromeClient().enterFullscreen(
|
| + *document.frame(),
|
| + RequestFullscreenCallbacks::create(document, element, requestType));
|
|
|
| // 7. Optionally, display a message indicating how the user can exit
|
| // displaying the context object fullscreen.
|
| @@ -562,8 +594,7 @@ void Fullscreen::exitFullscreen(Document& document) {
|
| }
|
|
|
| // Otherwise, enter fullscreen for the fullscreen element stack's top element.
|
| - from(document).m_pendingFullscreenElement = newTop;
|
| - from(document).didEnterFullscreen();
|
| + from(document).didEnterFullscreen(*newTop);
|
| }
|
|
|
| // https://fullscreen.spec.whatwg.org/#dom-document-fullscreenenabled
|
| @@ -575,8 +606,8 @@ bool Fullscreen::fullscreenEnabled(Document& document) {
|
| fullscreenIsSupported(document);
|
| }
|
|
|
| -void Fullscreen::didEnterFullscreen() {
|
| - if (!document()->isActive() || !document()->frame())
|
| +void Fullscreen::didEnterFullscreen(Element& element) {
|
| + if (!document() || !document()->isActive() || !document()->frame())
|
| return;
|
|
|
| // Start the timer for events enqueued by |requestFullscreen()|. The hover
|
| @@ -584,14 +615,10 @@ void Fullscreen::didEnterFullscreen() {
|
| document()->frame()->eventHandler().scheduleHoverStateUpdate();
|
| m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE);
|
|
|
| - Element* element = m_pendingFullscreenElement.release();
|
| - if (!element)
|
| - return;
|
| -
|
| - if (m_currentFullScreenElement == element)
|
| + if (m_currentFullScreenElement == &element)
|
| return;
|
|
|
| - if (!element->isConnected() || &element->document() != document()) {
|
| + if (!element.isConnected() || &element.document() != document()) {
|
| // The element was removed or has moved to another document since the
|
| // |requestFullscreen()| call. Exit fullscreen again to recover.
|
| // TODO(foolip): Fire a fullscreenerror event. This is currently difficult
|
| @@ -602,11 +629,14 @@ void Fullscreen::didEnterFullscreen() {
|
| return;
|
| }
|
|
|
| + if (m_currentFullScreenElement == &element)
|
| + return;
|
| +
|
| if (m_fullScreenLayoutObject)
|
| m_fullScreenLayoutObject->unwrapLayoutObject();
|
|
|
| Element* previousElement = m_currentFullScreenElement;
|
| - m_currentFullScreenElement = element;
|
| + m_currentFullScreenElement = &element;
|
|
|
| // Create a placeholder block for a the full-screen element, to keep the page
|
| // from reflowing when the element is removed from the normal flow. Only do
|
| @@ -650,11 +680,11 @@ void Fullscreen::didEnterFullscreen() {
|
| document()->updateStyleAndLayoutTree();
|
|
|
| document()->frame()->chromeClient().fullscreenElementChanged(previousElement,
|
| - element);
|
| + &element);
|
| }
|
|
|
| void Fullscreen::didExitFullscreen() {
|
| - if (!document()->isActive() || !document()->frame())
|
| + if (!document() || !document()->isActive() || !document()->frame())
|
| return;
|
|
|
| // Start the timer for events enqueued by |exitFullscreen()|. The hover state
|
| @@ -807,7 +837,6 @@ void Fullscreen::pushFullscreenElementStack(Element& element,
|
| }
|
|
|
| DEFINE_TRACE(Fullscreen) {
|
| - visitor->trace(m_pendingFullscreenElement);
|
| visitor->trace(m_fullscreenElementStack);
|
| visitor->trace(m_currentFullScreenElement);
|
| visitor->trace(m_eventQueue);
|
|
|