Commit 18746613 authored by François Beaufort's avatar François Beaufort Committed by Commit Bot

Fix Picture-in-Picture window resize algorithm

This CL makes sure Picture-in-Picture window size never gets bigger than
allowed.

Change-Id: Id008900ef18b85efa5823747f6529dd0d5abc57d
Reviewed-on: https://chromium-review.googlesource.com/c/1363279Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/master@{#615828}
parent b0bff15d
......@@ -246,11 +246,28 @@ gfx::Rect OverlayWindowViews::CalculateAndUpdateWindowBounds() {
if (!window_size.IsEmpty() && !natural_size_.IsEmpty()) {
float aspect_ratio = (float)natural_size_.width() / natural_size_.height();
WindowQuadrant quadrant =
GetCurrentWindowQuadrant(GetBounds(), controller_);
views::HitTest hit_test;
switch (quadrant) {
case OverlayWindowViews::WindowQuadrant::kBottomRight:
hit_test = views::HitTest::kTopLeft;
break;
case OverlayWindowViews::WindowQuadrant::kBottomLeft:
hit_test = views::HitTest::kTopRight;
break;
case OverlayWindowViews::WindowQuadrant::kTopLeft:
hit_test = views::HitTest::kBottomRight;
break;
case OverlayWindowViews::WindowQuadrant::kTopRight:
hit_test = views::HitTest::kBottomLeft;
break;
}
// Update the window size to adhere to the aspect ratio.
gfx::Rect window_rect(GetBounds().origin(), window_size);
views::WindowResizeUtils::SizeRectToAspectRatio(
views::HitTest::kBottomRight, aspect_ratio, min_size_, max_size_,
&window_rect);
hit_test, aspect_ratio, min_size_, max_size_, &window_rect);
window_size.SetSize(window_rect.width(), window_rect.height());
UpdateLayerBoundsWithLetterboxing(window_size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment