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/css-media.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/css-media.patch')
| -rw-r--r-- | openembedded/packages/gtkhtml2/files/css-media.patch | 487 |
1 files changed, 487 insertions, 0 deletions
diff --git a/openembedded/packages/gtkhtml2/files/css-media.patch b/openembedded/packages/gtkhtml2/files/css-media.patch new file mode 100644 index 0000000000..999ce196dc --- /dev/null +++ b/openembedded/packages/gtkhtml2/files/css-media.patch | |||
| @@ -0,0 +1,487 @@ | |||
| 1 | Index: gtkhtml2/libgtkhtml/css/cssmatcher.c | ||
| 2 | =================================================================== | ||
| 3 | --- gtkhtml2.orig/libgtkhtml/css/cssmatcher.c 2006-01-25 02:07:44.000000000 +0000 | ||
| 4 | +++ gtkhtml2/libgtkhtml/css/cssmatcher.c 2006-02-01 02:19:13.000000000 +0000 | ||
| 5 | @@ -2411,7 +2411,8 @@ | ||
| 6 | CssStatement *stat = list->data; | ||
| 7 | gint j; | ||
| 8 | |||
| 9 | - if (stat->type == CSS_IMPORT_RULE) { | ||
| 10 | + switch (stat->type) { | ||
| 11 | + case CSS_IMPORT_RULE: { | ||
| 12 | if (stat->s.import_rule.fetched) { | ||
| 13 | if (stat->s.import_rule.sheet) { | ||
| 14 | css_matcher_apply_stylesheet (doc, stat->s.import_rule.sheet, node, declaration_list, type, pseudo); | ||
| 15 | @@ -2440,31 +2441,65 @@ | ||
| 16 | g_free (str); | ||
| 17 | #endif | ||
| 18 | } | ||
| 19 | + break; | ||
| 20 | } | ||
| 21 | - | ||
| 22 | - /* FIXME: We need to support more than just rulesets here */ | ||
| 23 | - if (stat->type != CSS_RULESET) | ||
| 24 | - continue; | ||
| 25 | - | ||
| 26 | - for (j = 0; j < stat->s.ruleset->n_sel; j++) { | ||
| 27 | - CssSelector *sel = stat->s.ruleset->sel[j]; | ||
| 28 | + | ||
| 29 | + case CSS_MEDIA_RULE: | ||
| 30 | + case CSS_RULESET: { | ||
| 31 | + CssRuleset **rs; | ||
| 32 | + gint k, l; | ||
| 33 | |||
| 34 | - if (css_matcher_match_selector (sel, node, pseudo)) { | ||
| 35 | - int i; | ||
| 36 | + if (stat->type == CSS_MEDIA_RULE) { | ||
| 37 | + CssValueEntry *entry = stat->s.media_rule.media_list->v.entry; | ||
| 38 | + const gchar *media = html_document_get_media_type (doc); | ||
| 39 | + gboolean has_media = FALSE; | ||
| 40 | |||
| 41 | - for (i = 0; i < stat->s.ruleset->n_decl; i++) { | ||
| 42 | - CssDeclaration *decl = stat->s.ruleset->decl[i]; | ||
| 43 | - CssDeclarationListEntry *entry = g_new (CssDeclarationListEntry, 1); | ||
| 44 | + if (!media) break; | ||
| 45 | + | ||
| 46 | + for (; entry; entry = entry->next) { | ||
| 47 | + const gchar *value = css_value_to_string (entry->value); | ||
| 48 | + if (strcasecmp (media, value) == 0) { | ||
| 49 | + has_media = TRUE; | ||
| 50 | + break; | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | + if (!has_media) break; | ||
| 54 | + | ||
| 55 | + rs = stat->s.media_rule.rs; | ||
| 56 | + k = stat->s.media_rule.n_rs; | ||
| 57 | + } else { | ||
| 58 | + rs = &stat->s.ruleset; | ||
| 59 | + k = 1; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + for (l = 0; l < k; l++) { | ||
| 63 | + for (j = 0; rs[l] && (j < rs[l]->n_sel); j++) { | ||
| 64 | + CssSelector *sel = rs[l]->sel[j]; | ||
| 65 | |||
| 66 | - entry->spec = sel->a * 1000000 + sel->b * 1000 + sel->c; | ||
| 67 | - entry->type = type; | ||
| 68 | - entry->decl = g_new (CssDeclaration, 1); | ||
| 69 | - entry->decl->property = decl->property; | ||
| 70 | - entry->decl->expr = css_value_ref (decl->expr); | ||
| 71 | - entry->decl->important = decl->important; | ||
| 72 | - *declaration_list = g_list_insert_sorted (*declaration_list, entry, css_declaration_list_sorter); | ||
| 73 | + if (css_matcher_match_selector (sel, node, pseudo)) { | ||
| 74 | + int i; | ||
| 75 | + | ||
| 76 | + for (i = 0; i < rs[l]->n_decl; i++) { | ||
| 77 | + CssDeclaration *decl = rs[l]->decl[i]; | ||
| 78 | + CssDeclarationListEntry *entry = g_new (CssDeclarationListEntry, 1); | ||
| 79 | + | ||
| 80 | + entry->spec = sel->a * 1000000 + sel->b * 1000 + sel->c; | ||
| 81 | + entry->type = type; | ||
| 82 | + entry->decl = g_new (CssDeclaration, 1); | ||
| 83 | + entry->decl->property = decl->property; | ||
| 84 | + entry->decl->expr = css_value_ref (decl->expr); | ||
| 85 | + entry->decl->important = decl->important; | ||
| 86 | + *declaration_list = g_list_insert_sorted (*declaration_list, entry, css_declaration_list_sorter); | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | } | ||
| 90 | } | ||
| 91 | + break; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + default: | ||
| 95 | + g_warning ("Unhandled stylesheet"); | ||
| 96 | + break; | ||
| 97 | } | ||
| 98 | } | ||
| 99 | } | ||
| 100 | @@ -2781,7 +2816,7 @@ | ||
| 101 | css_matcher_html_to_css (doc, style, node); | ||
| 102 | |||
| 103 | if (!default_stylesheet) { | ||
| 104 | - default_stylesheet = css_parser_parse_stylesheet (html_css, strlen (html_css), NULL); | ||
| 105 | + default_stylesheet = css_parser_parse_stylesheet (html_css, strlen (html_css), NULL, NULL); | ||
| 106 | } | ||
| 107 | |||
| 108 | css_matcher_apply_stylesheet (doc, default_stylesheet, node, &declaration_list, CSS_STYLESHEET_DEFAULT, pseudo); | ||
| 109 | @@ -2800,25 +2835,31 @@ | ||
| 110 | prop = xmlGetProp (node, "style"); | ||
| 111 | |||
| 112 | if (prop) { | ||
| 113 | - CssRuleset *rs = css_parser_parse_style_attr (prop, strlen (prop), NULL); | ||
| 114 | - gint i; | ||
| 115 | + xmlChar *media_prop = xmlGetProp (node, "media"); | ||
| 116 | + const gchar *media = html_document_get_media_type (doc); | ||
| 117 | |||
| 118 | - if (rs) { | ||
| 119 | - for (i = 0; i < rs->n_decl; i++) { | ||
| 120 | - CssDeclarationListEntry *entry = g_new (CssDeclarationListEntry, 1); | ||
| 121 | - CssDeclaration *decl = rs->decl[i]; | ||
| 122 | - | ||
| 123 | - entry->type = CSS_STYLESHEET_STYLEDECL; | ||
| 124 | - entry->decl = g_new (CssDeclaration, 1); | ||
| 125 | - entry->decl->property = decl->property; | ||
| 126 | - entry->decl->expr = css_value_ref (decl->expr); | ||
| 127 | - entry->decl->important = decl->important; | ||
| 128 | - entry->spec = 0; | ||
| 129 | + if (!media_prop || (media && (strcasecmp (media, media_prop) == 0))) { | ||
| 130 | + CssRuleset *rs = css_parser_parse_style_attr (prop, strlen (prop), NULL); | ||
| 131 | + gint i; | ||
| 132 | + | ||
| 133 | + if (rs) { | ||
| 134 | + for (i = 0; i < rs->n_decl; i++) { | ||
| 135 | + CssDeclarationListEntry *entry = g_new (CssDeclarationListEntry, 1); | ||
| 136 | + CssDeclaration *decl = rs->decl[i]; | ||
| 137 | |||
| 138 | - declaration_list = g_list_insert_sorted (declaration_list, entry, css_declaration_list_sorter); | ||
| 139 | + entry->type = CSS_STYLESHEET_STYLEDECL; | ||
| 140 | + entry->decl = g_new (CssDeclaration, 1); | ||
| 141 | + entry->decl->property = decl->property; | ||
| 142 | + entry->decl->expr = css_value_ref (decl->expr); | ||
| 143 | + entry->decl->important = decl->important; | ||
| 144 | + entry->spec = 0; | ||
| 145 | + | ||
| 146 | + declaration_list = g_list_insert_sorted (declaration_list, entry, css_declaration_list_sorter); | ||
| 147 | + } | ||
| 148 | + css_ruleset_destroy (rs); | ||
| 149 | } | ||
| 150 | - css_ruleset_destroy (rs); | ||
| 151 | } | ||
| 152 | + if (media_prop) xmlFree (media_prop); | ||
| 153 | xmlFree (prop); | ||
| 154 | } | ||
| 155 | |||
| 156 | Index: gtkhtml2/libgtkhtml/document/htmldocument.c | ||
| 157 | =================================================================== | ||
| 158 | --- gtkhtml2.orig/libgtkhtml/document/htmldocument.c 2006-01-25 02:07:49.000000000 +0000 | ||
| 159 | +++ gtkhtml2/libgtkhtml/document/htmldocument.c 2006-02-01 02:19:13.000000000 +0000 | ||
| 160 | @@ -147,9 +147,7 @@ | ||
| 161 | if (!buffer) | ||
| 162 | return; | ||
| 163 | |||
| 164 | - sheet = css_parser_parse_stylesheet (buffer, len, (gchar *) stream_data->internal_data); | ||
| 165 | - g_free(stream_data->internal_data); | ||
| 166 | - stream_data->internal_data = NULL; | ||
| 167 | + sheet = css_parser_parse_stylesheet (buffer, len, (gchar *) stream_data->internal_data, stream_data->media); | ||
| 168 | |||
| 169 | for (list = sheet->stat; list; list = list->next) { | ||
| 170 | CssStatement *statement = list->data; | ||
| 171 | @@ -158,15 +156,13 @@ | ||
| 172 | switch (statement->type) { | ||
| 173 | case CSS_IMPORT_RULE: { | ||
| 174 | HtmlDocumentStreamData *stream_data_import; | ||
| 175 | - gchar *url; | ||
| 176 | |||
| 177 | - url = css_value_to_string (statement->s.import_rule.url); | ||
| 178 | stream_data_import = g_new (HtmlDocumentStreamData, 1); | ||
| 179 | stream_data_import->document = stream_data->document; | ||
| 180 | - stream_data_import->internal_data = g_strdup(url); | ||
| 181 | + stream_data_import->internal_data = css_value_to_string (statement->s.import_rule.url); | ||
| 182 | + stream_data_import->media = statement->s.import_rule.media ? statement->s.import_rule.media : g_strdup (stream_data->media); | ||
| 183 | stream = html_stream_buffer_new (html_document_stylesheet_stream_close, stream_data_import); | ||
| 184 | - g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, url, stream); | ||
| 185 | - g_free (url); | ||
| 186 | + g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, stream_data_import->internal_data, stream); | ||
| 187 | break; | ||
| 188 | } | ||
| 189 | default: | ||
| 190 | @@ -174,8 +170,11 @@ | ||
| 191 | } | ||
| 192 | } | ||
| 193 | |||
| 194 | - g_free (stream_data); | ||
| 195 | document->stylesheets = g_slist_append (document->stylesheets, sheet); | ||
| 196 | + | ||
| 197 | + g_free (stream_data->media); | ||
| 198 | + g_free(stream_data->internal_data); | ||
| 199 | + g_free (stream_data); | ||
| 200 | |||
| 201 | /* Restyle the document */ | ||
| 202 | style_change = html_document_restyle_node (document, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), NULL, TRUE); | ||
| 203 | @@ -216,21 +215,22 @@ | ||
| 204 | HtmlDocumentStreamData *stream_data; | ||
| 205 | HtmlStream *stream; | ||
| 206 | |||
| 207 | - stream_data = g_new (HtmlDocumentStreamData, 1); | ||
| 208 | + stream_data = g_new0 (HtmlDocumentStreamData, 1); | ||
| 209 | stream_data->document = document; | ||
| 210 | stream_data->internal_data = g_strdup(url); | ||
| 211 | + stream_data->media = xmlGetProp (node->xmlnode, "media"); | ||
| 212 | |||
| 213 | stream = html_stream_buffer_new (html_document_stylesheet_stream_close, stream_data); | ||
| 214 | |||
| 215 | g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, url, stream); | ||
| 216 | + g_free (url); | ||
| 217 | } | ||
| 218 | - g_free (url); | ||
| 219 | } else if (str && (strcasecmp (str, "icon") == 0)) { | ||
| 220 | gchar *url = xmlGetProp (node->xmlnode, "href"); | ||
| 221 | if (url) { | ||
| 222 | g_signal_emit (G_OBJECT (document), document_signals [REQUEST_ICON], 0, url); | ||
| 223 | + g_free (url); | ||
| 224 | } | ||
| 225 | - g_free (url); | ||
| 226 | } | ||
| 227 | g_free (str); | ||
| 228 | } | ||
| 229 | @@ -282,8 +282,10 @@ | ||
| 230 | CssStylesheet *ss; | ||
| 231 | HtmlStyleChange style_change; | ||
| 232 | GSList *list; | ||
| 233 | + xmlChar *media = xmlGetProp (node->xmlnode->parent, "media"); | ||
| 234 | |||
| 235 | - ss = css_parser_parse_stylesheet (node->xmlnode->content, strlen (node->xmlnode->content), NULL); | ||
| 236 | + ss = css_parser_parse_stylesheet (node->xmlnode->content, strlen (node->xmlnode->content), NULL, media); | ||
| 237 | + if (media) xmlFree (media); | ||
| 238 | |||
| 239 | for (list = ss->stat; list; list = list->next) { | ||
| 240 | CssStatement *statement = list->data; | ||
| 241 | @@ -296,9 +298,10 @@ | ||
| 242 | |||
| 243 | cssurl = css_value_to_string (statement->s.import_rule.url); | ||
| 244 | |||
| 245 | - stream_data = g_new (HtmlDocumentStreamData, 1); | ||
| 246 | + stream_data = g_new0 (HtmlDocumentStreamData, 1); | ||
| 247 | stream_data->document = document; | ||
| 248 | stream_data->internal_data = g_strdup(cssurl); | ||
| 249 | + stream_data->media = statement->s.import_rule.media; | ||
| 250 | |||
| 251 | stream = html_stream_buffer_new (html_document_stylesheet_stream_close, stream_data); | ||
| 252 | g_signal_emit (G_OBJECT (document), document_signals [REQUEST_URL], 0, cssurl, stream); | ||
| 253 | @@ -546,6 +549,9 @@ | ||
| 254 | |||
| 255 | if (document->parser) | ||
| 256 | g_object_unref (G_OBJECT (document->parser)); | ||
| 257 | + | ||
| 258 | + if (document->media_type) | ||
| 259 | + g_free (document->media_type); | ||
| 260 | |||
| 261 | parent_class->finalize (object); | ||
| 262 | } | ||
| 263 | @@ -753,6 +759,7 @@ | ||
| 264 | { | ||
| 265 | document->stylesheets = NULL; | ||
| 266 | document->image_factory = html_image_factory_new (); | ||
| 267 | + document->media_type = NULL; | ||
| 268 | |||
| 269 | g_signal_connect (G_OBJECT (document->image_factory), "request_image", | ||
| 270 | G_CALLBACK (html_document_request_image), document); | ||
| 271 | @@ -1129,7 +1136,7 @@ | ||
| 272 | } | ||
| 273 | |||
| 274 | CssStylesheet * | ||
| 275 | -html_document_add_stylesheet (HtmlDocument *document, const gchar *buffer, gint len) | ||
| 276 | +html_document_add_stylesheet (HtmlDocument *document, const gchar *buffer, gint len, const gchar *media) | ||
| 277 | { | ||
| 278 | CssStylesheet *sheet; | ||
| 279 | HtmlStyleChange style_change; | ||
| 280 | @@ -1140,7 +1147,7 @@ | ||
| 281 | * complications it would cause with removal. | ||
| 282 | */ | ||
| 283 | |||
| 284 | - sheet = css_parser_parse_stylesheet (buffer, len, NULL); | ||
| 285 | + sheet = css_parser_parse_stylesheet (buffer, len, NULL, media); | ||
| 286 | document->stylesheets = g_slist_append (document->stylesheets, sheet); | ||
| 287 | |||
| 288 | style_change = html_document_restyle_node (document, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), NULL, TRUE); | ||
| 289 | @@ -1159,3 +1166,24 @@ | ||
| 290 | return TRUE; | ||
| 291 | } | ||
| 292 | |||
| 293 | +void | ||
| 294 | +html_document_set_media_type (HtmlDocument *document, const gchar *type) | ||
| 295 | +{ | ||
| 296 | + HtmlStyleChange style_change; | ||
| 297 | + | ||
| 298 | + g_return_if_fail (HTML_IS_DOCUMENT (document)); | ||
| 299 | + | ||
| 300 | + if (document->media_type) | ||
| 301 | + g_free (document->media_type); | ||
| 302 | + | ||
| 303 | + document->media_type = g_strdup (type); | ||
| 304 | + | ||
| 305 | + style_change = html_document_restyle_node (document, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), NULL, TRUE); | ||
| 306 | + g_signal_emit (G_OBJECT (document), document_signals [STYLE_UPDATED], 0, DOM_NODE (dom_Document__get_documentElement (document->dom_document)), style_change); | ||
| 307 | +} | ||
| 308 | + | ||
| 309 | +const gchar * | ||
| 310 | +html_document_get_media_type (HtmlDocument *document) | ||
| 311 | +{ | ||
| 312 | + return document->media_type; | ||
| 313 | +} | ||
| 314 | Index: gtkhtml2/libgtkhtml/document/htmldocument.h | ||
| 315 | =================================================================== | ||
| 316 | --- gtkhtml2.orig/libgtkhtml/document/htmldocument.h 2006-01-25 02:07:49.000000000 +0000 | ||
| 317 | +++ gtkhtml2/libgtkhtml/document/htmldocument.h 2006-01-25 02:07:50.000000000 +0000 | ||
| 318 | @@ -64,6 +64,8 @@ | ||
| 319 | DomNode *hover_node; | ||
| 320 | DomNode *active_node; | ||
| 321 | DomElement *focus_element; | ||
| 322 | + | ||
| 323 | + gchar *media_type; | ||
| 324 | }; | ||
| 325 | |||
| 326 | struct _HtmlDocumentClass { | ||
| 327 | @@ -97,6 +99,7 @@ | ||
| 328 | struct _HtmlDocumentStreamData { | ||
| 329 | HtmlDocument *document; | ||
| 330 | gpointer internal_data; | ||
| 331 | + gchar *media; | ||
| 332 | }; | ||
| 333 | |||
| 334 | GType html_document_get_type (void); | ||
| 335 | @@ -113,9 +116,12 @@ | ||
| 336 | void html_document_update_focus_element (HtmlDocument *document, DomElement *element); | ||
| 337 | DomNode *html_document_find_anchor (HtmlDocument *doc, const gchar *anchor); | ||
| 338 | |||
| 339 | -CssStylesheet *html_document_add_stylesheet (HtmlDocument *document, const gchar *buffer, gint len); | ||
| 340 | +CssStylesheet *html_document_add_stylesheet (HtmlDocument *document, const gchar *buffer, gint len, const gchar *media); | ||
| 341 | gboolean html_document_remove_stylesheet (HtmlDocument *document, CssStylesheet *stylesheet); | ||
| 342 | |||
| 343 | +void html_document_set_media_type (HtmlDocument *document, const gchar *type); | ||
| 344 | +const gchar *html_document_get_media_type (HtmlDocument *document); | ||
| 345 | + | ||
| 346 | G_END_DECLS | ||
| 347 | |||
| 348 | #endif /* __HTMLDOCUMENT_H__ */ | ||
| 349 | Index: gtkhtml2/libgtkhtml/css/cssparser.c | ||
| 350 | =================================================================== | ||
| 351 | --- gtkhtml2.orig/libgtkhtml/css/cssparser.c 2006-01-25 02:05:54.000000000 +0000 | ||
| 352 | +++ gtkhtml2/libgtkhtml/css/cssparser.c 2006-01-25 02:07:50.000000000 +0000 | ||
| 353 | @@ -688,6 +688,32 @@ | ||
| 354 | return pos; | ||
| 355 | } | ||
| 356 | |||
| 357 | +static void | ||
| 358 | +css_parser_parse_media_list (const gchar *buffer, gint start_pos, gint end_pos, CssValue **ret_val) | ||
| 359 | +{ | ||
| 360 | + CssValue *list = NULL; | ||
| 361 | + while (start_pos < end_pos) { | ||
| 362 | + CssValue *val; | ||
| 363 | + HtmlAtom name; | ||
| 364 | + | ||
| 365 | + if (buffer[start_pos] == ',') | ||
| 366 | + start_pos++; | ||
| 367 | + | ||
| 368 | + start_pos = css_parser_parse_whitespace (buffer, start_pos, end_pos); | ||
| 369 | + | ||
| 370 | + if (start_pos >= end_pos) | ||
| 371 | + break; | ||
| 372 | + | ||
| 373 | + start_pos = css_parser_parse_ident (buffer, start_pos, end_pos, &name); | ||
| 374 | + val = css_value_ident_new (name); | ||
| 375 | + if (!list) list = css_value_list_new (); | ||
| 376 | + css_value_list_append (list, val, ','); | ||
| 377 | + | ||
| 378 | + start_pos = css_parser_parse_whitespace (buffer, start_pos, end_pos); | ||
| 379 | + } | ||
| 380 | + | ||
| 381 | + *ret_val = list; | ||
| 382 | +} | ||
| 383 | |||
| 384 | static gint | ||
| 385 | css_parser_parse_attr_selector (const gchar *buffer, gint start_pos, gint end_pos, CssTail *tail) | ||
| 386 | @@ -1329,7 +1355,7 @@ | ||
| 387 | |||
| 388 | /* g_print ("Going to return: %d\n", pos); */ | ||
| 389 | |||
| 390 | - return pos + 1; | ||
| 391 | + return pos; | ||
| 392 | |||
| 393 | break; | ||
| 394 | case HTML_ATOM_PAGE: | ||
| 395 | @@ -1390,7 +1416,8 @@ | ||
| 396 | break; | ||
| 397 | case HTML_ATOM_IMPORT: { | ||
| 398 | gchar *import_url; | ||
| 399 | - const gchar *s_url, *e_url; | ||
| 400 | + const gchar *s_url, *e_url, *e_import, *e_media; | ||
| 401 | + CssValue *value = NULL; | ||
| 402 | |||
| 403 | cur_pos = css_parser_parse_to_char (buffer, ';', pos, end_pos); | ||
| 404 | |||
| 405 | @@ -1411,6 +1438,7 @@ | ||
| 406 | return cur_pos + 1; | ||
| 407 | } | ||
| 408 | |||
| 409 | + e_import = e_url + 1; | ||
| 410 | s_url++; | ||
| 411 | e_url--; | ||
| 412 | |||
| 413 | @@ -1434,6 +1462,11 @@ | ||
| 414 | result->type = CSS_IMPORT_RULE; | ||
| 415 | |||
| 416 | result->s.import_rule.url = css_value_string_new (import_url); | ||
| 417 | + | ||
| 418 | + /* Check for media types */ | ||
| 419 | + e_media = buffer + cur_pos; | ||
| 420 | + if ((e_media > e_import) && (css_parser_parse_whitespace(e_import, 0, e_media-e_import) < (e_media-e_import))) | ||
| 421 | + result->s.import_rule.media = g_strndup (e_import, e_media-e_import); | ||
| 422 | |||
| 423 | *ret_val = result; | ||
| 424 | |||
| 425 | @@ -1489,7 +1522,7 @@ | ||
| 426 | } | ||
| 427 | |||
| 428 | CssStylesheet * | ||
| 429 | -css_parser_parse_stylesheet (const gchar *str, gint len, const gchar *base_url) | ||
| 430 | +css_parser_parse_stylesheet (const gchar *str, gint len, const gchar *base_url, const gchar *media) | ||
| 431 | { | ||
| 432 | CssStylesheet *result; | ||
| 433 | GSList *stat = NULL; | ||
| 434 | @@ -1515,12 +1548,23 @@ | ||
| 435 | pos = css_parser_parse_ruleset (buffer, pos, end_pos, &ruleset, base_url); | ||
| 436 | |||
| 437 | if (ruleset) { | ||
| 438 | - CssStatement *rulestatement; | ||
| 439 | - rulestatement = g_new0 (CssStatement, 1); | ||
| 440 | - rulestatement->type = CSS_RULESET; | ||
| 441 | - rulestatement->s.ruleset = ruleset; | ||
| 442 | + CssStatement *statement; | ||
| 443 | + | ||
| 444 | + if (media) { | ||
| 445 | + statement = g_new0 (CssStatement, 1); | ||
| 446 | |||
| 447 | - stat = g_slist_append (stat, rulestatement); | ||
| 448 | + statement->type = CSS_MEDIA_RULE; | ||
| 449 | + css_parser_parse_media_list (media, 0, strlen (media), &statement->s.media_rule.media_list); | ||
| 450 | + g_assert (statement->s.media_rule.media_list); | ||
| 451 | + statement->s.media_rule.rs = g_new (CssRuleset *, 1); | ||
| 452 | + statement->s.media_rule.rs[0] = ruleset; | ||
| 453 | + statement->s.media_rule.n_rs = 1; | ||
| 454 | + } else { | ||
| 455 | + statement = g_new0 (CssStatement, 1); | ||
| 456 | + statement->type = CSS_RULESET; | ||
| 457 | + statement->s.ruleset = ruleset; | ||
| 458 | + } | ||
| 459 | + stat = g_slist_append (stat, statement); | ||
| 460 | } | ||
| 461 | |||
| 462 | if (pos == -1) | ||
| 463 | Index: gtkhtml2/libgtkhtml/css/cssparser.h | ||
| 464 | =================================================================== | ||
| 465 | --- gtkhtml2.orig/libgtkhtml/css/cssparser.h 2006-01-25 02:05:54.000000000 +0000 | ||
| 466 | +++ gtkhtml2/libgtkhtml/css/cssparser.h 2006-01-25 02:07:50.000000000 +0000 | ||
| 467 | @@ -30,7 +30,7 @@ | ||
| 468 | |||
| 469 | G_BEGIN_DECLS | ||
| 470 | |||
| 471 | -CssStylesheet *css_parser_parse_stylesheet (const gchar *str, gint len, const gchar *base_url); | ||
| 472 | +CssStylesheet *css_parser_parse_stylesheet (const gchar *str, gint len, const gchar *base_url, const gchar *media); | ||
| 473 | CssRuleset *css_parser_parse_style_attr (const gchar *buffer, gint len, const gchar *base_url); | ||
| 474 | |||
| 475 | G_END_DECLS | ||
| 476 | Index: gtkhtml2/libgtkhtml/css/cssstylesheet.h | ||
| 477 | =================================================================== | ||
| 478 | --- gtkhtml2.orig/libgtkhtml/css/cssstylesheet.h 2006-02-01 02:19:56.000000000 +0000 | ||
| 479 | +++ gtkhtml2/libgtkhtml/css/cssstylesheet.h 2006-02-01 02:20:08.000000000 +0000 | ||
| 480 | @@ -99,6 +99,7 @@ | ||
| 481 | CssValue *url; | ||
| 482 | gboolean fetched; | ||
| 483 | gboolean fetching; | ||
| 484 | + gchar *media; | ||
| 485 | } import_rule; | ||
| 486 | |||
| 487 | } s; | ||
