Diff
Modified: branches/safari-608-branch/LayoutTests/ChangeLog (249166 => 249167)
--- branches/safari-608-branch/LayoutTests/ChangeLog 2019-08-27 20:24:00 UTC (rev 249166)
+++ branches/safari-608-branch/LayoutTests/ChangeLog 2019-08-27 21:01:04 UTC (rev 249167)
@@ -1,3 +1,7 @@
+2019-08-27 Alan Coon <alanc...@apple.com>
+
+ Revert r249147. rdar://problem/54751753
+
2019-08-27 Ryan Haddad <ryanhad...@apple.com>
Cherry-pick r249157. rdar://problem/53829560
Deleted: branches/safari-608-branch/LayoutTests/fullscreen/full-screen-request-removed-with-raf-expected.txt (249166 => 249167)
--- branches/safari-608-branch/LayoutTests/fullscreen/full-screen-request-removed-with-raf-expected.txt 2019-08-27 20:24:00 UTC (rev 249166)
+++ branches/safari-608-branch/LayoutTests/fullscreen/full-screen-request-removed-with-raf-expected.txt 2019-08-27 21:01:04 UTC (rev 249167)
@@ -1,7 +0,0 @@
-Tests that fullscreen is not entered if the fullscreen element ancestor is removed with rAF while entering fullscreen.
-
-Removed child element.
-
-SUCCESS
-END OF TEST
-
Deleted: branches/safari-608-branch/LayoutTests/fullscreen/full-screen-request-removed-with-raf.html (249166 => 249167)
--- branches/safari-608-branch/LayoutTests/fullscreen/full-screen-request-removed-with-raf.html 2019-08-27 20:24:00 UTC (rev 249166)
+++ branches/safari-608-branch/LayoutTests/fullscreen/full-screen-request-removed-with-raf.html 2019-08-27 21:01:04 UTC (rev 249167)
@@ -1,43 +0,0 @@
-
-<script src=""
-<script>
-
- window.addEventListener('load', (ev) => {
- var target = document.querySelector('#target');
-
- document.addEventListener('webkitfullscreenchange', (ev) => {
- if (document.webkitCurrentFullScreenElement && !document.webkitCurrentFullScreenElement.ownerDocument)
- consoleWrite("FAIL: document.webkitCurrentFullScreenElement.ownerDocument is NULL!");
- else
- consoleWrite("SUCCESS");
-
- document.webkitExitFullscreen();
- endTest();
- }, {once: true});
-
- document.addEventListener('webkitfullscreenerror', (ev) => {
- consoleWrite("SUCCESS");
- endTest();
- }, {once: true});
-
- function test()
- {
- target.webkitRequestFullScreen();
- window.requestAnimationFrame(() => {
- consoleWrite("Removed child element.");
- target.parentNode.removeChild(target);
- consoleWrite("");
- });
- }
-
- runWithKeyDown(test);
- });
-
-</script>
-
-<p>Tests that fullscreen is not entered if the fullscreen element ancestor is removed with rAF while entering fullscreen.</p>
-
-<div id=ancestor>
- <span id=target>Fullscreen target!</span>
-</div>
-
Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (249166 => 249167)
--- branches/safari-608-branch/Source/WebCore/ChangeLog 2019-08-27 20:24:00 UTC (rev 249166)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog 2019-08-27 21:01:04 UTC (rev 249167)
@@ -1,5 +1,9 @@
2019-08-27 Alan Coon <alanc...@apple.com>
+ Revert r249147. rdar://problem/54751753
+
+2019-08-27 Alan Coon <alanc...@apple.com>
+
Cherry-pick r249147. rdar://problem/54751753
Removing fullscreen element in rAF() callback after requestFullscreen() can leave fullscreen in inconsistent state.
Modified: branches/safari-608-branch/Source/WebCore/dom/FullscreenManager.cpp (249166 => 249167)
--- branches/safari-608-branch/Source/WebCore/dom/FullscreenManager.cpp 2019-08-27 20:24:00 UTC (rev 249166)
+++ branches/safari-608-branch/Source/WebCore/dom/FullscreenManager.cpp 2019-08-27 21:01:04 UTC (rev 249167)
@@ -120,16 +120,7 @@
}
}
- m_pendingFullscreenElement = element;
-
m_fullscreenTaskQueue.enqueueTask([this, element = makeRefPtr(element), checkType, hasKeyboardAccess, failedPreflights] () mutable {
- // Don't allow fullscreen if it has been cancelled or a different fullscreen element
- // has requested fullscreen.
- if (m_pendingFullscreenElement != element) {
- failedPreflights(WTFMove(element));
- return;
- }
-
// Don't allow fullscreen if document is hidden.
if (document().hidden()) {
failedPreflights(WTFMove(element));
@@ -218,13 +209,9 @@
// 5. Return, and run the remaining steps asynchronously.
// 6. Optionally, perform some animation.
m_areKeysEnabledInFullscreen = hasKeyboardAccess;
- m_fullscreenTaskQueue.enqueueTask([this, element = WTFMove(element), failedPreflights = WTFMove(failedPreflights)] () mutable {
- auto page = this->page();
- if (!page || document().hidden() || m_pendingFullscreenElement != element || !element->isConnected()) {
- failedPreflights(element);
- return;
- }
- page->chrome().client().enterFullScreenForElement(*element.get());
+ m_fullscreenTaskQueue.enqueueTask([this, element = WTFMove(element)] {
+ if (auto page = this->page())
+ page->chrome().client().enterFullScreenForElement(*element.get());
});
// 7. Optionally, display a message indicating how the user can exit displaying the context object fullscreen.
@@ -238,13 +225,8 @@
// "To fully exit fullscreen act as if the exitFullscreen() method was invoked on the top-level browsing
// context's document and subsequently empty that document's fullscreen element stack."
Document& topDocument = document().topDocument();
- if (!topDocument.fullscreenManager().fullscreenElement()) {
- // If there is a pending fullscreen element but no top document fullscreen element,
- // there is a pending task in enterFullscreen(). Cause it to cancel and fire an error
- // by clearing the pending fullscreen element.
- m_pendingFullscreenElement = nullptr;
+ if (!topDocument.fullscreenManager().fullscreenElement())
return;
- }
// To achieve that aim, remove all the elements from the top document's stack except for the first before
// calling webkitExitFullscreen():
@@ -263,13 +245,8 @@
Document* currentDoc = &document();
// 2. If doc's fullscreen element stack is empty, terminate these steps.
- if (m_fullscreenElementStack.isEmpty()) {
- // If there is a pending fullscreen element but an empty fullscreen element stack,
- // there is a pending task in requestFullscreenForElement(). Cause it to cancel and fire an error
- // by clearing the pending fullscreen element.
- m_pendingFullscreenElement = nullptr;
+ if (m_fullscreenElementStack.isEmpty())
return;
- }
// 3. Let descendants be all the doc's descendant browsing context's documents with a non-empty fullscreen
// element stack (if any), ordered so that the child of the doc is last and the document furthest
@@ -321,14 +298,6 @@
if (!page)
return;
- // If there is a pending fullscreen element but no fullscreen element
- // there is a pending task in requestFullscreenForElement(). Cause it to cancel and fire an error
- // by clearing the pending fullscreen element.
- if (!fullscreenElement && m_pendingFullscreenElement) {
- m_pendingFullscreenElement = nullptr;
- return;
- }
-
// Only exit out of full screen window mode if there are no remaining elements in the
// full screen stack.
if (!newTop) {
@@ -370,13 +339,6 @@
if (!page())
return;
- // If pending fullscreen element is unset or another element's was requested,
- // issue a cancel fullscreen request to the client
- if (m_pendingFullscreenElement != &element) {
- page()->chrome().client().exitFullScreenForElement(&element);
- return;
- }
-
ASSERT(page()->settings().fullScreenEnabled());
unwrapFullscreenRenderer(m_fullscreenRenderer.get(), m_fullscreenElement.get());
@@ -383,8 +345,6 @@
element.willBecomeFullscreenElement();
- ASSERT(&element == m_pendingFullscreenElement);
- m_pendingFullscreenElement = nullptr;
m_fullscreenElement = &element;
#if USE(NATIVE_FULLSCREEN_VIDEO)
@@ -425,32 +385,30 @@
void FullscreenManager::willExitFullscreen()
{
- auto fullscreenElement = fullscreenOrPendingElement();
- if (!fullscreenElement)
+ if (!m_fullscreenElement)
return;
if (!hasLivingRenderTree() || pageCacheState() != Document::NotInPageCache)
return;
- fullscreenElement->willStopBeingFullscreenElement();
+ m_fullscreenElement->willStopBeingFullscreenElement();
}
void FullscreenManager::didExitFullscreen()
{
- auto fullscreenElement = fullscreenOrPendingElement();
- if (!fullscreenElement)
+ if (!m_fullscreenElement)
return;
if (!hasLivingRenderTree() || pageCacheState() != Document::NotInPageCache)
return;
- fullscreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
+ m_fullscreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
+
m_areKeysEnabledInFullscreen = false;
unwrapFullscreenRenderer(m_fullscreenRenderer.get(), m_fullscreenElement.get());
m_fullscreenElement = nullptr;
- m_pendingFullscreenElement = nullptr;
scheduleFullStyleRebuild();
// When webkitCancelFullscreen is called, we call webkitExitFullscreen on the topDocument(). That
@@ -525,22 +483,25 @@
}
}
+void FullscreenManager::fullscreenElementRemoved()
+{
+ m_fullscreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
+ cancelFullscreen();
+}
+
void FullscreenManager::adjustFullscreenElementOnNodeRemoval(Node& node, Document::NodeRemoval nodeRemoval)
{
- auto fullscreenElement = fullscreenOrPendingElement();
- if (!fullscreenElement)
+ if (!m_fullscreenElement)
return;
bool elementInSubtree = false;
if (nodeRemoval == Document::NodeRemoval::ChildrenOfNode)
- elementInSubtree = fullscreenElement->isDescendantOf(node);
+ elementInSubtree = m_fullscreenElement->isDescendantOf(node);
else
- elementInSubtree = (fullscreenElement == &node) || fullscreenElement->isDescendantOf(node);
+ elementInSubtree = (m_fullscreenElement == &node) || m_fullscreenElement->isDescendantOf(node);
- if (elementInSubtree) {
- fullscreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
- cancelFullscreen();
- }
+ if (elementInSubtree)
+ fullscreenElementRemoved();
}
bool FullscreenManager::isAnimatingFullscreen() const
@@ -580,7 +541,6 @@
void FullscreenManager::clear()
{
m_fullscreenElement = nullptr;
- m_pendingFullscreenElement = nullptr;
m_fullscreenElementStack.clear();
}
Modified: branches/safari-608-branch/Source/WebCore/dom/FullscreenManager.h (249166 => 249167)
--- branches/safari-608-branch/Source/WebCore/dom/FullscreenManager.h 2019-08-27 20:24:00 UTC (rev 249166)
+++ branches/safari-608-branch/Source/WebCore/dom/FullscreenManager.h 2019-08-27 21:01:04 UTC (rev 249167)
@@ -108,9 +108,6 @@
private:
Document& m_document;
- RefPtr<Element> fullscreenOrPendingElement() const { return m_fullscreenElement ? m_fullscreenElement : m_pendingFullscreenElement; }
-
- RefPtr<Element> m_pendingFullscreenElement;
RefPtr<Element> m_fullscreenElement;
Vector<RefPtr<Element>> m_fullscreenElementStack;
WeakPtr<RenderFullScreen> m_fullscreenRenderer { nullptr };
Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (249166 => 249167)
--- branches/safari-608-branch/Source/WebKit/ChangeLog 2019-08-27 20:24:00 UTC (rev 249166)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog 2019-08-27 21:01:04 UTC (rev 249167)
@@ -1,5 +1,9 @@
2019-08-27 Alan Coon <alanc...@apple.com>
+ Revert r249147. rdar://problem/54751753
+
+2019-08-27 Alan Coon <alanc...@apple.com>
+
Cherry-pick r249147. rdar://problem/54751753
Removing fullscreen element in rAF() callback after requestFullscreen() can leave fullscreen in inconsistent state.
Modified: branches/safari-608-branch/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm (249166 => 249167)
--- branches/safari-608-branch/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm 2019-08-27 20:24:00 UTC (rev 249166)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm 2019-08-27 21:01:04 UTC (rev 249167)
@@ -447,7 +447,6 @@
RetainPtr<NSString> _EVOrganizationName;
BOOL _EVOrganizationNameIsValid;
BOOL _inInteractiveDismiss;
- BOOL _exitRequested;
RetainPtr<id> _notificationListener;
}
@@ -598,13 +597,6 @@
_repaintCallback = WebKit::VoidCallback::create([protectedSelf = retainPtr(self), self](WebKit::CallbackBase::Error) {
_repaintCallback = nullptr;
-
- if (_exitRequested) {
- _exitRequested = NO;
- [self _exitFullscreenImmediately];
- return;
- }
-
if (auto* manager = [protectedSelf _manager]) {
manager->willEnterFullScreen();
return;
@@ -648,12 +640,6 @@
[_rootViewController presentViewController:_fullscreenViewController.get() animated:YES completion:^{
_fullScreenState = WebKit::InFullScreen;
- if (_exitRequested) {
- _exitRequested = NO;
- [self _exitFullscreenImmediately];
- return;
- }
-
auto* page = [self._webView _page];
auto* manager = self._manager;
if (page && manager) {
@@ -671,11 +657,6 @@
- (void)requestExitFullScreen
{
- if (_fullScreenState != WebKit::InFullScreen) {
- _exitRequested = YES;
- return;
- }
-
if (auto* manager = self._manager) {
manager->requestExitFullScreen();
return;
@@ -687,10 +668,8 @@
- (void)exitFullScreen
{
- if (_fullScreenState < WebKit::InFullScreen) {
- _exitRequested = YES;
+ if (!self.isFullScreen)
return;
- }
_fullScreenState = WebKit::WaitingToExitFullScreen;
if (auto* manager = self._manager) {
Modified: branches/safari-608-branch/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h (249166 => 249167)
--- branches/safari-608-branch/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h 2019-08-27 20:24:00 UTC (rev 249166)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.h 2019-08-27 21:01:04 UTC (rev 249167)
@@ -73,9 +73,8 @@
LayerHostingContext* layerHostingContext() { return m_layerHostingContext.get(); }
void setLayerHostingContext(std::unique_ptr<LayerHostingContext>&&);
- enum class AnimationType { None, IntoFullscreen, FromFullscreen };
- AnimationType animationState() const { return m_animationType; }
- void setAnimationState(AnimationType flag) { m_animationType = flag; }
+ bool isAnimating() const { return m_isAnimating; }
+ void setIsAnimating(bool flag) { m_isAnimating = flag; }
bool targetIsFullscreen() const { return m_targetIsFullscreen; }
void setTargetIsFullscreen(bool flag) { m_targetIsFullscreen = flag; }
@@ -99,7 +98,7 @@
VideoFullscreenManager* m_manager;
uint64_t m_contextId;
std::unique_ptr<LayerHostingContext> m_layerHostingContext;
- AnimationType m_animationType { false };
+ bool m_isAnimating { false };
bool m_targetIsFullscreen { false };
WebCore::HTMLMediaElementEnums::VideoFullscreenMode m_fullscreenMode { WebCore::HTMLMediaElementEnums::VideoFullscreenModeNone };
bool m_fullscreenStandby { false };
Modified: branches/safari-608-branch/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm (249166 => 249167)
--- branches/safari-608-branch/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm 2019-08-27 20:24:00 UTC (rev 249166)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm 2019-08-27 21:01:04 UTC (rev 249167)
@@ -260,9 +260,9 @@
if (oldMode == HTMLMediaElementEnums::VideoFullscreenModeNone && mode != HTMLMediaElementEnums::VideoFullscreenModeNone)
model->setVideoLayerFrame(videoLayerFrame);
- if (interface->animationState() != VideoFullscreenInterfaceContext::AnimationType::None)
+ if (interface->isAnimating())
return;
- interface->setAnimationState(VideoFullscreenInterfaceContext::AnimationType::IntoFullscreen);
+ interface->setIsAnimating(true);
bool allowsPictureInPicture = videoElement.webkitSupportsPresentationMode(HTMLVideoElement::VideoPresentationMode::PictureInPicture);
@@ -296,9 +296,10 @@
interface.setTargetIsFullscreen(false);
- if (interface.animationState() == VideoFullscreenInterfaceContext::AnimationType::FromFullscreen)
+ if (interface.isAnimating())
return;
- interface.setAnimationState(VideoFullscreenInterfaceContext::AnimationType::FromFullscreen);
+
+ interface.setIsAnimating(true);
m_page->send(Messages::VideoFullscreenManagerProxy::ExitFullscreen(contextId, inlineVideoFrame(videoElement)));
}
@@ -437,7 +438,7 @@
auto [model, interface] = ensureModelAndInterface(contextId);
- interface->setAnimationState(VideoFullscreenInterfaceContext::AnimationType::None);
+ interface->setIsAnimating(false);
interface->setIsFullscreen(false);
RefPtr<HTMLVideoElement> videoElement = model->videoElement();
@@ -500,7 +501,7 @@
interface->setLayerHostingContext(nullptr);
}
- interface->setAnimationState(VideoFullscreenInterfaceContext::AnimationType::None);
+ interface->setIsAnimating(false);
interface->setIsFullscreen(false);
HTMLMediaElementEnums::VideoFullscreenMode mode = interface->fullscreenMode();
bool standby = interface->fullscreenStandby();