summaryrefslogtreecommitdiffstats
path: root/chrome/browser/notifications
diff options
context:
space:
mode:
authorlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-25 09:14:26 +0000
committerlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-25 09:14:26 +0000
commit99c1e2e11855ba759129418fa5752cebdadb033c (patch)
treec36596aa65f99fa2ecc55ae368f2d57382f3bf59 /chrome/browser/notifications
parentf215b6947acb9d8ab9475b240187ccb1f31cfc3f (diff)
downloadchromium_src-99c1e2e11855ba759129418fa5752cebdadb033c.zip
chromium_src-99c1e2e11855ba759129418fa5752cebdadb033c.tar.gz
chromium_src-99c1e2e11855ba759129418fa5752cebdadb033c.tar.bz2
Make it so that notifications only start resizing after the first paint is done.
Also, only allow them to grow. BUG=56693 TEST=Ran many tests manually. Automated test in progress (before closing the bug). Review URL: http://codereview.chromium.org/5331006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67396 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/notifications')
-rw-r--r--chrome/browser/notifications/balloon.cc12
-rw-r--r--chrome/browser/notifications/balloon_host.cc37
-rw-r--r--chrome/browser/notifications/balloon_host.h3
3 files changed, 48 insertions, 4 deletions
diff --git a/chrome/browser/notifications/balloon.cc b/chrome/browser/notifications/balloon.cc
index 96f3fca..b5431c7 100644
--- a/chrome/browser/notifications/balloon.cc
+++ b/chrome/browser/notifications/balloon.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/renderer_host/site_instance.h"
#include "gfx/rect.h"
+#include "gfx/size.h"
Balloon::Balloon(const Notification& notification, Profile* profile,
BalloonCollection* collection)
@@ -27,7 +28,16 @@ void Balloon::SetPosition(const gfx::Point& upper_left, bool reposition) {
}
void Balloon::SetContentPreferredSize(const gfx::Size& size) {
- collection_->ResizeBalloon(this, size);
+ gfx::Size new_size(size);
+ // Only allow the size of notifications to grow. This stops the balloon
+ // from jumping between sizes due to dynamic content. For example, the
+ // balloon's contents may adjust due to changes in
+ // document.body.clientHeight.
+ new_size.set_height(std::max(new_size.height(), content_size_.height()));
+
+ if (content_size_ == new_size)
+ return;
+ collection_->ResizeBalloon(this, new_size);
}
void Balloon::set_view(BalloonView* balloon_view) {
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc
index 04f0b89..387017d 100644
--- a/chrome/browser/notifications/balloon_host.cc
+++ b/chrome/browser/notifications/balloon_host.cc
@@ -20,6 +20,30 @@
#include "chrome/common/url_constants.h"
#include "webkit/glue/webpreferences.h"
+namespace {
+class BalloonPaintObserver : public RenderWidgetHost::PaintObserver {
+ public:
+ BalloonPaintObserver(BalloonHost* balloon_host)
+ : balloon_host_(balloon_host) {
+ }
+
+ virtual void RenderWidgetHostWillPaint(RenderWidgetHost* rhw) {}
+ virtual void RenderWidgetHostDidPaint(RenderWidgetHost* rwh);
+
+ private:
+ BalloonHost* balloon_host_;
+
+ DISALLOW_COPY_AND_ASSIGN(BalloonPaintObserver);
+};
+
+void BalloonPaintObserver::RenderWidgetHostDidPaint(RenderWidgetHost* rwh) {
+ balloon_host_->RenderWidgetHostDidPaint();
+ // WARNING: we may have been deleted (if the balloon host cleared the paint
+ // observer).
+}
+
+} // namespace
+
BalloonHost::BalloonHost(Balloon* balloon)
: render_view_host_(NULL),
balloon_(balloon),
@@ -92,8 +116,6 @@ void BalloonHost::RenderViewCreated(RenderViewHost* render_view_host) {
render_view_host->Send(new ViewMsg_DisableScrollbarsForSmallWindows(
render_view_host->routing_id(), balloon_->min_scrollbar_size()));
render_view_host->WasResized();
- render_view_host->EnablePreferredSizeChangedMode(
- kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow);
}
void BalloonHost::RenderViewReady(RenderViewHost* render_view_host) {
@@ -198,6 +220,7 @@ void BalloonHost::Init() {
rvh->set_view(render_widget_host_view());
rvh->CreateRenderView(string16());
+ rvh->set_paint_observer(new BalloonPaintObserver(this));
rvh->NavigateToURL(balloon_->notification().content_url());
initialized_ = true;
@@ -219,7 +242,15 @@ void BalloonHost::ClearInspectorSettings() {
RenderViewHostDelegateHelper::ClearInspectorSettings(GetProfile());
}
-BalloonHost::~BalloonHost() {}
+void BalloonHost::RenderWidgetHostDidPaint() {
+ render_view_host_->set_paint_observer(NULL);
+ render_view_host_->EnablePreferredSizeChangedMode(
+ kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow);
+}
+
+BalloonHost::~BalloonHost() {
+ DCHECK(!render_view_host_);
+}
void BalloonHost::NotifyDisconnect() {
if (!should_notify_on_disconnect_)
diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h
index 4e51eba..c5a88e7 100644
--- a/chrome/browser/notifications/balloon_host.h
+++ b/chrome/browser/notifications/balloon_host.h
@@ -112,6 +112,9 @@ class BalloonHost : public RenderViewHostDelegate,
const std::string& value);
virtual void ClearInspectorSettings();
+ // Called when the render view has painted.
+ void RenderWidgetHostDidPaint();
+
protected:
virtual ~BalloonHost();
// Must override in platform specific implementations.