summaryrefslogtreecommitdiffstats
path: root/openembedded/packages/gtkhtml2/files/fix-infinite-loop.patch
blob: c2f36daf884eaa8ba29d6ab9cf67d3d7b182e421 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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 {