Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #if defined (OS_WIN) | 9 #if defined (OS_WIN) |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 | 43 |
| 44 namespace { | 44 namespace { |
| 45 const char kExitEventName[] = "exit"; | 45 const char kExitEventName[] = "exit"; |
| 46 const char kIsTopLevel[] = "isTopLevel"; | 46 const char kIsTopLevel[] = "isTopLevel"; |
| 47 const char kLoadAbortEventName[] = "loadabort"; | 47 const char kLoadAbortEventName[] = "loadabort"; |
| 48 const char kLoadCommitEventName[] = "loadcommit"; | 48 const char kLoadCommitEventName[] = "loadcommit"; |
| 49 const char kLoadRedirectEventName[] = "loadredirect"; | 49 const char kLoadRedirectEventName[] = "loadredirect"; |
| 50 const char kLoadStartEventName[] = "loadstart"; | 50 const char kLoadStartEventName[] = "loadstart"; |
| 51 const char kLoadStopEventName[] = "loadstop"; | 51 const char kLoadStopEventName[] = "loadstop"; |
| 52 const char kNewURL[] = "newUrl"; | 52 const char kNewURL[] = "newUrl"; |
| 53 const char kNewHeight[] = "newHeight"; | |
| 54 const char kNewWidth[] = "newWidth"; | |
| 53 const char kOldURL[] = "oldUrl"; | 55 const char kOldURL[] = "oldUrl"; |
| 56 const char kOldHeight[] = "oldHeight"; | |
| 57 const char kOldWidth[] = "oldWidth"; | |
| 54 const char kPartitionAttribute[] = "partition"; | 58 const char kPartitionAttribute[] = "partition"; |
| 55 const char kPersistPrefix[] = "persist:"; | 59 const char kPersistPrefix[] = "persist:"; |
| 56 const char kProcessId[] = "processId"; | 60 const char kProcessId[] = "processId"; |
| 61 const char kSizeChangedEventName[] = "sizechanged"; | |
| 57 const char kSrcAttribute[] = "src"; | 62 const char kSrcAttribute[] = "src"; |
| 58 const char kType[] = "type"; | 63 const char kType[] = "type"; |
| 59 const char kURL[] = "url"; | 64 const char kURL[] = "url"; |
| 60 | 65 |
| 61 static std::string TerminationStatusToString(base::TerminationStatus status) { | 66 static std::string TerminationStatusToString(base::TerminationStatus status) { |
| 62 switch (status) { | 67 switch (status) { |
| 63 case base::TERMINATION_STATUS_NORMAL_TERMINATION: | 68 case base::TERMINATION_STATUS_NORMAL_TERMINATION: |
| 64 return "normal"; | 69 return "normal"; |
| 65 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | 70 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
| 66 return "abnormal"; | 71 return "abnormal"; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 93 auto_size_(false), | 98 auto_size_(false), |
| 94 max_height_(0), | 99 max_height_(0), |
| 95 max_width_(0), | 100 max_width_(0), |
| 96 min_height_(0), | 101 min_height_(0), |
| 97 min_width_(0), | 102 min_width_(0), |
| 98 process_id_(-1), | 103 process_id_(-1), |
| 99 persist_storage_(false), | 104 persist_storage_(false), |
| 100 content_window_routing_id_(MSG_ROUTING_NONE), | 105 content_window_routing_id_(MSG_ROUTING_NONE), |
| 101 focused_(false), | 106 focused_(false), |
| 102 visible_(true), | 107 visible_(true), |
| 108 size_changed_in_flight_(false), | |
| 103 current_nav_entry_index_(0), | 109 current_nav_entry_index_(0), |
| 104 nav_entry_count_(0) { | 110 nav_entry_count_(0) { |
| 105 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); | 111 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); |
| 106 bindings_.reset(new BrowserPluginBindings(this)); | 112 bindings_.reset(new BrowserPluginBindings(this)); |
| 107 | 113 |
| 108 InitializeEvents(); | 114 InitializeEvents(); |
| 109 | 115 |
| 110 ParseAttributes(params); | 116 ParseAttributes(params); |
| 111 } | 117 } |
| 112 | 118 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 // Once this instance has navigated, the storage partition cannot be changed, | 167 // Once this instance has navigated, the storage partition cannot be changed, |
| 162 // so this value is used for enforcing this. | 168 // so this value is used for enforcing this. |
| 163 navigate_src_sent_ = true; | 169 navigate_src_sent_ = true; |
| 164 src_ = src; | 170 src_ = src; |
| 165 } | 171 } |
| 166 | 172 |
| 167 void BrowserPlugin::SetAutoSizeAttribute(bool auto_size) { | 173 void BrowserPlugin::SetAutoSizeAttribute(bool auto_size) { |
| 168 if (auto_size_ == auto_size) | 174 if (auto_size_ == auto_size) |
| 169 return; | 175 return; |
| 170 auto_size_ = auto_size; | 176 auto_size_ = auto_size; |
| 177 last_view_size_ = plugin_rect_.size(); | |
| 178 //backing_store_.reset(); | |
|
lazyboy
2012/11/06 22:22:35
rm
Fady Samuel
2012/11/06 23:52:34
Done.
| |
| 171 UpdateGuestAutoSizeState(); | 179 UpdateGuestAutoSizeState(); |
| 172 } | 180 } |
| 173 | 181 |
| 174 void BrowserPlugin::PopulateAutoSizeParameters( | 182 void BrowserPlugin::PopulateAutoSizeParameters( |
| 175 BrowserPluginHostMsg_AutoSize_Params* params) const { | 183 BrowserPluginHostMsg_AutoSize_Params* params) { |
| 184 // If maxWidth or maxHeight have not been set, set them to the container size. | |
| 185 max_height_ = max_height_ ? max_height_ : height(); | |
| 186 max_width_ = max_width_ ? max_width_ : width(); | |
| 187 // minWidth should not be bigger than maxWidth, and minHeight should not be | |
| 188 // bigger than maxHeight. | |
| 189 min_height_ = std::min(min_height_, max_height_); | |
| 190 min_width_ = std::min(min_width_, max_width_); | |
| 176 params->enable = auto_size_; | 191 params->enable = auto_size_; |
| 177 params->max_height = max_height_; | 192 params->max_height = max_height_; |
| 178 params->max_width = max_width_; | 193 params->max_width = max_width_; |
| 179 params->min_height = min_height_; | 194 params->min_height = min_height_; |
| 180 params->min_width = min_width_; | 195 params->min_width = min_width_; |
| 196 | |
|
lazyboy
2012/11/06 22:22:35
nit: rm
Fady Samuel
2012/11/06 23:52:34
Done.
| |
| 181 } | 197 } |
| 182 | 198 |
| 183 void BrowserPlugin::UpdateGuestAutoSizeState() const { | 199 void BrowserPlugin::UpdateGuestAutoSizeState() { |
| 184 if (!navigate_src_sent_) | 200 if (!navigate_src_sent_) |
| 185 return; | 201 return; |
| 186 BrowserPluginHostMsg_AutoSize_Params params; | 202 BrowserPluginHostMsg_AutoSize_Params auto_size_params; |
| 187 PopulateAutoSizeParameters(¶ms); | 203 PopulateAutoSizeParameters(&auto_size_params); |
| 204 BrowserPluginHostMsg_ResizeGuest_Params resize_params; | |
| 205 int view_width = auto_size_params.max_width; | |
| 206 int view_height = auto_size_params.max_height; | |
| 207 if (!auto_size_params.enable) { | |
| 208 view_width = width(); | |
| 209 view_height = height(); | |
| 210 } | |
| 211 TransportDIB* new_damage_buffer = | |
| 212 PopulateResizeGuestParameters(&resize_params, view_width, view_height); | |
| 213 // AutoSize initiates a resize so we don't want to issue another resize, | |
| 214 // we just want to make sure the damage buffer has been updated. | |
| 215 resize_params.resize_pending = true; | |
| 216 DCHECK(new_damage_buffer); | |
| 188 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetAutoSize( | 217 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetAutoSize( |
| 189 render_view_routing_id_, | 218 render_view_routing_id_, |
| 190 instance_id_, | 219 instance_id_, |
| 191 params)); | 220 auto_size_params, |
| 221 resize_params)); | |
| 222 if (damage_buffer_) | |
| 223 FreeDamageBuffer(); | |
| 224 damage_buffer_ = new_damage_buffer; | |
| 225 } | |
| 226 | |
| 227 void BrowserPlugin::SizeChanged(const gfx::Size& old_view_size) { | |
|
lazyboy
2012/11/06 22:22:35
This is size changed due to auto sizing only, mayb
Fady Samuel
2012/11/06 23:52:34
Done.
| |
| 228 size_changed_in_flight_ = false; | |
| 229 if (!HasListeners(kSizeChangedEventName)) | |
| 230 return; | |
| 231 | |
| 232 WebKit::WebElement plugin = container()->element(); | |
| 233 v8::HandleScope handle_scope; | |
| 234 v8::Context::Scope context_scope( | |
| 235 plugin.document().frame()->mainWorldScriptContext()); | |
| 236 | |
| 237 // Construct the loadStart event object. | |
|
lazyboy
2012/11/06 22:22:35
nit: fix comment.
Fady Samuel
2012/11/06 23:52:34
Done.
| |
| 238 v8::Local<v8::Object> event = v8::Object::New(); | |
| 239 event->Set(v8::String::New(kOldHeight, sizeof(kOldHeight) - 1), | |
| 240 v8::Integer::New(old_view_size.height()), | |
| 241 v8::ReadOnly); | |
| 242 event->Set(v8::String::New(kOldWidth, sizeof(kOldWidth) - 1), | |
| 243 v8::Integer::New(old_view_size.width()), | |
| 244 v8::ReadOnly); | |
| 245 event->Set(v8::String::New(kNewHeight, sizeof(kNewHeight) - 1), | |
| 246 v8::Integer::New(last_view_size_.height()), | |
| 247 v8::ReadOnly); | |
| 248 event->Set(v8::String::New(kNewWidth, sizeof(kNewWidth) - 1), | |
| 249 v8::Integer::New(last_view_size_.width()), | |
| 250 v8::ReadOnly); | |
| 251 TriggerEvent(kSizeChangedEventName, &event); | |
| 192 } | 252 } |
| 193 | 253 |
| 194 void BrowserPlugin::SetMaxHeightAttribute(int max_height) { | 254 void BrowserPlugin::SetMaxHeightAttribute(int max_height) { |
| 195 if (max_height_ == max_height) | 255 if (max_height_ == max_height) |
| 196 return; | 256 return; |
| 197 max_height_ = max_height; | 257 max_height_ = max_height; |
| 198 if (!auto_size_) | 258 if (!auto_size_) |
| 199 return; | 259 return; |
| 200 UpdateGuestAutoSizeState(); | 260 UpdateGuestAutoSizeState(); |
| 201 } | 261 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 220 | 280 |
| 221 void BrowserPlugin::SetMinWidthAttribute(int min_width) { | 281 void BrowserPlugin::SetMinWidthAttribute(int min_width) { |
| 222 if (min_width_ == min_width) | 282 if (min_width_ == min_width) |
| 223 return; | 283 return; |
| 224 min_width_ = min_width; | 284 min_width_ = min_width; |
| 225 if (!auto_size_) | 285 if (!auto_size_) |
| 226 return; | 286 return; |
| 227 UpdateGuestAutoSizeState(); | 287 UpdateGuestAutoSizeState(); |
| 228 } | 288 } |
| 229 | 289 |
| 290 bool BrowserPlugin::InAutoSizeBounds(const gfx::Size& size) const { | |
| 291 return size.width() <= max_width_ && size.height() <= max_height_; | |
| 292 } | |
| 293 | |
| 230 NPObject* BrowserPlugin::GetContentWindow() const { | 294 NPObject* BrowserPlugin::GetContentWindow() const { |
| 231 if (content_window_routing_id_ == MSG_ROUTING_NONE) | 295 if (content_window_routing_id_ == MSG_ROUTING_NONE) |
| 232 return NULL; | 296 return NULL; |
| 233 RenderViewImpl* guest_render_view = static_cast<RenderViewImpl*>( | 297 RenderViewImpl* guest_render_view = static_cast<RenderViewImpl*>( |
| 234 ChildThread::current()->ResolveRoute(content_window_routing_id_)); | 298 ChildThread::current()->ResolveRoute(content_window_routing_id_)); |
| 235 if (!guest_render_view) | 299 if (!guest_render_view) |
| 236 return NULL; | 300 return NULL; |
| 237 WebKit::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); | 301 WebKit::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); |
| 238 return guest_frame->windowObject(); | 302 return guest_frame->windowObject(); |
| 239 } | 303 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 return render_view_->GetWebView()->deviceScaleFactor(); | 377 return render_view_->GetWebView()->deviceScaleFactor(); |
| 314 } | 378 } |
| 315 | 379 |
| 316 void BrowserPlugin::InitializeEvents() { | 380 void BrowserPlugin::InitializeEvents() { |
| 317 event_listener_map_[kExitEventName] = EventListeners(); | 381 event_listener_map_[kExitEventName] = EventListeners(); |
| 318 event_listener_map_[kLoadAbortEventName] = EventListeners(); | 382 event_listener_map_[kLoadAbortEventName] = EventListeners(); |
| 319 event_listener_map_[kLoadCommitEventName] = EventListeners(); | 383 event_listener_map_[kLoadCommitEventName] = EventListeners(); |
| 320 event_listener_map_[kLoadRedirectEventName] = EventListeners(); | 384 event_listener_map_[kLoadRedirectEventName] = EventListeners(); |
| 321 event_listener_map_[kLoadStartEventName] = EventListeners(); | 385 event_listener_map_[kLoadStartEventName] = EventListeners(); |
| 322 event_listener_map_[kLoadStopEventName] = EventListeners(); | 386 event_listener_map_[kLoadStopEventName] = EventListeners(); |
| 387 event_listener_map_[kSizeChangedEventName] = EventListeners(); | |
| 323 } | 388 } |
| 324 | 389 |
| 325 void BrowserPlugin::RemoveEventListeners() { | 390 void BrowserPlugin::RemoveEventListeners() { |
| 326 EventListenerMap::iterator event_listener_map_iter = | 391 EventListenerMap::iterator event_listener_map_iter = |
| 327 event_listener_map_.begin(); | 392 event_listener_map_.begin(); |
| 328 for (; event_listener_map_iter != event_listener_map_.end(); | 393 for (; event_listener_map_iter != event_listener_map_.end(); |
| 329 ++event_listener_map_iter) { | 394 ++event_listener_map_iter) { |
| 330 EventListeners& listeners = | 395 EventListeners& listeners = |
| 331 event_listener_map_[event_listener_map_iter->first]; | 396 event_listener_map_[event_listener_map_iter->first]; |
| 332 EventListeners::iterator it = listeners.begin(); | 397 EventListeners::iterator it = listeners.begin(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 if (!navigate_src_sent_) | 485 if (!navigate_src_sent_) |
| 421 return; | 486 return; |
| 422 BrowserPluginManager::Get()->Send( | 487 BrowserPluginManager::Get()->Send( |
| 423 new BrowserPluginHostMsg_Reload(render_view_routing_id_, | 488 new BrowserPluginHostMsg_Reload(render_view_routing_id_, |
| 424 instance_id_)); | 489 instance_id_)); |
| 425 } | 490 } |
| 426 | 491 |
| 427 void BrowserPlugin::UpdateRect( | 492 void BrowserPlugin::UpdateRect( |
| 428 int message_id, | 493 int message_id, |
| 429 const BrowserPluginMsg_UpdateRect_Params& params) { | 494 const BrowserPluginMsg_UpdateRect_Params& params) { |
| 430 if (width() != params.view_size.width() || | 495 if ((!auto_size_ && |
| 431 height() != params.view_size.height()) { | 496 (width() != params.view_size.width() || |
| 497 height() != params.view_size.height())) || | |
| 498 (auto_size_ && (!InAutoSizeBounds(params.view_size)))) { | |
| 432 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( | 499 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( |
| 433 render_view_routing_id_, | 500 render_view_routing_id_, |
| 434 instance_id_, | 501 instance_id_, |
| 435 message_id, | 502 message_id, |
| 436 gfx::Size(width(), height()))); | 503 gfx::Size(width(), height()))); |
| 437 return; | 504 return; |
| 438 } | 505 } |
| 506 // If the view size has changed since we last updated. | |
| 507 if (auto_size_ && (params.view_size != last_view_size_)) { | |
| 508 if (backing_store_) | |
| 509 backing_store_->Clear(SK_ColorWHITE); | |
| 510 gfx::Size old_view_size = last_view_size_; | |
| 511 last_view_size_ = params.view_size; | |
| 512 // Schedule a SizeChanged instead of calling it directly to ensure that | |
| 513 // the backing store has been updated before the developer attempts to | |
|
lazyboy
2012/11/06 22:22:35
I'm not sure I totally understand this one, if you
Fady Samuel
2012/11/06 23:52:34
Yes. Also, if there are multiple updateRects queue
lazyboy
2012/11/07 07:39:09
Ah, I was about to suggest you write a test for th
| |
| 514 // resize to avoid flicker. |size_changed_in_flight_| acts as a form of | |
| 515 // flow control for SizeChanged events. If the guest's view size is changing | |
| 516 // rapidly before a SizeChanged event fires, then we avoid scheduling | |
| 517 // another SizedChanged event. SizedChanged reads the new size from | |
| 518 // |last_view_size_| so we can be sure that it always fires an event | |
| 519 // with the last seen view size. | |
| 520 if (container_ && !size_changed_in_flight_) { | |
| 521 size_changed_in_flight_ = true; | |
| 522 MessageLoop::current()->PostTask( | |
| 523 FROM_HERE, | |
| 524 base::Bind(&BrowserPlugin::SizeChanged, base::Unretained(this), | |
| 525 old_view_size)); | |
| 526 } | |
| 527 } | |
| 439 | 528 |
| 440 float backing_store_scale_factor = | 529 float backing_store_scale_factor = |
| 441 backing_store_.get() ? backing_store_->GetScaleFactor() : 1.0f; | 530 backing_store_.get() ? backing_store_->GetScaleFactor() : 1.0f; |
| 442 | 531 |
| 443 if (params.is_resize_ack || | 532 if (!backing_store_ || params.is_resize_ack || |
| 444 backing_store_scale_factor != params.scale_factor) { | 533 (backing_store_scale_factor != params.scale_factor) || |
| 534 params.view_size.width() > backing_store_->GetSize().width() || | |
| 535 params.view_size.height() > backing_store_->GetSize().height()) { | |
| 536 int backing_store_width = auto_size_ ? max_width_ : width(); | |
| 537 int backing_store_height = auto_size_ ? max_height_: height(); | |
| 445 resize_pending_ = !params.is_resize_ack; | 538 resize_pending_ = !params.is_resize_ack; |
| 446 backing_store_.reset( | 539 backing_store_.reset( |
| 447 new BrowserPluginBackingStore(gfx::Size(width(), height()), | 540 new BrowserPluginBackingStore( |
| 448 params.scale_factor)); | 541 gfx::Size(backing_store_width, backing_store_height), |
| 542 params.scale_factor)); | |
| 449 } | 543 } |
| 450 | 544 |
| 451 // Update the backing store. | 545 // Update the backing store. |
| 452 if (!params.scroll_rect.IsEmpty()) { | 546 if (!params.scroll_rect.IsEmpty()) { |
| 453 backing_store_->ScrollBackingStore(params.dx, | 547 backing_store_->ScrollBackingStore(params.dx, |
| 454 params.dy, | 548 params.dy, |
| 455 params.scroll_rect, | 549 params.scroll_rect, |
| 456 params.view_size); | 550 params.view_size); |
| 457 } | 551 } |
| 458 for (unsigned i = 0; i < params.copy_rects.size(); i++) { | 552 for (unsigned i = 0; i < params.copy_rects.size(); i++) { |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 | 840 |
| 747 void BrowserPlugin::updateGeometry( | 841 void BrowserPlugin::updateGeometry( |
| 748 const WebRect& window_rect, | 842 const WebRect& window_rect, |
| 749 const WebRect& clip_rect, | 843 const WebRect& clip_rect, |
| 750 const WebVector<WebRect>& cut_outs_rects, | 844 const WebVector<WebRect>& cut_outs_rects, |
| 751 bool is_visible) { | 845 bool is_visible) { |
| 752 int old_width = width(); | 846 int old_width = width(); |
| 753 int old_height = height(); | 847 int old_height = height(); |
| 754 plugin_rect_ = window_rect; | 848 plugin_rect_ = window_rect; |
| 755 if (auto_size_ || (old_width == window_rect.width && | 849 if (auto_size_ || (old_width == window_rect.width && |
| 756 old_height == window_rect.height)) { | 850 old_height == window_rect.height)) { |
| 757 return; | 851 return; |
| 758 } | 852 } |
| 759 | |
| 760 const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width); | |
| 761 // Make sure the size of the damage buffer is at least four bytes so that we | |
| 762 // can fit in a magic word to verify that the memory is shared correctly. | |
| 763 size_t size = | |
| 764 std::max(sizeof(unsigned int), | |
| 765 static_cast<size_t>(window_rect.height * | |
| 766 stride * | |
| 767 GetDeviceScaleFactor() * | |
| 768 GetDeviceScaleFactor())); | |
| 769 | |
| 770 // Don't drop the old damage buffer until after we've made sure that the | |
| 771 // browser process has dropped it. | |
| 772 TransportDIB* new_damage_buffer = CreateTransportDIB(size); | |
| 773 pending_resize_params_.reset(); | 853 pending_resize_params_.reset(); |
| 774 | 854 |
| 775 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params( | 855 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params( |
| 776 new BrowserPluginHostMsg_ResizeGuest_Params); | 856 new BrowserPluginHostMsg_ResizeGuest_Params); |
| 777 params->damage_buffer_id = new_damage_buffer->id(); | 857 |
| 778 #if defined(OS_MACOSX) | 858 TransportDIB* new_damage_buffer = |
| 779 // |damage_buffer_id| is not enough to retrieve the damage buffer (on browser | 859 PopulateResizeGuestParameters(params.get(), width(), height()); |
| 780 // side) since we don't let the browser cache the damage buffer. We need a | 860 DCHECK(new_damage_buffer); |
| 781 // handle to the damage buffer for this. | |
| 782 params->damage_buffer_handle = new_damage_buffer->handle(); | |
| 783 #endif | |
| 784 #if defined(OS_WIN) | |
| 785 params->damage_buffer_size = size; | |
| 786 #endif | |
| 787 params->width = window_rect.width; | |
| 788 params->height = window_rect.height; | |
| 789 params->resize_pending = resize_pending_; | |
| 790 params->scale_factor = GetDeviceScaleFactor(); | |
| 791 | 861 |
| 792 if (navigate_src_sent_) { | 862 if (navigate_src_sent_) { |
| 793 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest( | 863 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest( |
| 794 render_view_routing_id_, | 864 render_view_routing_id_, |
| 795 instance_id_, | 865 instance_id_, |
| 796 *params)); | 866 *params)); |
| 797 resize_pending_ = true; | 867 resize_pending_ = true; |
| 798 } else { | 868 } else { |
| 799 // Until an actual navigation occurs, there is no browser-side embedder | 869 // Until an actual navigation occurs, there is no browser-side embedder |
| 800 // present to notify about geometry updates. In this case, after we've | 870 // present to notify about geometry updates. In this case, after we've |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 813 // We don't need to (nor should we) send ViewHostMsg_FreeTransportDIB | 883 // We don't need to (nor should we) send ViewHostMsg_FreeTransportDIB |
| 814 // message to the browser to free the damage buffer since we manage the | 884 // message to the browser to free the damage buffer since we manage the |
| 815 // damage buffer ourselves. | 885 // damage buffer ourselves. |
| 816 delete damage_buffer_; | 886 delete damage_buffer_; |
| 817 #else | 887 #else |
| 818 RenderProcess::current()->FreeTransportDIB(damage_buffer_); | 888 RenderProcess::current()->FreeTransportDIB(damage_buffer_); |
| 819 damage_buffer_ = NULL; | 889 damage_buffer_ = NULL; |
| 820 #endif | 890 #endif |
| 821 } | 891 } |
| 822 | 892 |
| 893 TransportDIB* BrowserPlugin::PopulateResizeGuestParameters( | |
| 894 BrowserPluginHostMsg_ResizeGuest_Params* params, | |
| 895 int view_width, int view_height) { | |
| 896 const size_t stride = skia::PlatformCanvas::StrideForWidth(view_width); | |
| 897 // Make sure the size of the damage buffer is at least four bytes so that we | |
| 898 // can fit in a magic word to verify that the memory is shared correctly. | |
| 899 size_t size = | |
| 900 std::max(sizeof(unsigned int), | |
| 901 static_cast<size_t>(view_height * | |
| 902 stride * | |
| 903 GetDeviceScaleFactor() * | |
| 904 GetDeviceScaleFactor())); | |
| 905 | |
| 906 // Don't drop the old damage buffer until after we've made sure that the | |
| 907 // browser process has dropped it. | |
| 908 TransportDIB* new_damage_buffer = CreateTransportDIB(size); | |
| 909 params->damage_buffer_id = new_damage_buffer->id(); | |
| 910 #if defined(OS_MACOSX) | |
| 911 // |damage_buffer_id| is not enough to retrieve the damage buffer (on browser | |
| 912 // side) since we don't let the browser cache the damage buffer. We need a | |
| 913 // handle to the damage buffer for this. | |
| 914 params->damage_buffer_handle = new_damage_buffer->handle(); | |
| 915 #endif | |
| 916 #if defined(OS_WIN) | |
| 917 params->damage_buffer_size = size; | |
| 918 #endif | |
| 919 params->width = view_width; | |
| 920 params->height = view_height; | |
| 921 params->resize_pending = resize_pending_; | |
| 922 params->scale_factor = GetDeviceScaleFactor(); | |
| 923 return new_damage_buffer; | |
| 924 } | |
| 925 | |
| 823 BrowserPluginHostMsg_ResizeGuest_Params* | 926 BrowserPluginHostMsg_ResizeGuest_Params* |
| 824 BrowserPlugin::GetPendingResizeParams() { | 927 BrowserPlugin::GetPendingResizeParams() { |
| 825 if (pending_resize_params_.get()) { | 928 if (pending_resize_params_.get()) { |
| 826 resize_pending_ = true; | 929 resize_pending_ = true; |
| 827 return pending_resize_params_.release(); | 930 return pending_resize_params_.release(); |
| 828 } else { | 931 } else { |
| 829 BrowserPluginHostMsg_ResizeGuest_Params* params = | 932 BrowserPluginHostMsg_ResizeGuest_Params* params = |
| 830 new BrowserPluginHostMsg_ResizeGuest_Params; | 933 new BrowserPluginHostMsg_ResizeGuest_Params; |
| 831 | 934 |
| 832 // We don't have a pending resize to send, so we send an invalid transport | 935 // We don't have a pending resize to send, so we send an invalid transport |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 954 void* notify_data) { | 1057 void* notify_data) { |
| 955 } | 1058 } |
| 956 | 1059 |
| 957 void BrowserPlugin::didFailLoadingFrameRequest( | 1060 void BrowserPlugin::didFailLoadingFrameRequest( |
| 958 const WebKit::WebURL& url, | 1061 const WebKit::WebURL& url, |
| 959 void* notify_data, | 1062 void* notify_data, |
| 960 const WebKit::WebURLError& error) { | 1063 const WebKit::WebURLError& error) { |
| 961 } | 1064 } |
| 962 | 1065 |
| 963 } // namespace content | 1066 } // namespace content |
| OLD | NEW |