summaryrefslogtreecommitdiff
path: root/openembedded/packages/gtkhtml2/files
diff options
context:
space:
mode:
authorChris Lord <chris@openedhand.com>2006-02-01 09:52:55 +0000
committerChris Lord <chris@openedhand.com>2006-02-01 09:52:55 +0000
commitda8ed2882801ca513eef5b696de14ea99c485354 (patch)
treead43f2132fd8896e1c2c4aefe75ad572273d469a /openembedded/packages/gtkhtml2/files
parent27700c91dd31d47332e6533241982d856772e08b (diff)
downloadopenembedded-core-da8ed2882801ca513eef5b696de14ea99c485354.tar.gz
openembedded-core-da8ed2882801ca513eef5b696de14ea99c485354.tar.bz2
openembedded-core-da8ed2882801ca513eef5b696de14ea99c485354.tar.xz
openembedded-core-da8ed2882801ca513eef5b696de14ea99c485354.zip
Add libsoup, libspidermonkey, libxml2 cvs, patched gtkhtml2 and web
packages git-svn-id: https://svn.o-hand.com/repos/poky@245 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'openembedded/packages/gtkhtml2/files')
-rw-r--r--openembedded/packages/gtkhtml2/files/at-import_box-pos.patch767
-rw-r--r--openembedded/packages/gtkhtml2/files/css-media.patch487
-rw-r--r--openembedded/packages/gtkhtml2/files/css-stylesheet-user.patch54
-rw-r--r--openembedded/packages/gtkhtml2/files/fix-background-min-max.patch66
-rw-r--r--openembedded/packages/gtkhtml2/files/fix-background-none.patch40
-rw-r--r--openembedded/packages/gtkhtml2/files/fix-recreation.patch407
6 files changed, 1821 insertions, 0 deletions
diff --git a/openembedded/packages/gtkhtml2/files/at-import_box-pos.patch b/openembedded/packages/gtkhtml2/files/at-import_box-pos.patch
new file mode 100644
index 000000000..89e60e5d2
--- /dev/null
+++ b/openembedded/packages/gtkhtml2/files/at-import_box-pos.patch
@@ -0,0 +1,767 @@
+Index: libgtkhtml/css/cssmatcher.c
+===================================================================
+RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/css/cssmatcher.c,v
+retrieving revision 1.53
+diff -u -r1.53 cssmatcher.c
+--- libgtkhtml/css/cssmatcher.c 26 Oct 2005 02:04:24 -0000 1.53
++++ libgtkhtml/css/cssmatcher.c 18 Jan 2006 18:24:09 -0000
+@@ -79,7 +79,7 @@
+ element_name = html_atom_list_get_atom (html_atom_list, node->name);
+
+ /* Look at the element name */
+- if (!simple->is_star && simple->element_name != element_name)
++ if ((!simple->is_star) && (simple->element_name != element_name))
+ return FALSE;
+
+ str = xmlGetProp (node, "id");
+@@ -2373,7 +2373,7 @@
+ CssStylesheet *ss;
+
+ if (html_stream_get_written (stream) != 0) {
+- ss = css_parser_parse_stylesheet (context->str->str, context->str->len);
++ ss = css_parser_parse_stylesheet (context->str->str, context->str->len, NULL);
+
+ context->stat->s.import_rule.fetched = TRUE;
+
+@@ -2770,7 +2770,7 @@
+ css_matcher_html_to_css (doc, style, node);
+
+ if (!default_stylesheet) {
+- default_stylesheet = css_parser_parse_stylesheet (html_css, strlen (html_css));
++ default_stylesheet = css_parser_parse_stylesheet (html_css, strlen (html_css), NULL);
+ }
+
+ css_matcher_apply_stylesheet (doc, default_stylesheet, node, &declaration_list, CSS_STYLESHEET_DEFAULT, pseudo);
+@@ -2789,7 +2789,7 @@
+ prop = xmlGetProp (node, "style");
+
+ if (prop) {
+- CssRuleset *rs = css_parser_parse_style_attr (prop, strlen (prop));
++ CssRuleset *rs = css_parser_parse_style_attr (prop, strlen (prop), NULL);
+ gint i;
+
+ if (rs) {
+Index: libgtkhtml/css/cssparser.c
+===================================================================
+RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/css/cssparser.c,v
+retrieving revision 1.23
+diff -u -r1.23 cssparser.c
+--- libgtkhtml/css/cssparser.c 25 Sep 2005 02:07:21 -0000 1.23
++++ libgtkhtml/css/cssparser.c 18 Jan 2006 18:24:09 -0000
+@@ -49,7 +49,7 @@
+
+ const gint css_n_dimensions = sizeof (css_dimensions) / sizeof (css_dimensions[0]);
+
+-static gint css_parser_parse_value (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val);
++static gint css_parser_parse_value (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val, const gchar *base_url);
+
+ /* FIXME: Needs more whitespace types */
+ static gint
+@@ -443,7 +443,7 @@
+ }
+
+ static gint
+-css_parser_parse_term (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val)
++css_parser_parse_term (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val, const gchar *base_url)
+ {
+ gint pos;
+ HtmlAtom atom;
+@@ -481,7 +481,7 @@
+ return -1;
+ }
+
+- pos = css_parser_parse_value (buffer, save_pos + 1, func_end, &val);
++ pos = css_parser_parse_value (buffer, save_pos + 1, func_end, &val, base_url);
+
+ if (pos == -1) {
+ /*
+@@ -495,10 +495,48 @@
+ pos = func_end;
+ }
+ if (pos != -1) {
+- if (ret_val)
++ if (ret_val) {
+ *ret_val = css_value_function_new (atom, val);
+- else
++
++ if ((*ret_val)->v.function->name == HTML_ATOM_URL &&
++ (*ret_val)->v.function->args) {
++ gchar *str = css_value_to_string ((*ret_val)->v.function->args);
++
++ if (base_url && str) {
++ regex_t reg;
++
++ regcomp (&reg, "^[a-zA-Z][a-zA-Z0-9.+-]*:", REG_NOSUB);
++ if (((*ret_val)->v.function->args->v.s[0] != '/') && (regexec (&reg, (*ret_val)->v.function->args->v.s, 0, NULL, 0))) {
++ gchar *temp_base, *eptr;
++
++ temp_base = g_strdup(base_url);
++ eptr = strrchr(temp_base, '?');
++
++ if (eptr != NULL)
++ *eptr = '\0';
++
++ eptr = strrchr(temp_base, '/');
++ if (eptr != NULL) {
++ gchar *temp_arg = g_strdup((*ret_val)->v.function->args->v.s);
++
++ *eptr = '\0';
++
++ g_free((*ret_val)->v.function->args->v.s);
++ (*ret_val)->v.function->args->v.s = g_strconcat(temp_base, "/", temp_arg, NULL);
++ g_free(temp_arg);
++ }
++
++ g_free(temp_base);
++ }
++ regfree (&reg);
++ }
++
++ g_free (str);
++ }
++ }
++ else {
+ css_value_unref (val);
++ }
+ }
+
+ /* This is due to the ) */
+@@ -566,7 +604,7 @@
+ }
+
+ static gint
+-css_parser_parse_value (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val)
++css_parser_parse_value (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val, const gchar *base_url)
+ {
+ gint pos = start_pos;
+ gint n = 0;
+@@ -589,7 +627,7 @@
+ css_value_list_append (list, term, list_sep);
+ }
+
+- pos = css_parser_parse_term (buffer, pos, end_pos, &term);
++ pos = css_parser_parse_term (buffer, pos, end_pos, &term, base_url);
+
+ if (pos == -1) {
+ if (list)
+@@ -618,7 +656,7 @@
+ }
+ else {
+ /* Try and parse the term to see if it's valid */
+- if (css_parser_parse_term (buffer, pos, end_pos, NULL) == -1) {
++ if (css_parser_parse_term (buffer, pos, end_pos, NULL, base_url) == -1) {
+ if (term)
+ css_value_unref (term);
+ if (list)
+@@ -1005,7 +1043,7 @@
+ }
+
+ static gint
+-css_parser_parse_declaration (const gchar *buffer, gint start_pos, gint end_pos, CssDeclaration **ret_val)
++css_parser_parse_declaration (const gchar *buffer, gint start_pos, gint end_pos, CssDeclaration **ret_val, const gchar *base_url)
+ {
+ CssValue *value;
+ CssDeclaration *result;
+@@ -1040,7 +1078,7 @@
+
+ pos = css_parser_parse_whitespace (buffer, pos, prio_pos);
+
+- pos = css_parser_parse_value (buffer, pos, prio_pos, &value);
++ pos = css_parser_parse_value (buffer, pos, prio_pos, &value, base_url);
+
+ if (pos == -1) {
+ return end_pos;
+@@ -1063,7 +1101,7 @@
+ }
+
+ static CssDeclaration **
+-css_parser_parse_declarations (const gchar *buffer, gint start_pos, gint end_pos, gint *num_decl)
++css_parser_parse_declarations (const gchar *buffer, gint start_pos, gint end_pos, gint *num_decl, const gchar *base_url)
+ {
+ gint pos = start_pos;
+ gint cur_pos = start_pos;
+@@ -1079,7 +1117,7 @@
+
+ pos = css_parser_parse_to_char (buffer, ';', pos, end_pos);
+
+- pos = css_parser_parse_declaration (buffer, cur_pos, pos, &declaration);
++ pos = css_parser_parse_declaration (buffer, cur_pos, pos, &declaration, base_url);
+
+ if (declaration) {
+ if (n_decl == n_decl_max)
+@@ -1100,7 +1138,7 @@
+ }
+
+ static gint
+-css_parser_parse_ruleset (const gchar *buffer, gint start_pos, gint end_pos, CssRuleset **ret_val)
++css_parser_parse_ruleset (const gchar *buffer, gint start_pos, gint end_pos, CssRuleset **ret_val, const gchar *base_url)
+ {
+ gint cur_pos;
+ gint pos;
+@@ -1143,7 +1181,7 @@
+ }
+ cur_pos = css_parser_parse_whitespace (buffer, cur_pos, end_pos);
+
+- decl = css_parser_parse_declarations (buffer, cur_pos, pos, &n_decl);
++ decl = css_parser_parse_declarations (buffer, cur_pos, pos, &n_decl, base_url);
+
+ pos++;
+
+@@ -1186,7 +1224,8 @@
+ }
+ else if (str[pos] == '/' &&
+ pos + 1 <= len &&
+- str[pos + 1] == '/') {
++ str[pos + 1] == '/' &&
++ (pos == 0 || str[pos-1] != ':')) {
+ while (pos < len &&
+ str[pos] != '\n')
+ pos++;
+@@ -1204,7 +1243,7 @@
+ }
+
+ static gint
+-css_parser_parse_atkeyword (const gchar *buffer, gint start_pos, gint end_pos, CssStatement **ret_val)
++css_parser_parse_atkeyword (const gchar *buffer, gint start_pos, gint end_pos, CssStatement **ret_val, const gchar *base_url)
+ {
+ gint pos = start_pos;
+ gint tmp_pos, cur_pos;
+@@ -1257,14 +1296,14 @@
+ tmp_pos++;
+
+
+- rs = g_new (CssRuleset *, n_rs_max);
++ rs = g_new0 (CssRuleset *, n_rs_max);
+
+ /* g_print ("wheee: \"%s\"\n", g_strndup (buffer + cur_pos, tmp_pos - cur_pos )); */
+ pos = cur_pos;
+ while (pos < tmp_pos) {
+ CssRuleset *ruleset;
+
+- pos = css_parser_parse_ruleset (buffer, pos, tmp_pos, &ruleset);
++ pos = css_parser_parse_ruleset (buffer, pos, tmp_pos, &ruleset, base_url);
+
+ if (n_rs == n_rs_max)
+ rs = g_realloc (rs, sizeof (CssRuleset *) *
+@@ -1277,7 +1316,7 @@
+
+ pos = css_parser_parse_whitespace (buffer, tmp_pos + 1, end_pos);
+
+- result = g_new (CssStatement, 1);
++ result = g_new0 (CssStatement, 1);
+ result->type = CSS_MEDIA_RULE;
+ result->s.media_rule.rs = rs;
+ result->s.media_rule.n_rs = n_rs;
+@@ -1318,11 +1357,11 @@
+
+ pos = css_parser_parse_whitespace (buffer, pos, cur_pos);
+
+- decl = css_parser_parse_declarations (buffer, pos, cur_pos, &n_decl);
++ decl = css_parser_parse_declarations (buffer, pos, cur_pos, &n_decl, base_url);
+
+ g_print ("N_decl is: %d\n", n_decl);
+
+- result = g_new (CssStatement, 1);
++ result = g_new0 (CssStatement, 1);
+ result->type = CSS_PAGE_RULE;
+ result->s.page_rule.name = name;
+ result->s.page_rule.pseudo = pseudo;
+@@ -1337,8 +1376,8 @@
+ pos = css_parser_parse_whitespace (buffer, pos + 1, end_pos);
+ cur_pos = css_parser_parse_to_char (buffer, '}', pos, end_pos);
+
+- decl = css_parser_parse_declarations (buffer, pos, cur_pos, &n_decl);
+- result = g_new (CssStatement, 1);
++ decl = css_parser_parse_declarations (buffer, pos, cur_pos, &n_decl, base_url);
++ result = g_new0 (CssStatement, 1);
+ result->type = CSS_FONT_FACE_RULE;
+
+ result->s.font_face_rule.n_decl = n_decl;
+@@ -1349,8 +1388,61 @@
+ return cur_pos + 1;
+
+ break;
++ case HTML_ATOM_IMPORT: {
++ gchar *import_url;
++ const gchar *s_url, *e_url;
++
++ cur_pos = css_parser_parse_to_char (buffer, ';', pos, end_pos);
++
++ if (strchr (buffer + pos, '(')) {
++ s_url = strchr (buffer + pos, '(');
++ e_url = strchr (s_url, ')');
++ } else if (strchr (buffer + pos, '\"')) {
++ s_url = strchr (buffer + pos, '\"');
++ e_url = strchr (s_url + 1, '\"');
++ } else if (strchr (buffer + pos, '\'')) {
++ s_url = strchr (buffer + pos, '\'');
++ e_url = strchr (s_url + 1, '\'');
++ }
++
++ if (!s_url || !e_url || ((e_url - s_url) < 1)) {
++ g_warning ("Invalid @import line");
++ *ret_val = NULL;
++ return cur_pos + 1;
++ }
++
++ s_url++;
++ e_url--;
++
++ if ((*s_url == '\"') && (*e_url == '\"')) {
++ s_url++;
++ e_url--;
++ } else if ((*s_url == '\'') && (*e_url == '\'')) {
++ s_url++;
++ e_url--;
++ }
++
++ if (s_url > e_url) {
++ g_warning ("Invalid @import line");
++ *ret_val = NULL;
++ return cur_pos + 1;
++ }
++
++ import_url = g_strndup (s_url, strlen (s_url) - strlen (e_url) + 1);
++
++ result = g_new0 (CssStatement, 1);
++ result->type = CSS_IMPORT_RULE;
+
++ result->s.import_rule.url = css_value_string_new (import_url);
++
++ *ret_val = result;
++
++ return cur_pos + 1;
++
++ break;
++ }
+ default:
++ g_warning ("Unhandled keyword %d - %s", keyword, buffer);
+ /* Unknown keyword detected, skip to next block */
+ while (pos < end_pos) {
+ /* Handle a dangling semi-colon */
+@@ -1373,7 +1465,7 @@
+ }
+
+ CssRuleset *
+-css_parser_parse_style_attr (const gchar *buffer, gint len)
++css_parser_parse_style_attr (const gchar *buffer, gint len, const gchar *base_url)
+ {
+ CssRuleset *result;
+
+@@ -1382,7 +1474,7 @@
+
+ /* FIXME: Are comments allowed here? */
+
+- decl = css_parser_parse_declarations (buffer, 0, len, &n_decl);
++ decl = css_parser_parse_declarations (buffer, 0, len, &n_decl, base_url);
+
+ if (!decl)
+ return NULL;
+@@ -1397,9 +1489,8 @@
+ }
+
+ CssStylesheet *
+-css_parser_parse_stylesheet (const gchar *str, gint len)
++css_parser_parse_stylesheet (const gchar *str, gint len, const gchar *base_url)
+ {
+- CssStatement *statement;
+ CssStylesheet *result;
+ GSList *stat = NULL;
+ gchar *buffer;
+@@ -1413,26 +1504,23 @@
+ end_pos = len;
+ while (pos < len) {
+ if (buffer[pos] == '@') {
+- pos = css_parser_parse_atkeyword (buffer, pos + 1, len, &statement);
+-#if 0
+- if (statement) {
+- if (n_stat == n_stat_max)
+- stat = g_realloc (stat, sizeof (CssStatement) *
+- (n_stat_max <<= 1));
+- stat[n_stat++] = statement;
++ CssStatement *atstatement = NULL;
++ pos = css_parser_parse_atkeyword (buffer, pos + 1, len, &atstatement, base_url);
++ if (atstatement) {
++ stat = g_slist_append (stat, atstatement);
+ }
+-#endif
+ }
+ else {
+ CssRuleset *ruleset;
+- pos = css_parser_parse_ruleset (buffer, pos, end_pos, &ruleset);
++ pos = css_parser_parse_ruleset (buffer, pos, end_pos, &ruleset, base_url);
+
+ if (ruleset) {
+- statement = g_new (CssStatement, 1);
+- statement->type = CSS_RULESET;
+- statement->s.ruleset = ruleset;
++ CssStatement *rulestatement;
++ rulestatement = g_new0 (CssStatement, 1);
++ rulestatement->type = CSS_RULESET;
++ rulestatement->s.ruleset = ruleset;
+
+- stat = g_slist_append (stat, statement);
++ stat = g_slist_append (stat, rulestatement);
+ }
+
+ if (pos == -1)
+@@ -1444,7 +1532,7 @@
+
+ g_free (buffer);
+
+- result = g_new (CssStylesheet, 1);
++ result = g_new0 (CssStylesheet, 1);
+ result->stat = stat;
+
+ return result;
+Index: libgtkhtml/css/cssparser.h
+===================================================================
+RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/css/cssparser.h,v
+retrieving revision 1.7
+diff -u -r1.7 cssparser.h
+--- libgtkhtml/css/cssparser.h 6 Dec 2002 17:16:54 -0000 1.7
++++ libgtkhtml/css/cssparser.h 18 Jan 2006 18:24:09 -0000
+@@ -24,13 +24,14 @@
+ #define __CSSPARSER_H__
+
+ #include <glib.h>
++#include <regex.h>
+
+ #include "cssstylesheet.h"
+
+ G_BEGIN_DECLS
+
+-CssStylesheet *css_parser_parse_stylesheet (const gchar *str, gint len);
+-CssRuleset *css_parser_parse_style_attr (const gchar *buffer, gint len);
++CssStylesheet *css_parser_parse_stylesheet (const gchar *str, gint len, const gchar *base_url);
++CssRuleset *css_parser_parse_style_attr (const gchar *buffer, gint len, const gchar *base_url);
+
+ G_END_DECLS
+
+Index: libgtkhtml/css/cssstylesheet.h
+===================================================================
+RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/css/cssstylesheet.h,v
+retrieving revision 1.7
+diff -u -r1.7 cssstylesheet.h
+--- libgtkhtml/css/cssstylesheet.h 21 Apr 2004 14:17:00 -0000 1.7
++++ libgtkhtml/css/cssstylesheet.h 18 Jan 2006 18:24:09 -0000
+@@ -181,6 +181,7 @@
+ };
+
+ struct _CssStylesheet {
++ gchar *url;
+ gboolean disabled;
+ GSList *stat;
+ };
+Index: libgtkhtml/css/cssvalue.c
+===================================================================
+RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/css/cssvalue.c,v
+retrieving revision 1.6
+diff -u -r1.6 cssvalue.c
+--- libgtkhtml/css/cssvalue.c 21 Apr 2004 14:17:00 -0000 1.6
++++ libgtkhtml/css/cssvalue.c 18 Jan 2006 18:24:09 -0000
+@@ -64,7 +64,7 @@
+ function->name = name;
+ function->args = args;
+
+- result = g_new (CssValue, 1);
++ result = g_new0 (CssValue, 1);
+ result->ref_count = 1;
+ result->value_type = CSS_FUNCTION;
+ result->v.function = function;
+Index: libgtkhtml/document/htmldocument.c
+===================================================================
+RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/document/htmldocument.c,v
+retrieving revision 1.122
+diff -u -r1.122 htmldocument.c
+--- libgtkhtml/document/htmldocument.c 21 Feb 2005 17:31:31 -0000 1.122
++++ libgtkhtml/document/htmldocument.c 18 Jan 2006 18:24:11 -0000
+@@ -139,14 +139,42 @@
+ html_document_stylesheet_stream_close (const gchar *buffer, gint len, gpointer data)
+ {
+ CssStylesheet *sheet;
+- HtmlDocument *document = HTML_DOCUMENT (data);
++ HtmlDocumentStreamData *stream_data = (HtmlDocumentStreamData *) data;
++ HtmlDocument *document = stream_data->document;
+ HtmlStyleChange style_change;
+-
++ GSList *list;
++
+ if (!buffer)
+ return;
+
+- sheet = css_parser_parse_stylesheet (buffer, len);
++ sheet = css_parser_parse_stylesheet (buffer, len, (gchar *) stream_data->internal_data);
++ g_free(stream_data->internal_data);
++ stream_data->internal_data = NULL;
++
++ for (list = sheet->stat; list; list = list->next) {
++ CssStatement *statement = list->data;
++ HtmlStream *stream;
++
++ switch (statement->type) {
++ case CSS_IMPORT_RULE: {
++ HtmlDocumentStreamData *stream_data_import;
++ gchar *url;
++
++ url = css_value_to_string (statement->s.import_rule.url);
++ stream_data_import = g_new (HtmlDocumentStreamData, 1);
++ stream_data_import->document = stream_data->document;
++ stream_data_import->internal_data = g_strdup(url);
++ stream = html_stream_buffer_new (html_document_stylesheet_stream_close, stream_data_import);
++ g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, url, stream);
++ g_free (url);
++ break;
++ }
++ default:
++ break;
++ }
++ }
+
++ g_free (stream_data);
+ document->stylesheets = g_slist_append (document->stylesheets, sheet);
+
+ /* Restyle the document */
+@@ -184,9 +212,15 @@
+
+ if (str && (strcasecmp (str, "stylesheet") == 0)) {
+ gchar *url = xmlGetProp (node->xmlnode, "href");
+-
+ if (url) {
+- HtmlStream *stream = html_stream_buffer_new (html_document_stylesheet_stream_close, document);
++ HtmlDocumentStreamData *stream_data;
++ HtmlStream *stream;
++
++ stream_data = g_new (HtmlDocumentStreamData, 1);
++ stream_data->document = document;
++ stream_data->internal_data = g_strdup(url);
++
++ stream = html_stream_buffer_new (html_document_stylesheet_stream_close, stream_data);
+
+ g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, url, stream);
+ }
+@@ -247,12 +281,39 @@
+
+ CssStylesheet *ss;
+ HtmlStyleChange style_change;
+-
+- ss = css_parser_parse_stylesheet (node->xmlnode->content, strlen (node->xmlnode->content));
+- document->stylesheets = g_slist_append (document->stylesheets, ss);
++ GSList *list;
++
++ ss = css_parser_parse_stylesheet (node->xmlnode->content, strlen (node->xmlnode->content), NULL);
++
++ for (list = ss->stat; list; list = list->next) {
++ CssStatement *statement = list->data;
++ HtmlStream *stream;
++
++ switch (statement->type) {
++ case CSS_IMPORT_RULE: {
++ gchar *cssurl;
++ HtmlDocumentStreamData *stream_data;
++
++ cssurl = css_value_to_string (statement->s.import_rule.url);
++
++ stream_data = g_new (HtmlDocumentStreamData, 1);
++ stream_data->document = document;
++ stream_data->internal_data = g_strdup(cssurl);
++
++ stream = html_stream_buffer_new (html_document_stylesheet_stream_close, stream_data);
++ g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, cssurl, stream);
++ g_free (cssurl);
++ break;
++ }
++ default:
++ break;
++ }
++ }
++
++ document->stylesheets = g_slist_append ( document->stylesheets, ss);
+
+ /* Restyle the document */
+- style_change = html_document_restyle_node (document, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), NULL, TRUE);
++ style_change = html_document_restyle_node (document, DOM_NODE (dom_Document__get_documentElement ( document->dom_document)), NULL, TRUE);
+ g_signal_emit (G_OBJECT (document), document_signals [STYLE_UPDATED], 0, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), style_change);
+ }
+ else if ((node->xmlnode->type == XML_TEXT_NODE || node->xmlnode->type == XML_COMMENT_NODE) && node->xmlnode->parent && strcasecmp (node->xmlnode->parent->name, "script") == 0) {
+Index: libgtkhtml/document/htmldocument.h
+===================================================================
+RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/document/htmldocument.h,v
+retrieving revision 1.35
+diff -u -r1.35 htmldocument.h
+--- libgtkhtml/document/htmldocument.h 13 Feb 2005 15:33:19 -0000 1.35
++++ libgtkhtml/document/htmldocument.h 18 Jan 2006 18:24:12 -0000
+@@ -25,6 +25,7 @@
+
+ typedef struct _HtmlDocument HtmlDocument;
+ typedef struct _HtmlDocumentClass HtmlDocumentClass;
++typedef struct _HtmlDocumentStreamData HtmlDocumentStreamData;
+
+ #include <gtk/gtk.h>
+
+@@ -93,6 +94,10 @@
+ gboolean (*dom_mouse_out) (HtmlDocument *document, DomEvent *event);
+ };
+
++struct _HtmlDocumentStreamData {
++ HtmlDocument *document;
++ gpointer internal_data;
++};
+
+ GType html_document_get_type (void);
+
+Index: libgtkhtml/layout/htmlboxblock.c
+===================================================================
+RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/layout/htmlboxblock.c,v
+retrieving revision 1.115
+diff -u -r1.115 htmlboxblock.c
+--- libgtkhtml/layout/htmlboxblock.c 6 Jan 2004 10:09:56 -0000 1.115
++++ libgtkhtml/layout/htmlboxblock.c 18 Jan 2006 18:24:14 -0000
+@@ -100,17 +100,21 @@
+ HtmlBoxBlock *block = HTML_BOX_BLOCK (self);
+ gint full_width;
+
++#if 0
+ if (relayout->get_min_width || relayout->get_max_width) {
++#endif
+
+ /* Only expand the width of the block box if the width is of type "auto" */
+ if (HTML_BOX_GET_STYLE (self)->box->width.type == HTML_LENGTH_AUTO && line->width > *boxwidth) {
+-
++
+ *boxwidth = line->width;
+ block->containing_width = line->width;
+ self->width = *boxwidth + html_box_horizontal_mbp_sum (self);
+ block->force_relayout = TRUE;
+ }
++#if 0
+ }
++#endif
+ full_width = MAX (line->width, line->full_width);
+
+ if (full_width > block->full_width)
+@@ -233,7 +237,7 @@
+ HtmlBoxBlock *block = HTML_BOX_BLOCK (self);
+ HtmlLineBox *line;
+
+- /* If it is a flotbox, just add it */
++ /* If it is a floatbox, just add it */
+ if (HTML_BOX_GET_STYLE (box)->Float != HTML_FLOAT_NONE) {
+ html_box_block_handle_float (self, relayout, box, *y, boxwidth);
+ return NULL;
+Index: libgtkhtml/layout/htmlstyleinherited.c
+===================================================================
+RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/layout/htmlstyleinherited.c,v
+retrieving revision 1.15
+diff -u -r1.15 htmlstyleinherited.c
+--- libgtkhtml/layout/htmlstyleinherited.c 6 Dec 2002 17:17:15 -0000 1.15
++++ libgtkhtml/layout/htmlstyleinherited.c 18 Jan 2006 18:24:15 -0000
+@@ -300,6 +300,37 @@
+ *size = (gint) (val->v.d * old_size);
+ return TRUE;
+ default:
++ switch (val->v.atom) {
++ /* FIXME: These values are copy/pasted from html.css.h, X_SMALL is guessed */
++ case HTML_ATOM_XX_SMALL:
++ *size = (gint) (0.67 * old_size);
++ return TRUE;
++ case HTML_ATOM_X_SMALL:
++ *size = (gint) (0.75 * old_size);
++ return TRUE;
++ case HTML_ATOM_SMALL:
++ *size = (gint) (0.83 * old_size);
++ return TRUE;
++ case HTML_ATOM_MEDIUM:
++ *size = (gint) (1 * old_size);
++ return TRUE;
++ case HTML_ATOM_LARGE:
++ *size = (gint) (1.17 * old_size);
++ return TRUE;
++ case HTML_ATOM_X_LARGE:
++ *size = (gint) (1.5 * old_size);
++ return TRUE;
++ case HTML_ATOM_XX_LARGE:
++ *size = (gint) (2 * old_size);
++ return TRUE;
++ /* FIXME: These are absolutely guessed. Size should always be one of the above seven. */
++ case HTML_ATOM_LARGER:
++ *size = (gint) (0.8 * old_size);
++ return TRUE;
++ case HTML_ATOM_SMALLER:
++ *size = (gint) (1.2 * old_size);
++ return TRUE;
++ }
+ return FALSE;
+ }
+ }
+Index: libgtkhtml/view/htmlevent.c
+===================================================================
+RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/view/htmlevent.c,v
+retrieving revision 1.41
+diff -u -r1.41 htmlevent.c
+--- libgtkhtml/view/htmlevent.c 14 Sep 2004 06:34:27 -0000 1.41
++++ libgtkhtml/view/htmlevent.c 18 Jan 2006 18:24:17 -0000
+@@ -46,14 +46,48 @@
+ static gboolean
+ html_event_xy_in_box (HtmlBox *box, gint tx, gint ty, gint x, gint y)
+ {
++ gint ox, oy;
++ gboolean rv;
++
++ ox = box->x;
++ oy = box->y;
++
++ rv = TRUE;
++
++ if ((HTML_BOX_GET_STYLE (box)->position == HTML_POSITION_RELATIVE ||
++ HTML_BOX_GET_STYLE (box)->position == HTML_POSITION_ABSOLUTE)) {
++ gint width = html_box_get_containing_block_width (box);
++ gint height = html_box_get_containing_block_height (box);
++
++ if (HTML_BOX_GET_STYLE (box)->surround->position.left.type != HTML_LENGTH_AUTO)
++ box->x += html_length_get_value (&HTML_BOX_GET_STYLE (box)->surround->position.left, width);
++ else if (HTML_BOX_GET_STYLE (box)->surround->position.right.type != HTML_LENGTH_AUTO) {
++ if (HTML_BOX_GET_STYLE (box)->display == HTML_DISPLAY_INLINE)
++ box->x -= html_length_get_value (&HTML_BOX_GET_STYLE (box)->surround->position.right, width);
++ else
++ box->x += width - box->width - html_length_get_value (&HTML_BOX_GET_STYLE (box)->surround->position.right, width);
++ }
++ if (HTML_BOX_GET_STYLE (box)->surround->position.top.type != HTML_LENGTH_AUTO)
++ box->y += html_length_get_value (&HTML_BOX_GET_STYLE (box)->surround->position.top, height);
++
++ else if (HTML_BOX_GET_STYLE (box)->surround->position.bottom.type != HTML_LENGTH_AUTO) {
++ if (HTML_BOX_GET_STYLE (box)->display == HTML_DISPLAY_INLINE)
++ box->y -= html_length_get_value (&HTML_BOX_GET_STYLE (box)->surround->position.bottom, height);
++ else
++ box->y += height - box->height - html_length_get_value (&HTML_BOX_GET_STYLE (box)->surround->position.bottom, height);
++ }
++ }
+
+ if (x < box->x + tx ||
+ x > box->x + tx + box->width ||
+ y < box->y + ty ||
+ y > box->y + ty + box->height)
+- return FALSE;
++ rv = FALSE;
++
++ box->x = ox;
++ box->y = oy;
+
+- return TRUE;
++ return rv;
+ }
+
+ static void
+@@ -64,12 +98,6 @@
+ box = self->children;
+
+ while (box) {
+-
+- /* Ignore positioned boxes, because their ->x and->y positions is not their correct positions */
+- if (HTML_BOX_GET_STYLE (box)->position != HTML_POSITION_STATIC) {
+- box = box->next;
+- continue;
+- }
+ /* These boxes always has x = 0, y = 0, w = 0 and h = 0 so we have to do
+ * a special case for these */
+ if (HTML_IS_BOX_INLINE (box) || HTML_IS_BOX_TABLE_ROW_GROUP (box) || HTML_IS_BOX_FORM (box)) {
diff --git a/openembedded/packages/gtkhtml2/files/css-media.patch b/openembedded/packages/gtkhtml2/files/css-media.patch
new file mode 100644
index 000000000..999ce196d
--- /dev/null
+++ b/openembedded/packages/gtkhtml2/files/css-media.patch
@@ -0,0 +1,487 @@
+Index: gtkhtml2/libgtkhtml/css/cssmatcher.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/css/cssmatcher.c 2006-01-25 02:07:44.000000000 +0000
++++ gtkhtml2/libgtkhtml/css/cssmatcher.c 2006-02-01 02:19:13.000000000 +0000
+@@ -2411,7 +2411,8 @@
+ CssStatement *stat = list->data;
+ gint j;
+
+- if (stat->type == CSS_IMPORT_RULE) {
++ switch (stat->type) {
++ case CSS_IMPORT_RULE: {
+ if (stat->s.import_rule.fetched) {
+ if (stat->s.import_rule.sheet) {
+ css_matcher_apply_stylesheet (doc, stat->s.import_rule.sheet, node, declaration_list, type, pseudo);
+@@ -2440,31 +2441,65 @@
+ g_free (str);
+ #endif
+ }
++ break;
+ }
+-
+- /* FIXME: We need to support more than just rulesets here */
+- if (stat->type != CSS_RULESET)
+- continue;
+-
+- for (j = 0; j < stat->s.ruleset->n_sel; j++) {
+- CssSelector *sel = stat->s.ruleset->sel[j];
++
++ case CSS_MEDIA_RULE:
++ case CSS_RULESET: {
++ CssRuleset **rs;
++ gint k, l;
+
+- if (css_matcher_match_selector (sel, node, pseudo)) {
+- int i;
++ if (stat->type == CSS_MEDIA_RULE) {
++ CssValueEntry *entry = stat->s.media_rule.media_list->v.entry;
++ const gchar *media = html_document_get_media_type (doc);
++ gboolean has_media = FALSE;
+
+- for (i = 0; i < stat->s.ruleset->n_decl; i++) {
+- CssDeclaration *decl = stat->s.ruleset->decl[i];
+- CssDeclarationListEntry *entry = g_new (CssDeclarationListEntry, 1);
++ if (!media) break;
++
++ for (; entry; entry = entry->next) {
++ const gchar *value = css_value_to_string (entry->value);
++ if (strcasecmp (media, value) == 0) {
++ has_media = TRUE;
++ break;
++ }
++ }
++ if (!has_media) break;
++
++ rs = stat->s.media_rule.rs;
++ k = stat->s.media_rule.n_rs;
++ } else {
++ rs = &stat->s.ruleset;
++ k = 1;
++ }
++
++ for (l = 0; l < k; l++) {
++ for (j = 0; rs[l] && (j < rs[l]->n_sel); j++) {
++ CssSelector *sel = rs[l]->sel[j];
+
+- entry->spec = sel->a * 1000000 + sel->b * 1000 + sel->c;
+- entry->type = type;
+- entry->decl = g_new (CssDeclaration, 1);
+- entry->decl->property = decl->property;
+- entry->decl->expr = css_value_ref (decl->expr);
+- entry->decl->important = decl->important;
+- *declaration_list = g_list_insert_sorted (*declaration_list, entry, css_declaration_list_sorter);
++ if (css_matcher_match_selector (sel, node, pseudo)) {
++ int i;
++
++ for (i = 0; i < rs[l]->n_decl; i++) {
++ CssDeclaration *decl = rs[l]->decl[i];
++ CssDeclarationListEntry *entry = g_new (CssDeclarationListEntry, 1);
++
++ entry->spec = sel->a * 1000000 + sel->b * 1000 + sel->c;
++ entry->type = type;
++ entry->decl = g_new (CssDeclaration, 1);
++ entry->decl->property = decl->property;
++ entry->decl->expr = css_value_ref (decl->expr);
++ entry->decl->important = decl->important;
++ *declaration_list = g_list_insert_sorted (*declaration_list, entry, css_declaration_list_sorter);
++ }
++ }
+ }
+ }
++ break;
++ }
++
++ default:
++ g_warning ("Unhandled stylesheet");
++ break;
+ }
+ }
+ }
+@@ -2781,7 +2816,7 @@
+ css_matcher_html_to_css (doc, style, node);
+
+ if (!default_stylesheet) {
+- default_stylesheet = css_parser_parse_stylesheet (html_css, strlen (html_css), NULL);
++ default_stylesheet = css_parser_parse_stylesheet (html_css, strlen (html_css), NULL, NULL);
+ }
+
+ css_matcher_apply_stylesheet (doc, default_stylesheet, node, &declaration_list, CSS_STYLESHEET_DEFAULT, pseudo);
+@@ -2800,25 +2835,31 @@
+ prop = xmlGetProp (node, "style");
+
+ if (prop) {
+- CssRuleset *rs = css_parser_parse_style_attr (prop, strlen (prop), NULL);
+- gint i;
++ xmlChar *media_prop = xmlGetProp (node, "media");
++ const gchar *media = html_document_get_media_type (doc);
+
+- if (rs) {
+- for (i = 0; i < rs->n_decl; i++) {
+- CssDeclarationListEntry *entry = g_new (CssDeclarationListEntry, 1);
+- CssDeclaration *decl = rs->decl[i];
+-
+- entry->type = CSS_STYLESHEET_STYLEDECL;
+- entry->decl = g_new (CssDeclaration, 1);
+- entry->decl->property = decl->property;
+- entry->decl->expr = css_value_ref (decl->expr);
+- entry->decl->important = decl->important;
+- entry->spec = 0;
++ if (!media_prop || (media && (strcasecmp (media, media_prop) == 0))) {
++ CssRuleset *rs = css_parser_parse_style_attr (prop, strlen (prop), NULL);
++ gint i;
++
++ if (rs) {
++ for (i = 0; i < rs->n_decl; i++) {
++ CssDeclarationListEntry *entry = g_new (CssDeclarationListEntry, 1);
++ CssDeclaration *decl = rs->decl[i];
+
+- declaration_list = g_list_insert_sorted (declaration_list, entry, css_declaration_list_sorter);
++ entry->type = CSS_STYLESHEET_STYLEDECL;
++ entry->decl = g_new (CssDeclaration, 1);
++ entry->decl->property = decl->property;
++ entry->decl->expr = css_value_ref (decl->expr);
++ entry->decl->important = decl->important;
++ entry->spec = 0;
++
++ declaration_list = g_list_insert_sorted (declaration_list, entry, css_declaration_list_sorter);
++ }
++ css_ruleset_destroy (rs);
+ }
+- css_ruleset_destroy (rs);
+ }
++ if (media_prop) xmlFree (media_prop);
+ xmlFree (prop);
+ }
+
+Index: gtkhtml2/libgtkhtml/document/htmldocument.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/document/htmldocument.c 2006-01-25 02:07:49.000000000 +0000
++++ gtkhtml2/libgtkhtml/document/htmldocument.c 2006-02-01 02:19:13.000000000 +0000
+@@ -147,9 +147,7 @@
+ if (!buffer)
+ return;
+
+- sheet = css_parser_parse_stylesheet (buffer, len, (gchar *) stream_data->internal_data);
+- g_free(stream_data->internal_data);
+- stream_data->internal_data = NULL;
++ sheet = css_parser_parse_stylesheet (buffer, len, (gchar *) stream_data->internal_data, stream_data->media);
+
+ for (list = sheet->stat; list; list = list->next) {
+ CssStatement *statement = list->data;
+@@ -158,15 +156,13 @@
+ switch (statement->type) {
+ case CSS_IMPORT_RULE: {
+ HtmlDocumentStreamData *stream_data_import;
+- gchar *url;
+
+- url = css_value_to_string (statement->s.import_rule.url);
+ stream_data_import = g_new (HtmlDocumentStreamData, 1);
+ stream_data_import->document = stream_data->document;
+- stream_data_import->internal_data = g_strdup(url);
++ stream_data_import->internal_data = css_value_to_string (statement->s.import_rule.url);
++ stream_data_import->media = statement->s.import_rule.media ? statement->s.import_rule.media : g_strdup (stream_data->media);
+ stream = html_stream_buffer_new (html_document_stylesheet_stream_close, stream_data_import);
+- g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, url, stream);
+- g_free (url);
++ g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, stream_data_import->internal_data, stream);
+ break;
+ }
+ default:
+@@ -174,8 +170,11 @@
+ }
+ }
+
+- g_free (stream_data);
+ document->stylesheets = g_slist_append (document->stylesheets, sheet);
++
++ g_free (stream_data->media);
++ g_free(stream_data->internal_data);
++ g_free (stream_data);
+
+ /* Restyle the document */
+ style_change = html_document_restyle_node (document, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), NULL, TRUE);
+@@ -216,21 +215,22 @@
+ HtmlDocumentStreamData *stream_data;
+ HtmlStream *stream;
+
+- stream_data = g_new (HtmlDocumentStreamData, 1);
++ stream_data = g_new0 (HtmlDocumentStreamData, 1);
+ stream_data->document = document;
+ stream_data->internal_data = g_strdup(url);
++ stream_data->media = xmlGetProp (node->xmlnode, "media");
+
+ stream = html_stream_buffer_new (html_document_stylesheet_stream_close, stream_data);
+
+ g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, url, stream);
++ g_free (url);
+ }
+- g_free (url);
+ } else if (str && (strcasecmp (str, "icon") == 0)) {
+ gchar *url = xmlGetProp (node->xmlnode, "href");
+ if (url) {
+ g_signal_emit (G_OBJECT (document), document_signals [REQUEST_ICON], 0, url);
++ g_free (url);
+ }
+- g_free (url);
+ }
+ g_free (str);
+ }
+@@ -282,8 +282,10 @@
+ CssStylesheet *ss;
+ HtmlStyleChange style_change;
+ GSList *list;
++ xmlChar *media = xmlGetProp (node->xmlnode->parent, "media");
+
+- ss = css_parser_parse_stylesheet (node->xmlnode->content, strlen (node->xmlnode->content), NULL);
++ ss = css_parser_parse_stylesheet (node->xmlnode->content, strlen (node->xmlnode->content), NULL, media);
++ if (media) xmlFree (media);
+
+ for (list = ss->stat; list; list = list->next) {
+ CssStatement *statement = list->data;
+@@ -296,9 +298,10 @@
+
+ cssurl = css_value_to_string (statement->s.import_rule.url);
+
+- stream_data = g_new (HtmlDocumentStreamData, 1);
++ stream_data = g_new0 (HtmlDocumentStreamData, 1);
+ stream_data->document = document;
+ stream_data->internal_data = g_strdup(cssurl);
++ stream_data->media = statement->s.import_rule.media;
+
+ stream = html_stream_buffer_new (html_document_stylesheet_stream_close, stream_data);
+ g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, cssurl, stream);
+@@ -546,6 +549,9 @@
+
+ if (document->parser)
+ g_object_unref (G_OBJECT (document->parser));
++
++ if (document->media_type)
++ g_free (document->media_type);
+
+ parent_class->finalize (object);
+ }
+@@ -753,6 +759,7 @@
+ {
+ document->stylesheets = NULL;
+ document->image_factory = html_image_factory_new ();
++ document->media_type = NULL;
+
+ g_signal_connect (G_OBJECT (document->image_factory), "request_image",
+ G_CALLBACK (html_document_request_image), document);
+@@ -1129,7 +1136,7 @@
+ }
+
+ CssStylesheet *
+-html_document_add_stylesheet (HtmlDocument *document, const gchar *buffer, gint len)
++html_document_add_stylesheet (HtmlDocument *document, const gchar *buffer, gint len, const gchar *media)
+ {
+ CssStylesheet *sheet;
+ HtmlStyleChange style_change;
+@@ -1140,7 +1147,7 @@
+ * complications it would cause with removal.
+ */
+
+- sheet = css_parser_parse_stylesheet (buffer, len, NULL);
++ sheet = css_parser_parse_stylesheet (buffer, len, NULL, media);
+ document->stylesheets = g_slist_append (document->stylesheets, sheet);
+
+ style_change = html_document_restyle_node (document, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), NULL, TRUE);
+@@ -1159,3 +1166,24 @@
+ return TRUE;
+ }
+
++void
++html_document_set_media_type (HtmlDocument *document, const gchar *type)
++{
++ HtmlStyleChange style_change;
++
++ g_return_if_fail (HTML_IS_DOCUMENT (document));
++
++ if (document->media_type)
++ g_free (document->media_type);
++
++ document->media_type = g_strdup (type);
++
++ style_change = html_document_restyle_node (document, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), NULL, TRUE);
++ g_signal_emit (G_OBJECT (document), document_signals [STYLE_UPDATED], 0, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), style_change);
++}
++
++const gchar *
++html_document_get_media_type (HtmlDocument *document)
++{
++ return document->media_type;
++}
+Index: gtkhtml2/libgtkhtml/document/htmldocument.h
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/document/htmldocument.h 2006-01-25 02:07:49.000000000 +0000
++++ gtkhtml2/libgtkhtml/document/htmldocument.h 2006-01-25 02:07:50.000000000 +0000
+@@ -64,6 +64,8 @@
+ DomNode *hover_node;
+ DomNode *active_node;
+ DomElement *focus_element;
++
++ gchar *media_type;
+ };
+
+ struct _HtmlDocumentClass {
+@@ -97,6 +99,7 @@
+ struct _HtmlDocumentStreamData {
+ HtmlDocument *document;
+ gpointer internal_data;
++ gchar *media;
+ };
+
+ GType html_document_get_type (void);
+@@ -113,9 +116,12 @@
+ void html_document_update_focus_element (HtmlDocument *document, DomElement *element);
+ DomNode *html_document_find_anchor (HtmlDocument *doc, const gchar *anchor);
+
+-CssStylesheet *html_document_add_stylesheet (HtmlDocument *document, const gchar *buffer, gint len);
++CssStylesheet *html_document_add_stylesheet (HtmlDocument *document, const gchar *buffer, gint len, const gchar *media);
+ gboolean html_document_remove_stylesheet (HtmlDocument *document, CssStylesheet *stylesheet);
+
++void html_document_set_media_type (HtmlDocument *document, const gchar *type);
++const gchar *html_document_get_media_type (HtmlDocument *document);
++
+ G_END_DECLS
+
+ #endif /* __HTMLDOCUMENT_H__ */
+Index: gtkhtml2/libgtkhtml/css/cssparser.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/css/cssparser.c 2006-01-25 02:05:54.000000000 +0000
++++ gtkhtml2/libgtkhtml/css/cssparser.c 2006-01-25 02:07:50.000000000 +0000
+@@ -688,6 +688,32 @@
+ return pos;
+ }
+
++static void
++css_parser_parse_media_list (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val)
++{
++ CssValue *list = NULL;
++ while (start_pos < end_pos) {
++ CssValue *val;
++ HtmlAtom name;
++
++ if (buffer[start_pos] == ',')
++ start_pos++;
++
++ start_pos = css_parser_parse_whitespace (buffer, start_pos, end_pos);
++
++ if (start_pos >= end_pos)
++ break;
++
++ start_pos = css_parser_parse_ident (buffer, start_pos, end_pos, &name);
++ val = css_value_ident_new (name);
++ if (!list) list = css_value_list_new ();
++ css_value_list_append (list, val, ',');
++
++ start_pos = css_parser_parse_whitespace (buffer, start_pos, end_pos);
++ }
++
++ *ret_val = list;
++}
+
+ static gint
+ css_parser_parse_attr_selector (const gchar *buffer, gint start_pos, gint end_pos, CssTail *tail)
+@@ -1329,7 +1355,7 @@
+
+ /* g_print ("Going to return: %d\n", pos); */
+
+- return pos + 1;
++ return pos;
+
+ break;
+ case HTML_ATOM_PAGE:
+@@ -1390,7 +1416,8 @@
+ break;
+ case HTML_ATOM_IMPORT: {
+ gchar *import_url;
+- const gchar *s_url, *e_url;
++ const gchar *s_url, *e_url, *e_import, *e_media;
++ CssValue *value = NULL;
+
+ cur_pos = css_parser_parse_to_char (buffer, ';', pos, end_pos);
+
+@@ -1411,6 +1438,7 @@
+ return cur_pos + 1;
+ }
+
++ e_import = e_url + 1;
+ s_url++;
+ e_url--;
+
+@@ -1434,6 +1462,11 @@
+ result->type = CSS_IMPORT_RULE;
+
+ result->s.import_rule.url = css_value_string_new (import_url);
++
++ /* Check for media types */
++ e_media = buffer + cur_pos;
++ if ((e_media > e_import) && (css_parser_parse_whitespace(e_import, 0, e_media-e_import) < (e_media-e_import)))
++ result->s.import_rule.media = g_strndup (e_import, e_media-e_import);
+
+ *ret_val = result;
+
+@@ -1489,7 +1522,7 @@
+ }
+
+ CssStylesheet *
+-css_parser_parse_stylesheet (const gchar *str, gint len, const gchar *base_url)
++css_parser_parse_stylesheet (const gchar *str, gint len, const gchar *base_url, const gchar *media)
+ {
+ CssStylesheet *result;
+ GSList *stat = NULL;
+@@ -1515,12 +1548,23 @@
+ pos = css_parser_parse_ruleset (buffer, pos, end_pos, &ruleset, base_url);
+
+ if (ruleset) {
+- CssStatement *rulestatement;
+- rulestatement = g_new0 (CssStatement, 1);
+- rulestatement->type = CSS_RULESET;
+- rulestatement->s.ruleset = ruleset;
++ CssStatement *statement;
++
++ if (media) {
++ statement = g_new0 (CssStatement, 1);
+
+- stat = g_slist_append (stat, rulestatement);
++ statement->type = CSS_MEDIA_RULE;
++ css_parser_parse_media_list (media, 0, strlen (media), &statement->s.media_rule.media_list);
++ g_assert (statement->s.media_rule.media_list);
++ statement->s.media_rule.rs = g_new (CssRuleset *, 1);
++ statement->s.media_rule.rs[0] = ruleset;
++ statement->s.media_rule.n_rs = 1;
++ } else {
++ statement = g_new0 (CssStatement, 1);
++ statement->type = CSS_RULESET;
++ statement->s.ruleset = ruleset;
++ }
++ stat = g_slist_append (stat, statement);
+ }
+
+ if (pos == -1)
+Index: gtkhtml2/libgtkhtml/css/cssparser.h
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/css/cssparser.h 2006-01-25 02:05:54.000000000 +0000
++++ gtkhtml2/libgtkhtml/css/cssparser.h 2006-01-25 02:07:50.000000000 +0000
+@@ -30,7 +30,7 @@
+
+ G_BEGIN_DECLS
+
+-CssStylesheet *css_parser_parse_stylesheet (const gchar *str, gint len, const gchar *base_url);
++CssStylesheet *css_parser_parse_stylesheet (const gchar *str, gint len, const gchar *base_url, const gchar *media);
+ CssRuleset *css_parser_parse_style_attr (const gchar *buffer, gint len, const gchar *base_url);
+
+ G_END_DECLS
+Index: gtkhtml2/libgtkhtml/css/cssstylesheet.h
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/css/cssstylesheet.h 2006-02-01 02:19:56.000000000 +0000
++++ gtkhtml2/libgtkhtml/css/cssstylesheet.h 2006-02-01 02:20:08.000000000 +0000
+@@ -99,6 +99,7 @@
+ CssValue *url;
+ gboolean fetched;
+ gboolean fetching;
++ gchar *media;
+ } import_rule;
+
+ } s;
diff --git a/openembedded/packages/gtkhtml2/files/css-stylesheet-user.patch b/openembedded/packages/gtkhtml2/files/css-stylesheet-user.patch
new file mode 100644
index 000000000..85fe53512
--- /dev/null
+++ b/openembedded/packages/gtkhtml2/files/css-stylesheet-user.patch
@@ -0,0 +1,54 @@
+Index: gtkhtml2/libgtkhtml/document/htmldocument.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/document/htmldocument.c 2006-01-21 02:24:09.000000000 +0000
++++ gtkhtml2/libgtkhtml/document/htmldocument.c 2006-01-21 04:21:37.000000000 +0000
+@@ -1127,3 +1127,35 @@
+ else
+ return NULL;
+ }
++
++CssStylesheet *
++html_document_add_stylesheet (HtmlDocument *document, const gchar *buffer, gint len)
++{
++ CssStylesheet *sheet;
++ HtmlStyleChange style_change;
++
++ g_return_val_if_fail (buffer && (len > 0) && HTML_IS_DOCUMENT (document), NULL);
++
++ /* Note: @import not supported for user stylesheets, due to
++ * complications it would cause with removal.
++ */
++
++ sheet = css_parser_parse_stylesheet (buffer, len, NULL);
++ document->stylesheets = g_slist_append (document->stylesheets, sheet);
++
++ style_change = html_document_restyle_node (document, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), NULL, TRUE);
++ g_signal_emit (G_OBJECT (document), document_signals [STYLE_UPDATED], 0, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), style_change);
++
++ return sheet;
++}
++
++gboolean
++html_document_remove_stylesheet (HtmlDocument *document, CssStylesheet *stylesheet)
++{
++ g_return_val_if_fail (stylesheet && HTML_IS_DOCUMENT (document), FALSE);
++
++ document->stylesheets = g_slist_remove (document->stylesheets, stylesheet);
++
++ return TRUE;
++}
++
+Index: gtkhtml2/libgtkhtml/document/htmldocument.h
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/document/htmldocument.h 2006-01-21 02:24:09.000000000 +0000
++++ gtkhtml2/libgtkhtml/document/htmldocument.h 2006-01-21 03:48:55.000000000 +0000
+@@ -113,6 +113,9 @@
+ void html_document_update_focus_element (HtmlDocument *document, DomElement *element);
+ DomNode *html_document_find_anchor (HtmlDocument *doc, const gchar *anchor);
+
++CssStylesheet *html_document_add_stylesheet (HtmlDocument *document, const gchar *buffer, gint len);
++gboolean html_document_remove_stylesheet (HtmlDocument *document, CssStylesheet *stylesheet);
++
+ G_END_DECLS
+
+ #endif /* __HTMLDOCUMENT_H__ */
diff --git a/openembedded/packages/gtkhtml2/files/fix-background-min-max.patch b/openembedded/packages/gtkhtml2/files/fix-background-min-max.patch
new file mode 100644
index 000000000..af557c8fa
--- /dev/null
+++ b/openembedded/packages/gtkhtml2/files/fix-background-min-max.patch
@@ -0,0 +1,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
diff --git a/openembedded/packages/gtkhtml2/files/fix-background-none.patch b/openembedded/packages/gtkhtml2/files/fix-background-none.patch
new file mode 100644
index 000000000..076f31200
--- /dev/null
+++ b/openembedded/packages/gtkhtml2/files/fix-background-none.patch
@@ -0,0 +1,40 @@
+Index: gtkhtml2/libgtkhtml/css/cssmatcher.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/css/cssmatcher.c 2006-01-21 01:02:23.000000000 +0000
++++ gtkhtml2/libgtkhtml/css/cssmatcher.c 2006-01-25 02:07:44.000000000 +0000
+@@ -596,7 +596,13 @@
+ g_object_unref (G_OBJECT(image));
+ return TRUE;
+ }
+- }
++ } else if (val->value_type == CSS_IDENT &&
++ val->v.atom == HTML_ATOM_NONE) {
++ if (style->background->image) {
++ g_object_unref (style->background->image);
++ style->background->image = NULL;
++ }
++ }
+ return FALSE;
+ }
+
+@@ -1256,7 +1262,10 @@
+ }
+ else if (val->value_type == CSS_FUNCTION)
+ handle_background_image (document, style, val);
+- else if (css_parse_color (val, &color))
++ else if (val->value_type == CSS_IDENT && val->v.atom == HTML_ATOM_NONE) {
++ handle_background_image (document, style, val);
++ style->background->color.transparent = TRUE;
++ } else if (css_parse_color (val, &color))
+ html_style_set_background_color (style, &color);
+
+ break;
+@@ -1273,6 +1282,8 @@
+
+ if (val->v.atom == HTML_ATOM_INHERIT)
+ html_style_set_background_color (style, &parent_style->background->color);
++ else if (val->v.atom == HTML_ATOM_NONE)
++ style->background->color.transparent = TRUE;
+ else if (css_parse_color (val, &color))
+ html_style_set_background_color (style, &color);
+ break;
diff --git a/openembedded/packages/gtkhtml2/files/fix-recreation.patch b/openembedded/packages/gtkhtml2/files/fix-recreation.patch
new file mode 100644
index 000000000..3bc636bae
--- /dev/null
+++ b/openembedded/packages/gtkhtml2/files/fix-recreation.patch
@@ -0,0 +1,407 @@
+Index: gtkhtml2/libgtkhtml/document/htmldocument.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/document/htmldocument.c 2006-01-25 19:19:23.000000000 +0000
++++ gtkhtml2/libgtkhtml/document/htmldocument.c 2006-01-25 19:21:10.000000000 +0000
+@@ -110,11 +110,6 @@
+
+ if (style_change != HTML_STYLE_CHANGE_NONE) {
+
+- /* FIXME: Workaround bug #199, we don't support recreation
+- * of dom nodes and layout boxes / jonas
+- */
+- new_style->display = node->style->display;
+-
+ html_style_ref (new_style);
+ html_style_unref (node->style);
+ node->style = new_style;
+Index: gtkhtml2/libgtkhtml/layout/htmlboxfactory.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/layout/htmlboxfactory.c 2006-01-25 19:19:23.000000000 +0000
++++ gtkhtml2/libgtkhtml/layout/htmlboxfactory.c 2006-01-25 19:21:10.000000000 +0000
+@@ -99,7 +99,7 @@
+
+
+ HtmlBox *
+-html_box_factory_new_box (HtmlView *view, DomNode *node)
++html_box_factory_new_box (HtmlView *view, DomNode *node, gboolean force_new)
+ {
+ HtmlBox *box = NULL, *parent_box;
+ HtmlStyle *style = node->style, *parent_style = NULL;
+@@ -117,7 +117,7 @@
+
+ box = parent_box->children;
+
+- while (box) {
++ while (box && !force_new) {
+ if (HTML_IS_BOX_TEXT (box) && box->dom_node == node) {
+
+ html_box_text_set_text (HTML_BOX_TEXT (box), node->xmlnode->content);
+Index: gtkhtml2/libgtkhtml/layout/htmlboxfactory.h
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/layout/htmlboxfactory.h 2006-01-25 19:19:23.000000000 +0000
++++ gtkhtml2/libgtkhtml/layout/htmlboxfactory.h 2006-01-25 19:21:10.000000000 +0000
+@@ -33,7 +33,7 @@
+
+ HtmlBox * html_box_factory_get_box (HtmlView *view, DomNode *node, HtmlBox *parent_box);
+ HtmlStyleChange html_box_factory_restyle_box (HtmlView *view, HtmlBox *box, HtmlAtom pseudo);
+-HtmlBox * html_box_factory_new_box (HtmlView *view, DomNode *node);
++HtmlBox * html_box_factory_new_box (HtmlView *view, DomNode *node, gboolean force_new);
+
+ G_END_DECLS
+
+Index: gtkhtml2/libgtkhtml/layout/htmlstyle.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/layout/htmlstyle.c 2006-01-25 19:19:23.000000000 +0000
++++ gtkhtml2/libgtkhtml/layout/htmlstyle.c 2006-01-25 19:21:10.000000000 +0000
+@@ -416,7 +416,7 @@
+ html_style_compare (const HtmlStyle *s1, const HtmlStyle *s2)
+ {
+ /* RECREATE begin */
+- if (s1->display != s1->display)
++ if (s1->display != s2->display)
+ return HTML_STYLE_CHANGE_RECREATE;
+ /* RECREATE end */
+
+Index: gtkhtml2/libgtkhtml/view/htmlview.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/view/htmlview.c 2006-01-25 19:19:23.000000000 +0000
++++ gtkhtml2/libgtkhtml/view/htmlview.c 2006-01-25 19:21:10.000000000 +0000
+@@ -1908,7 +1908,7 @@
+
+ g_assert (node->style != NULL);
+
+- new_box = html_box_factory_new_box (view, node);
++ new_box = html_box_factory_new_box (view, node, FALSE);
+
+ if (new_box) {
+
+@@ -2001,8 +2001,9 @@
+ html_view_remove_layout_box (view, box->dom_node);
+
+ /* Check if we're trying to remove the root box */
+- if (box == view->root)
++ if (box == view->root) {
+ view->root = NULL;
++ }
+
+ html_box_remove (box);
+ g_object_unref (G_OBJECT (box));
+@@ -2131,6 +2132,56 @@
+ }
+
+ switch (style_change) {
++ case HTML_STYLE_CHANGE_RECREATE: {
++ HtmlBox *new_box = NULL;
++
++ /* Don't replace boxes where display: none has been set */
++ if (style->display == HTML_DISPLAY_NONE) {
++ html_view_removed (document, node, view);
++ break;
++ }
++
++ new_box = html_box_factory_new_box (view, node, TRUE);
++ g_assert (new_box);
++
++ new_box->dom_node = node;
++ g_object_add_weak_pointer (G_OBJECT (node), (gpointer *)&(new_box->dom_node));
++ new_box->next = box->next;
++ new_box->prev = box->prev;
++ new_box->parent = box->parent;
++ new_box->children = box->children;
++
++ if (box->next) box->next->prev = new_box;
++ if (box->prev) box->prev->next = new_box;
++ if (box->parent)
++ if (box->parent->children == box)
++ box->parent->children = new_box;
++ if (box->children) {
++ HtmlBox *child = box->children;
++ while (child) {
++ if (child->parent == box)
++ child->parent = new_box;
++ child = child->prev;
++ }
++ child = box->children->next;
++ while (child) {
++ if (child->parent == box)
++ child->parent = new_box;
++ child = child->next;
++ }
++ }
++
++ if (view->root == box)
++ view->root = new_box;
++
++ html_view_remove_layout_box (view, node);
++ g_object_unref (box);
++
++ html_box_handle_html_properties (new_box, node->xmlnode);
++ html_view_add_layout_box (view, node, new_box);
++ html_view_relayout_callback (document, node, view);
++ break;
++ }
+ case HTML_STYLE_CHANGE_REPAINT:
+ html_view_repaint_callback (document, node, view);
+ break;
+Index: gtkhtml2/libgtkhtml/css/cssmatcher.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/css/cssmatcher.c 2006-01-25 19:19:23.000000000 +0000
++++ gtkhtml2/libgtkhtml/css/cssmatcher.c 2006-01-25 19:21:10.000000000 +0000
+@@ -2781,7 +2781,7 @@
+ }
+ }
+ if (strcasecmp ("table", n->name) == 0) {
+- if ((str = xmlGetProp (n, "align"))) {
++ if ((style->display != HTML_DISPLAY_BLOCK) && (str = xmlGetProp (n, "align"))) {
+ if (strcasecmp (str, "left") == 0)
+ style->Float = HTML_FLOAT_LEFT;
+ else if (strcasecmp (str, "right") == 0)
+Index: gtkhtml2/libgtkhtml/layout/htmlbox.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/layout/htmlbox.c 2006-01-25 19:21:09.000000000 +0000
++++ gtkhtml2/libgtkhtml/layout/htmlbox.c 2006-01-25 19:21:10.000000000 +0000
+@@ -308,7 +308,7 @@
+ else if (style->surround->margin.left.type != HTML_LENGTH_AUTO &&
+ style->surround->margin.right.type != HTML_LENGTH_AUTO) {
+
+- if (HTML_BOX_GET_STYLE (box->parent)->inherited->direction == HTML_DIRECTION_RTL) {
++ if (HTML_BOX_GET_STYLE (html_box_get_containing_block (box))->inherited->direction == HTML_DIRECTION_RTL) {
+
+ return width - html_length_get_value (&style->box->width, width) -
+ html_box_left_padding (box, width) - html_box_right_padding (box, width) -
+@@ -348,7 +348,7 @@
+ else if (style->surround->margin.left.type != HTML_LENGTH_AUTO &&
+ style->surround->margin.right.type != HTML_LENGTH_AUTO) {
+
+- if (HTML_BOX_GET_STYLE (box->parent)->inherited->direction == HTML_DIRECTION_LTR) {
++ if (HTML_BOX_GET_STYLE (html_box_get_containing_block (box))->inherited->direction == HTML_DIRECTION_LTR) {
+
+ return width - html_length_get_value (&style->box->width, width) -
+ html_box_left_padding (box, width) - html_box_right_padding (box, width) -
+@@ -820,35 +820,36 @@
+ int tmp;
+ gint old_width = *boxwidth;
+ gint old_height = *boxheight;
++ HtmlBox *parent = html_box_get_containing_block (self);
+
+- if (self->parent) {
++ if (parent) {
+ if (HTML_BOX_GET_STYLE (self)->box->min_width.type != HTML_LENGTH_AUTO) {
+- tmp = html_length_get_value (&HTML_BOX_GET_STYLE (self)->box->min_width, self->parent->width -
+- html_box_horizontal_mbp_sum (self->parent) - html_box_horizontal_mbp_sum (self));
++ tmp = html_length_get_value (&HTML_BOX_GET_STYLE (self)->box->min_width, parent->width -
++ html_box_horizontal_mbp_sum (parent) - html_box_horizontal_mbp_sum (self));
+ if (*boxwidth < tmp)
+ *boxwidth = tmp;
+
+ }
+
+ if (HTML_BOX_GET_STYLE (self)->box->max_width.type != HTML_LENGTH_AUTO) {
+- tmp = html_length_get_value (&HTML_BOX_GET_STYLE (self)->box->max_width, self->parent->width -
+- html_box_horizontal_mbp_sum (self->parent) - html_box_horizontal_mbp_sum (self));
++ tmp = html_length_get_value (&HTML_BOX_GET_STYLE (self)->box->max_width, parent->width -
++ html_box_horizontal_mbp_sum (parent) - html_box_horizontal_mbp_sum (self));
+ if (*boxwidth > tmp)
+ *boxwidth = tmp;
+
+ }
+
+ if (HTML_BOX_GET_STYLE (self)->box->min_height.type != HTML_LENGTH_AUTO) {
+- tmp = html_length_get_value (&HTML_BOX_GET_STYLE (self)->box->min_height, self->parent->height -
+- html_box_horizontal_mbp_sum (self->parent) - html_box_horizontal_mbp_sum (self));
++ tmp = html_length_get_value (&HTML_BOX_GET_STYLE (self)->box->min_height, parent->height -
++ html_box_horizontal_mbp_sum (parent) - html_box_horizontal_mbp_sum (self));
+ if (*boxheight < tmp)
+ *boxheight = tmp;
+
+ }
+
+ if (HTML_BOX_GET_STYLE (self)->box->max_height.type != HTML_LENGTH_AUTO) {
+- tmp = html_length_get_value (&HTML_BOX_GET_STYLE (self)->box->max_height, self->parent->height -
+- html_box_horizontal_mbp_sum (self->parent) - html_box_horizontal_mbp_sum (self));
++ tmp = html_length_get_value (&HTML_BOX_GET_STYLE (self)->box->max_height, parent->height -
++ html_box_horizontal_mbp_sum (parent) - html_box_horizontal_mbp_sum (self));
+ if (*boxheight > tmp)
+ *boxheight = tmp;
+
+Index: gtkhtml2/libgtkhtml/layout/htmlboxblock.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/layout/htmlboxblock.c 2006-01-25 19:19:23.000000000 +0000
++++ gtkhtml2/libgtkhtml/layout/htmlboxblock.c 2006-01-25 19:21:10.000000000 +0000
+@@ -358,8 +358,7 @@
+
+ /* Get the prefered width */
+ /* If the width wasn't specified by CSS, use the width of the containing box (parent) */
+-
+- if (self->parent) {
++ if (html_box_get_containing_block (self)) {
+
+ if (style->Float != HTML_FLOAT_NONE)
+ new_width = html_length_get_value (&style->box->width, html_box_get_containing_block_width (self));
+Index: gtkhtml2/libgtkhtml/graphics/htmlimagefactory.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/graphics/htmlimagefactory.c 2006-01-25 19:19:23.000000000 +0000
++++ gtkhtml2/libgtkhtml/graphics/htmlimagefactory.c 2006-01-25 19:21:10.000000000 +0000
+@@ -127,7 +127,7 @@
+ }
+
+ static void
+-html_image_shutdown (HtmlImage *image, HtmlImageFactory *image_factory)
++html_image_shutdown (HtmlImageFactory *image_factory, HtmlImage *image)
+ {
+ g_hash_table_remove (image_factory->image_hash, image->uri);
+ }
+@@ -146,8 +146,7 @@
+
+ image = HTML_IMAGE (g_object_new (HTML_IMAGE_TYPE, NULL));
+
+- g_signal_connect (G_OBJECT (image), "last_unref",
+- G_CALLBACK (html_image_shutdown), image_factory);
++ g_object_weak_ref (G_OBJECT (image), (GWeakNotify)html_image_shutdown, image_factory);
+
+ image->loading = TRUE;
+
+Index: gtkhtml2/libgtkhtml/layout/html/htmlboxembeddedimage.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/layout/html/htmlboxembeddedimage.c 2006-01-25 19:19:23.000000000 +0000
++++ gtkhtml2/libgtkhtml/layout/html/htmlboxembeddedimage.c 2006-01-25 19:21:10.000000000 +0000
+@@ -64,25 +64,36 @@
+ }
+
+ static void
+-html_box_embedded_image_class_init (HtmlBoxClass *klass)
++html_box_embedded_image_resize_image (HtmlImage *image, HtmlBoxEmbeddedImage *box)
+ {
+-
+- klass->paint = html_box_embedded_image_paint;
+- klass->relayout = html_box_embedded_image_relayout;
++ g_signal_emit_by_name (G_OBJECT (box->view->document), "relayout_node", HTML_BOX (box)->dom_node);
++}
+
+- parent_class = g_type_class_peek_parent (klass);
++static void
++html_box_embedded_image_repaint_image (HtmlImage *image, gint x, gint y, gint width, gint height, HtmlBoxEmbeddedImage *box)
++{
++ g_signal_emit_by_name (G_OBJECT (box->view->document), "repaint_node", HTML_BOX (box)->dom_node);
+ }
+
+ static void
+-html_box_embedded_image_resize_image (HtmlImage *image, HtmlBoxEmbeddedImage *box)
++html_box_embedded_image_finalize (GObject *object)
+ {
+- g_signal_emit_by_name (G_OBJECT (box->view->document), "relayout_node", HTML_BOX (box)->dom_node);
++ HtmlBoxEmbeddedImage *image = HTML_BOX_EMBEDDED_IMAGE (object);
++
++ g_signal_handlers_disconnect_by_func (G_OBJECT (image->image), G_CALLBACK (html_box_embedded_image_resize_image), image);
++ g_signal_handlers_disconnect_by_func (G_OBJECT (image->image), G_CALLBACK (html_box_embedded_image_repaint_image), image);
+ }
+
+ static void
+-html_box_embedded_image_repaint_image (HtmlImage *image, gint x, gint y, gint width, gint height, HtmlBoxEmbeddedImage *box)
++html_box_embedded_image_class_init (HtmlBoxClass *klass)
+ {
+- g_signal_emit_by_name (G_OBJECT (box->view->document), "repaint_node", HTML_BOX (box)->dom_node);
++ GObjectClass *object_class = (GObjectClass *)klass;
++
++ klass->paint = html_box_embedded_image_paint;
++ klass->relayout = html_box_embedded_image_relayout;
++ object_class->finalize = html_box_embedded_image_finalize;
++
++ parent_class = g_type_class_peek_parent (klass);
+ }
+
+ void
+Index: gtkhtml2/libgtkhtml/layout/htmlboxtext.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/layout/htmlboxtext.c 2006-01-25 19:19:23.000000000 +0000
++++ gtkhtml2/libgtkhtml/layout/htmlboxtext.c 2006-01-25 19:21:10.000000000 +0000
+@@ -146,6 +146,7 @@
+
+ master = text->master;
+ if (master) {
++ html_box_text_destroy_slaves (text);
+ html_box_text_free_master (master);
+ g_free (master);
+ text->master = NULL;
+Index: gtkhtml2/libgtkhtml/layout/html/htmlboximage.c
+===================================================================
+--- gtkhtml2.orig/libgtkhtml/layout/html/htmlboximage.c 2006-01-25 19:21:09.000000000 +0000
++++ gtkhtml2/libgtkhtml/layout/html/htmlboximage.c 2006-01-25 19:21:33.000000000 +0000
+@@ -195,10 +195,41 @@
+ }
+
+ static void
++html_box_image_resize_image (HtmlImage *image, HtmlBoxImage *box)
++{
++ g_signal_emit_by_name (G_OBJECT (box->view->document), "relayout_node", HTML_BOX (box)->dom_node);
++}
++
++static void
++html_box_image_repaint_image (HtmlImage *image, gint x, gint y, gint width, gint height, HtmlBoxImage *box)
++{
++ gdouble real_x, real_y;
++ gdouble real_width, real_height;
++
++ if (box->scaled_pixbuf && image->pixbuf) {
++
++ html_box_image_update_scaled_pixbuf (box, gdk_pixbuf_get_width (box->scaled_pixbuf), gdk_pixbuf_get_height (box->scaled_pixbuf));
++ real_y = (y * gdk_pixbuf_get_height (box->scaled_pixbuf)) / (gdouble)gdk_pixbuf_get_height (image->pixbuf);
++ real_x = (x * gdk_pixbuf_get_width (box->scaled_pixbuf)) / (gdouble)gdk_pixbuf_get_width (image->pixbuf);
++
++ real_height = (height * gdk_pixbuf_get_height (box->scaled_pixbuf)) / (gdouble)gdk_pixbuf_get_height (image->pixbuf);
++ real_width = (width * gdk_pixbuf_get_width (box->scaled_pixbuf)) / (gdouble)gdk_pixbuf_get_width (image->pixbuf);
++
++ gtk_widget_queue_draw_area (GTK_WIDGET (box->view),
++ html_box_get_absolute_x (HTML_BOX (box)), /* + floor (real_x + 0.5),*/
++ html_box_get_absolute_y (HTML_BOX (box)),/* + floor (real_y + 0.5),*/
++ floor (real_width + real_x + 0.5),
++ floor (real_height + real_y + 0.5));
++ }
++}
++
++static void
+ html_box_image_finalize (GObject *object)
+ {
+ HtmlBoxImage *image = HTML_BOX_IMAGE (object);
+
++ g_signal_handlers_disconnect_by_func (G_OBJECT (image->image), G_CALLBACK (html_box_image_resize_image), image);
++ g_signal_handlers_disconnect_by_func (G_OBJECT (image->image), G_CALLBACK (html_box_image_repaint_image), image);
+ if (image->scaled_pixbuf)
+ g_object_unref (image->scaled_pixbuf);
+
+@@ -262,35 +293,6 @@
+ return HTML_BOX (box);
+ }
+
+-static void
+-html_box_image_resize_image (HtmlImage *image, HtmlBoxImage *box)
+-{
+- g_signal_emit_by_name (G_OBJECT (box->view->document), "relayout_node", HTML_BOX (box)->dom_node);
+-}
+-
+-static void
+-html_box_image_repaint_image (HtmlImage *image, gint x, gint y, gint width, gint height, HtmlBoxImage *box)
+-{
+- gdouble real_x, real_y;
+- gdouble real_width, real_height;
+-
+- if (box->scaled_pixbuf && image->pixbuf) {
+-
+- html_box_image_update_scaled_pixbuf (box, gdk_pixbuf_get_width (box->scaled_pixbuf), gdk_pixbuf_get_height (box->scaled_pixbuf));
+- real_y = (y * gdk_pixbuf_get_height (box->scaled_pixbuf)) / (gdouble)gdk_pixbuf_get_height (image->pixbuf);
+- real_x = (x * gdk_pixbuf_get_width (box->scaled_pixbuf)) / (gdouble)gdk_pixbuf_get_width (image->pixbuf);
+-
+- real_height = (height * gdk_pixbuf_get_height (box->scaled_pixbuf)) / (gdouble)gdk_pixbuf_get_height (image->pixbuf);
+- real_width = (width * gdk_pixbuf_get_width (box->scaled_pixbuf)) / (gdouble)gdk_pixbuf_get_width (image->pixbuf);
+-
+- gtk_widget_queue_draw_area (GTK_WIDGET (box->view),
+- html_box_get_absolute_x (HTML_BOX (box)), /* + floor (real_x + 0.5),*/
+- html_box_get_absolute_y (HTML_BOX (box)),/* + floor (real_y + 0.5),*/
+- floor (real_width + real_x + 0.5),
+- floor (real_height + real_y + 0.5));
+- }
+-}
+-
+ void
+ html_box_image_set_image (HtmlBoxImage *box, HtmlImage *image)
+ {