Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 914c16e8faccc6f14fd3eef8bfaac5065509b98a https://github.com/WebKit/WebKit/commit/914c16e8faccc6f14fd3eef8bfaac5065509b98a Author: Chris Dumez <cdu...@apple.com> Date: 2023-02-01 (Wed, 01 Feb 2023)
Changed paths: M LayoutTests/TestExpectations A LayoutTests/fast/dom/Orientation/no-orientation-change-event-when-unparenting-view-expected.txt A LayoutTests/fast/dom/Orientation/no-orientation-change-event-when-unparenting-view.html M LayoutTests/platform/ios/TestExpectations M Source/WebCore/platform/ScreenOrientationProvider.cpp M Source/WebCore/platform/ScreenOrientationProvider.h M Source/WebCore/platform/ios/ScreenOrientationProviderIOS.mm Log Message: ----------- Regression(ScreenOrientation API) Fullscreen exits right away on Youtube https://bugs.webkit.org/show_bug.cgi?id=251396 rdar://104269674 Reviewed by Wenson Hsieh. When entering fullscreen on youtube, the view would lose its window and then get added to a new Window. This would end up calling `ScreenOrientationProvider::setWindow()` first with nil then with the new window. To determine the screen orientation, the ScreenOrientationProvider currently needs access to the window object inside platformCurrentOrientation(). If it didn't have a window, platformCurrentOrientation() would just return PortraitPrimary. When updating the window, setWindow() would call screenOrientationDidChange() which would call platformCurrentOrientation() again to make sure the cached orientation is still accurate and to notify the clients that the orientation has changed otherwise. However, since platformCurrentOrientation() requires a window, there is no point in calling screenOrientationDidChange() if the new window is nil. It will just reset the orientation to the PortaitPrimary value and potentially send an incorrect orientation change notification to clients. This incorrect notification is what was causing the fullscreen mode to exit (since fullscreen mode exists on orientation change). To address this, I made 2 changes: 1. setWindow() now only calls screenOrientationDidChange() if the new window is non-nil. 2. platformCurrentOrientation() now returns a std::optional<> to make it clear when it wasn't able to determinate the orientation. 4. In screenOrientationDidChange(), if platformCurrentOrientation() returns std::nullopt, we now return early so that we don't send clients a potentially inaccurate orientation. Once the view gets added again to a window, we'll call screenOrientationDidChange() again to make sure we send a change notification if needed. * Source/WebCore/platform/ScreenOrientationProvider.cpp: (WebCore::ScreenOrientationProvider::screenOrientationDidChange): (WebCore::ScreenOrientationProvider::currentOrientation): (WebCore::ScreenOrientationProvider::platformCurrentOrientation): * Source/WebCore/platform/ScreenOrientationProvider.h: * Source/WebCore/platform/ios/ScreenOrientationProviderIOS.mm: (WebCore::ScreenOrientationProvider::platformCurrentOrientation): (WebCore::ScreenOrientationProvider::setWindow): Canonical link: https://commits.webkit.org/259678@main _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes