OLD | NEW |
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 BrowserPlugin::BrowserPlugin( | 69 BrowserPlugin::BrowserPlugin( |
70 RenderViewImpl* render_view, | 70 RenderViewImpl* render_view, |
71 WebKit::WebFrame* frame, | 71 WebKit::WebFrame* frame, |
72 const WebPluginParams& params) | 72 const WebPluginParams& params) |
73 : guest_instance_id_(browser_plugin::kInstanceIDNone), | 73 : guest_instance_id_(browser_plugin::kInstanceIDNone), |
74 attached_(false), | 74 attached_(false), |
75 render_view_(render_view->AsWeakPtr()), | 75 render_view_(render_view->AsWeakPtr()), |
76 render_view_routing_id_(render_view->GetRoutingID()), | 76 render_view_routing_id_(render_view->GetRoutingID()), |
77 container_(NULL), | 77 container_(NULL), |
78 damage_buffer_sequence_id_(0), | 78 damage_buffer_sequence_id_(0), |
79 resize_ack_received_(true), | 79 paint_ack_received_(true), |
80 last_device_scale_factor_(1.0f), | 80 last_device_scale_factor_(1.0f), |
81 sad_guest_(NULL), | 81 sad_guest_(NULL), |
82 guest_crashed_(false), | 82 guest_crashed_(false), |
83 auto_size_ack_pending_(false), | 83 is_auto_size_state_dirty_(false), |
84 persist_storage_(false), | 84 persist_storage_(false), |
85 valid_partition_id_(true), | 85 valid_partition_id_(true), |
86 content_window_routing_id_(MSG_ROUTING_NONE), | 86 content_window_routing_id_(MSG_ROUTING_NONE), |
87 plugin_focused_(false), | 87 plugin_focused_(false), |
88 visible_(true), | 88 visible_(true), |
89 before_first_navigation_(true), | 89 before_first_navigation_(true), |
90 mouse_locked_(false), | 90 mouse_locked_(false), |
91 browser_plugin_manager_(render_view->GetBrowserPluginManager()), | 91 browser_plugin_manager_(render_view->GetBrowserPluginManager()), |
92 compositing_enabled_(false), | 92 compositing_enabled_(false), |
93 weak_ptr_factory_(this) { | 93 weak_ptr_factory_(this) { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } | 288 } |
289 | 289 |
290 browser_plugin_manager()->Send( | 290 browser_plugin_manager()->Send( |
291 new BrowserPluginHostMsg_NavigateGuest(render_view_routing_id_, | 291 new BrowserPluginHostMsg_NavigateGuest(render_view_routing_id_, |
292 guest_instance_id_, | 292 guest_instance_id_, |
293 src)); | 293 src)); |
294 return true; | 294 return true; |
295 } | 295 } |
296 | 296 |
297 void BrowserPlugin::ParseAutoSizeAttribute() { | 297 void BrowserPlugin::ParseAutoSizeAttribute() { |
298 auto_size_ack_pending_ = true; | |
299 last_view_size_ = plugin_rect_.size(); | 298 last_view_size_ = plugin_rect_.size(); |
| 299 is_auto_size_state_dirty_ = true; |
300 UpdateGuestAutoSizeState(GetAutoSizeAttribute()); | 300 UpdateGuestAutoSizeState(GetAutoSizeAttribute()); |
301 } | 301 } |
302 | 302 |
303 void BrowserPlugin::PopulateAutoSizeParameters( | 303 void BrowserPlugin::PopulateAutoSizeParameters( |
304 BrowserPluginHostMsg_AutoSize_Params* params, bool current_auto_size) { | 304 BrowserPluginHostMsg_AutoSize_Params* params, bool auto_size_enabled) { |
305 params->enable = current_auto_size; | 305 params->enable = auto_size_enabled; |
306 // No need to populate the params if autosize is off. | 306 // No need to populate the params if autosize is off. |
307 if (current_auto_size) { | 307 if (auto_size_enabled) { |
308 params->max_size = gfx::Size(GetAdjustedMaxWidth(), GetAdjustedMaxHeight()); | 308 params->max_size = gfx::Size(GetAdjustedMaxWidth(), GetAdjustedMaxHeight()); |
309 params->min_size = gfx::Size(GetAdjustedMinWidth(), GetAdjustedMinHeight()); | 309 params->min_size = gfx::Size(GetAdjustedMinWidth(), GetAdjustedMinHeight()); |
| 310 |
| 311 if (max_auto_size_ != params->max_size) |
| 312 is_auto_size_state_dirty_ = true; |
| 313 |
| 314 max_auto_size_ = params->max_size; |
| 315 } else { |
| 316 max_auto_size_ = gfx::Size(); |
310 } | 317 } |
311 } | 318 } |
312 | 319 |
313 void BrowserPlugin::UpdateGuestAutoSizeState(bool current_auto_size) { | 320 void BrowserPlugin::UpdateGuestAutoSizeState(bool auto_size_enabled) { |
314 // If we haven't yet heard back from the guest about the last resize request, | 321 // 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 | 322 // then we don't issue another request until we do in |
316 // BrowserPlugin::UpdateRect. | 323 // BrowserPlugin::UpdateRect. |
317 if (!HasGuestInstanceID() || !resize_ack_received_) | 324 if (!HasGuestInstanceID() || !paint_ack_received_) |
318 return; | 325 return; |
| 326 |
319 BrowserPluginHostMsg_AutoSize_Params auto_size_params; | 327 BrowserPluginHostMsg_AutoSize_Params auto_size_params; |
320 BrowserPluginHostMsg_ResizeGuest_Params resize_guest_params; | 328 BrowserPluginHostMsg_ResizeGuest_Params resize_guest_params; |
321 if (current_auto_size) { | 329 if (auto_size_enabled) { |
322 GetDamageBufferWithSizeParams(&auto_size_params, &resize_guest_params); | 330 GetDamageBufferWithSizeParams(&auto_size_params, |
| 331 &resize_guest_params, |
| 332 true); |
323 } else { | 333 } else { |
324 GetDamageBufferWithSizeParams(NULL, &resize_guest_params); | 334 GetDamageBufferWithSizeParams(NULL, &resize_guest_params, true); |
325 } | 335 } |
326 resize_ack_received_ = false; | 336 paint_ack_received_ = false; |
327 browser_plugin_manager()->Send( | 337 browser_plugin_manager()->Send( |
328 new BrowserPluginHostMsg_SetAutoSize(render_view_routing_id_, | 338 new BrowserPluginHostMsg_SetAutoSize(render_view_routing_id_, |
329 guest_instance_id_, | 339 guest_instance_id_, |
330 auto_size_params, | 340 auto_size_params, |
331 resize_guest_params)); | 341 resize_guest_params)); |
332 } | 342 } |
333 | 343 |
334 // static | 344 // static |
335 bool BrowserPlugin::UsesDamageBuffer( | 345 bool BrowserPlugin::UsesDamageBuffer( |
336 const BrowserPluginMsg_UpdateRect_Params& params) { | 346 const BrowserPluginMsg_UpdateRect_Params& params) { |
(...skipping 21 matching lines...) Expand all Loading... |
358 | 368 |
359 void BrowserPlugin::Attach(scoped_ptr<base::DictionaryValue> extra_params) { | 369 void BrowserPlugin::Attach(scoped_ptr<base::DictionaryValue> extra_params) { |
360 BrowserPluginHostMsg_Attach_Params attach_params; | 370 BrowserPluginHostMsg_Attach_Params attach_params; |
361 attach_params.focused = ShouldGuestBeFocused(); | 371 attach_params.focused = ShouldGuestBeFocused(); |
362 attach_params.visible = visible_; | 372 attach_params.visible = visible_; |
363 attach_params.name = GetNameAttribute(); | 373 attach_params.name = GetNameAttribute(); |
364 attach_params.storage_partition_id = storage_partition_id_; | 374 attach_params.storage_partition_id = storage_partition_id_; |
365 attach_params.persist_storage = persist_storage_; | 375 attach_params.persist_storage = persist_storage_; |
366 attach_params.src = GetSrcAttribute(); | 376 attach_params.src = GetSrcAttribute(); |
367 GetDamageBufferWithSizeParams(&attach_params.auto_size_params, | 377 GetDamageBufferWithSizeParams(&attach_params.auto_size_params, |
368 &attach_params.resize_guest_params); | 378 &attach_params.resize_guest_params, |
| 379 false); |
369 | 380 |
370 browser_plugin_manager()->Send( | 381 browser_plugin_manager()->Send( |
371 new BrowserPluginHostMsg_Attach(render_view_routing_id_, | 382 new BrowserPluginHostMsg_Attach(render_view_routing_id_, |
372 guest_instance_id_, attach_params, | 383 guest_instance_id_, attach_params, |
373 *extra_params)); | 384 *extra_params)); |
374 } | 385 } |
375 | 386 |
376 void BrowserPlugin::DidCommitCompositorFrame() { | 387 void BrowserPlugin::DidCommitCompositorFrame() { |
377 if (compositing_helper_.get()) | 388 if (compositing_helper_.get()) |
378 compositing_helper_->DidCommitCompositorFrame(); | 389 compositing_helper_->DidCommitCompositorFrame(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 // damage buffer then we know the guest will no longer use the current | 502 // damage buffer then we know the guest will no longer use the current |
492 // damage buffer. At this point, we drop the current damage buffer, and | 503 // damage buffer. At this point, we drop the current damage buffer, and |
493 // mark the pending damage buffer as the current damage buffer. | 504 // mark the pending damage buffer as the current damage buffer. |
494 if (UsesPendingDamageBuffer(params)) { | 505 if (UsesPendingDamageBuffer(params)) { |
495 SwapDamageBuffers(); | 506 SwapDamageBuffers(); |
496 use_new_damage_buffer = true; | 507 use_new_damage_buffer = true; |
497 } | 508 } |
498 | 509 |
499 bool auto_size = GetAutoSizeAttribute(); | 510 bool auto_size = GetAutoSizeAttribute(); |
500 // We receive a resize ACK in regular mode, but not in autosize. | 511 // We receive a resize ACK in regular mode, but not in autosize. |
501 // In SW, |resize_ack_received_| is reset in SwapDamageBuffers(). | 512 // In SW, |paint_ack_received_| is reset in SwapDamageBuffers(). |
502 // In HW mode, we need to do it here so we can continue sending | 513 // In HW mode, we need to do it here so we can continue sending |
503 // resize messages when needed. | 514 // resize messages when needed. |
504 if (params.is_resize_ack || | 515 if (params.is_resize_ack || |
505 (!params.needs_ack && (auto_size || auto_size_ack_pending_))) { | 516 (!params.needs_ack && (auto_size || is_auto_size_state_dirty_))) { |
506 resize_ack_received_ = true; | 517 paint_ack_received_ = true; |
507 } | 518 } |
508 | 519 |
509 auto_size_ack_pending_ = false; | 520 bool was_auto_size_state_dirty = auto_size && is_auto_size_state_dirty_; |
| 521 is_auto_size_state_dirty_ = false; |
510 | 522 |
511 if ((!auto_size && (width() != params.view_size.width() || | 523 if ((!auto_size && (width() != params.view_size.width() || |
512 height() != params.view_size.height())) || | 524 height() != params.view_size.height())) || |
513 (auto_size && (!InAutoSizeBounds(params.view_size))) || | 525 (auto_size && was_auto_size_state_dirty) || |
514 GetDeviceScaleFactor() != params.scale_factor) { | 526 GetDeviceScaleFactor() != params.scale_factor) { |
515 // We are HW accelerated, render widget does not expect an ack, | 527 // We are HW accelerated, render widget does not expect an ack, |
516 // but we still need to update the size. | 528 // but we still need to update the size. |
517 if (!params.needs_ack) { | 529 if (!params.needs_ack) { |
518 UpdateGuestAutoSizeState(auto_size); | 530 UpdateGuestAutoSizeState(auto_size); |
519 return; | 531 return; |
520 } | 532 } |
521 | 533 |
522 if (!resize_ack_received_) { | 534 if (!paint_ack_received_) { |
523 // The guest has not yet responded to the last resize request, and | 535 // The guest has not yet responded to the last resize request, and |
524 // so we don't want to do anything at this point other than ACK the guest. | 536 // so we don't want to do anything at this point other than ACK the guest. |
525 if (auto_size) | 537 if (auto_size) |
526 PopulateAutoSizeParameters(&auto_size_params, auto_size); | 538 PopulateAutoSizeParameters(&auto_size_params, auto_size); |
527 } else { | 539 } else { |
528 // If we have no pending damage buffer, then the guest has not caught up | 540 // If we have no pending damage buffer, then the guest has not caught up |
529 // with the BrowserPlugin container. We now tell the guest about the new | 541 // with the BrowserPlugin container. We now tell the guest about the new |
530 // container size. | 542 // container size. |
531 if (auto_size) { | 543 if (auto_size) { |
532 GetDamageBufferWithSizeParams(&auto_size_params, | 544 GetDamageBufferWithSizeParams(&auto_size_params, |
533 &resize_guest_params); | 545 &resize_guest_params, |
| 546 was_auto_size_state_dirty); |
534 } else { | 547 } else { |
535 GetDamageBufferWithSizeParams(NULL, &resize_guest_params); | 548 GetDamageBufferWithSizeParams(NULL, |
| 549 &resize_guest_params, |
| 550 was_auto_size_state_dirty); |
536 } | 551 } |
537 } | 552 } |
538 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( | 553 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( |
539 render_view_routing_id_, | 554 render_view_routing_id_, |
540 guest_instance_id_, | 555 guest_instance_id_, |
541 true, | 556 true, |
542 auto_size_params, | 557 auto_size_params, |
543 resize_guest_params)); | 558 resize_guest_params)); |
544 return; | 559 return; |
545 } | 560 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( | 609 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( |
595 render_view_routing_id_, | 610 render_view_routing_id_, |
596 guest_instance_id_, | 611 guest_instance_id_, |
597 UsesDamageBuffer(params), | 612 UsesDamageBuffer(params), |
598 auto_size_params, | 613 auto_size_params, |
599 resize_guest_params)); | 614 resize_guest_params)); |
600 } | 615 } |
601 | 616 |
602 void BrowserPlugin::ParseSizeContraintsChanged() { | 617 void BrowserPlugin::ParseSizeContraintsChanged() { |
603 bool auto_size = GetAutoSizeAttribute(); | 618 bool auto_size = GetAutoSizeAttribute(); |
604 if (auto_size) | 619 if (auto_size) { |
| 620 is_auto_size_state_dirty_ = true; |
605 UpdateGuestAutoSizeState(true); | 621 UpdateGuestAutoSizeState(true); |
| 622 } |
606 } | 623 } |
607 | 624 |
608 bool BrowserPlugin::InAutoSizeBounds(const gfx::Size& size) const { | 625 bool BrowserPlugin::InAutoSizeBounds(const gfx::Size& size) const { |
609 return size.width() <= GetAdjustedMaxWidth() && | 626 return size.width() <= GetAdjustedMaxWidth() && |
610 size.height() <= GetAdjustedMaxHeight(); | 627 size.height() <= GetAdjustedMaxHeight(); |
611 } | 628 } |
612 | 629 |
613 NPObject* BrowserPlugin::GetContentWindow() const { | 630 NPObject* BrowserPlugin::GetContentWindow() const { |
614 if (content_window_routing_id_ == MSG_ROUTING_NONE) | 631 if (content_window_routing_id_ == MSG_ROUTING_NONE) |
615 return NULL; | 632 return NULL; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 ParseSrcAttribute(&error); | 757 ParseSrcAttribute(&error); |
741 } | 758 } |
742 | 759 |
743 float BrowserPlugin::GetDeviceScaleFactor() const { | 760 float BrowserPlugin::GetDeviceScaleFactor() const { |
744 if (!render_view_.get()) | 761 if (!render_view_.get()) |
745 return 1.0f; | 762 return 1.0f; |
746 return render_view_->GetWebView()->deviceScaleFactor(); | 763 return render_view_->GetWebView()->deviceScaleFactor(); |
747 } | 764 } |
748 | 765 |
749 void BrowserPlugin::UpdateDeviceScaleFactor(float device_scale_factor) { | 766 void BrowserPlugin::UpdateDeviceScaleFactor(float device_scale_factor) { |
750 if (last_device_scale_factor_ == device_scale_factor || !resize_ack_received_) | 767 if (last_device_scale_factor_ == device_scale_factor || !paint_ack_received_) |
751 return; | 768 return; |
752 | 769 |
753 BrowserPluginHostMsg_ResizeGuest_Params params; | 770 BrowserPluginHostMsg_ResizeGuest_Params params; |
754 PopulateResizeGuestParameters(¶ms, plugin_rect()); | 771 PopulateResizeGuestParameters(¶ms, plugin_rect(), false); |
755 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( | 772 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( |
756 render_view_routing_id_, | 773 render_view_routing_id_, |
757 guest_instance_id_, | 774 guest_instance_id_, |
758 params)); | 775 params)); |
759 } | 776 } |
760 | 777 |
761 void BrowserPlugin::TriggerEvent(const std::string& event_name, | 778 void BrowserPlugin::TriggerEvent(const std::string& event_name, |
762 std::map<std::string, base::Value*>* props) { | 779 std::map<std::string, base::Value*>* props) { |
763 if (!container()) | 780 if (!container()) |
764 return; | 781 return; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 compositing_helper_ = | 870 compositing_helper_ = |
854 new BrowserPluginCompositingHelper(container_, | 871 new BrowserPluginCompositingHelper(container_, |
855 browser_plugin_manager(), | 872 browser_plugin_manager(), |
856 guest_instance_id_, | 873 guest_instance_id_, |
857 render_view_routing_id_); | 874 render_view_routing_id_); |
858 } | 875 } |
859 } else { | 876 } else { |
860 // We're switching back to the software path. We create a new damage | 877 // We're switching back to the software path. We create a new damage |
861 // buffer that can accommodate the current size of the container. | 878 // buffer that can accommodate the current size of the container. |
862 BrowserPluginHostMsg_ResizeGuest_Params params; | 879 BrowserPluginHostMsg_ResizeGuest_Params params; |
863 PopulateResizeGuestParameters(¶ms, plugin_rect()); | |
864 // Request a full repaint from the guest even if its size is not actually | 880 // Request a full repaint from the guest even if its size is not actually |
865 // changing. | 881 // changing. |
866 params.repaint = true; | 882 PopulateResizeGuestParameters(¶ms, |
867 resize_ack_received_ = false; | 883 plugin_rect(), |
| 884 true /* needs_repaint */); |
| 885 paint_ack_received_ = false; |
868 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( | 886 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( |
869 render_view_routing_id_, | 887 render_view_routing_id_, |
870 guest_instance_id_, | 888 guest_instance_id_, |
871 params)); | 889 params)); |
872 } | 890 } |
873 compositing_helper_->EnableCompositing(enable); | 891 compositing_helper_->EnableCompositing(enable); |
874 } | 892 } |
875 | 893 |
876 void BrowserPlugin::destroy() { | 894 void BrowserPlugin::destroy() { |
877 // If the plugin was initialized then it has a valid |npp_| identifier, and | 895 // If the plugin was initialized then it has a valid |npp_| identifier, and |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 const WebRect& clip_rect, | 1019 const WebRect& clip_rect, |
1002 const WebVector<WebRect>& cut_outs_rects, | 1020 const WebVector<WebRect>& cut_outs_rects, |
1003 bool is_visible) { | 1021 bool is_visible) { |
1004 int old_width = width(); | 1022 int old_width = width(); |
1005 int old_height = height(); | 1023 int old_height = height(); |
1006 plugin_rect_ = window_rect; | 1024 plugin_rect_ = window_rect; |
1007 if (!attached()) | 1025 if (!attached()) |
1008 return; | 1026 return; |
1009 | 1027 |
1010 // In AutoSize mode, guests don't care when the BrowserPlugin container is | 1028 // In AutoSize mode, guests don't care when the BrowserPlugin container is |
1011 // resized. If |!resize_ack_received_|, then we are still waiting on a | 1029 // resized. If |!paint_ack_received_|, then we are still waiting on a |
1012 // previous resize to be ACK'ed and so we don't issue additional resizes | 1030 // previous resize to be ACK'ed and so we don't issue additional resizes |
1013 // until the previous one is ACK'ed. | 1031 // until the previous one is ACK'ed. |
1014 // TODO(mthiesse): Assess the performance of calling GetAutoSizeAttribute() on | 1032 // TODO(mthiesse): Assess the performance of calling GetAutoSizeAttribute() on |
1015 // resize. | 1033 // resize. |
1016 if (!resize_ack_received_ || | 1034 if (!paint_ack_received_ || |
1017 (old_width == window_rect.width && old_height == window_rect.height) || | 1035 (old_width == window_rect.width && old_height == window_rect.height) || |
1018 GetAutoSizeAttribute()) { | 1036 GetAutoSizeAttribute()) { |
1019 // Let the browser know about the updated view rect. | 1037 // Let the browser know about the updated view rect. |
1020 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateGeometry( | 1038 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateGeometry( |
1021 render_view_routing_id_, guest_instance_id_, plugin_rect_)); | 1039 render_view_routing_id_, guest_instance_id_, plugin_rect_)); |
1022 return; | 1040 return; |
1023 } | 1041 } |
1024 | 1042 |
1025 BrowserPluginHostMsg_ResizeGuest_Params params; | 1043 BrowserPluginHostMsg_ResizeGuest_Params params; |
1026 PopulateResizeGuestParameters(¶ms, plugin_rect()); | 1044 PopulateResizeGuestParameters(¶ms, plugin_rect(), false); |
1027 resize_ack_received_ = false; | 1045 paint_ack_received_ = false; |
1028 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( | 1046 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( |
1029 render_view_routing_id_, | 1047 render_view_routing_id_, |
1030 guest_instance_id_, | 1048 guest_instance_id_, |
1031 params)); | 1049 params)); |
1032 } | 1050 } |
1033 | 1051 |
1034 void BrowserPlugin::SwapDamageBuffers() { | 1052 void BrowserPlugin::SwapDamageBuffers() { |
1035 current_damage_buffer_.reset(pending_damage_buffer_.release()); | 1053 current_damage_buffer_.reset(pending_damage_buffer_.release()); |
1036 resize_ack_received_ = true; | 1054 paint_ack_received_ = true; |
1037 } | 1055 } |
1038 | 1056 |
1039 void BrowserPlugin::PopulateResizeGuestParameters( | 1057 void BrowserPlugin::PopulateResizeGuestParameters( |
1040 BrowserPluginHostMsg_ResizeGuest_Params* params, | 1058 BrowserPluginHostMsg_ResizeGuest_Params* params, |
1041 const gfx::Rect& view_rect) { | 1059 const gfx::Rect& view_rect, |
| 1060 bool needs_repaint) { |
1042 params->size_changed = true; | 1061 params->size_changed = true; |
1043 params->view_rect = view_rect; | 1062 params->view_rect = view_rect; |
| 1063 params->repaint = needs_repaint; |
1044 params->scale_factor = GetDeviceScaleFactor(); | 1064 params->scale_factor = GetDeviceScaleFactor(); |
1045 if (last_device_scale_factor_ != params->scale_factor){ | 1065 if (last_device_scale_factor_ != params->scale_factor){ |
1046 params->repaint = true; | 1066 params->repaint = true; |
1047 last_device_scale_factor_ = params->scale_factor; | 1067 last_device_scale_factor_ = params->scale_factor; |
1048 } | 1068 } |
1049 | 1069 |
1050 // In HW compositing mode, we do not need a damage buffer. | 1070 // In HW compositing mode, we do not need a damage buffer. |
1051 if (compositing_enabled_) | 1071 if (compositing_enabled_) |
1052 return; | 1072 return; |
1053 | 1073 |
(...skipping 10 matching lines...) Expand all Loading... |
1064 params->damage_buffer_size = size; | 1084 params->damage_buffer_size = size; |
1065 pending_damage_buffer_.reset( | 1085 pending_damage_buffer_.reset( |
1066 CreateDamageBuffer(size, ¶ms->damage_buffer_handle)); | 1086 CreateDamageBuffer(size, ¶ms->damage_buffer_handle)); |
1067 if (!pending_damage_buffer_) | 1087 if (!pending_damage_buffer_) |
1068 NOTREACHED(); | 1088 NOTREACHED(); |
1069 params->damage_buffer_sequence_id = ++damage_buffer_sequence_id_; | 1089 params->damage_buffer_sequence_id = ++damage_buffer_sequence_id_; |
1070 } | 1090 } |
1071 | 1091 |
1072 void BrowserPlugin::GetDamageBufferWithSizeParams( | 1092 void BrowserPlugin::GetDamageBufferWithSizeParams( |
1073 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, | 1093 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, |
1074 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params) { | 1094 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params, |
1075 if (auto_size_params) | 1095 bool needs_repaint) { |
| 1096 if (auto_size_params) { |
1076 PopulateAutoSizeParameters(auto_size_params, GetAutoSizeAttribute()); | 1097 PopulateAutoSizeParameters(auto_size_params, GetAutoSizeAttribute()); |
| 1098 } else { |
| 1099 max_auto_size_ = gfx::Size(); |
| 1100 } |
1077 gfx::Size view_size = (auto_size_params && auto_size_params->enable) ? | 1101 gfx::Size view_size = (auto_size_params && auto_size_params->enable) ? |
1078 auto_size_params->max_size : gfx::Size(width(), height()); | 1102 auto_size_params->max_size : gfx::Size(width(), height()); |
1079 if (view_size.IsEmpty()) | 1103 if (view_size.IsEmpty()) |
1080 return; | 1104 return; |
1081 resize_ack_received_ = false; | 1105 paint_ack_received_ = false; |
1082 gfx::Rect view_rect = gfx::Rect(plugin_rect_.origin(), view_size); | 1106 gfx::Rect view_rect = gfx::Rect(plugin_rect_.origin(), view_size); |
1083 PopulateResizeGuestParameters(resize_guest_params, view_rect); | 1107 PopulateResizeGuestParameters(resize_guest_params, view_rect, needs_repaint); |
1084 } | 1108 } |
1085 | 1109 |
1086 #if defined(OS_POSIX) | 1110 #if defined(OS_POSIX) |
1087 base::SharedMemory* BrowserPlugin::CreateDamageBuffer( | 1111 base::SharedMemory* BrowserPlugin::CreateDamageBuffer( |
1088 const size_t size, | 1112 const size_t size, |
1089 base::SharedMemoryHandle* damage_buffer_handle) { | 1113 base::SharedMemoryHandle* damage_buffer_handle) { |
1090 scoped_ptr<base::SharedMemory> shared_buf( | 1114 scoped_ptr<base::SharedMemory> shared_buf( |
1091 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer( | 1115 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer( |
1092 size).release()); | 1116 size).release()); |
1093 | 1117 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 const WebKit::WebMouseEvent& event) { | 1303 const WebKit::WebMouseEvent& event) { |
1280 browser_plugin_manager()->Send( | 1304 browser_plugin_manager()->Send( |
1281 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 1305 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
1282 guest_instance_id_, | 1306 guest_instance_id_, |
1283 plugin_rect_, | 1307 plugin_rect_, |
1284 &event)); | 1308 &event)); |
1285 return true; | 1309 return true; |
1286 } | 1310 } |
1287 | 1311 |
1288 } // namespace content | 1312 } // namespace content |
OLD | NEW |