summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-02 18:40:14 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-02 18:40:14 +0000
commit6ce7abc518969dfa1699a71ae87fda611012abd9 (patch)
treeaa34ed9e6d1fbf23bc7868b394f7ff032116017c /webkit/glue
parent9732c032ed9b6664149f03472475d31844a1c8ba (diff)
downloadchromium_src-6ce7abc518969dfa1699a71ae87fda611012abd9.zip
chromium_src-6ce7abc518969dfa1699a71ae87fda611012abd9.tar.gz
chromium_src-6ce7abc518969dfa1699a71ae87fda611012abd9.tar.bz2
Hide plugins in minimized/hidden windows on the Mac
Watch for window minizing and app hiding so we know when pages aren't visible for reasons other than being in background tabs. Manually hide plugins in non-visible windows, as a temporary workaround for bug 34266. BUG=30838 TEST=Minimize a window or hide the application while a Flash or Quicktime movie is playing; CPU usage should be the same as if it were in a background tab. Review URL: http://codereview.chromium.org/563010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37851 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h3
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm16
2 files changed, 16 insertions, 3 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index eb05e27..e6e5d20 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -132,7 +132,7 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
void SetWindowHasFocus(bool has_focus);
// Returns whether or not the window the plugin is in has focus.
bool GetWindowHasFocus() const { return containing_window_has_focus_; }
- // Informs the plugin that its tab has been hidden or shown.
+ // Informs the plugin that its tab or window has been hidden or shown.
void SetContainerVisibility(bool is_visible);
// Informs the delegate that the plugin set a Carbon ThemeCursor.
void SetThemeCursor(ThemeCursor cursor);
@@ -363,6 +363,7 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
bool containing_window_has_focus_;
bool container_is_visible_;
bool have_called_set_window_;
+ gfx::Rect cached_clip_rect_;
#endif
// Called by the message filter hook when the plugin enters a modal loop.
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 02d1dcb..27aaf13 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -342,8 +342,10 @@ void WebPluginDelegateImpl::WindowlessUpdateGeometry(
const gfx::Rect& window_rect,
const gfx::Rect& clip_rect) {
bool old_clip_was_empty = clip_rect_.IsEmpty();
- bool new_clip_is_empty = clip_rect.IsEmpty();
- clip_rect_ = clip_rect;
+ cached_clip_rect_ = clip_rect;
+ if (container_is_visible_) // Remove check when cached_clip_rect_ is removed.
+ clip_rect_ = clip_rect;
+ bool new_clip_is_empty = clip_rect_.IsEmpty();
// Only resend to the instance if the geometry has changed (see note in
// WindowlesSetWindow for why we only care about the clip rect switching
@@ -550,6 +552,16 @@ void WebPluginDelegateImpl::SetContainerVisibility(bool is_visible) {
return;
container_is_visible_ = is_visible;
+ // TODO(stuartmorgan): This is a temporary workarond for
+ // <http://crbug.com/34266>. When that is fixed, the cached_clip_rect_ code
+ // should all be removed.
+ if (is_visible) {
+ clip_rect_ = cached_clip_rect_;
+ } else {
+ clip_rect_.set_width(0);
+ clip_rect_.set_height(0);
+ }
+
// TODO(stuartmorgan): We may need to remember whether we had focus, and
// restore it ourselves when we become visible again. Revisit once SetFocus
// is actually being called in all the cases it should be, at which point