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

Unified Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 11360106: Browser Plugin: Implement AutoSize (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reupload Created 8 years, 1 month 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
Index: content/browser/browser_plugin/browser_plugin_guest.cc
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index c7921f4ccef7fcef25f1b76a4734e1050115b20d..f9c8a865fb326377f4596f94233e72308fed93d8 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -194,6 +194,25 @@ void BrowserPluginGuest::DragStatusUpdate(WebKit::WebDragStatus drag_status,
}
}
+void BrowserPluginGuest::SetAutoSize(
+ const BrowserPluginHostMsg_AutoSize_Params& auto_size_params,
+ const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params) {
+ auto_size_ = auto_size_params.enable;
+ max_height_ = auto_size_params.max_height;
+ max_width_ = auto_size_params.max_width;
+ min_height_ = auto_size_params.min_height;
+ min_width_ = auto_size_params.min_width;
+ if (auto_size_) {
+ web_contents()->GetRenderViewHost()->EnableAutoResize(
+ gfx::Size(min_width_, min_height_), gfx::Size(max_width_, max_height_));
lazyboy 2012/11/06 22:22:35 probably easier to keep these as gfx::Size min_aut
Fady Samuel 2012/11/06 23:52:34 Done.
+ } else {
+ web_contents()->GetRenderViewHost()->DisableAutoResize(
+ gfx::Size(resize_guest_params.width, resize_guest_params.height));
+ }
+ // We call resize here to update the damage buffer.
+ Resize(embedder_web_contents_->GetRenderViewHost(), resize_guest_params);
+}
+
void BrowserPluginGuest::UpdateDragCursor(WebKit::WebDragOperation operation) {
RenderViewHostImpl* embedder_render_view_host =
static_cast<RenderViewHostImpl*>(
@@ -286,6 +305,10 @@ void BrowserPluginGuest::SetDamageBuffer(
damage_buffer_scale_factor_ = scale_factor;
}
+bool BrowserPluginGuest::InAutoSizeBounds(const gfx::Size& size) const {
+ return size.width() <= max_width_ && size.height() <= max_height_;
+}
+
void BrowserPluginGuest::UpdateRect(
RenderViewHost* render_view_host,
const ViewHostMsg_UpdateRect_Params& params) {
@@ -298,14 +321,16 @@ void BrowserPluginGuest::UpdateRect(
if (!params.needs_ack)
return;
- // Only copy damage if the guest's view size is equal to the damage buffer's
- // size and the guest's scale factor is equal to the damage buffer's scale
- // factor.
+ // Only copy damage if the guest is in autosize mode and the guest's view size
+ // is less than the maximum size or the guest's view size is equal to the
+ // damage buffer's size and the guest's scale factor is equal to the damage
+ // buffer's scale factor.
// The scaling change can happen due to asynchronous updates of the DPI on a
// resolution change.
- if (params.view_size.width() == damage_view_size().width() &&
- params.view_size.height() == damage_view_size().height() &&
- params.scale_factor == damage_buffer_scale_factor()) {
+ if ((auto_size_ && InAutoSizeBounds(params.view_size)) ||
lazyboy 2012/11/06 22:22:35 Do we need to handle the case where auto_size is s
Fady Samuel 2012/11/06 23:52:34 Good catch. In this case, we still want to drop th
+ (params.view_size.width() == damage_view_size().width() &&
+ params.view_size.height() == damage_view_size().height() &&
+ params.scale_factor == damage_buffer_scale_factor())) {
TransportDIB* dib = render_view_host->GetProcess()->
GetTransportDIB(params.bitmap);
if (dib) {
@@ -526,6 +551,12 @@ void BrowserPluginGuest::RenderViewReady() {
bool embedder_visible =
embedder_web_contents_->GetBrowserPluginEmbedder()->visible();
SetVisibility(embedder_visible, visible());
+ if (auto_size_) {
+ web_contents()->GetRenderViewHost()->EnableAutoResize(
+ gfx::Size(min_width_, min_height_), gfx::Size(max_width_, max_height_));
+ } else {
+ web_contents()->GetRenderViewHost()->DisableAutoResize(damage_view_size_);
+ }
}
void BrowserPluginGuest::RenderViewGone(base::TerminationStatus status) {

Powered by Google App Engine
This is Rietveld 408576698