Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1196)

Unified Diff: ui/views/controls/webview/webview.cc

Issue 2654413002: Stretching NativeViewHost, and misc tab capture fixes.
Patch Set: Gettin' it all working on ui/cocoa and MacViews too. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/native/native_view_host_wrapper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « ui/views/controls/native/native_view_host_wrapper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698