Skip to content

Commit

Permalink
[visionOS] Videos on youtube.com are cropped in compatibility mode wh…
Browse files Browse the repository at this point in the history
…en using a mobile UA

https://bugs.webkit.org/show_bug.cgi?id=260192
rdar://112444285

Reviewed by Mike Wyrzykowski and Richard Robinson.

Unlike the desktop site, YouTube's mobile site fullscreens the <video> element
rather than an element containing the <video>. Currently, on visionOS, WebKit
always uses element fullscreen (rather than the native player) when playing
fullscreen <video>. However, this results in cropping on YouTube's mobile site
as YouTube sets `object-fit: cover` on the <video>. On iPadOS, this CSS would
have no observable effect, as the native player is used.

This issue does not reproduce with YouTube's mobile site in Safari on visionOS,
even though element fullscreen is enforced, as the fullscreen window's aspect
ratio matches the <video>.

However, in compatibility mode, the fullscreen behavior should match iPadOS.
Fix by ensuring element fullscreen is not forced for <video> fullscreen in
compatibility mode.

* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::enterFullscreen):

Use the existing `videoFullscreenRequiresElementFullscreen` to determine whether
to force element fullscreen for <video>. This flag is only true when running on
visionOS, and compatibility mode is not active.

Canonical link: https://commits.webkit.org/266920@main
  • Loading branch information
pxlcoder committed Aug 15, 2023
1 parent 28bfc96 commit d409ef2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Source/WebCore/html/HTMLMediaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6768,7 +6768,12 @@ void HTMLMediaElement::enterFullscreen(VideoFullscreenMode mode)
m_changingVideoFullscreenMode = true;

#if ENABLE(FULLSCREEN_API) && ENABLE(VIDEO_USES_ELEMENT_FULLSCREEN)
if (document().settings().fullScreenEnabled() && mode == VideoFullscreenModeStandard) {
#if PLATFORM(IOS_FAMILY)
bool videoUsesElementFullscreen = document().settings().videoFullscreenRequiresElementFullscreen();
#else
constexpr bool videoUsesElementFullscreen = true;
#endif
if (videoUsesElementFullscreen && document().settings().fullScreenEnabled() && mode == VideoFullscreenModeStandard) {
m_temporarilyAllowingInlinePlaybackAfterFullscreen = false;
m_waitingToEnterFullscreen = true;
document().fullscreenManager().requestFullscreenForElement(*this, nullptr, FullscreenManager::ExemptIFrameAllowFullscreenRequirement);
Expand Down

0 comments on commit d409ef2

Please sign in to comment.