diff options
| author | Chris Lord <chris@openedhand.com> | 2006-02-01 09:52:55 +0000 |
|---|---|---|
| committer | Chris Lord <chris@openedhand.com> | 2006-02-01 09:52:55 +0000 |
| commit | da8ed2882801ca513eef5b696de14ea99c485354 (patch) | |
| tree | ad43f2132fd8896e1c2c4aefe75ad572273d469a /openembedded/packages/gtkhtml2/files/at-import_box-pos.patch | |
| parent | 27700c91dd31d47332e6533241982d856772e08b (diff) | |
| download | poky-da8ed2882801ca513eef5b696de14ea99c485354.tar.gz | |
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/at-import_box-pos.patch')
| -rw-r--r-- | openembedded/packages/gtkhtml2/files/at-import_box-pos.patch | 767 |
1 files changed, 767 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 0000000000..89e60e5d28 --- /dev/null +++ b/openembedded/packages/gtkhtml2/files/at-import_box-pos.patch | |||
| @@ -0,0 +1,767 @@ | |||
| 1 | Index: libgtkhtml/css/cssmatcher.c | ||
| 2 | =================================================================== | ||
| 3 | RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/css/cssmatcher.c,v | ||
| 4 | retrieving revision 1.53 | ||
| 5 | diff -u -r1.53 cssmatcher.c | ||
| 6 | --- libgtkhtml/css/cssmatcher.c 26 Oct 2005 02:04:24 -0000 1.53 | ||
| 7 | +++ libgtkhtml/css/cssmatcher.c 18 Jan 2006 18:24:09 -0000 | ||
| 8 | @@ -79,7 +79,7 @@ | ||
| 9 | element_name = html_atom_list_get_atom (html_atom_list, node->name); | ||
| 10 | |||
| 11 | /* Look at the element name */ | ||
| 12 | - if (!simple->is_star && simple->element_name != element_name) | ||
| 13 | + if ((!simple->is_star) && (simple->element_name != element_name)) | ||
| 14 | return FALSE; | ||
| 15 | |||
| 16 | str = xmlGetProp (node, "id"); | ||
| 17 | @@ -2373,7 +2373,7 @@ | ||
| 18 | CssStylesheet *ss; | ||
| 19 | |||
| 20 | if (html_stream_get_written (stream) != 0) { | ||
| 21 | - ss = css_parser_parse_stylesheet (context->str->str, context->str->len); | ||
| 22 | + ss = css_parser_parse_stylesheet (context->str->str, context->str->len, NULL); | ||
| 23 | |||
| 24 | context->stat->s.import_rule.fetched = TRUE; | ||
| 25 | |||
| 26 | @@ -2770,7 +2770,7 @@ | ||
| 27 | css_matcher_html_to_css (doc, style, node); | ||
| 28 | |||
| 29 | if (!default_stylesheet) { | ||
| 30 | - default_stylesheet = css_parser_parse_stylesheet (html_css, strlen (html_css)); | ||
| 31 | + default_stylesheet = css_parser_parse_stylesheet (html_css, strlen (html_css), NULL); | ||
| 32 | } | ||
| 33 | |||
| 34 | css_matcher_apply_stylesheet (doc, default_stylesheet, node, &declaration_list, CSS_STYLESHEET_DEFAULT, pseudo); | ||
| 35 | @@ -2789,7 +2789,7 @@ | ||
| 36 | prop = xmlGetProp (node, "style"); | ||
| 37 | |||
| 38 | if (prop) { | ||
| 39 | - CssRuleset *rs = css_parser_parse_style_attr (prop, strlen (prop)); | ||
| 40 | + CssRuleset *rs = css_parser_parse_style_attr (prop, strlen (prop), NULL); | ||
| 41 | gint i; | ||
| 42 | |||
| 43 | if (rs) { | ||
| 44 | Index: libgtkhtml/css/cssparser.c | ||
| 45 | =================================================================== | ||
| 46 | RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/css/cssparser.c,v | ||
| 47 | retrieving revision 1.23 | ||
| 48 | diff -u -r1.23 cssparser.c | ||
| 49 | --- libgtkhtml/css/cssparser.c 25 Sep 2005 02:07:21 -0000 1.23 | ||
| 50 | +++ libgtkhtml/css/cssparser.c 18 Jan 2006 18:24:09 -0000 | ||
| 51 | @@ -49,7 +49,7 @@ | ||
| 52 | |||
| 53 | const gint css_n_dimensions = sizeof (css_dimensions) / sizeof (css_dimensions[0]); | ||
| 54 | |||
| 55 | -static gint css_parser_parse_value (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val); | ||
| 56 | +static gint css_parser_parse_value (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val, const gchar *base_url); | ||
| 57 | |||
| 58 | /* FIXME: Needs more whitespace types */ | ||
| 59 | static gint | ||
| 60 | @@ -443,7 +443,7 @@ | ||
| 61 | } | ||
| 62 | |||
| 63 | static gint | ||
| 64 | -css_parser_parse_term (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val) | ||
| 65 | +css_parser_parse_term (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val, const gchar *base_url) | ||
| 66 | { | ||
| 67 | gint pos; | ||
| 68 | HtmlAtom atom; | ||
| 69 | @@ -481,7 +481,7 @@ | ||
| 70 | return -1; | ||
| 71 | } | ||
| 72 | |||
| 73 | - pos = css_parser_parse_value (buffer, save_pos + 1, func_end, &val); | ||
| 74 | + pos = css_parser_parse_value (buffer, save_pos + 1, func_end, &val, base_url); | ||
| 75 | |||
| 76 | if (pos == -1) { | ||
| 77 | /* | ||
| 78 | @@ -495,10 +495,48 @@ | ||
| 79 | pos = func_end; | ||
| 80 | } | ||
| 81 | if (pos != -1) { | ||
| 82 | - if (ret_val) | ||
| 83 | + if (ret_val) { | ||
| 84 | *ret_val = css_value_function_new (atom, val); | ||
| 85 | - else | ||
| 86 | + | ||
| 87 | + if ((*ret_val)->v.function->name == HTML_ATOM_URL && | ||
| 88 | + (*ret_val)->v.function->args) { | ||
| 89 | + gchar *str = css_value_to_string ((*ret_val)->v.function->args); | ||
| 90 | + | ||
| 91 | + if (base_url && str) { | ||
| 92 | + regex_t reg; | ||
| 93 | + | ||
| 94 | + regcomp (®, "^[a-zA-Z][a-zA-Z0-9.+-]*:", REG_NOSUB); | ||
| 95 | + if (((*ret_val)->v.function->args->v.s[0] != '/') && (regexec (®, (*ret_val)->v.function->args->v.s, 0, NULL, 0))) { | ||
| 96 | + gchar *temp_base, *eptr; | ||
| 97 | + | ||
| 98 | + temp_base = g_strdup(base_url); | ||
| 99 | + eptr = strrchr(temp_base, '?'); | ||
| 100 | + | ||
| 101 | + if (eptr != NULL) | ||
| 102 | + *eptr = '\0'; | ||
| 103 | + | ||
| 104 | + eptr = strrchr(temp_base, '/'); | ||
| 105 | + if (eptr != NULL) { | ||
| 106 | + gchar *temp_arg = g_strdup((*ret_val)->v.function->args->v.s); | ||
| 107 | + | ||
| 108 | + *eptr = '\0'; | ||
| 109 | + | ||
| 110 | + g_free((*ret_val)->v.function->args->v.s); | ||
| 111 | + (*ret_val)->v.function->args->v.s = g_strconcat(temp_base, "/", temp_arg, NULL); | ||
| 112 | + g_free(temp_arg); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + g_free(temp_base); | ||
| 116 | + } | ||
| 117 | + regfree (®); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + g_free (str); | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + else { | ||
| 124 | css_value_unref (val); | ||
| 125 | + } | ||
| 126 | } | ||
| 127 | |||
| 128 | /* This is due to the ) */ | ||
| 129 | @@ -566,7 +604,7 @@ | ||
| 130 | } | ||
| 131 | |||
| 132 | static gint | ||
| 133 | -css_parser_parse_value (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val) | ||
| 134 | +css_parser_parse_value (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val, const gchar *base_url) | ||
| 135 | { | ||
| 136 | gint pos = start_pos; | ||
| 137 | gint n = 0; | ||
| 138 | @@ -589,7 +627,7 @@ | ||
| 139 | css_value_list_append (list, term, list_sep); | ||
| 140 | } | ||
| 141 | |||
| 142 | - pos = css_parser_parse_term (buffer, pos, end_pos, &term); | ||
| 143 | + pos = css_parser_parse_term (buffer, pos, end_pos, &term, base_url); | ||
| 144 | |||
| 145 | if (pos == -1) { | ||
| 146 | if (list) | ||
| 147 | @@ -618,7 +656,7 @@ | ||
| 148 | } | ||
| 149 | else { | ||
| 150 | /* Try and parse the term to see if it's valid */ | ||
| 151 | - if (css_parser_parse_term (buffer, pos, end_pos, NULL) == -1) { | ||
| 152 | + if (css_parser_parse_term (buffer, pos, end_pos, NULL, base_url) == -1) { | ||
| 153 | if (term) | ||
| 154 | css_value_unref (term); | ||
| 155 | if (list) | ||
| 156 | @@ -1005,7 +1043,7 @@ | ||
| 157 | } | ||
| 158 | |||
| 159 | static gint | ||
| 160 | -css_parser_parse_declaration (const gchar *buffer, gint start_pos, gint end_pos, CssDeclaration **ret_val) | ||
| 161 | +css_parser_parse_declaration (const gchar *buffer, gint start_pos, gint end_pos, CssDeclaration **ret_val, const gchar *base_url) | ||
| 162 | { | ||
| 163 | CssValue *value; | ||
| 164 | CssDeclaration *result; | ||
| 165 | @@ -1040,7 +1078,7 @@ | ||
| 166 | |||
| 167 | pos = css_parser_parse_whitespace (buffer, pos, prio_pos); | ||
| 168 | |||
| 169 | - pos = css_parser_parse_value (buffer, pos, prio_pos, &value); | ||
| 170 | + pos = css_parser_parse_value (buffer, pos, prio_pos, &value, base_url); | ||
| 171 | |||
| 172 | if (pos == -1) { | ||
| 173 | return end_pos; | ||
| 174 | @@ -1063,7 +1101,7 @@ | ||
| 175 | } | ||
| 176 | |||
| 177 | static CssDeclaration ** | ||
| 178 | -css_parser_parse_declarations (const gchar *buffer, gint start_pos, gint end_pos, gint *num_decl) | ||
| 179 | +css_parser_parse_declarations (const gchar *buffer, gint start_pos, gint end_pos, gint *num_decl, const gchar *base_url) | ||
| 180 | { | ||
| 181 | gint pos = start_pos; | ||
| 182 | gint cur_pos = start_pos; | ||
| 183 | @@ -1079,7 +1117,7 @@ | ||
| 184 | |||
| 185 | pos = css_parser_parse_to_char (buffer, ';', pos, end_pos); | ||
| 186 | |||
| 187 | - pos = css_parser_parse_declaration (buffer, cur_pos, pos, &declaration); | ||
| 188 | + pos = css_parser_parse_declaration (buffer, cur_pos, pos, &declaration, base_url); | ||
| 189 | |||
| 190 | if (declaration) { | ||
| 191 | if (n_decl == n_decl_max) | ||
| 192 | @@ -1100,7 +1138,7 @@ | ||
| 193 | } | ||
| 194 | |||
| 195 | static gint | ||
| 196 | -css_parser_parse_ruleset (const gchar *buffer, gint start_pos, gint end_pos, CssRuleset **ret_val) | ||
| 197 | +css_parser_parse_ruleset (const gchar *buffer, gint start_pos, gint end_pos, CssRuleset **ret_val, const gchar *base_url) | ||
| 198 | { | ||
| 199 | gint cur_pos; | ||
| 200 | gint pos; | ||
| 201 | @@ -1143,7 +1181,7 @@ | ||
| 202 | } | ||
| 203 | cur_pos = css_parser_parse_whitespace (buffer, cur_pos, end_pos); | ||
| 204 | |||
| 205 | - decl = css_parser_parse_declarations (buffer, cur_pos, pos, &n_decl); | ||
| 206 | + decl = css_parser_parse_declarations (buffer, cur_pos, pos, &n_decl, base_url); | ||
| 207 | |||
| 208 | pos++; | ||
| 209 | |||
| 210 | @@ -1186,7 +1224,8 @@ | ||
| 211 | } | ||
| 212 | else if (str[pos] == '/' && | ||
| 213 | pos + 1 <= len && | ||
| 214 | - str[pos + 1] == '/') { | ||
| 215 | + str[pos + 1] == '/' && | ||
| 216 | + (pos == 0 || str[pos-1] != ':')) { | ||
| 217 | while (pos < len && | ||
| 218 | str[pos] != '\n') | ||
| 219 | pos++; | ||
| 220 | @@ -1204,7 +1243,7 @@ | ||
| 221 | } | ||
| 222 | |||
| 223 | static gint | ||
| 224 | -css_parser_parse_atkeyword (const gchar *buffer, gint start_pos, gint end_pos, CssStatement **ret_val) | ||
| 225 | +css_parser_parse_atkeyword (const gchar *buffer, gint start_pos, gint end_pos, CssStatement **ret_val, const gchar *base_url) | ||
| 226 | { | ||
| 227 | gint pos = start_pos; | ||
| 228 | gint tmp_pos, cur_pos; | ||
| 229 | @@ -1257,14 +1296,14 @@ | ||
| 230 | tmp_pos++; | ||
| 231 | |||
| 232 | |||
| 233 | - rs = g_new (CssRuleset *, n_rs_max); | ||
| 234 | + rs = g_new0 (CssRuleset *, n_rs_max); | ||
| 235 | |||
| 236 | /* g_print ("wheee: \"%s\"\n", g_strndup (buffer + cur_pos, tmp_pos - cur_pos )); */ | ||
| 237 | pos = cur_pos; | ||
| 238 | while (pos < tmp_pos) { | ||
| 239 | CssRuleset *ruleset; | ||
| 240 | |||
| 241 | - pos = css_parser_parse_ruleset (buffer, pos, tmp_pos, &ruleset); | ||
| 242 | + pos = css_parser_parse_ruleset (buffer, pos, tmp_pos, &ruleset, base_url); | ||
| 243 | |||
| 244 | if (n_rs == n_rs_max) | ||
| 245 | rs = g_realloc (rs, sizeof (CssRuleset *) * | ||
| 246 | @@ -1277,7 +1316,7 @@ | ||
| 247 | |||
| 248 | pos = css_parser_parse_whitespace (buffer, tmp_pos + 1, end_pos); | ||
| 249 | |||
| 250 | - result = g_new (CssStatement, 1); | ||
| 251 | + result = g_new0 (CssStatement, 1); | ||
| 252 | result->type = CSS_MEDIA_RULE; | ||
| 253 | result->s.media_rule.rs = rs; | ||
| 254 | result->s.media_rule.n_rs = n_rs; | ||
| 255 | @@ -1318,11 +1357,11 @@ | ||
| 256 | |||
| 257 | pos = css_parser_parse_whitespace (buffer, pos, cur_pos); | ||
| 258 | |||
| 259 | - decl = css_parser_parse_declarations (buffer, pos, cur_pos, &n_decl); | ||
| 260 | + decl = css_parser_parse_declarations (buffer, pos, cur_pos, &n_decl, base_url); | ||
| 261 | |||
| 262 | g_print ("N_decl is: %d\n", n_decl); | ||
| 263 | |||
| 264 | - result = g_new (CssStatement, 1); | ||
| 265 | + result = g_new0 (CssStatement, 1); | ||
| 266 | result->type = CSS_PAGE_RULE; | ||
| 267 | result->s.page_rule.name = name; | ||
| 268 | result->s.page_rule.pseudo = pseudo; | ||
| 269 | @@ -1337,8 +1376,8 @@ | ||
| 270 | pos = css_parser_parse_whitespace (buffer, pos + 1, end_pos); | ||
| 271 | cur_pos = css_parser_parse_to_char (buffer, '}', pos, end_pos); | ||
| 272 | |||
| 273 | - decl = css_parser_parse_declarations (buffer, pos, cur_pos, &n_decl); | ||
| 274 | - result = g_new (CssStatement, 1); | ||
| 275 | + decl = css_parser_parse_declarations (buffer, pos, cur_pos, &n_decl, base_url); | ||
| 276 | + result = g_new0 (CssStatement, 1); | ||
| 277 | result->type = CSS_FONT_FACE_RULE; | ||
| 278 | |||
| 279 | result->s.font_face_rule.n_decl = n_decl; | ||
| 280 | @@ -1349,8 +1388,61 @@ | ||
| 281 | return cur_pos + 1; | ||
| 282 | |||
| 283 | break; | ||
| 284 | + case HTML_ATOM_IMPORT: { | ||
| 285 | + gchar *import_url; | ||
| 286 | + const gchar *s_url, *e_url; | ||
| 287 | + | ||
| 288 | + cur_pos = css_parser_parse_to_char (buffer, ';', pos, end_pos); | ||
| 289 | + | ||
| 290 | + if (strchr (buffer + pos, '(')) { | ||
| 291 | + s_url = strchr (buffer + pos, '('); | ||
| 292 | + e_url = strchr (s_url, ')'); | ||
| 293 | + } else if (strchr (buffer + pos, '\"')) { | ||
| 294 | + s_url = strchr (buffer + pos, '\"'); | ||
| 295 | + e_url = strchr (s_url + 1, '\"'); | ||
| 296 | + } else if (strchr (buffer + pos, '\'')) { | ||
| 297 | + s_url = strchr (buffer + pos, '\''); | ||
| 298 | + e_url = strchr (s_url + 1, '\''); | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | + if (!s_url || !e_url || ((e_url - s_url) < 1)) { | ||
| 302 | + g_warning ("Invalid @import line"); | ||
| 303 | + *ret_val = NULL; | ||
| 304 | + return cur_pos + 1; | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + s_url++; | ||
| 308 | + e_url--; | ||
| 309 | + | ||
| 310 | + if ((*s_url == '\"') && (*e_url == '\"')) { | ||
| 311 | + s_url++; | ||
| 312 | + e_url--; | ||
| 313 | + } else if ((*s_url == '\'') && (*e_url == '\'')) { | ||
| 314 | + s_url++; | ||
| 315 | + e_url--; | ||
| 316 | + } | ||
| 317 | + | ||
| 318 | + if (s_url > e_url) { | ||
| 319 | + g_warning ("Invalid @import line"); | ||
| 320 | + *ret_val = NULL; | ||
| 321 | + return cur_pos + 1; | ||
| 322 | + } | ||
| 323 | + | ||
| 324 | + import_url = g_strndup (s_url, strlen (s_url) - strlen (e_url) + 1); | ||
| 325 | + | ||
| 326 | + result = g_new0 (CssStatement, 1); | ||
| 327 | + result->type = CSS_IMPORT_RULE; | ||
| 328 | |||
| 329 | + result->s.import_rule.url = css_value_string_new (import_url); | ||
| 330 | + | ||
| 331 | + *ret_val = result; | ||
| 332 | + | ||
| 333 | + return cur_pos + 1; | ||
| 334 | + | ||
| 335 | + break; | ||
| 336 | + } | ||
| 337 | default: | ||
| 338 | + g_warning ("Unhandled keyword %d - %s", keyword, buffer); | ||
| 339 | /* Unknown keyword detected, skip to next block */ | ||
| 340 | while (pos < end_pos) { | ||
| 341 | /* Handle a dangling semi-colon */ | ||
| 342 | @@ -1373,7 +1465,7 @@ | ||
| 343 | } | ||
| 344 | |||
| 345 | CssRuleset * | ||
| 346 | -css_parser_parse_style_attr (const gchar *buffer, gint len) | ||
| 347 | +css_parser_parse_style_attr (const gchar *buffer, gint len, const gchar *base_url) | ||
| 348 | { | ||
| 349 | CssRuleset *result; | ||
| 350 | |||
| 351 | @@ -1382,7 +1474,7 @@ | ||
| 352 | |||
| 353 | /* FIXME: Are comments allowed here? */ | ||
| 354 | |||
| 355 | - decl = css_parser_parse_declarations (buffer, 0, len, &n_decl); | ||
| 356 | + decl = css_parser_parse_declarations (buffer, 0, len, &n_decl, base_url); | ||
| 357 | |||
| 358 | if (!decl) | ||
| 359 | return NULL; | ||
| 360 | @@ -1397,9 +1489,8 @@ | ||
| 361 | } | ||
| 362 | |||
| 363 | CssStylesheet * | ||
| 364 | -css_parser_parse_stylesheet (const gchar *str, gint len) | ||
| 365 | +css_parser_parse_stylesheet (const gchar *str, gint len, const gchar *base_url) | ||
| 366 | { | ||
| 367 | - CssStatement *statement; | ||
| 368 | CssStylesheet *result; | ||
| 369 | GSList *stat = NULL; | ||
| 370 | gchar *buffer; | ||
| 371 | @@ -1413,26 +1504,23 @@ | ||
| 372 | end_pos = len; | ||
| 373 | while (pos < len) { | ||
| 374 | if (buffer[pos] == '@') { | ||
| 375 | - pos = css_parser_parse_atkeyword (buffer, pos + 1, len, &statement); | ||
| 376 | -#if 0 | ||
| 377 | - if (statement) { | ||
| 378 | - if (n_stat == n_stat_max) | ||
| 379 | - stat = g_realloc (stat, sizeof (CssStatement) * | ||
| 380 | - (n_stat_max <<= 1)); | ||
| 381 | - stat[n_stat++] = statement; | ||
| 382 | + CssStatement *atstatement = NULL; | ||
| 383 | + pos = css_parser_parse_atkeyword (buffer, pos + 1, len, &atstatement, base_url); | ||
| 384 | + if (atstatement) { | ||
| 385 | + stat = g_slist_append (stat, atstatement); | ||
| 386 | } | ||
| 387 | -#endif | ||
| 388 | } | ||
| 389 | else { | ||
| 390 | CssRuleset *ruleset; | ||
| 391 | - pos = css_parser_parse_ruleset (buffer, pos, end_pos, &ruleset); | ||
| 392 | + pos = css_parser_parse_ruleset (buffer, pos, end_pos, &ruleset, base_url); | ||
| 393 | |||
| 394 | if (ruleset) { | ||
| 395 | - statement = g_new (CssStatement, 1); | ||
| 396 | - statement->type = CSS_RULESET; | ||
| 397 | - statement->s.ruleset = ruleset; | ||
| 398 | + CssStatement *rulestatement; | ||
| 399 | + rulestatement = g_new0 (CssStatement, 1); | ||
| 400 | + rulestatement->type = CSS_RULESET; | ||
| 401 | + rulestatement->s.ruleset = ruleset; | ||
| 402 | |||
| 403 | - stat = g_slist_append (stat, statement); | ||
| 404 | + stat = g_slist_append (stat, rulestatement); | ||
| 405 | } | ||
| 406 | |||
| 407 | if (pos == -1) | ||
| 408 | @@ -1444,7 +1532,7 @@ | ||
| 409 | |||
| 410 | g_free (buffer); | ||
| 411 | |||
| 412 | - result = g_new (CssStylesheet, 1); | ||
| 413 | + result = g_new0 (CssStylesheet, 1); | ||
| 414 | result->stat = stat; | ||
| 415 | |||
| 416 | return result; | ||
| 417 | Index: libgtkhtml/css/cssparser.h | ||
| 418 | =================================================================== | ||
| 419 | RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/css/cssparser.h,v | ||
| 420 | retrieving revision 1.7 | ||
| 421 | diff -u -r1.7 cssparser.h | ||
| 422 | --- libgtkhtml/css/cssparser.h 6 Dec 2002 17:16:54 -0000 1.7 | ||
| 423 | +++ libgtkhtml/css/cssparser.h 18 Jan 2006 18:24:09 -0000 | ||
| 424 | @@ -24,13 +24,14 @@ | ||
| 425 | #define __CSSPARSER_H__ | ||
| 426 | |||
| 427 | #include <glib.h> | ||
| 428 | +#include <regex.h> | ||
| 429 | |||
| 430 | #include "cssstylesheet.h" | ||
| 431 | |||
| 432 | G_BEGIN_DECLS | ||
| 433 | |||
| 434 | -CssStylesheet *css_parser_parse_stylesheet (const gchar *str, gint len); | ||
| 435 | -CssRuleset *css_parser_parse_style_attr (const gchar *buffer, gint len); | ||
| 436 | +CssStylesheet *css_parser_parse_stylesheet (const gchar *str, gint len, const gchar *base_url); | ||
| 437 | +CssRuleset *css_parser_parse_style_attr (const gchar *buffer, gint len, const gchar *base_url); | ||
| 438 | |||
| 439 | G_END_DECLS | ||
| 440 | |||
| 441 | Index: libgtkhtml/css/cssstylesheet.h | ||
| 442 | =================================================================== | ||
| 443 | RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/css/cssstylesheet.h,v | ||
| 444 | retrieving revision 1.7 | ||
| 445 | diff -u -r1.7 cssstylesheet.h | ||
| 446 | --- libgtkhtml/css/cssstylesheet.h 21 Apr 2004 14:17:00 -0000 1.7 | ||
| 447 | +++ libgtkhtml/css/cssstylesheet.h 18 Jan 2006 18:24:09 -0000 | ||
| 448 | @@ -181,6 +181,7 @@ | ||
| 449 | }; | ||
| 450 | |||
| 451 | struct _CssStylesheet { | ||
| 452 | + gchar *url; | ||
| 453 | gboolean disabled; | ||
| 454 | GSList *stat; | ||
| 455 | }; | ||
| 456 | Index: libgtkhtml/css/cssvalue.c | ||
| 457 | =================================================================== | ||
| 458 | RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/css/cssvalue.c,v | ||
| 459 | retrieving revision 1.6 | ||
| 460 | diff -u -r1.6 cssvalue.c | ||
| 461 | --- libgtkhtml/css/cssvalue.c 21 Apr 2004 14:17:00 -0000 1.6 | ||
| 462 | +++ libgtkhtml/css/cssvalue.c 18 Jan 2006 18:24:09 -0000 | ||
| 463 | @@ -64,7 +64,7 @@ | ||
| 464 | function->name = name; | ||
| 465 | function->args = args; | ||
| 466 | |||
| 467 | - result = g_new (CssValue, 1); | ||
| 468 | + result = g_new0 (CssValue, 1); | ||
| 469 | result->ref_count = 1; | ||
| 470 | result->value_type = CSS_FUNCTION; | ||
| 471 | result->v.function = function; | ||
| 472 | Index: libgtkhtml/document/htmldocument.c | ||
| 473 | =================================================================== | ||
| 474 | RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/document/htmldocument.c,v | ||
| 475 | retrieving revision 1.122 | ||
| 476 | diff -u -r1.122 htmldocument.c | ||
| 477 | --- libgtkhtml/document/htmldocument.c 21 Feb 2005 17:31:31 -0000 1.122 | ||
| 478 | +++ libgtkhtml/document/htmldocument.c 18 Jan 2006 18:24:11 -0000 | ||
| 479 | @@ -139,14 +139,42 @@ | ||
| 480 | html_document_stylesheet_stream_close (const gchar *buffer, gint len, gpointer data) | ||
| 481 | { | ||
| 482 | CssStylesheet *sheet; | ||
| 483 | - HtmlDocument *document = HTML_DOCUMENT (data); | ||
| 484 | + HtmlDocumentStreamData *stream_data = (HtmlDocumentStreamData *) data; | ||
| 485 | + HtmlDocument *document = stream_data->document; | ||
| 486 | HtmlStyleChange style_change; | ||
| 487 | - | ||
| 488 | + GSList *list; | ||
| 489 | + | ||
| 490 | if (!buffer) | ||
| 491 | return; | ||
| 492 | |||
| 493 | - sheet = css_parser_parse_stylesheet (buffer, len); | ||
| 494 | + sheet = css_parser_parse_stylesheet (buffer, len, (gchar *) stream_data->internal_data); | ||
| 495 | + g_free(stream_data->internal_data); | ||
| 496 | + stream_data->internal_data = NULL; | ||
| 497 | + | ||
| 498 | + for (list = sheet->stat; list; list = list->next) { | ||
| 499 | + CssStatement *statement = list->data; | ||
| 500 | + HtmlStream *stream; | ||
| 501 | + | ||
| 502 | + switch (statement->type) { | ||
| 503 | + case CSS_IMPORT_RULE: { | ||
| 504 | + HtmlDocumentStreamData *stream_data_import; | ||
| 505 | + gchar *url; | ||
| 506 | + | ||
| 507 | + url = css_value_to_string (statement->s.import_rule.url); | ||
| 508 | + stream_data_import = g_new (HtmlDocumentStreamData, 1); | ||
| 509 | + stream_data_import->document = stream_data->document; | ||
| 510 | + stream_data_import->internal_data = g_strdup(url); | ||
| 511 | + stream = html_stream_buffer_new (html_document_stylesheet_stream_close, stream_data_import); | ||
| 512 | + g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, url, stream); | ||
| 513 | + g_free (url); | ||
| 514 | + break; | ||
| 515 | + } | ||
| 516 | + default: | ||
| 517 | + break; | ||
| 518 | + } | ||
| 519 | + } | ||
| 520 | |||
| 521 | + g_free (stream_data); | ||
| 522 | document->stylesheets = g_slist_append (document->stylesheets, sheet); | ||
| 523 | |||
| 524 | /* Restyle the document */ | ||
| 525 | @@ -184,9 +212,15 @@ | ||
| 526 | |||
| 527 | if (str && (strcasecmp (str, "stylesheet") == 0)) { | ||
| 528 | gchar *url = xmlGetProp (node->xmlnode, "href"); | ||
| 529 | - | ||
| 530 | if (url) { | ||
| 531 | - HtmlStream *stream = html_stream_buffer_new (html_document_stylesheet_stream_close, document); | ||
| 532 | + HtmlDocumentStreamData *stream_data; | ||
| 533 | + HtmlStream *stream; | ||
| 534 | + | ||
| 535 | + stream_data = g_new (HtmlDocumentStreamData, 1); | ||
| 536 | + stream_data->document = document; | ||
| 537 | + stream_data->internal_data = g_strdup(url); | ||
| 538 | + | ||
| 539 | + stream = html_stream_buffer_new (html_document_stylesheet_stream_close, stream_data); | ||
| 540 | |||
| 541 | g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, url, stream); | ||
| 542 | } | ||
| 543 | @@ -247,12 +281,39 @@ | ||
| 544 | |||
| 545 | CssStylesheet *ss; | ||
| 546 | HtmlStyleChange style_change; | ||
| 547 | - | ||
| 548 | - ss = css_parser_parse_stylesheet (node->xmlnode->content, strlen (node->xmlnode->content)); | ||
| 549 | - document->stylesheets = g_slist_append (document->stylesheets, ss); | ||
| 550 | + GSList *list; | ||
| 551 | + | ||
| 552 | + ss = css_parser_parse_stylesheet (node->xmlnode->content, strlen (node->xmlnode->content), NULL); | ||
| 553 | + | ||
| 554 | + for (list = ss->stat; list; list = list->next) { | ||
| 555 | + CssStatement *statement = list->data; | ||
| 556 | + HtmlStream *stream; | ||
| 557 | + | ||
| 558 | + switch (statement->type) { | ||
| 559 | + case CSS_IMPORT_RULE: { | ||
| 560 | + gchar *cssurl; | ||
| 561 | + HtmlDocumentStreamData *stream_data; | ||
| 562 | + | ||
| 563 | + cssurl = css_value_to_string (statement->s.import_rule.url); | ||
| 564 | + | ||
| 565 | + stream_data = g_new (HtmlDocumentStreamData, 1); | ||
| 566 | + stream_data->document = document; | ||
| 567 | + stream_data->internal_data = g_strdup(cssurl); | ||
| 568 | + | ||
| 569 | + stream = html_stream_buffer_new (html_document_stylesheet_stream_close, stream_data); | ||
| 570 | + g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, cssurl, stream); | ||
| 571 | + g_free (cssurl); | ||
| 572 | + break; | ||
| 573 | + } | ||
| 574 | + default: | ||
| 575 | + break; | ||
| 576 | + } | ||
| 577 | + } | ||
| 578 | + | ||
| 579 | + document->stylesheets = g_slist_append ( document->stylesheets, ss); | ||
| 580 | |||
| 581 | /* Restyle the document */ | ||
| 582 | - style_change = html_document_restyle_node (document, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), NULL, TRUE); | ||
| 583 | + style_change = html_document_restyle_node (document, DOM_NODE (dom_Document__get_documentElement ( document->dom_document)), NULL, TRUE); | ||
| 584 | g_signal_emit (G_OBJECT (document), document_signals [STYLE_UPDATED], 0, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), style_change); | ||
| 585 | } | ||
| 586 | else if ((node->xmlnode->type == XML_TEXT_NODE || node->xmlnode->type == XML_COMMENT_NODE) && node->xmlnode->parent && strcasecmp (node->xmlnode->parent->name, "script") == 0) { | ||
| 587 | Index: libgtkhtml/document/htmldocument.h | ||
| 588 | =================================================================== | ||
| 589 | RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/document/htmldocument.h,v | ||
| 590 | retrieving revision 1.35 | ||
| 591 | diff -u -r1.35 htmldocument.h | ||
| 592 | --- libgtkhtml/document/htmldocument.h 13 Feb 2005 15:33:19 -0000 1.35 | ||
| 593 | +++ libgtkhtml/document/htmldocument.h 18 Jan 2006 18:24:12 -0000 | ||
| 594 | @@ -25,6 +25,7 @@ | ||
| 595 | |||
| 596 | typedef struct _HtmlDocument HtmlDocument; | ||
| 597 | typedef struct _HtmlDocumentClass HtmlDocumentClass; | ||
| 598 | +typedef struct _HtmlDocumentStreamData HtmlDocumentStreamData; | ||
| 599 | |||
| 600 | #include <gtk/gtk.h> | ||
| 601 | |||
| 602 | @@ -93,6 +94,10 @@ | ||
| 603 | gboolean (*dom_mouse_out) (HtmlDocument *document, DomEvent *event); | ||
| 604 | }; | ||
| 605 | |||
| 606 | +struct _HtmlDocumentStreamData { | ||
| 607 | + HtmlDocument *document; | ||
| 608 | + gpointer internal_data; | ||
| 609 | +}; | ||
| 610 | |||
| 611 | GType html_document_get_type (void); | ||
| 612 | |||
| 613 | Index: libgtkhtml/layout/htmlboxblock.c | ||
| 614 | =================================================================== | ||
| 615 | RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/layout/htmlboxblock.c,v | ||
| 616 | retrieving revision 1.115 | ||
| 617 | diff -u -r1.115 htmlboxblock.c | ||
| 618 | --- libgtkhtml/layout/htmlboxblock.c 6 Jan 2004 10:09:56 -0000 1.115 | ||
| 619 | +++ libgtkhtml/layout/htmlboxblock.c 18 Jan 2006 18:24:14 -0000 | ||
| 620 | @@ -100,17 +100,21 @@ | ||
| 621 | HtmlBoxBlock *block = HTML_BOX_BLOCK (self); | ||
| 622 | gint full_width; | ||
| 623 | |||
| 624 | +#if 0 | ||
| 625 | if (relayout->get_min_width || relayout->get_max_width) { | ||
| 626 | +#endif | ||
| 627 | |||
| 628 | /* Only expand the width of the block box if the width is of type "auto" */ | ||
| 629 | if (HTML_BOX_GET_STYLE (self)->box->width.type == HTML_LENGTH_AUTO && line->width > *boxwidth) { | ||
| 630 | - | ||
| 631 | + | ||
| 632 | *boxwidth = line->width; | ||
| 633 | block->containing_width = line->width; | ||
| 634 | self->width = *boxwidth + html_box_horizontal_mbp_sum (self); | ||
| 635 | block->force_relayout = TRUE; | ||
| 636 | } | ||
| 637 | +#if 0 | ||
| 638 | } | ||
| 639 | +#endif | ||
| 640 | full_width = MAX (line->width, line->full_width); | ||
| 641 | |||
| 642 | if (full_width > block->full_width) | ||
| 643 | @@ -233,7 +237,7 @@ | ||
| 644 | HtmlBoxBlock *block = HTML_BOX_BLOCK (self); | ||
| 645 | HtmlLineBox *line; | ||
| 646 | |||
| 647 | - /* If it is a flotbox, just add it */ | ||
| 648 | + /* If it is a floatbox, just add it */ | ||
| 649 | if (HTML_BOX_GET_STYLE (box)->Float != HTML_FLOAT_NONE) { | ||
| 650 | html_box_block_handle_float (self, relayout, box, *y, boxwidth); | ||
| 651 | return NULL; | ||
| 652 | Index: libgtkhtml/layout/htmlstyleinherited.c | ||
| 653 | =================================================================== | ||
| 654 | RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/layout/htmlstyleinherited.c,v | ||
| 655 | retrieving revision 1.15 | ||
| 656 | diff -u -r1.15 htmlstyleinherited.c | ||
| 657 | --- libgtkhtml/layout/htmlstyleinherited.c 6 Dec 2002 17:17:15 -0000 1.15 | ||
| 658 | +++ libgtkhtml/layout/htmlstyleinherited.c 18 Jan 2006 18:24:15 -0000 | ||
| 659 | @@ -300,6 +300,37 @@ | ||
| 660 | *size = (gint) (val->v.d * old_size); | ||
| 661 | return TRUE; | ||
| 662 | default: | ||
| 663 | + switch (val->v.atom) { | ||
| 664 | + /* FIXME: These values are copy/pasted from html.css.h, X_SMALL is guessed */ | ||
| 665 | + case HTML_ATOM_XX_SMALL: | ||
| 666 | + *size = (gint) (0.67 * old_size); | ||
| 667 | + return TRUE; | ||
| 668 | + case HTML_ATOM_X_SMALL: | ||
| 669 | + *size = (gint) (0.75 * old_size); | ||
| 670 | + return TRUE; | ||
| 671 | + case HTML_ATOM_SMALL: | ||
| 672 | + *size = (gint) (0.83 * old_size); | ||
| 673 | + return TRUE; | ||
| 674 | + case HTML_ATOM_MEDIUM: | ||
| 675 | + *size = (gint) (1 * old_size); | ||
| 676 | + return TRUE; | ||
| 677 | + case HTML_ATOM_LARGE: | ||
| 678 | + *size = (gint) (1.17 * old_size); | ||
| 679 | + return TRUE; | ||
| 680 | + case HTML_ATOM_X_LARGE: | ||
| 681 | + *size = (gint) (1.5 * old_size); | ||
| 682 | + return TRUE; | ||
| 683 | + case HTML_ATOM_XX_LARGE: | ||
| 684 | + *size = (gint) (2 * old_size); | ||
| 685 | + return TRUE; | ||
| 686 | + /* FIXME: These are absolutely guessed. Size should always be one of the above seven. */ | ||
| 687 | + case HTML_ATOM_LARGER: | ||
| 688 | + *size = (gint) (0.8 * old_size); | ||
| 689 | + return TRUE; | ||
| 690 | + case HTML_ATOM_SMALLER: | ||
| 691 | + *size = (gint) (1.2 * old_size); | ||
| 692 | + return TRUE; | ||
| 693 | + } | ||
| 694 | return FALSE; | ||
| 695 | } | ||
| 696 | } | ||
| 697 | Index: libgtkhtml/view/htmlevent.c | ||
| 698 | =================================================================== | ||
| 699 | RCS file: /cvs/gnome/gtkhtml2/libgtkhtml/view/htmlevent.c,v | ||
| 700 | retrieving revision 1.41 | ||
| 701 | diff -u -r1.41 htmlevent.c | ||
| 702 | --- libgtkhtml/view/htmlevent.c 14 Sep 2004 06:34:27 -0000 1.41 | ||
| 703 | +++ libgtkhtml/view/htmlevent.c 18 Jan 2006 18:24:17 -0000 | ||
| 704 | @@ -46,14 +46,48 @@ | ||
| 705 | static gboolean | ||
| 706 | html_event_xy_in_box (HtmlBox *box, gint tx, gint ty, gint x, gint y) | ||
| 707 | { | ||
| 708 | + gint ox, oy; | ||
| 709 | + gboolean rv; | ||
| 710 | + | ||
| 711 | + ox = box->x; | ||
| 712 | + oy = box->y; | ||
| 713 | + | ||
| 714 | + rv = TRUE; | ||
| 715 | + | ||
| 716 | + if ((HTML_BOX_GET_STYLE (box)->position == HTML_POSITION_RELATIVE || | ||
| 717 | + HTML_BOX_GET_STYLE (box)->position == HTML_POSITION_ABSOLUTE)) { | ||
| 718 | + gint width = html_box_get_containing_block_width (box); | ||
| 719 | + gint height = html_box_get_containing_block_height (box); | ||
| 720 | + | ||
| 721 | + if (HTML_BOX_GET_STYLE (box)->surround->position.left.type != HTML_LENGTH_AUTO) | ||
| 722 | + box->x += html_length_get_value (&HTML_BOX_GET_STYLE (box)->surround->position.left, width); | ||
| 723 | + else if (HTML_BOX_GET_STYLE (box)->surround->position.right.type != HTML_LENGTH_AUTO) { | ||
| 724 | + if (HTML_BOX_GET_STYLE (box)->display == HTML_DISPLAY_INLINE) | ||
| 725 | + box->x -= html_length_get_value (&HTML_BOX_GET_STYLE (box)->surround->position.right, width); | ||
| 726 | + else | ||
| 727 | + box->x += width - box->width - html_length_get_value (&HTML_BOX_GET_STYLE (box)->surround->position.right, width); | ||
| 728 | + } | ||
| 729 | + if (HTML_BOX_GET_STYLE (box)->surround->position.top.type != HTML_LENGTH_AUTO) | ||
| 730 | + box->y += html_length_get_value (&HTML_BOX_GET_STYLE (box)->surround->position.top, height); | ||
| 731 | + | ||
| 732 | + else if (HTML_BOX_GET_STYLE (box)->surround->position.bottom.type != HTML_LENGTH_AUTO) { | ||
| 733 | + if (HTML_BOX_GET_STYLE (box)->display == HTML_DISPLAY_INLINE) | ||
| 734 | + box->y -= html_length_get_value (&HTML_BOX_GET_STYLE (box)->surround->position.bottom, height); | ||
| 735 | + else | ||
| 736 | + box->y += height - box->height - html_length_get_value (&HTML_BOX_GET_STYLE (box)->surround->position.bottom, height); | ||
| 737 | + } | ||
| 738 | + } | ||
| 739 | |||
| 740 | if (x < box->x + tx || | ||
| 741 | x > box->x + tx + box->width || | ||
| 742 | y < box->y + ty || | ||
| 743 | y > box->y + ty + box->height) | ||
| 744 | - return FALSE; | ||
| 745 | + rv = FALSE; | ||
| 746 | + | ||
| 747 | + box->x = ox; | ||
| 748 | + box->y = oy; | ||
| 749 | |||
| 750 | - return TRUE; | ||
| 751 | + return rv; | ||
| 752 | } | ||
| 753 | |||
| 754 | static void | ||
| 755 | @@ -64,12 +98,6 @@ | ||
| 756 | box = self->children; | ||
| 757 | |||
| 758 | while (box) { | ||
| 759 | - | ||
| 760 | - /* Ignore positioned boxes, because their ->x and->y positions is not their correct positions */ | ||
| 761 | - if (HTML_BOX_GET_STYLE (box)->position != HTML_POSITION_STATIC) { | ||
| 762 | - box = box->next; | ||
| 763 | - continue; | ||
| 764 | - } | ||
| 765 | /* These boxes always has x = 0, y = 0, w = 0 and h = 0 so we have to do | ||
| 766 | * a special case for these */ | ||
| 767 | if (HTML_IS_BOX_INLINE (box) || HTML_IS_BOX_TABLE_ROW_GROUP (box) || HTML_IS_BOX_FORM (box)) { | ||
