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 /chrome/browser/gtk/nine_box.cc | |
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
Diffstat (limited to 'chrome/browser/gtk/nine_box.cc')
-rw-r--r-- | chrome/browser/gtk/nine_box.cc | 19 |
1 files changed, 10 insertions, 9 deletions
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); |