diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-11 01:16:28 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-11 01:16:28 +0000 |
commit | 78a851f6bcfaca69a31bc0b7547e07feffd57e37 (patch) | |
tree | 725d4da87fba5e27f3ceacded775153c131f99d6 | |
parent | ef8add6933ae3bfe221079842be9c675a59506fb (diff) | |
download | chromium_src-78a851f6bcfaca69a31bc0b7547e07feffd57e37.zip chromium_src-78a851f6bcfaca69a31bc0b7547e07feffd57e37.tar.gz chromium_src-78a851f6bcfaca69a31bc0b7547e07feffd57e37.tar.bz2 |
If widget is too small to render a nine box, just return (don't DCHECK).
When I initially added that DCHECK, we did not have any animations, so it was always a mistake to have a widget that was too small. Now that we do have animations, this is no longer true. Instead of having to work around this DCHECK with minimum size hacks, get rid of the hack and paint nothing.
TEST=download a safe thing and an unsafe thing. Open and close the bookmark bar and findbar a lot. Everything looks ok and doesn't crash.
http://crbug.com/13343
Review URL: http://codereview.chromium.org/118393
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18135 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/download_item_gtk.cc | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/nine_box.cc | 19 |
2 files changed, 11 insertions, 14 deletions
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc index cab2faa..619aed5 100644 --- a/chrome/browser/gtk/download_item_gtk.cc +++ b/chrome/browser/gtk/download_item_gtk.cc @@ -42,10 +42,7 @@ const int kTextWidth = 140; // The minimum width we will ever draw the download item. Used as a lower bound // during animation. This number comes from the width of the images used to // make the download item. -const int kMinDownloadItemWidth = 13 + download_util::kSmallProgressIconSize; - -// As above, but for the dangerous download prompt. -const int kMinDangerousDownloadWidth = 16; +const int kMinDownloadItemWidth = download_util::kSmallProgressIconSize; const char* kLabelColorMarkup = "<span color='#%s'>%s</span>"; const char* kFilenameColor = "576C95"; // 87, 108, 149 @@ -421,7 +418,6 @@ void DownloadItemGtk::AnimationProgressed(const Animation* animation) { dangerous_hbox_start_width_) * new_item_animation_->GetCurrentValue(); int showing_width = dangerous_hbox_start_width_ + progress; - showing_width = std::max(kMinDangerousDownloadWidth, showing_width); gtk_widget_set_size_request(dangerous_hbox_, showing_width, -1); } else { DCHECK(animation == new_item_animation_.get()); diff --git a/chrome/browser/gtk/nine_box.cc b/chrome/browser/gtk/nine_box.cc index 6a380ca..888cedf 100644 --- a/chrome/browser/gtk/nine_box.cc +++ b/chrome/browser/gtk/nine_box.cc @@ -73,6 +73,16 @@ void NineBox::RenderToWidget(GtkWidget* dst) const { int dst_width = dst->allocation.width; int dst_height = dst->allocation.height; + // The upper-left and lower-right corners of the center square in the + // rendering of the ninebox. + int x1 = gdk_pixbuf_get_width(images_[0]); + int y1 = gdk_pixbuf_get_height(images_[0]); + int x2 = images_[2] ? dst_width - gdk_pixbuf_get_width(images_[2]) : x1; + int y2 = images_[6] ? dst_height - gdk_pixbuf_get_height(images_[6]) : y1; + // Paint nothing if there's not enough room. + if (x2 < x1 || y2 < y1) + return; + cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(dst->window)); // For widgets that have their own window, the allocation (x,y) coordinates // are GdkWindow relative. For other widgets, the coordinates are relative @@ -82,15 +92,6 @@ void NineBox::RenderToWidget(GtkWidget* dst) const { cairo_translate(cr, dst->allocation.x, dst->allocation.y); } - // The upper-left and lower-right corners of the center square in the - // rendering of the ninebox. - int x1 = gdk_pixbuf_get_width(images_[0]); - int y1 = gdk_pixbuf_get_height(images_[0]); - int x2 = images_[2] ? dst_width - gdk_pixbuf_get_width(images_[2]) : x1; - int y2 = images_[6] ? dst_height - gdk_pixbuf_get_height(images_[6]) : y1; - DCHECK_GE(x2, x1); - DCHECK_GE(y2, y1); - // Top row, center image is horizontally tiled. if (images_[0]) DrawPixbuf(cr, images_[0], 0, 0); |