Title: [272251] branches/safari-611-branch
Revision
272251
Author
[email protected]
Date
2021-02-02 17:39:29 -0800 (Tue, 02 Feb 2021)

Log Message

Cherry-pick r271656. rdar://problem/73890220

    [Mac] Netflix controls do not fade out after entering fullscreen
    https://bugs.webkit.org/show_bug.cgi?id=220472
    <rdar://70602577>

    Reviewed by Eric Carlson.

    Test: TestWebKitAPI/Tests/mac/FullscreenPointerLeave.mm

    Netflix uses a "pointerleave" event over their playback controls to trigger setting their "fade out controls"
    timer, but a "pointerleave" event isn't fired when the element moves out from under the pointer (either due to
    style changes, or the window screen location moving due to entering fullscreen).

    Work around this behavior by sending a synthetic mouse event after entering fullscreen, which causes the
    "pointerleave" event to be fired if, indeed, the pointer is no longer over the element in question.

    * UIProcess/mac/WKFullScreenWindowController.mm:
    (-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271656 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-611-branch/Source/WebKit/ChangeLog (272250 => 272251)


--- branches/safari-611-branch/Source/WebKit/ChangeLog	2021-02-03 01:39:26 UTC (rev 272250)
+++ branches/safari-611-branch/Source/WebKit/ChangeLog	2021-02-03 01:39:29 UTC (rev 272251)
@@ -1,3 +1,48 @@
+2021-02-02  Alan Coon  <[email protected]>
+
+        Cherry-pick r271656. rdar://problem/73890220
+
+    [Mac] Netflix controls do not fade out after entering fullscreen
+    https://bugs.webkit.org/show_bug.cgi?id=220472
+    <rdar://70602577>
+    
+    Reviewed by Eric Carlson.
+    
+    Test: TestWebKitAPI/Tests/mac/FullscreenPointerLeave.mm
+    
+    Netflix uses a "pointerleave" event over their playback controls to trigger setting their "fade out controls"
+    timer, but a "pointerleave" event isn't fired when the element moves out from under the pointer (either due to
+    style changes, or the window screen location moving due to entering fullscreen).
+    
+    Work around this behavior by sending a synthetic mouse event after entering fullscreen, which causes the
+    "pointerleave" event to be fired if, indeed, the pointer is no longer over the element in question.
+    
+    * UIProcess/mac/WKFullScreenWindowController.mm:
+    (-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271656 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-01-20  Jer Noble  <[email protected]>
+
+            [Mac] Netflix controls do not fade out after entering fullscreen
+            https://bugs.webkit.org/show_bug.cgi?id=220472
+            <rdar://70602577>
+
+            Reviewed by Eric Carlson.
+
+            Test: TestWebKitAPI/Tests/mac/FullscreenPointerLeave.mm
+
+            Netflix uses a "pointerleave" event over their playback controls to trigger setting their "fade out controls"
+            timer, but a "pointerleave" event isn't fired when the element moves out from under the pointer (either due to
+            style changes, or the window screen location moving due to entering fullscreen).
+
+            Work around this behavior by sending a synthetic mouse event after entering fullscreen, which causes the
+            "pointerleave" event to be fired if, indeed, the pointer is no longer over the element in question.
+
+            * UIProcess/mac/WKFullScreenWindowController.mm:
+            (-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]):
+
 2021-02-01  Alan Coon  <[email protected]>
 
         Cherry-pick r271939. rdar://problem/73838846

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm (272250 => 272251)


--- branches/safari-611-branch/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm	2021-02-03 01:39:26 UTC (rev 272250)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm	2021-02-03 01:39:29 UTC (rev 272251)
@@ -30,6 +30,7 @@
 
 #import "AppKitSPI.h"
 #import "LayerTreeContext.h"
+#import "NativeWebMouseEvent.h"
 #import "VideoFullscreenManagerProxy.h"
 #import "WKAPICast.h"
 #import "WKViewInternal.h"
@@ -396,6 +397,19 @@
         _page->setTopContentInset(_savedTopContentInset);
         [self _manager]->didExitFullScreen();
         [self _manager]->setAnimatingFullScreen(false);
+
+        // FIXME(53342): remove once pointer events fire when elements move out from under the pointer.
+        NSEvent *fakeEvent = [NSEvent mouseEventWithType:NSEventTypeMouseMoved
+            location:[NSEvent mouseLocation]
+            modifierFlags:[[NSApp currentEvent] modifierFlags]
+            timestamp:[NSDate timeIntervalSinceReferenceDate]
+            windowNumber:[[_webView window] windowNumber]
+            context:nullptr
+            eventNumber:0
+            clickCount:0
+            pressure:0];
+        WebKit::NativeWebMouseEvent webEvent(fakeEvent, nil, _webView);
+        _page->handleMouseEvent(webEvent);
     }
 
     ALLOW_DEPRECATED_DECLARATIONS_BEGIN

Modified: branches/safari-611-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (272250 => 272251)


--- branches/safari-611-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-02-03 01:39:26 UTC (rev 272250)
+++ branches/safari-611-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-02-03 01:39:29 UTC (rev 272251)
@@ -1052,6 +1052,7 @@
 		CDCFFEC122E26A1500DF4223 /* NoPauseWhenSwitchingTabs.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDCFFEC022E268D500DF4223 /* NoPauseWhenSwitchingTabs.mm */; };
 		CDD68F0D22C18317000CF0AE /* WKWebViewCloseAllMediaPresentations.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDD68F0C22C18317000CF0AE /* WKWebViewCloseAllMediaPresentations.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 */; };
 		CDF0B78A216D48DC00421ECC /* CloseWebViewDuringEnterFullscreen.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDF0B789216D484300421ECC /* CloseWebViewDuringEnterFullscreen.mm */; };
 		CDF92237216D186400647AA7 /* CloseWebViewAfterEnterFullscreen.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDF92236216D186400647AA7 /* CloseWebViewAfterEnterFullscreen.mm */; };
@@ -1427,6 +1428,7 @@
 				1A7E8B3618120B2F00AEB74A /* FragmentNavigation.html in Copy Resources */,
 				F47728991E4AE3C1007ABF6A /* full-page-contenteditable.html in Copy Resources */,
 				F4E0A28B211E4A2B00AF7C7F /* full-page-dropzone.html in Copy Resources */,
+				CDB4776225568E2700FF5D2A /* full-screen-scroll-position.html in Copy Resources */,
 				F4F405BC1D4C0D1C007A9707 /* full-size-autoplaying-video-with-audio.html in Copy Resources */,
 				CD78E11E1DB7EE2A0014A2DE /* FullscreenDelegate.html in Copy Resources */,
 				3FBD1B4A1D3D66AB00E6D6FA /* FullscreenLayoutConstraints.html in Copy Resources */,
@@ -2786,6 +2788,7 @@
 		CDD68F0C22C18317000CF0AE /* WKWebViewCloseAllMediaPresentations.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewCloseAllMediaPresentations.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>"; };
 		CDED342E249DDD9D0002AE7A /* AudioRoutingArbitration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AudioRoutingArbitration.mm; sourceTree = "<group>"; };
 		CDF0B789216D484300421ECC /* CloseWebViewDuringEnterFullscreen.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CloseWebViewDuringEnterFullscreen.mm; sourceTree = "<group>"; };
 		CDF92236216D186400647AA7 /* CloseWebViewAfterEnterFullscreen.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CloseWebViewAfterEnterFullscreen.mm; sourceTree = "<group>"; };
@@ -3823,6 +3826,7 @@
 				F43E3BC020DADB8000A4E7ED /* fixed-nav-bar.html */,
 				93575C551D30366E000D604D /* focus-inputs.html */,
 				F46128D8211E496300D9FADB /* full-page-dropzone.html */,
+				CDB477612556894B00FF5D2A /* full-screen-scroll-position.html */,
 				F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */,
 				CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */,
 				3FBD1B491D39D1DB00E6D6FA /* FullscreenLayoutConstraints.html */,
@@ -4522,6 +4526,7 @@
 				F456AB1B213EDBA300CB2CEF /* FontManagerTests.mm */,
 				1A7E8B33181208DE00AEB74A /* FragmentNavigation.mm */,
 				CDB213BC24EF522800FDE301 /* FullscreenFocus.mm */,
+				CDE77D2425A6591C00D4115E /* FullscreenPointerLeave.mm */,
 				CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */,
 				51EB125824C68589000CB030 /* HIDGamepads.mm */,
 				9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */,
@@ -5268,6 +5273,8 @@
 				CDCF78A8244A32F700480311 /* FullscreenAlert.mm in Sources */,
 				CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */,
 				CDB213BD24EF522800FDE301 /* FullscreenFocus.mm in Sources */,
+				CDE77D2525A6591C00D4115E /* FullscreenPointerLeave.mm in Sources */,
+				CDB477602556886800FF5D2A /* FullScreenScrollPosition.mm in Sources */,
 				CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */,
 				83DB79691EF63B3C00BFA5E5 /* Function.cpp in Sources */,
 				7CCE7EF81A411AE600447C4C /* Geolocation.cpp in Sources */,

Added: branches/safari-611-branch/Tools/TestWebKitAPI/Tests/mac/FullscreenPointerLeave.mm (0 => 272251)


--- branches/safari-611-branch/Tools/TestWebKitAPI/Tests/mac/FullscreenPointerLeave.mm	                        (rev 0)
+++ branches/safari-611-branch/Tools/TestWebKitAPI/Tests/mac/FullscreenPointerLeave.mm	2021-02-03 01:39:29 UTC (rev 272251)
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+#import "config.h"
+
+#if PLATFORM(MAC)
+
+#import "TestCocoa.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/_WKFullscreenDelegate.h>
+#import <wtf/RetainPtr.h>
+
+namespace TestWebKitAPI {
+
+TEST(Fullscreen, PointerLeave)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [configuration preferences]._fullScreenEnabled = YES;
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
+
+    bool pointerenter = false;
+    bool pointerleave = false;
+    bool fullscreenchange = false;
+    [webView performAfterReceivingMessage:@"pointerenter" action:[&] { pointerenter = true; }];
+    [webView performAfterReceivingMessage:@"pointerleave" action:[&] { pointerleave = true; }];
+    [webView performAfterReceivingMessage:@"webkitfullscreenchange" action:[&] { fullscreenchange = true; }];
+    [webView synchronouslyLoadHTMLString:
+        @"<style>#target { width:100px; height: 100px; }</style>"
+        @"<div id=target></div>"
+        @"<script>"
+        @"let eventToMessage = event => { window.webkit.messageHandlers.testHandler.postMessage(event.type); }"
+        @"target.addEventListener('pointerenter', eventToMessage, {once:true});"
+        @"target.addEventListener('pointerleave', eventToMessage, {once:true});"
+        @"document.addEventListener('webkitfullscreenchange', eventToMessage, {once:true});"
+        @"</script>"];
+
+    [webView mouseMoveToPoint:NSMakePoint(50, 50) withFlags:0];
+    Util::runFor(&pointerenter, 5);
+
+    [webView objectByEvaluatingJavaScriptWithUserGesture:@"target.webkitRequestFullscreen()"];
+    Util::runFor(&fullscreenchange, 5);
+    Util::runFor(&pointerleave, 5);
+}
+
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to