Skip to content

Commit

Permalink
REGRESSION(265672@main) Netflix.com video is zoomed in and cropped in…
Browse files Browse the repository at this point in the history
… Fullscreen

https://bugs.webkit.org/show_bug.cgi?id=267837
rdar://120803564

Reviewed by Mike Wyrzykowski.

At certain combinations of screen aspect ratio and content aspect ratio, Netflix.com content
becomes zoomed-in-and-cropped when in fullscreen mode.

Netflix sizes the <video> element to 100% width, and a fixed height, where that height is much
taller than the height of the viewport. It then relies on `object-fit: contain` to resize the
video content within that larger element space.

265672@main attempted to correct for "pixel cracks" at certain combinations of content aspect
ratio and window aspect ratio by detecting that situation and slightly resizing the videoBox
to "cover" the viewport rather than "contain" it. However with Netflix.com's layout, this
calculation resulted in making the videoBox much larger than necessary.

Revert 265672@main, and its follow-up fixes, 265672@main and 265672@main.

* Source/WebCore/rendering/RenderVideo.cpp:
(WebCore::RenderVideo::videoBox const):
(WebCore::RenderVideo::updatePlayer):
(WebCore::contentSizeAlmostEqualsFrameSize): Deleted.
(WebCore::RenderVideo::inElementOrVideoFullscreen const): Deleted.
* Source/WebCore/rendering/RenderVideo.h:

Canonical link: https://commits.webkit.org/273277@main
  • Loading branch information
jernoble committed Jan 21, 2024
1 parent b8e2893 commit f9bd534
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
25 changes: 2 additions & 23 deletions Source/WebCore/rendering/RenderVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,6 @@ void RenderVideo::imageChanged(WrappedImagePtr newImage, const IntRect* rect)
updateIntrinsicSize();
}

static bool contentSizeAlmostEqualsFrameSize(const IntSize& frameContentsSize, const LayoutSize& contentSize, float deviceScaleFactor)
{
LayoutUnit pointSizeLayoutUnits = LayoutUnit(deviceScaleFactor);
return absoluteValue(frameContentsSize.width() - contentSize.width()) <= pointSizeLayoutUnits && absoluteValue(frameContentsSize.height() - contentSize.height()) <= pointSizeLayoutUnits;
}

IntRect RenderVideo::videoBox() const
{
auto mediaPlayer = videoElement().player();
Expand All @@ -194,11 +188,7 @@ IntRect RenderVideo::videoBox() const
if (videoElement().shouldDisplayPosterImage())
intrinsicSize = m_cachedImageSize;

auto videoBoxRect = snappedIntRect(replacedContentRect(intrinsicSize));
if (!intrinsicSize.isEmpty() && inElementOrVideoFullscreen() && contentSizeAlmostEqualsFrameSize(view().frameView().layoutSize(), videoBoxRect.size(), page().deviceScaleFactor()))
return snappedIntRect({ contentBoxLocation(), contentSize().fitToAspectRatio(intrinsicSize, AspectRatioFitGrow) });

return videoBoxRect;
return snappedIntRect(replacedContentRect(intrinsicSize));
}

bool RenderVideo::shouldDisplayVideo() const
Expand Down Expand Up @@ -298,15 +288,6 @@ void RenderVideo::updateFromElement()
updatePlayer();
}

bool RenderVideo::inElementOrVideoFullscreen() const
{
bool result = videoElement().isFullscreen();
#if ENABLE(FULLSCREEN_API)
result = result || document().fullscreenManager().isFullscreen();
#endif
return result;
}

void RenderVideo::updatePlayer()
{
if (renderTreeBeingDestroyed())
Expand All @@ -323,9 +304,7 @@ void RenderVideo::updatePlayer()
if (videoElement().inActiveDocument())
contentChanged(VideoChanged);

auto videoBoxSize = videoBox().size();
bool fitToFillInFullscreen = inElementOrVideoFullscreen() && contentSizeAlmostEqualsFrameSize(view().frameView().layoutSize(), videoBoxSize, page().deviceScaleFactor());
videoElement().updateMediaPlayer(videoBoxSize, style().objectFit() != ObjectFit::Fill && !fitToFillInFullscreen);
videoElement().updateMediaPlayer(videoBox().size(), style().objectFit() != ObjectFit::Fill);
}

LayoutUnit RenderVideo::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/rendering/RenderVideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class RenderVideo final : public RenderMedia {
void updatePlayer();

bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect, unsigned maxDepthToTest) const final;
bool inElementOrVideoFullscreen() const;

LayoutSize m_cachedImageSize;
};
Expand Down

0 comments on commit f9bd534

Please sign in to comment.