summaryrefslogtreecommitdiff
path: root/openembedded/packages/gtkhtml2/files/fix-background-min-max.patch
blob: af557c8fa48cd7e96e947b0874e16ef43b6453f6 (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
Index: gtkhtml2/libgtkhtml/layout/html/htmlboximage.c
===================================================================
--- gtkhtml2.orig/libgtkhtml/layout/html/htmlboximage.c	2005-12-28 22:07:37.000000000 +0000
+++ gtkhtml2/libgtkhtml/layout/html/htmlboximage.c	2006-01-22 03:20:36.000000000 +0000
@@ -167,6 +167,8 @@
 					width = (gint)(floor ((gfloat)(height * gdk_pixbuf_get_width (pixbuf))/(gfloat)gdk_pixbuf_get_height (pixbuf)) + 0.5);
 			}
 		}
+		
+		html_box_check_min_max_width_height (box, &width, &height);
 
 		if (old_width != width || old_height != height)
 			html_box_image_update_scaled_pixbuf (image, width, height);
Index: gtkhtml2/libgtkhtml/layout/htmlbox.c
===================================================================
--- gtkhtml2.orig/libgtkhtml/layout/htmlbox.c	2004-01-08 08:57:29.000000000 +0000
+++ gtkhtml2/libgtkhtml/layout/htmlbox.c	2006-01-22 03:20:41.000000000 +0000
@@ -24,6 +24,7 @@
 #include "layout/htmlbox.h"
 #include "layout/htmlboxtext.h"
 #include "layout/html/htmlboxform.h"
+#include "layout/html/htmlboximage.h"
 #include "layout/htmlboxinline.h"
 #include "layout/htmlboxtablerow.h"
 #include "gtkhtmlcontext.h"
@@ -817,6 +818,8 @@
 html_box_check_min_max_width_height (HtmlBox *self, gint *boxwidth, gint *boxheight) 
 {
 	int tmp;
+	gint old_width = *boxwidth;
+	gint old_height = *boxheight;
 
 	if (self->parent) {
 		if (HTML_BOX_GET_STYLE (self)->box->min_width.type != HTML_LENGTH_AUTO) {
@@ -868,6 +871,31 @@
 			if (*boxheight > html_length_get_value (&HTML_BOX_GET_STYLE (self)->box->max_height, 0))
 				*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 */
+	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)) {
+			*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)) {
+			*boxheight = *boxheight * (gdouble)(*boxwidth / (gdouble)old_width);
+			return;
+		}
+		
+		if ((*boxheight < old_height) && (*boxwidth <= old_width)) {
+			*boxwidth = *boxwidth * (gdouble)(*boxheight / (gdouble)old_height);
+			return;
+		}
+	}
 }
 
 static void