Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Videos disappear when switching from landscape to portrait on cnn.com
https://bugs.webkit.org/show_bug.cgi?id=259666 rdar://112416568 Reviewed by Eric Carlson. On CNN.com, the JS listens for the window `resize` event instead of the orientation change event and queries `screen.orientation.angle` when this event is fired to determine if we're in landscape or portrait. The issue is that Safari has very special handling to deal with rotation (_beginAnimatedResizeWithUpdates & _endAnimatedResize), where it temporarily overrides the screen orientation. While `window.orientation` was properly handling this (making sure `window.orientation` stays consistent with the viewport size), `window.screen.orientation.angle` wasn't. As a result, we'd fire a resize event for the rotation but the value returned by `window.screen.orientation.angle` would be inconsistent, causing CNN.com to make the wrong decision and not removing a CSS class when it should have. This was the root cause of the bug. To address the issue, I am updating `window.screen.orientation` to get its orientation from the same place as `window.orientation`, instead of the ScreenOrientationProvider, which didn't properly deal with Safari animated resizing. This actually simplifies the code a lot and gets rid of the bug. * LayoutTests/fast/screen-orientation/orientation-in-resize-event-expected.txt: Added. * LayoutTests/fast/screen-orientation/orientation-in-resize-event.html: Added. * LayoutTests/platform/glib/TestExpectations: * LayoutTests/platform/mac/TestExpectations: * Source/WebCore/Headers.cmake: * Source/WebCore/Sources.txt: * Source/WebCore/SourcesCocoa.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/platform/ScreenOrientationProvider.cpp: Removed. * Source/WebCore/platform/ScreenOrientationProvider.h: Removed. * Source/WebCore/platform/ios/ScreenOrientationProviderIOS.mm: Removed. * Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm: (WebKit::WebPageProxy::setCocoaView): * Source/WebKit/UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::didAttachToRunningProcess): * Source/WebKit/UIProcess/WebPageProxy.h: * Source/WebKit/UIProcess/WebScreenOrientationManagerProxy.cpp: (WebKit::toString): (WebKit::WebScreenOrientationManagerProxy::WebScreenOrientationManagerProxy): (WebKit::WebScreenOrientationManagerProxy::~WebScreenOrientationManagerProxy): (WebKit::WebScreenOrientationManagerProxy::currentOrientation): (WebKit::WebScreenOrientationManagerProxy::setCurrentOrientation): (WebKit::WebScreenOrientationManagerProxy::lock): (WebKit::WebScreenOrientationManagerProxy::setShouldSendChangeNotification): (WebKit::WebScreenOrientationManagerProxy::screenOrientationDidChange): Deleted. (WebKit::WebScreenOrientationManagerProxy::platformInitialize): Deleted. (WebKit::WebScreenOrientationManagerProxy::platformDestroy): Deleted. * Source/WebKit/UIProcess/WebScreenOrientationManagerProxy.h: * Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::toScreenOrientationType): (WebKit::WebPageProxy::setDeviceOrientation): * Source/WebKit/UIProcess/ios/WebScreenOrientationManagerProxyIOS.mm: (WebKit::WebScreenOrientationManagerProxy::platformInitialize): Deleted. (WebKit::WebScreenOrientationManagerProxy::platformDestroy): Deleted. (WebKit::WebScreenOrientationManagerProxy::setWindow): Deleted. (WebKit::WebScreenOrientationManagerProxy::webViewDidMoveToWindow): Deleted. Canonical link: https://commits.webkit.org/266531@main
- Loading branch information
Showing
19 changed files
with
111 additions
and
388 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
LayoutTests/fast/screen-orientation/orientation-in-resize-event-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Checks that screen.orientation.type returns an up-to-date value in the 'resize' event listener. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS wasPortrait is true | ||
Simulating rotation to landscape | ||
* in resize event listener | ||
PASS isLandscape is true | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
43 changes: 43 additions & 0 deletions
43
LayoutTests/fast/screen-orientation/orientation-in-resize-event.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] --> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="initial-scale=1.0"> | ||
<script src="../../resources/js-test.js"></script | ||
</head> | ||
<body> | ||
<script> | ||
description("Checks that screen.orientation.type returns an up-to-date value in the 'resize' event listener."); | ||
jsTestIsAsync = true; | ||
|
||
function getRotationUIScript() | ||
{ | ||
return ` | ||
(function() { | ||
uiController.simulateRotationLikeSafari('landscape-right', function() { | ||
uiController.doAfterVisibleContentRectUpdate(function () { | ||
uiController.uiScriptComplete(); | ||
}) | ||
}); | ||
})();` | ||
} | ||
|
||
let wasPortrait = screen.orientation.type.startsWith("portrait"); | ||
shouldBeTrue("wasPortrait"); | ||
onload = () => { | ||
debug("Simulating rotation to landscape"); | ||
testRunner.runUIScript(getRotationUIScript(), function(result) { }); | ||
}; | ||
|
||
onresize = (e) => { | ||
let isLandscapeSize = window.innerWidth > window.innerHeight; | ||
if (!isLandscapeSize) | ||
return; | ||
|
||
debug("* in resize event listener"); | ||
isLandscape = screen.orientation.type.startsWith("landscape"); | ||
shouldBeTrue("isLandscape"); | ||
finishJSTest(); | ||
}; | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.