mirror of
https://git.yoctoproject.org/poky
synced 2026-01-29 21:08:42 +01:00
Update gtkhtml2 and Web packages
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@338 311d38ba-8fff-0310-9ca6-ca027cbcb966
This commit is contained in:
@@ -1,141 +0,0 @@
|
||||
Index: libgtkhtml/document/htmldocument.c
|
||||
===================================================================
|
||||
--- libgtkhtml/document/htmldocument.c.orig 2006-02-11 05:21:28.000000000 +0000
|
||||
+++ libgtkhtml/document/htmldocument.c 2006-02-11 15:41:06.000000000 +0000
|
||||
@@ -48,6 +48,7 @@ enum {
|
||||
|
||||
/* DOM change events */
|
||||
NODE_INSERTED,
|
||||
+ NODE_FINISHED,
|
||||
NODE_REMOVED,
|
||||
TEXT_UPDATED,
|
||||
STYLE_UPDATED,
|
||||
@@ -536,6 +537,12 @@ html_document_new_node (HtmlParser *pars
|
||||
}
|
||||
|
||||
static void
|
||||
+html_document_finished_node (HtmlParser *parser, DomNode *node, HtmlDocument *document)
|
||||
+{
|
||||
+ g_signal_emit (G_OBJECT (document), document_signals [NODE_FINISHED], 0, node);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
html_document_finalize (GObject *object)
|
||||
{
|
||||
HtmlDocument *document = HTML_DOCUMENT (object);
|
||||
@@ -639,6 +646,16 @@ html_document_class_init (HtmlDocumentCl
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1,
|
||||
DOM_TYPE_NODE);
|
||||
+
|
||||
+ document_signals [NODE_FINISHED] =
|
||||
+ g_signal_new ("node_finished",
|
||||
+ G_TYPE_FROM_CLASS (object_class),
|
||||
+ G_SIGNAL_RUN_LAST,
|
||||
+ G_STRUCT_OFFSET (HtmlDocumentClass, node_finished),
|
||||
+ NULL, NULL,
|
||||
+ g_cclosure_marshal_VOID__OBJECT,
|
||||
+ G_TYPE_NONE, 1,
|
||||
+ DOM_TYPE_NODE);
|
||||
|
||||
document_signals [NODE_REMOVED] =
|
||||
g_signal_new ("node_removed",
|
||||
@@ -818,6 +835,9 @@ html_document_open_stream (HtmlDocument
|
||||
g_signal_connect (document->parser, "done_parsing",
|
||||
(GCallback) html_document_done_parsing,
|
||||
document);
|
||||
+ g_signal_connect (document->parser, "finished_node",
|
||||
+ (GCallback) html_document_finished_node,
|
||||
+ document);
|
||||
|
||||
document->state = HTML_DOCUMENT_STATE_PARSING;
|
||||
return TRUE;
|
||||
Index: libgtkhtml/document/htmldocument.h
|
||||
===================================================================
|
||||
--- libgtkhtml/document/htmldocument.h.orig 2006-02-11 05:21:28.000000000 +0000
|
||||
+++ libgtkhtml/document/htmldocument.h 2006-02-11 15:35:38.000000000 +0000
|
||||
@@ -80,6 +80,7 @@ struct _HtmlDocumentClass {
|
||||
|
||||
/* DOM change events */
|
||||
void (*node_inserted) (HtmlDocument *document, DomNode *node);
|
||||
+ void (*node_finished) (HtmlDocument *document, DomNode *node);
|
||||
void (*node_removed) (HtmlDocument *document, DomNode *node);
|
||||
void (*text_updated) (HtmlDocument *document, DomNode *node);
|
||||
void (*style_updated) (HtmlDocument *document, DomNode *node, HtmlStyleChange style_change);
|
||||
Index: libgtkhtml/document/htmlparser.c
|
||||
===================================================================
|
||||
--- libgtkhtml/document/htmlparser.c.orig 2006-01-17 11:50:54.000000000 +0000
|
||||
+++ libgtkhtml/document/htmlparser.c 2006-02-11 17:21:20.000000000 +0000
|
||||
@@ -28,6 +28,7 @@ enum {
|
||||
NEW_NODE,
|
||||
DONE_PARSING,
|
||||
PARSED_DOCUMENT_NODE,
|
||||
+ FINISHED_NODE,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
@@ -84,8 +85,13 @@ static void
|
||||
html_endElement (void *ctx, const xmlChar *name)
|
||||
{
|
||||
HtmlParser *parser = HTML_PARSER (ctx);
|
||||
+ DomNode *node;
|
||||
|
||||
xmlSAX2EndElement (parser->xmlctxt, name);
|
||||
+
|
||||
+ node = dom_Node_mkref (xmlGetLastChild (parser->xmlctxt->node));
|
||||
+ if (node)
|
||||
+ g_signal_emit (G_OBJECT (parser), parser_signals [FINISHED_NODE], 0, node);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -241,6 +247,15 @@ html_parser_class_init (HtmlParserClass
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
+ parser_signals [FINISHED_NODE] =
|
||||
+ g_signal_new ("finished_node",
|
||||
+ G_TYPE_FROM_CLASS (object_class),
|
||||
+ G_SIGNAL_RUN_LAST,
|
||||
+ G_STRUCT_OFFSET (HtmlParserClass, finished_node),
|
||||
+ NULL, NULL,
|
||||
+ g_cclosure_marshal_VOID__OBJECT,
|
||||
+ G_TYPE_NONE, 1,
|
||||
+ DOM_TYPE_NODE);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -281,11 +296,11 @@ html_parser_set_type (HtmlParser *parser
|
||||
/* FIXME: Free parser if existing */
|
||||
if (parser_type == HTML_PARSER_TYPE_HTML) {
|
||||
parser->xmlctxt = htmlCreatePushParserCtxt (SAXHandler, parser,
|
||||
- parser->chars, parser->res, NULL, 0);
|
||||
+ NULL, 0, NULL, 0);
|
||||
}
|
||||
else {
|
||||
parser->xmlctxt = xmlCreatePushParserCtxt (SAXHandler, parser,
|
||||
- parser->chars, parser->res, NULL);
|
||||
+ NULL, 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
Index: libgtkhtml/document/htmlparser.h
|
||||
===================================================================
|
||||
--- libgtkhtml/document/htmlparser.h.orig 2006-01-17 11:50:54.000000000 +0000
|
||||
+++ libgtkhtml/document/htmlparser.h 2006-02-11 18:57:51.000000000 +0000
|
||||
@@ -57,8 +57,6 @@ struct _HtmlParser {
|
||||
|
||||
/* Used by libxml */
|
||||
xmlParserCtxtPtr xmlctxt;
|
||||
- int res;
|
||||
- char chars[10];
|
||||
|
||||
gboolean blocking;
|
||||
DomNode *blocking_node;
|
||||
@@ -71,6 +69,7 @@ struct _HtmlParserClass {
|
||||
void (* done_parsing) (HtmlParser *parser);
|
||||
void (* new_node) (HtmlParser *parser, DomNode *node);
|
||||
void (* parsed_document_node) (HtmlParser *parser, DomDocument *document);
|
||||
+ void (* finished_node) (HtmlParser *parser, DomNode *node);
|
||||
};
|
||||
typedef struct _HtmlParserClass HtmlParserClass;
|
||||
|
||||
@@ -1,686 +0,0 @@
|
||||
Index: libgtkhtml/css/cssmatcher.c
|
||||
===================================================================
|
||||
--- libgtkhtml/css/cssmatcher.c.orig 2006-02-04 20:10:47.000000000 +0000
|
||||
+++ libgtkhtml/css/cssmatcher.c 2006-02-05 18:19:15.000000000 +0000
|
||||
@@ -79,7 +79,7 @@ css_matcher_match_simple_selector (CssSi
|
||||
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");
|
||||
@@ -2384,7 +2384,7 @@ css_matcher_sheet_stream_close (HtmlStre
|
||||
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;
|
||||
|
||||
@@ -2781,7 +2781,7 @@ css_matcher_get_style (HtmlDocument *doc
|
||||
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);
|
||||
@@ -2800,7 +2800,7 @@ css_matcher_get_style (HtmlDocument *doc
|
||||
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
|
||||
===================================================================
|
||||
--- libgtkhtml/css/cssparser.c.orig 2006-02-04 20:10:47.000000000 +0000
|
||||
+++ libgtkhtml/css/cssparser.c 2006-02-05 18:19:15.000000000 +0000
|
||||
@@ -49,7 +49,7 @@ const gchar *css_dimensions[] = {
|
||||
|
||||
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 @@ css_parser_parse_number (const gchar *bu
|
||||
}
|
||||
|
||||
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 @@ css_parser_parse_term (const gchar *buff
|
||||
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 @@ css_parser_parse_term (const gchar *buff
|
||||
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 (®, "^[a-zA-Z][a-zA-Z0-9.+-]*:", REG_NOSUB);
|
||||
+ if (((*ret_val)->v.function->args->v.s[0] != '/') && (regexec (®, (*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 (®);
|
||||
+ }
|
||||
+
|
||||
+ g_free (str);
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
css_value_unref (val);
|
||||
+ }
|
||||
}
|
||||
|
||||
/* This is due to the ) */
|
||||
@@ -566,7 +604,7 @@ css_parser_parse_term (const gchar *buff
|
||||
}
|
||||
|
||||
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_parser_parse_value (const gchar *buf
|
||||
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 @@ css_parser_parse_value (const gchar *buf
|
||||
}
|
||||
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 @@ css_parser_parse_selectors (const gchar
|
||||
}
|
||||
|
||||
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 @@ css_parser_parse_declaration (const gcha
|
||||
|
||||
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 @@ css_parser_parse_declaration (const gcha
|
||||
}
|
||||
|
||||
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 @@ css_parser_parse_declarations (const gch
|
||||
|
||||
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 @@ css_parser_parse_declarations (const gch
|
||||
}
|
||||
|
||||
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 @@ css_parser_parse_ruleset (const gchar *b
|
||||
}
|
||||
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 @@ css_parser_prepare_stylesheet (const gch
|
||||
}
|
||||
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 @@ css_parser_prepare_stylesheet (const gch
|
||||
}
|
||||
|
||||
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 @@ css_parser_parse_atkeyword (const gchar
|
||||
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 @@ css_parser_parse_atkeyword (const gchar
|
||||
|
||||
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 @@ css_parser_parse_atkeyword (const gchar
|
||||
|
||||
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 @@ css_parser_parse_atkeyword (const gchar
|
||||
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 @@ css_parser_parse_atkeyword (const gchar
|
||||
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 @@ css_parser_parse_atkeyword (const gchar
|
||||
}
|
||||
|
||||
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 @@ css_parser_parse_style_attr (const gchar
|
||||
|
||||
/* 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 @@ css_parser_parse_style_attr (const gchar
|
||||
}
|
||||
|
||||
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 @@ css_parser_parse_stylesheet (const gchar
|
||||
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 @@ css_parser_parse_stylesheet (const gchar
|
||||
|
||||
g_free (buffer);
|
||||
|
||||
- result = g_new (CssStylesheet, 1);
|
||||
+ result = g_new0 (CssStylesheet, 1);
|
||||
result->stat = stat;
|
||||
|
||||
return result;
|
||||
Index: libgtkhtml/css/cssparser.h
|
||||
===================================================================
|
||||
--- libgtkhtml/css/cssparser.h.orig 2006-02-04 20:10:47.000000000 +0000
|
||||
+++ libgtkhtml/css/cssparser.h 2006-02-05 18:19:15.000000000 +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
|
||||
===================================================================
|
||||
--- libgtkhtml/css/cssstylesheet.h.orig 2006-02-04 20:10:47.000000000 +0000
|
||||
+++ libgtkhtml/css/cssstylesheet.h 2006-02-05 18:19:15.000000000 +0000
|
||||
@@ -181,6 +181,7 @@ struct _CssTail {
|
||||
};
|
||||
|
||||
struct _CssStylesheet {
|
||||
+ gchar *url;
|
||||
gboolean disabled;
|
||||
GSList *stat;
|
||||
};
|
||||
Index: libgtkhtml/css/cssvalue.c
|
||||
===================================================================
|
||||
--- libgtkhtml/css/cssvalue.c.orig 2006-02-04 20:10:47.000000000 +0000
|
||||
+++ libgtkhtml/css/cssvalue.c 2006-02-04 20:13:33.000000000 +0000
|
||||
@@ -64,7 +64,7 @@ css_value_function_new (HtmlAtom name, C
|
||||
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
|
||||
===================================================================
|
||||
--- libgtkhtml/document/htmldocument.c.orig 2006-02-04 20:10:47.000000000 +0000
|
||||
+++ libgtkhtml/document/htmldocument.c 2006-02-05 18:19:17.000000000 +0000
|
||||
@@ -134,14 +134,42 @@ static void
|
||||
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 */
|
||||
@@ -179,9 +207,15 @@ html_document_node_inserted_traverser (H
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -242,12 +276,39 @@ html_document_node_inserted_traverser (H
|
||||
|
||||
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
|
||||
===================================================================
|
||||
--- libgtkhtml/document/htmldocument.h.orig 2006-02-04 20:10:47.000000000 +0000
|
||||
+++ libgtkhtml/document/htmldocument.h 2006-02-05 18:19:17.000000000 +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 @@ struct _HtmlDocumentClass {
|
||||
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
|
||||
===================================================================
|
||||
--- libgtkhtml/layout/htmlboxblock.c.orig 2006-02-04 20:10:47.000000000 +0000
|
||||
+++ libgtkhtml/layout/htmlboxblock.c 2006-02-04 20:13:33.000000000 +0000
|
||||
@@ -100,17 +100,21 @@ html_real_box_block_update_geometry (Htm
|
||||
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)
|
||||
Index: libgtkhtml/view/htmlevent.c
|
||||
===================================================================
|
||||
--- libgtkhtml/view/htmlevent.c.orig 2006-02-04 20:10:47.000000000 +0000
|
||||
+++ libgtkhtml/view/htmlevent.c 2006-02-04 20:13:33.000000000 +0000
|
||||
@@ -46,14 +46,48 @@ html_event_find_parent_dom_node (HtmlBox
|
||||
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 @@ html_event_find_box_traverser (HtmlBox *
|
||||
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)) {
|
||||
@@ -1,466 +0,0 @@
|
||||
Index: libgtkhtml/css/cssmatcher.c
|
||||
===================================================================
|
||||
--- libgtkhtml/css/cssmatcher.c.orig 2006-02-11 05:18:03.000000000 +0000
|
||||
+++ libgtkhtml/css/cssmatcher.c 2006-02-11 05:21:28.000000000 +0000
|
||||
@@ -2411,7 +2411,8 @@ css_matcher_apply_stylesheet (HtmlDocume
|
||||
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 @@ css_matcher_apply_stylesheet (HtmlDocume
|
||||
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_get_style (HtmlDocument *doc
|
||||
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 @@ css_matcher_get_style (HtmlDocument *doc
|
||||
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: libgtkhtml/document/htmldocument.c
|
||||
===================================================================
|
||||
--- libgtkhtml/document/htmldocument.c.orig 2006-02-11 05:21:18.000000000 +0000
|
||||
+++ libgtkhtml/document/htmldocument.c 2006-02-11 05:21:28.000000000 +0000
|
||||
@@ -142,9 +142,7 @@ html_document_stylesheet_stream_close (c
|
||||
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;
|
||||
@@ -153,15 +151,13 @@ html_document_stylesheet_stream_close (c
|
||||
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:
|
||||
@@ -169,8 +165,11 @@ html_document_stylesheet_stream_close (c
|
||||
}
|
||||
}
|
||||
|
||||
- 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);
|
||||
@@ -211,21 +210,22 @@ html_document_node_inserted_traverser (H
|
||||
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);
|
||||
}
|
||||
@@ -277,8 +277,10 @@ html_document_node_inserted_traverser (H
|
||||
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;
|
||||
@@ -291,9 +293,10 @@ html_document_node_inserted_traverser (H
|
||||
|
||||
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);
|
||||
@@ -541,6 +544,9 @@ html_document_finalize (GObject *object)
|
||||
|
||||
if (document->parser)
|
||||
g_object_unref (G_OBJECT (document->parser));
|
||||
+
|
||||
+ if (document->media_type)
|
||||
+ g_free (document->media_type);
|
||||
|
||||
parent_class->finalize (object);
|
||||
}
|
||||
@@ -748,6 +754,7 @@ html_document_init (HtmlDocument *docume
|
||||
{
|
||||
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);
|
||||
@@ -1159,3 +1166,24 @@ html_document_remove_stylesheet (HtmlDoc
|
||||
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: libgtkhtml/document/htmldocument.h
|
||||
===================================================================
|
||||
--- libgtkhtml/document/htmldocument.h.orig 2006-02-11 05:20:51.000000000 +0000
|
||||
+++ libgtkhtml/document/htmldocument.h 2006-02-11 05:21:28.000000000 +0000
|
||||
@@ -64,6 +64,8 @@ struct _HtmlDocument {
|
||||
DomNode *hover_node;
|
||||
DomNode *active_node;
|
||||
DomElement *focus_element;
|
||||
+
|
||||
+ gchar *media_type;
|
||||
};
|
||||
|
||||
struct _HtmlDocumentClass {
|
||||
@@ -97,6 +99,7 @@ struct _HtmlDocumentClass {
|
||||
struct _HtmlDocumentStreamData {
|
||||
HtmlDocument *document;
|
||||
gpointer internal_data;
|
||||
+ gchar *media;
|
||||
};
|
||||
|
||||
GType html_document_get_type (void);
|
||||
@@ -116,6 +119,10 @@ DomNode *html_document_find_anchor
|
||||
void html_document_add_stylesheet (HtmlDocument *document, CssStylesheet *stylesheet);
|
||||
void 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: libgtkhtml/css/cssparser.c
|
||||
===================================================================
|
||||
--- libgtkhtml/css/cssparser.c.orig 2006-02-11 05:18:03.000000000 +0000
|
||||
+++ libgtkhtml/css/cssparser.c 2006-02-11 05:21:28.000000000 +0000
|
||||
@@ -688,6 +688,32 @@ css_parser_parse_value (const gchar *buf
|
||||
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 @@ css_parser_parse_atkeyword (const gchar
|
||||
|
||||
/* g_print ("Going to return: %d\n", pos); */
|
||||
|
||||
- return pos + 1;
|
||||
+ return pos;
|
||||
|
||||
break;
|
||||
case HTML_ATOM_PAGE:
|
||||
@@ -1390,7 +1416,8 @@ css_parser_parse_atkeyword (const gchar
|
||||
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 @@ css_parser_parse_atkeyword (const gchar
|
||||
return cur_pos + 1;
|
||||
}
|
||||
|
||||
+ e_import = e_url + 1;
|
||||
s_url++;
|
||||
e_url--;
|
||||
|
||||
@@ -1434,6 +1462,11 @@ css_parser_parse_atkeyword (const gchar
|
||||
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 @@ css_parser_parse_style_attr (const gchar
|
||||
}
|
||||
|
||||
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 @@ css_parser_parse_stylesheet (const gchar
|
||||
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: libgtkhtml/css/cssparser.h
|
||||
===================================================================
|
||||
--- libgtkhtml/css/cssparser.h.orig 2006-02-11 05:18:03.000000000 +0000
|
||||
+++ libgtkhtml/css/cssparser.h 2006-02-11 05:21:28.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: libgtkhtml/css/cssstylesheet.h
|
||||
===================================================================
|
||||
--- libgtkhtml/css/cssstylesheet.h.orig 2006-02-11 05:18:03.000000000 +0000
|
||||
+++ libgtkhtml/css/cssstylesheet.h 2006-02-11 05:21:28.000000000 +0000
|
||||
@@ -99,6 +99,7 @@ struct _CssStatement {
|
||||
CssValue *url;
|
||||
gboolean fetched;
|
||||
gboolean fetching;
|
||||
+ gchar *media;
|
||||
} import_rule;
|
||||
|
||||
} s;
|
||||
@@ -1,59 +0,0 @@
|
||||
Index: libgtkhtml/document/htmldocument.c
|
||||
===================================================================
|
||||
--- libgtkhtml/document/htmldocument.c.orig 2006-02-11 05:06:30.000000000 +0000
|
||||
+++ libgtkhtml/document/htmldocument.c 2006-02-11 05:21:18.000000000 +0000
|
||||
@@ -1122,3 +1122,40 @@ html_document_find_anchor (HtmlDocument
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
+
|
||||
+void
|
||||
+html_document_add_stylesheet (HtmlDocument *document, CssStylesheet *sheet)
|
||||
+{
|
||||
+ HtmlStyleChange style_change;
|
||||
+
|
||||
+ g_return_if_fail (HTML_IS_DOCUMENT (document));
|
||||
+
|
||||
+ /* Note: @import not supported for user stylesheets, due to
|
||||
+ * complications it would cause with removal.
|
||||
+ */
|
||||
+
|
||||
+ document->stylesheets = g_slist_append (document->stylesheets, sheet);
|
||||
+
|
||||
+ if (document->dom_document) {
|
||||
+ 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);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+html_document_remove_stylesheet (HtmlDocument *document, CssStylesheet *stylesheet)
|
||||
+{
|
||||
+ HtmlStyleChange style_change;
|
||||
+
|
||||
+ g_return_if_fail (stylesheet && HTML_IS_DOCUMENT (document));
|
||||
+
|
||||
+ document->stylesheets = g_slist_remove (document->stylesheets, stylesheet);
|
||||
+
|
||||
+ if (document->dom_document) {
|
||||
+ 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 TRUE;
|
||||
+}
|
||||
+
|
||||
Index: libgtkhtml/document/htmldocument.h
|
||||
===================================================================
|
||||
--- libgtkhtml/document/htmldocument.h.orig 2006-02-11 05:06:30.000000000 +0000
|
||||
+++ libgtkhtml/document/htmldocument.h 2006-02-11 05:20:51.000000000 +0000
|
||||
@@ -113,6 +113,9 @@ void html_document_update_active_nod
|
||||
void html_document_update_focus_element (HtmlDocument *document, DomElement *element);
|
||||
DomNode *html_document_find_anchor (HtmlDocument *doc, const gchar *anchor);
|
||||
|
||||
+void html_document_add_stylesheet (HtmlDocument *document, CssStylesheet *stylesheet);
|
||||
+void html_document_remove_stylesheet (HtmlDocument *document, CssStylesheet *stylesheet);
|
||||
+
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __HTMLDOCUMENT_H__ */
|
||||
@@ -1,91 +0,0 @@
|
||||
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 {
|
||||
@@ -1,25 +0,0 @@
|
||||
Index: libgtkhtml/layout/htmlbox.c
|
||||
===================================================================
|
||||
--- libgtkhtml/layout/htmlbox.c.orig 2006-02-06 01:50:52.000000000 +0000
|
||||
+++ libgtkhtml/layout/htmlbox.c 2006-02-06 01:53:16.000000000 +0000
|
||||
@@ -151,17 +151,13 @@ simple_margin (HtmlStyle *style)
|
||||
static gboolean
|
||||
need_containing_width (HtmlBox *box, gint width)
|
||||
{
|
||||
- HtmlStyle *style;
|
||||
-
|
||||
if (width > 0)
|
||||
return FALSE;
|
||||
|
||||
- style = HTML_BOX_GET_STYLE (box);
|
||||
-
|
||||
- if (simple_margin (style))
|
||||
- return FALSE;
|
||||
+ if (html_box_get_containing_block (box))
|
||||
+ return TRUE;
|
||||
|
||||
- return TRUE;
|
||||
+ return FALSE;
|
||||
}
|
||||
|
||||
gint
|
||||
@@ -1,93 +0,0 @@
|
||||
Index: libgtkhtml/view/htmlview.c
|
||||
===================================================================
|
||||
--- libgtkhtml/view/htmlview.c.orig 2006-02-11 05:06:22.000000000 +0000
|
||||
+++ libgtkhtml/view/htmlview.c 2006-02-11 05:07:01.000000000 +0000
|
||||
@@ -2135,38 +2135,31 @@ html_view_style_updated (HtmlDocument *d
|
||||
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);
|
||||
+ if (!style || style->display == HTML_DISPLAY_NONE)
|
||||
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));
|
||||
+ html_box_handle_html_properties (new_box, node->xmlnode);
|
||||
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) {
|
||||
if (box->parent->children == box)
|
||||
box->parent->children = new_box;
|
||||
+ }
|
||||
+ if (box->next) box->next->prev = new_box;
|
||||
+ if (box->prev) box->prev->next = 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;
|
||||
+ HtmlBox *temp = child->next;
|
||||
+ html_box_append_child (new_box, child);
|
||||
+ child = temp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2176,7 +2169,6 @@ html_view_style_updated (HtmlDocument *d
|
||||
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;
|
||||
Index: libgtkhtml/graphics/htmlimage.c
|
||||
===================================================================
|
||||
--- libgtkhtml/graphics/htmlimage.c.orig 2006-02-11 05:06:22.000000000 +0000
|
||||
+++ libgtkhtml/graphics/htmlimage.c 2006-02-11 05:06:34.000000000 +0000
|
||||
@@ -142,6 +142,7 @@ static void
|
||||
html_image_init (HtmlImage *image)
|
||||
{
|
||||
image->pixbuf = NULL;
|
||||
+ image->stream = NULL;
|
||||
image->broken = FALSE;
|
||||
image->loading = FALSE;
|
||||
image->loader = gdk_pixbuf_loader_new ();
|
||||
Index: libgtkhtml/graphics/htmlimagefactory.c
|
||||
===================================================================
|
||||
--- libgtkhtml/graphics/htmlimagefactory.c.orig 2006-02-11 05:06:22.000000000 +0000
|
||||
+++ libgtkhtml/graphics/htmlimagefactory.c 2006-02-11 05:07:43.000000000 +0000
|
||||
@@ -146,7 +146,7 @@ html_image_factory_get_image (HtmlImageF
|
||||
|
||||
image = HTML_IMAGE (g_object_new (HTML_IMAGE_TYPE, NULL));
|
||||
|
||||
- g_object_weak_ref (G_OBJECT (image), (GWeakNotify)html_image_shutdown, image_factory);
|
||||
+ g_signal_connect_swapped (G_OBJECT (image), "last_unref", G_CALLBACK (html_image_shutdown), image_factory);
|
||||
|
||||
image->loading = TRUE;
|
||||
|
||||
@@ -154,6 +154,7 @@ html_image_factory_get_image (HtmlImageF
|
||||
image);
|
||||
|
||||
image->stream = stream;
|
||||
+ g_object_add_weak_pointer (G_OBJECT (stream), (gpointer *) &(image->stream));
|
||||
g_object_add_weak_pointer (G_OBJECT (image), (gpointer *) &(stream->user_data));
|
||||
|
||||
g_signal_emit (G_OBJECT (image_factory), image_factory_signals [REQUEST_IMAGE], 0, uri, stream);
|
||||
@@ -1,29 +0,0 @@
|
||||
Index: libgtkhtml/view/htmlview.c
|
||||
===================================================================
|
||||
--- libgtkhtml/view/htmlview.c.orig 2006-02-11 04:45:41.000000000 +0000
|
||||
+++ libgtkhtml/view/htmlview.c 2006-02-11 04:45:42.000000000 +0000
|
||||
@@ -2286,9 +2286,7 @@ html_view_realize (GtkWidget *widget)
|
||||
* GtkLayout uses the bg color for background but we want
|
||||
* to use base color.
|
||||
*/
|
||||
- widget->style = gtk_style_copy (widget->style);
|
||||
- widget->style->bg[GTK_STATE_NORMAL] =
|
||||
- widget->style->base[GTK_STATE_NORMAL];
|
||||
+ gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &widget->style->base[GTK_STATE_NORMAL]);
|
||||
/*
|
||||
* Store the font size so we can adjust size of HtmlFontSpecification
|
||||
* if the size changes.
|
||||
@@ -3189,9 +3187,10 @@ html_view_style_set (GtkWidget *widget,
|
||||
"focus-line-width", &focus_width,
|
||||
NULL);
|
||||
|
||||
-
|
||||
- widget->style->bg[GTK_STATE_NORMAL] =
|
||||
- widget->style->base[GTK_STATE_NORMAL];
|
||||
+ if (!gdk_color_equal (&widget->style->bg[GTK_STATE_NORMAL], &widget->style->base[GTK_STATE_NORMAL])) {
|
||||
+ gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &widget->style->base[GTK_STATE_NORMAL]);
|
||||
+ return;
|
||||
+ }
|
||||
fsize = pango_font_description_get_size (widget->style->font_desc) / (gfloat) PANGO_SCALE;
|
||||
new_isize = (gint) fsize;
|
||||
old_isize = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "html-view-font-size"));
|
||||
@@ -4,17 +4,14 @@ DESCRIPTION = "A GTK+ HTML rendering library."
|
||||
LICENSE = "GPL"
|
||||
MAINTAINER = "Chris Lord <chris@openedhand.com>"
|
||||
PV = "2.11.0+cvs${SRCDATE}"
|
||||
PR = "r1"
|
||||
PR = "r2"
|
||||
|
||||
SRC_URI = "cvs://anonymous@anoncvs.gnome.org/cvs/gnome;module=gtkhtml2 \
|
||||
file://at-import_box-pos.patch;patch=1;pnum=0 \
|
||||
file://css-stylesheet-user.patch;patch=1;pnum=0 \
|
||||
file://css-media.patch;patch=1;pnum=0 \
|
||||
file://fix-infinite-loop.patch;patch=1;pnum=0 \
|
||||
file://fix-margin-inherit.patch;patch=1;pnum=0 \
|
||||
file://fix-recreation2.patch;patch=1;pnum=0 \
|
||||
file://fix-style-change.patch;patch=1;pnum=0 \
|
||||
file://add-end-element-signal.patch;patch=1;pnum=0"
|
||||
http://svn.o-hand.com/repos/web/trunk/patches/at-import_box-pos.patch;patch=1;pnum=0 \
|
||||
http://svn.o-hand.com/repos/web/trunk/patches/css-stylesheet-user.patch;patch=1;pnum=0 \
|
||||
http://svn.o-hand.com/repos/web/trunk/patches/css-media.patch;patch=1;pnum=0 \
|
||||
http://svn.o-hand.com/repos/web/trunk/patches/fix-margin-inherit.patch;patch=1;pnum=0 \
|
||||
http://svn.o-hand.com/repos/web/trunk/patches/add-end-element-signal.patch;patch=1;pnum=0"
|
||||
|
||||
S = "${WORKDIR}/${PN}"
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
LICENSE = "GPL"
|
||||
SECTION = "x11"
|
||||
DEPENDS = "glib-2.0 gtk+ libglade gtkhtml2 curl gconf js"
|
||||
DEPENDS = "libxml2 glib-2.0 gtk+ libglade gtkhtml2 curl gconf js"
|
||||
MAINTAINER = "Chris Lord <chris@openedhand.com>"
|
||||
DESCRIPTION = "Web is a multi-platform web browsing application."
|
||||
|
||||
SRC_URI = "http://www.soton.ac.uk/~cil103/stuff/${PN}-${PV}.tar.gz"
|
||||
SRC_URI = "svn://svn.o-hand.com/repos/${PN};module=trunk;proto=http"
|
||||
S = "${WORKDIR}/trunk"
|
||||
|
||||
inherit autotools pkgconfig
|
||||
|
||||
Reference in New Issue
Block a user