Index: libgtkhtml/layout/htmlbox.c
===================================================================
--- libgtkhtml/layout/htmlbox.c.orig 2006-02-08 23:43:30.000000000 +0000
+++ libgtkhtml/layout/htmlbox.c 2006-02-11 04:49:55.000000000 +0000
@@ -873,26 +873,21 @@ html_box_check_min_max_width_height (Htm
*boxheight = html_length_get_value (&HTML_BOX_GET_STYLE (self)->box->max_height, 0);
}
- /* Maintain aspect ratio if it's an image - bias towards making image smaller */
+ /* Maintain aspect ratio if it's an image */
if (HTML_IS_BOX_IMAGE (self)) {
if ((*boxwidth > old_width) && (*boxheight >= old_height)) {
*boxheight = *boxheight * (gdouble)(*boxwidth / (gdouble)old_width);
- html_box_check_min_max_width_height (self, boxwidth, boxheight);
return;
}
-
- if ((*boxheight > old_height) && (*boxwidth >= old_width)) {
+ else if ((*boxheight > old_height) && (*boxwidth >= old_width)) {
*boxwidth = *boxwidth * (gdouble)(*boxheight / (gdouble)old_height);
- html_box_check_min_max_width_height (self, boxwidth, boxheight);
return;
}
-
- if ((*boxwidth < old_width) && (*boxheight <= old_height)) {
+ else if ((*boxwidth < old_width) && (*boxheight <= old_height)) {
*boxheight = *boxheight * (gdouble)(*boxwidth / (gdouble)old_width);
return;
}
-
- if ((*boxheight < old_height) && (*boxwidth <= old_width)) {
+ else if ((*boxheight < old_height) && (*boxwidth <= old_width)) {
*boxwidth = *boxwidth * (gdouble)(*boxheight / (gdouble)old_height);
return;
}
Index: libgtkhtml/layout/html/htmlboximage.c
===================================================================
--- libgtkhtml/layout/html/htmlboximage.c.orig 2006-02-08 23:41:33.000000000 +0000
+++ libgtkhtml/layout/html/htmlboximage.c 2006-02-11 05:01:36.000000000 +0000
@@ -176,8 +176,26 @@ html_box_image_relayout (HtmlBox *box, H
html_box_check_min_max_width_height (box, &width, &height);
- if (old_width != width || old_height != height)
+ /* Guard against oscillation - When max-width/height alters the
+ * size of an image, the aspect ratio is maintained, but this
+ * can cause an infinite resizing loop as the size oscillates
+ * between two sizes that alternately require and don't
+ * require a scrollbar.
+ */
+ if ((old_width != width || old_height != height) && (width != image->last_width[1] || height != image->last_height[1])) {
html_box_image_update_scaled_pixbuf (image, width, height);
+ image->last_width[1] = image->last_width[0];
+ image->last_height[1] = image->last_height[0];
+ image->last_width[0] = width;
+ image->last_height[0] = height;
+ } else {
+ image->last_width[1] = image->last_width[0];
+ image->last_height[1] = image->last_height[0];
+ image->last_width[0] = width;
+ image->last_height[0] = height;
+ width = old_width;
+ height = old_height;
+ }
}
else {
if (style->width.type != HTML_LENGTH_AUTO)
@@ -239,6 +257,10 @@ html_box_image_init (HtmlBoxImage *image
image->content_height = 20;
image->image = NULL;
image->scaled_pixbuf = NULL;
+ image->last_width[0] = 0;
+ image->last_height[0] = 0;
+ image->last_width[1] = 0;
+ image->last_height[1] = 0;
}
GType
Index: libgtkhtml/layout/html/htmlboximage.h
===================================================================
--- libgtkhtml/layout/html/htmlboximage.h.orig 2001-08-05 12:45:30.000000000 +0100
+++ libgtkhtml/layout/html/htmlboximage.h 2006-02-11 04:40:44.000000000 +0000
@@ -49,6 +49,8 @@ struct _HtmlBoxImage {
GdkPixbuf *scaled_pixbuf;
gboolean updated;
HtmlView *view;
+
+ gint last_width[2], last_height[2];
};
struct _HtmlBoxImageClass {