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 030f37b40bfab05f500cbca80fb27e088fde4520..7c21265ad8bb4cb4274928c5306af854c0d99410 100644 |
--- a/third_party/WebKit/Source/core/dom/Fullscreen.cpp |
+++ b/third_party/WebKit/Source/core/dom/Fullscreen.cpp |
@@ -27,6 +27,7 @@ |
#include "core/dom/Fullscreen.h" |
+#include "bindings/core/v8/ExceptionMessages.h" |
#include "core/HTMLNames.h" |
#include "core/dom/Document.h" |
#include "core/dom/ElementTraversal.h" |
@@ -42,10 +43,9 @@ |
#include "core/html/HTMLMediaElement.h" |
#include "core/input/EventHandler.h" |
#include "core/inspector/ConsoleMessage.h" |
-#include "core/layout/LayoutBlockFlow.h" |
-#include "core/layout/LayoutFullScreen.h" |
-#include "core/layout/api/LayoutFullScreenItem.h" |
#include "core/page/ChromeClient.h" |
+#include "core/page/Page.h" |
+#include "core/style/ComputedStyle.h" |
#include "platform/UserGestureIndicator.h" |
namespace blink { |
@@ -196,7 +196,6 @@ bool Fullscreen::isFullScreen(Document& document) |
Fullscreen::Fullscreen(Document& document) |
: ContextLifecycleObserver(&document) |
- , m_fullScreenLayoutObject(nullptr) |
, m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired) |
, m_forCrossProcessAncestor(false) |
{ |
@@ -216,9 +215,6 @@ void Fullscreen::contextDestroyed() |
{ |
m_eventQueue.clear(); |
- if (m_fullScreenLayoutObject) |
- m_fullScreenLayoutObject->destroy(); |
- |
m_fullScreenElement = nullptr; |
m_fullScreenElementStack.clear(); |
@@ -486,31 +482,13 @@ bool Fullscreen::fullscreenEnabled(Document& document) |
void Fullscreen::didEnterFullScreenForElement(Element* element) |
{ |
DCHECK(element); |
+ DCHECK(element->isInTopLayer()); |
+ |
if (!document()->isActive()) |
return; |
- if (m_fullScreenLayoutObject) |
- m_fullScreenLayoutObject->unwrapLayoutObject(); |
- |
m_fullScreenElement = 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 this for a LayoutBox, as only |
- // a box will have a frameRect. The placeholder will be created in setFullScreenLayoutObject() |
- // during layout. |
- LayoutObject* layoutObject = m_fullScreenElement->layoutObject(); |
- bool shouldCreatePlaceholder = layoutObject && layoutObject->isBox(); |
- if (shouldCreatePlaceholder) { |
- m_savedPlaceholderFrameRect = toLayoutBox(layoutObject)->frameRect(); |
- m_savedPlaceholderComputedStyle = ComputedStyle::clone(layoutObject->styleRef()); |
- } |
- |
- // TODO(alexmos): When |m_forCrossProcessAncestor| is true, some of |
- // this layout work has already been done in another process, so it should |
- // not be necessary to repeat it here. |
- if (m_fullScreenElement != document()->documentElement()) |
- LayoutFullScreen::wrapLayoutObject(layoutObject, layoutObject ? layoutObject->parent() : 0, document()); |
- |
if (m_forCrossProcessAncestor) { |
DCHECK(m_fullScreenElement->isFrameOwnerElement()); |
DCHECK(toHTMLFrameOwnerElement(m_fullScreenElement)->contentFrame()->isRemoteFrame()); |
@@ -541,6 +519,7 @@ void Fullscreen::didExitFullScreenForElement() |
if (!document()->isActive()) |
return; |
+ document()->removeFromTopLayer(m_fullScreenElement.get()); |
m_fullScreenElement->willStopBeingFullscreenElement(); |
if (m_forCrossProcessAncestor) |
@@ -548,9 +527,7 @@ void Fullscreen::didExitFullScreenForElement() |
m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false); |
- if (m_fullScreenLayoutObject) |
- LayoutFullScreenItem(m_fullScreenLayoutObject).unwrapLayoutObject(); |
- |
+ // TODO(foolip): redundant with something the top layer machinery does? |
document()->styleEngine().ensureFullscreenUAStyle(); |
m_fullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen); |
m_fullScreenElement = nullptr; |
@@ -570,28 +547,12 @@ void Fullscreen::didExitFullScreenForElement() |
m_forCrossProcessAncestor = false; |
} |
-void Fullscreen::setFullScreenLayoutObject(LayoutFullScreen* layoutObject) |
-{ |
- if (layoutObject == m_fullScreenLayoutObject) |
- return; |
- |
- if (layoutObject && m_savedPlaceholderComputedStyle) { |
- layoutObject->createPlaceholder(m_savedPlaceholderComputedStyle.release(), m_savedPlaceholderFrameRect); |
- } else if (layoutObject && m_fullScreenLayoutObject && m_fullScreenLayoutObject->placeholder()) { |
- LayoutBlockFlow* placeholder = m_fullScreenLayoutObject->placeholder(); |
- layoutObject->createPlaceholder(ComputedStyle::clone(placeholder->styleRef()), placeholder->frameRect()); |
- } |
- |
- if (m_fullScreenLayoutObject) |
- m_fullScreenLayoutObject->unwrapLayoutObject(); |
- DCHECK(!m_fullScreenLayoutObject); |
- |
- m_fullScreenLayoutObject = layoutObject; |
-} |
- |
-void Fullscreen::fullScreenLayoutObjectDestroyed() |
+void Fullscreen::didUpdateSize(Element& element) |
{ |
- m_fullScreenLayoutObject = nullptr; |
+ // StyleAdjuster will set the size so we need to do a style recalc. |
+ // Normally changing size means layout so just doing a style recalc is a |
+ // bit surprising. |
+ element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::FullScreen)); |
} |
void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) |
@@ -676,12 +637,14 @@ void Fullscreen::popFullscreenElementStack() |
if (m_fullScreenElementStack.isEmpty()) |
return; |
+ document()->removeFromTopLayer(m_fullScreenElementStack.last().first.get()); |
m_fullScreenElementStack.removeLast(); |
} |
void Fullscreen::pushFullscreenElementStack(Element& element, RequestType requestType) |
{ |
m_fullScreenElementStack.append(std::make_pair(&element, requestType)); |
+ document()->addToTopLayer(&element); |
} |
DEFINE_TRACE(Fullscreen) |