Commit 058dfa9b authored by brettw@google.com's avatar brettw@google.com

Don't send DidChangeView to the plugin unless the parameters have actually changed.

Apparently WebKit sends the update for every layout, even if nothing has changed.
Review URL: http://codereview.chromium.org/7761005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98511 0039d316-1c4b-4281-b951-d872f2087c98
parent 4e36da13
...@@ -217,6 +217,7 @@ PluginInstance::PluginInstance( ...@@ -217,6 +217,7 @@ PluginInstance::PluginInstance(
pp_instance_(0), pp_instance_(0),
container_(NULL), container_(NULL),
full_frame_(false), full_frame_(false),
sent_did_change_view_(false),
has_webkit_focus_(false), has_webkit_focus_(false),
has_content_area_focus_(false), has_content_area_focus_(false),
find_identifier_(-1), find_identifier_(-1),
...@@ -505,18 +506,22 @@ PP_Var PluginInstance::GetInstanceObject() { ...@@ -505,18 +506,22 @@ PP_Var PluginInstance::GetInstanceObject() {
void PluginInstance::ViewChanged(const gfx::Rect& position, void PluginInstance::ViewChanged(const gfx::Rect& position,
const gfx::Rect& clip) { const gfx::Rect& clip) {
fullscreen_ = (fullscreen_container_ != NULL);
position_ = position;
if (clip.IsEmpty()) {
// WebKit can give weird (x,y) positions for empty clip rects (since the // WebKit can give weird (x,y) positions for empty clip rects (since the
// position technically doesn't matter). But we want to make these // position technically doesn't matter). But we want to make these
// consistent since this is given to the plugin, so force everything to 0 // consistent since this is given to the plugin, so force everything to 0
// in the "everything is clipped" case. // in the "everything is clipped" case.
clip_ = gfx::Rect(); gfx::Rect new_clip;
} else { if (!clip.IsEmpty())
clip_ = clip; new_clip = clip;
}
// Don't notify the plugin if we've already sent these same params before.
if (sent_did_change_view_ && position == position_ && new_clip == clip_)
return;
sent_did_change_view_ = true;
position_ = position;
clip_ = new_clip;
fullscreen_ = (fullscreen_container_ != NULL);
PP_Rect pp_position, pp_clip; PP_Rect pp_position, pp_clip;
RectToPPRect(position_, &pp_position); RectToPPRect(position_, &pp_position);
......
...@@ -361,6 +361,11 @@ class PluginInstance : public base::RefCounted<PluginInstance>, ...@@ -361,6 +361,11 @@ class PluginInstance : public base::RefCounted<PluginInstance>,
// an entire document rather than an embed tag. // an entire document rather than an embed tag.
bool full_frame_; bool full_frame_;
// Indicates if we've ever sent a didChangeView to the plugin. This ensure we
// always send an initial notification, even if the position and clip are the
// same as the default values.
bool sent_did_change_view_;
// Position in the viewport (which moves as the page is scrolled) of this // Position in the viewport (which moves as the page is scrolled) of this
// plugin. This will be a 0-sized rectangle if the plugin has not yet been // plugin. This will be a 0-sized rectangle if the plugin has not yet been
// laid out. // laid out.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment