| Index: ui/views/controls/webview/webview.cc
|
| diff --git a/ui/views/controls/webview/webview.cc b/ui/views/controls/webview/webview.cc
|
| index 6eb474020e9a4f4ef369cec93f01d1d4017acd42..46056693d37897356568263625a34d2ff6eb65b4 100644
|
| --- a/ui/views/controls/webview/webview.cc
|
| +++ b/ui/views/controls/webview/webview.cc
|
| @@ -138,36 +138,26 @@ void WebView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
|
| (web_contents()->GetDelegate() &&
|
| web_contents()->GetDelegate()->
|
| IsFullscreenForTabOrPending(web_contents())))) {
|
| + holder_->SetRenderingSize(gfx::Size());
|
| holder_->SetBoundsRect(holder_bounds);
|
| return;
|
| }
|
|
|
| - // Size the holder to the capture video resolution and center it. If this
|
| - // WebView is not large enough to contain the holder at the preferred size,
|
| - // scale down to fit (preserving aspect ratio).
|
| + // For screen-captured fullscreened content, scale the |holder_| to fit within
|
| + // this View and center it.
|
| const gfx::Size capture_size = web_contents()->GetPreferredSize();
|
| - if (capture_size.width() <= holder_bounds.width() &&
|
| - capture_size.height() <= holder_bounds.height()) {
|
| - // No scaling, just centering.
|
| - holder_bounds.ClampToCenteredSize(capture_size);
|
| + const int64_t x =
|
| + static_cast<int64_t>(capture_size.width()) * holder_bounds.height();
|
| + const int64_t y =
|
| + static_cast<int64_t>(capture_size.height()) * holder_bounds.width();
|
| + if (y < x) {
|
| + holder_bounds.ClampToCenteredSize(gfx::Size(
|
| + holder_bounds.width(), static_cast<int>(y / capture_size.width())));
|
| } else {
|
| - // Scale down, preserving aspect ratio, and center.
|
| - // TODO(miu): This is basically media::ComputeLetterboxRegion(), and it
|
| - // looks like others have written this code elsewhere. Let's considate
|
| - // into a shared function ui/gfx/geometry or around there.
|
| - const int64_t x =
|
| - static_cast<int64_t>(capture_size.width()) * holder_bounds.height();
|
| - const int64_t y =
|
| - static_cast<int64_t>(capture_size.height()) * holder_bounds.width();
|
| - if (y < x) {
|
| - holder_bounds.ClampToCenteredSize(gfx::Size(
|
| - holder_bounds.width(), static_cast<int>(y / capture_size.width())));
|
| - } else {
|
| - holder_bounds.ClampToCenteredSize(gfx::Size(
|
| - static_cast<int>(x / capture_size.height()), holder_bounds.height()));
|
| - }
|
| + holder_bounds.ClampToCenteredSize(gfx::Size(
|
| + static_cast<int>(x / capture_size.height()), holder_bounds.height()));
|
| }
|
| -
|
| + holder_->SetRenderingSize(capture_size);
|
| holder_->SetBoundsRect(holder_bounds);
|
| }
|
|
|
|
|