Diff
Modified: trunk/Source/WebCore/ChangeLog (274459 => 274460)
--- trunk/Source/WebCore/ChangeLog 2021-03-16 02:01:13 UTC (rev 274459)
+++ trunk/Source/WebCore/ChangeLog 2021-03-16 03:03:22 UTC (rev 274460)
@@ -1,3 +1,21 @@
+2021-03-15 Jer Noble <jer.no...@apple.com>
+
+ [WK2] Can get stuck in fullscreen mode if node is removed prior to receiving willEnterFullscreen()
+ https://bugs.webkit.org/show_bug.cgi?id=223218
+ <rdar://75009548>
+
+ Reviewed by Eric Carlson.
+
+ Return false from the following functions if a preflight check kept the function
+ from completing.
+
+ * dom/FullscreenManager.cpp:
+ (WebCore::FullscreenManager::willEnterFullscreen):
+ (WebCore::FullscreenManager::didEnterFullscreen):
+ (WebCore::FullscreenManager::willExitFullscreen):
+ (WebCore::FullscreenManager::didExitFullscreen):
+ * dom/FullscreenManager.h:
+
2021-03-15 Zalan Bujtas <za...@apple.com>
[Multi-column] Ignore line grid offset when the grid line is shorter than 0.5px
Modified: trunk/Source/WebCore/dom/FullscreenManager.cpp (274459 => 274460)
--- trunk/Source/WebCore/dom/FullscreenManager.cpp 2021-03-16 02:01:13 UTC (rev 274459)
+++ trunk/Source/WebCore/dom/FullscreenManager.cpp 2021-03-16 03:03:22 UTC (rev 274460)
@@ -350,20 +350,20 @@
fullscreenElement->parentElement()->invalidateStyleAndRenderersForSubtree();
}
-void FullscreenManager::willEnterFullscreen(Element& element)
+bool FullscreenManager::willEnterFullscreen(Element& element)
{
if (!document().hasLivingRenderTree() || document().backForwardCacheState() != Document::NotInBackForwardCache)
- return;
+ return false;
// Protect against being called after the document has been removed from the page.
if (!page())
- return;
+ return false;
// 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;
+ return true;
}
ASSERT(page()->settings().fullScreenEnabled());
@@ -394,40 +394,44 @@
document().resolveStyle(Document::ResolveStyleType::Rebuild);
dispatchFullscreenChangeEvents();
+
+ return true;
}
-void FullscreenManager::didEnterFullscreen()
+bool FullscreenManager::didEnterFullscreen()
{
if (!m_fullscreenElement)
- return;
+ return false;
if (!hasLivingRenderTree() || backForwardCacheState() != Document::NotInBackForwardCache)
- return;
+ return false;
m_fullscreenElement->didBecomeFullscreenElement();
+ return true;
}
-void FullscreenManager::willExitFullscreen()
+bool FullscreenManager::willExitFullscreen()
{
auto fullscreenElement = fullscreenOrPendingElement();
if (!fullscreenElement)
- return;
+ return false;
if (!hasLivingRenderTree() || backForwardCacheState() != Document::NotInBackForwardCache)
- return;
+ return false;
fullscreenElement->willStopBeingFullscreenElement();
+ return true;
}
-void FullscreenManager::didExitFullscreen()
+bool FullscreenManager::didExitFullscreen()
{
m_pendingExitFullscreen = false;
auto fullscreenElement = fullscreenOrPendingElement();
if (!fullscreenElement)
- return;
+ return false;
if (!hasLivingRenderTree() || backForwardCacheState() != Document::NotInBackForwardCache)
- return;
+ return false;
fullscreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
if (m_fullscreenElement)
@@ -448,6 +452,7 @@
Document& exitingDocument = eventTargetQueuesEmpty ? topDocument() : document();
exitingDocument.fullscreenManager().dispatchFullscreenChangeEvents();
+ return true;
}
void FullscreenManager::setFullscreenRenderer(RenderTreeBuilder& builder, RenderFullScreen& renderer)
Modified: trunk/Source/WebCore/dom/FullscreenManager.h (274459 => 274460)
--- trunk/Source/WebCore/dom/FullscreenManager.h 2021-03-16 02:01:13 UTC (rev 274459)
+++ trunk/Source/WebCore/dom/FullscreenManager.h 2021-03-16 03:03:22 UTC (rev 274460)
@@ -74,10 +74,10 @@
};
WEBCORE_EXPORT void requestFullscreenForElement(Element*, FullscreenCheckType);
- WEBCORE_EXPORT void willEnterFullscreen(Element&);
- WEBCORE_EXPORT void didEnterFullscreen();
- WEBCORE_EXPORT void willExitFullscreen();
- WEBCORE_EXPORT void didExitFullscreen();
+ WEBCORE_EXPORT bool willEnterFullscreen(Element&);
+ WEBCORE_EXPORT bool didEnterFullscreen();
+ WEBCORE_EXPORT bool willExitFullscreen();
+ WEBCORE_EXPORT bool didExitFullscreen();
void setFullscreenRenderer(RenderTreeBuilder&, RenderFullScreen&);
RenderFullScreen* fullscreenRenderer() const;
Modified: trunk/Source/WebKit/ChangeLog (274459 => 274460)
--- trunk/Source/WebKit/ChangeLog 2021-03-16 02:01:13 UTC (rev 274459)
+++ trunk/Source/WebKit/ChangeLog 2021-03-16 03:03:22 UTC (rev 274460)
@@ -1,3 +1,22 @@
+2021-03-15 Jer Noble <jer.no...@apple.com>
+
+ [WK2] Can get stuck in fullscreen mode if node is removed prior to receiving willEnterFullscreen()
+ https://bugs.webkit.org/show_bug.cgi?id=223218
+ <rdar://75009548>
+
+ Reviewed by Eric Carlson.
+
+ There are a number of preflight checks made in each of the listed functions below,
+ and those preflights can corrupt the state machine of the UIProcess's fullscreen
+ code. If any of the preflights fail, use the new return value of those methods to
+ close() the fullscreen presentation.
+
+ * WebProcess/FullScreen/WebFullScreenManager.cpp:
+ (WebKit::WebFullScreenManager::willEnterFullScreen):
+ (WebKit::WebFullScreenManager::didEnterFullScreen):
+ (WebKit::WebFullScreenManager::willExitFullScreen):
+ (WebKit::WebFullScreenManager::requestExitFullScreen):
+
2021-03-15 Chris Dumez <cdu...@apple.com>
Avoid heap allocation in RemoteAudioDestinationProxy::renderQuantum()
Modified: trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp (274459 => 274460)
--- trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp 2021-03-16 02:01:13 UTC (rev 274459)
+++ trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp 2021-03-16 03:03:22 UTC (rev 274460)
@@ -161,7 +161,11 @@
if (!m_element)
return;
- m_element->document().fullscreenManager().willEnterFullscreen(*m_element);
+ if (!m_element->document().fullscreenManager().willEnterFullscreen(*m_element)) {
+ close();
+ return;
+ }
+
#if !PLATFORM(IOS_FAMILY)
m_page->hidePageBanners();
#endif
@@ -178,7 +182,10 @@
if (!m_element)
return;
- m_element->document().fullscreenManager().didEnterFullscreen();
+ if (!m_element->document().fullscreenManager().didEnterFullscreen()) {
+ close();
+ return;
+ }
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
auto* currentPlaybackControlsElement = m_page->playbackSessionManager().currentPlaybackControlsElement();
@@ -198,7 +205,10 @@
#endif
m_finalFrame = screenRectOfContents(m_element.get());
- m_element->document().fullscreenManager().willExitFullscreen();
+ if (!m_element->document().fullscreenManager().willExitFullscreen()) {
+ close();
+ return;
+ }
#if !PLATFORM(IOS_FAMILY)
m_page->showPageBanners();
#endif
@@ -238,8 +248,16 @@
void WebFullScreenManager::requestExitFullScreen()
{
ASSERT(m_element);
- if (!m_element)
+ if (!m_element) {
+ close();
return;
+ }
+
+ auto& topDocument = m_element->document().topDocument();
+ if (!topDocument.fullscreenManager().fullscreenElement()) {
+ close();
+ return;
+ }
m_element->document().fullscreenManager().cancelFullscreen();
}
Modified: trunk/Tools/ChangeLog (274459 => 274460)
--- trunk/Tools/ChangeLog 2021-03-16 02:01:13 UTC (rev 274459)
+++ trunk/Tools/ChangeLog 2021-03-16 03:03:22 UTC (rev 274460)
@@ -1,3 +1,15 @@
+2021-03-15 Jer Noble <jer.no...@apple.com>
+
+ [WK2] Can get stuck in fullscreen mode if node is removed prior to receiving willEnterFullscreen()
+ https://bugs.webkit.org/show_bug.cgi?id=223218
+ <rdar://75009548>
+
+ Reviewed by Eric Carlson.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitCocoa/FullscreenRemoveNodeBeforeEnter.mm: Added.
+ (TestWebKitAPI::TEST):
+
2021-03-15 Alex Christensen <achristen...@webkit.org>
REGRESSION(r271642) Another app was relying on DOMWindow reuse
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (274459 => 274460)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-03-16 02:01:13 UTC (rev 274459)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-03-16 03:03:22 UTC (rev 274460)
@@ -1065,6 +1065,7 @@
CDCFA7AA1E45183200C2433D /* SampleMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDCFA7A91E45122F00C2433D /* SampleMap.cpp */; };
CDCFFEC122E26A1500DF4223 /* NoPauseWhenSwitchingTabs.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDCFFEC022E268D500DF4223 /* NoPauseWhenSwitchingTabs.mm */; };
CDD68F0D22C18317000CF0AE /* WKWebViewCloseAllMediaPresentations.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDD68F0C22C18317000CF0AE /* WKWebViewCloseAllMediaPresentations.mm */; };
+ CDDC7C6925FFF6D000224278 /* FullscreenRemoveNodeBeforeEnter.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDDC7C6825FFF6D000224278 /* FullscreenRemoveNodeBeforeEnter.mm */; };
CDE195B51CFE0B880053D256 /* FullscreenTopContentInset.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDE195B21CFE0ADE0053D256 /* FullscreenTopContentInset.html */; };
CDE77D2525A6591C00D4115E /* FullscreenPointerLeave.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDE77D2425A6591C00D4115E /* FullscreenPointerLeave.mm */; };
CDED342F249DDE0E0002AE7A /* AudioRoutingArbitration.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDED342E249DDD9D0002AE7A /* AudioRoutingArbitration.mm */; };
@@ -2820,6 +2821,8 @@
CDCFA7A91E45122F00C2433D /* SampleMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SampleMap.cpp; sourceTree = "<group>"; };
CDCFFEC022E268D500DF4223 /* NoPauseWhenSwitchingTabs.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NoPauseWhenSwitchingTabs.mm; sourceTree = "<group>"; };
CDD68F0C22C18317000CF0AE /* WKWebViewCloseAllMediaPresentations.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewCloseAllMediaPresentations.mm; sourceTree = "<group>"; };
+ CDDC7C6725FFF6D000224278 /* FullscreenRemoveNodeBeforeEnter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FullscreenRemoveNodeBeforeEnter.h; sourceTree = "<group>"; };
+ CDDC7C6825FFF6D000224278 /* FullscreenRemoveNodeBeforeEnter.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenRemoveNodeBeforeEnter.mm; sourceTree = "<group>"; };
CDE195B21CFE0ADE0053D256 /* FullscreenTopContentInset.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FullscreenTopContentInset.html; sourceTree = "<group>"; };
CDE195B31CFE0ADE0053D256 /* TopContentInset.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TopContentInset.mm; sourceTree = "<group>"; };
CDE77D2425A6591C00D4115E /* FullscreenPointerLeave.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenPointerLeave.mm; sourceTree = "<group>"; };
@@ -3351,6 +3354,8 @@
CDCF78A7244A2EDB00480311 /* FullscreenAlert.mm */,
CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */,
3F1B52681D3D7129008D60C4 /* FullscreenLayoutConstraints.mm */,
+ CDDC7C6725FFF6D000224278 /* FullscreenRemoveNodeBeforeEnter.h */,
+ CDDC7C6825FFF6D000224278 /* FullscreenRemoveNodeBeforeEnter.mm */,
631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */,
07E1F6A01FFC3A080096C7EC /* GetDisplayMedia.mm */,
2DADF26221CB8F32003D3E3A /* GetResourceData.mm */,
@@ -5331,6 +5336,7 @@
CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */,
CDB213BD24EF522800FDE301 /* FullscreenFocus.mm in Sources */,
CDE77D2525A6591C00D4115E /* FullscreenPointerLeave.mm in Sources */,
+ CDDC7C6925FFF6D000224278 /* FullscreenRemoveNodeBeforeEnter.mm in Sources */,
CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */,
83DB79691EF63B3C00BFA5E5 /* Function.cpp in Sources */,
7CCE7EF81A411AE600447C4C /* Geolocation.cpp in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenRemoveNodeBeforeEnter.mm (0 => 274460)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenRemoveNodeBeforeEnter.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FullscreenRemoveNodeBeforeEnter.mm 2021-03-16 03:03:22 UTC (rev 274460)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if PLATFORM(MAC)
+// FIXME: Fullscreen tests do not work when run on iOS because the test binary is not a real "app".
+// Enable this test on iOS once that issue is resolved.
+
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+namespace TestWebKitAPI {
+
+TEST(Fullscreen, RemoveNodeBeforeEnter)
+{
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [configuration preferences]._fullScreenEnabled = YES;
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get() addToWindow:YES]);
+
+ [webView synchronouslyLoadHTMLString:
+ @"<html><head><script>"
+ @"function enterFullscreenThenRemove() { "
+ @" let target = document.querySelector('div');"
+ @" target.webkitRequestFullscreen();"
+ @" setTimeout(() => { "
+ @" target.parentNode.removeChild(target);"
+ @" window.webkit.messageHandlers.testHandler.postMessage(\"noderemoved\");"
+ @" });"
+ @"}"
+ @"</script></head><body><div>some text</div></body></html>"];
+
+ ASSERT_FALSE([webView _isInFullscreen]);
+
+ __block bool nodeRemoved = false;
+ [webView performAfterReceivingMessage:@"noderemoved" action:^{ nodeRemoved = true; }];
+
+ [webView evaluateJavaScript:@"enterFullscreenThenRemove()" completionHandler:nil];
+
+ TestWebKitAPI::Util::run(&nodeRemoved);
+
+ // Allow the potential negative result time to occur.
+ TestWebKitAPI::Util::sleep(0.5);
+
+ // Fullscreen mode should eventually close.
+ int tries = 0;
+ do {
+ if (![webView _isInFullscreen])
+ break;
+ TestWebKitAPI::Util::sleep(0.1);
+ } while (++tries <= 100);
+
+ ASSERT_FALSE([webView _isInFullscreen]);
+}
+
+} // namespace TestWebKitAPI
+
+#endif