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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 23499003: Improve <webview> autosize: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/browser_plugin/browser_plugin.h" 5 #include "content/renderer/browser_plugin/browser_plugin.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 // If we haven't yet heard back from the guest about the last resize request, 314 // If we haven't yet heard back from the guest about the last resize request,
315 // then we don't issue another request until we do in 315 // then we don't issue another request until we do in
316 // BrowserPlugin::UpdateRect. 316 // BrowserPlugin::UpdateRect.
317 if (!HasGuestInstanceID() || !resize_ack_received_) 317 if (!HasGuestInstanceID() || !resize_ack_received_)
318 return; 318 return;
319 BrowserPluginHostMsg_AutoSize_Params auto_size_params; 319 BrowserPluginHostMsg_AutoSize_Params auto_size_params;
320 BrowserPluginHostMsg_ResizeGuest_Params resize_guest_params; 320 BrowserPluginHostMsg_ResizeGuest_Params resize_guest_params;
321 if (current_auto_size) { 321 if (current_auto_size) {
322 GetDamageBufferWithSizeParams(&auto_size_params, &resize_guest_params); 322 GetDamageBufferWithSizeParams(&auto_size_params, &resize_guest_params);
323 } else { 323 } else {
324 last_seen_auto_view_size_ = gfx::Size();
324 GetDamageBufferWithSizeParams(NULL, &resize_guest_params); 325 GetDamageBufferWithSizeParams(NULL, &resize_guest_params);
325 } 326 }
326 resize_ack_received_ = false; 327 resize_ack_received_ = false;
327 browser_plugin_manager()->Send( 328 browser_plugin_manager()->Send(
328 new BrowserPluginHostMsg_SetAutoSize(render_view_routing_id_, 329 new BrowserPluginHostMsg_SetAutoSize(render_view_routing_id_,
329 guest_instance_id_, 330 guest_instance_id_,
330 auto_size_params, 331 auto_size_params,
331 resize_guest_params)); 332 resize_guest_params));
332 } 333 }
333 334
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 // In SW, |resize_ack_received_| is reset in SwapDamageBuffers(). 502 // In SW, |resize_ack_received_| is reset in SwapDamageBuffers().
502 // In HW mode, we need to do it here so we can continue sending 503 // In HW mode, we need to do it here so we can continue sending
503 // resize messages when needed. 504 // resize messages when needed.
504 if (params.is_resize_ack || 505 if (params.is_resize_ack ||
505 (!params.needs_ack && (auto_size || auto_size_ack_pending_))) { 506 (!params.needs_ack && (auto_size || auto_size_ack_pending_))) {
506 resize_ack_received_ = true; 507 resize_ack_received_ = true;
507 } 508 }
508 509
509 auto_size_ack_pending_ = false; 510 auto_size_ack_pending_ = false;
510 511
511 if ((!auto_size && (width() != params.view_size.width() || 512 bool needs_new_damage_buffer = false;
513 if (auto_size && !params.view_size.IsEmpty()) {
514 if (params.view_size.width() > last_seen_auto_view_size_.width() ||
515 params.view_size.height() > last_seen_auto_view_size_.height()) {
516 // The width or height of the view size increased, so we would need new
517 // damage buffer to hold increased pixels.
518 needs_new_damage_buffer = true;
Fady Samuel 2013/08/27 14:16:18 I don't understand this fix. We set the damage buf
lazyboy 2013/08/27 23:22:17 As discussed offline, the CL changed quite a bit a
519 // A repaint is necessary to receive a UpdateRect for new size.
520 resize_guest_params.repaint = true;
521 }
522 last_seen_auto_view_size_ = params.view_size;
523 }
524
525 if (needs_new_damage_buffer ||
526 (!auto_size && (width() != params.view_size.width() ||
512 height() != params.view_size.height())) || 527 height() != params.view_size.height())) ||
513 (auto_size && (!InAutoSizeBounds(params.view_size))) || 528 (auto_size && (!InAutoSizeBounds(params.view_size))) ||
514 GetDeviceScaleFactor() != params.scale_factor) { 529 GetDeviceScaleFactor() != params.scale_factor) {
515 // We are HW accelerated, render widget does not expect an ack, 530 // We are HW accelerated, render widget does not expect an ack,
516 // but we still need to update the size. 531 // but we still need to update the size.
517 if (!params.needs_ack) { 532 if (!params.needs_ack) {
518 UpdateGuestAutoSizeState(auto_size); 533 UpdateGuestAutoSizeState(auto_size);
519 return; 534 return;
520 } 535 }
521 536
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 const WebKit::WebMouseEvent& event) { 1294 const WebKit::WebMouseEvent& event) {
1280 browser_plugin_manager()->Send( 1295 browser_plugin_manager()->Send(
1281 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 1296 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
1282 guest_instance_id_, 1297 guest_instance_id_,
1283 plugin_rect_, 1298 plugin_rect_,
1284 &event)); 1299 &event));
1285 return true; 1300 return true;
1286 } 1301 }
1287 1302
1288 } // namespace content 1303 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698