OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 PluginInstance::PluginInstance( | 210 PluginInstance::PluginInstance( |
211 PluginDelegate* delegate, | 211 PluginDelegate* delegate, |
212 PluginModule* module, | 212 PluginModule* module, |
213 ::ppapi::PPP_Instance_Combined* instance_interface) | 213 ::ppapi::PPP_Instance_Combined* instance_interface) |
214 : delegate_(delegate), | 214 : delegate_(delegate), |
215 module_(module), | 215 module_(module), |
216 instance_interface_(instance_interface), | 216 instance_interface_(instance_interface), |
217 pp_instance_(0), | 217 pp_instance_(0), |
218 container_(NULL), | 218 container_(NULL), |
219 full_frame_(false), | 219 full_frame_(false), |
| 220 sent_did_change_view_(false), |
220 has_webkit_focus_(false), | 221 has_webkit_focus_(false), |
221 has_content_area_focus_(false), | 222 has_content_area_focus_(false), |
222 find_identifier_(-1), | 223 find_identifier_(-1), |
223 plugin_find_interface_(NULL), | 224 plugin_find_interface_(NULL), |
224 plugin_messaging_interface_(NULL), | 225 plugin_messaging_interface_(NULL), |
225 plugin_input_event_interface_(NULL), | 226 plugin_input_event_interface_(NULL), |
226 plugin_private_interface_(NULL), | 227 plugin_private_interface_(NULL), |
227 plugin_pdf_interface_(NULL), | 228 plugin_pdf_interface_(NULL), |
228 plugin_policy_updated_interface_(NULL), | 229 plugin_policy_updated_interface_(NULL), |
229 plugin_selection_interface_(NULL), | 230 plugin_selection_interface_(NULL), |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 | 499 |
499 // If the plugin supports the private instance interface, try to retrieve its | 500 // If the plugin supports the private instance interface, try to retrieve its |
500 // instance object. | 501 // instance object. |
501 if (LoadPrivateInterface()) | 502 if (LoadPrivateInterface()) |
502 return plugin_private_interface_->GetInstanceObject(pp_instance()); | 503 return plugin_private_interface_->GetInstanceObject(pp_instance()); |
503 return PP_MakeUndefined(); | 504 return PP_MakeUndefined(); |
504 } | 505 } |
505 | 506 |
506 void PluginInstance::ViewChanged(const gfx::Rect& position, | 507 void PluginInstance::ViewChanged(const gfx::Rect& position, |
507 const gfx::Rect& clip) { | 508 const gfx::Rect& clip) { |
| 509 // WebKit can give weird (x,y) positions for empty clip rects (since the |
| 510 // position technically doesn't matter). But we want to make these |
| 511 // consistent since this is given to the plugin, so force everything to 0 |
| 512 // in the "everything is clipped" case. |
| 513 gfx::Rect new_clip; |
| 514 if (!clip.IsEmpty()) |
| 515 new_clip = clip; |
| 516 |
| 517 // Don't notify the plugin if we've already sent these same params before. |
| 518 if (sent_did_change_view_ && position == position_ && new_clip == clip_) |
| 519 return; |
| 520 |
| 521 sent_did_change_view_ = true; |
| 522 position_ = position; |
| 523 clip_ = new_clip; |
508 fullscreen_ = (fullscreen_container_ != NULL); | 524 fullscreen_ = (fullscreen_container_ != NULL); |
509 position_ = position; | |
510 | |
511 if (clip.IsEmpty()) { | |
512 // WebKit can give weird (x,y) positions for empty clip rects (since the | |
513 // position technically doesn't matter). But we want to make these | |
514 // consistent since this is given to the plugin, so force everything to 0 | |
515 // in the "everything is clipped" case. | |
516 clip_ = gfx::Rect(); | |
517 } else { | |
518 clip_ = clip; | |
519 } | |
520 | 525 |
521 PP_Rect pp_position, pp_clip; | 526 PP_Rect pp_position, pp_clip; |
522 RectToPPRect(position_, &pp_position); | 527 RectToPPRect(position_, &pp_position); |
523 RectToPPRect(clip_, &pp_clip); | 528 RectToPPRect(clip_, &pp_clip); |
524 instance_interface_->DidChangeView(pp_instance(), &pp_position, &pp_clip); | 529 instance_interface_->DidChangeView(pp_instance(), &pp_position, &pp_clip); |
525 } | 530 } |
526 | 531 |
527 void PluginInstance::SetWebKitFocus(bool has_focus) { | 532 void PluginInstance::SetWebKitFocus(bool has_focus) { |
528 if (has_webkit_focus_ == has_focus) | 533 if (has_webkit_focus_ == has_focus) |
529 return; | 534 return; |
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 } | 1556 } |
1552 | 1557 |
1553 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { | 1558 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { |
1554 cursor_.reset(cursor); | 1559 cursor_.reset(cursor); |
1555 if (fullscreen_container_) | 1560 if (fullscreen_container_) |
1556 fullscreen_container_->DidChangeCursor(*cursor); | 1561 fullscreen_container_->DidChangeCursor(*cursor); |
1557 } | 1562 } |
1558 | 1563 |
1559 } // namespace ppapi | 1564 } // namespace ppapi |
1560 } // namespace webkit | 1565 } // namespace webkit |
OLD | NEW |