summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@gnome.org>2004-03-04 23:36:04 +0000
committerDodji Seketeli <dodji@src.gnome.org>2004-03-04 23:36:04 +0000
commitc2ae0c55befcb725f4d068c9ef8a8f54101b9047 (patch)
tree5050e45508bd3fdbf4bd11202ff39e839916813f
parent586d0453fb8d672415039b3fef920535e463657e (diff)
downloadlibcroco-c2ae0c55befcb725f4d068c9ef8a8f54101b9047.tar.gz
fixed silly bug in there. added the support of the "!important" keyword at
2004-03-05 Dodji Seketeli <dodji@gnome.org> * csslint/csslint.c: (parse_cmd_line) fixed silly bug in there. * src/cr-declaration.[ch],src/cr-om-parser.c, src/cr-parser.[ch],src/cr-statement.c,tests/test2-main.c, tests/test3-main.c: added the support of the "!important" keyword at the parsing level. * tests/test-inputs/test4.1.css: update nr tests to reflect the new !important thing. * src/cr-sel-eng.c: (put_css_properties_in_props_list): fix a small subtle bug in here. Selection engine is becoming more and more reliable ;).
-rw-r--r--ChangeLog16
-rw-r--r--csslint/csslint.c1
-rw-r--r--src/cr-declaration.c73
-rw-r--r--src/cr-declaration.h9
-rw-r--r--src/cr-doc-handler.h8
-rw-r--r--src/cr-om-parser.c8
-rw-r--r--src/cr-parser.c199
-rw-r--r--src/cr-parser.h6
-rw-r--r--src/cr-prop-list.c2
-rw-r--r--src/cr-sel-eng.c18
-rw-r--r--src/cr-statement.c35
-rw-r--r--tests/test-inputs/test4.1.css2
-rw-r--r--tests/test-output-refs/test4.1.css.out2
-rw-r--r--tests/test2-main.c3
-rw-r--r--tests/test3-main.c3
15 files changed, 199 insertions, 186 deletions
diff --git a/ChangeLog b/ChangeLog
index e3dffa6..186afcd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2004-03-05 Dodji Seketeli <dodji@gnome.org>
+
+ * csslint/csslint.c:
+ (parse_cmd_line) fixed silly bug in there.
+ * src/cr-declaration.[ch],src/cr-om-parser.c,
+ src/cr-parser.[ch],src/cr-statement.c,tests/test2-main.c,
+ tests/test3-main.c:
+ added the support of the "!important"
+ keyword at the parsing level.
+ * tests/test-inputs/test4.1.css: update nr tests to reflect
+ the new !important thing.
+ * src/cr-sel-eng.c:
+ (put_css_properties_in_props_list): fix a small subtle
+ bug in here. Selection engine is becoming more and more
+ reliable ;).
+
2004-03-04 Dodji Seketeli <dodji@gnome.org>
* src/cr-enc-handler.c:
diff --git a/csslint/csslint.c b/csslint/csslint.c
index c0d01c6..2ac1745 100644
--- a/csslint/csslint.c
+++ b/csslint/csslint.c
@@ -141,7 +141,6 @@ parse_cmd_line (int a_argc, char **a_argv,
exit (-1);
}
a_options->user_sheet_path = a_argv[i] ;
- i++ ;
}
else if (!strcmp (a_argv[i], "--ua-sheet"))
{
diff --git a/src/cr-declaration.c b/src/cr-declaration.c
index 6b413da..38b8b5c 100644
--- a/src/cr-declaration.c
+++ b/src/cr-declaration.c
@@ -43,61 +43,16 @@
static void
dump (CRDeclaration *a_this, FILE *a_fp, glong a_indent)
{
- guchar *str = NULL, *tmp_str = NULL, *tmp_str2 = NULL;
+ guchar *str = NULL ;
g_return_if_fail (a_this) ;
-
- if (a_this->property && a_this->property->str)
- {
- tmp_str = g_strndup (a_this->property->str,
- a_this->property->len) ;
- if (tmp_str)
- {
- tmp_str2 = g_strconcat (tmp_str, " : ", NULL) ;
- if (!tmp_str2) goto error ;
- if (tmp_str)
- {
- g_free (tmp_str) ;
- tmp_str = NULL ;
- }
- str = tmp_str2 ;
- }
-
- if (str)
- {
- cr_utils_dump_n_chars (' ', a_fp, a_indent) ;
- fprintf (a_fp,"%s", str) ;
- g_free (str) ;
- str = NULL ;
- }
- else
- goto error ;
-
- if (a_this->value)
- {
- cr_term_dump (a_this->value, a_fp) ;
- }
-
- }
-
- return ;
-
- error:
+ str = cr_declaration_to_string (a_this, a_indent) ;
if (str)
{
+ fprintf (a_fp,"%s", str) ;
g_free (str) ;
str = NULL ;
- }
- if (tmp_str)
- {
- g_free (tmp_str) ;
- tmp_str = NULL ;
- }
- if (tmp_str2)
- {
- g_free (tmp_str2) ;
- tmp_str2 = NULL ;
- }
+ }
}
/**
@@ -166,6 +121,7 @@ cr_declaration_parse_from_buf (CRStatement *a_statement,
GString *property = NULL;
CRDeclaration *result = NULL ;
CRParser * parser = NULL ;
+ gboolean important = FALSE ;
g_return_val_if_fail (a_str, NULL) ;
if (a_statement)
@@ -182,7 +138,7 @@ cr_declaration_parse_from_buf (CRStatement *a_statement,
goto cleanup ;
status = cr_parser_parse_declaration (parser, &property,
- &value) ;
+ &value, &important) ;
if (status != CR_OK || !property)
goto cleanup ;
@@ -191,6 +147,7 @@ cr_declaration_parse_from_buf (CRStatement *a_statement,
{
property = NULL ;
value = NULL ;
+ result->important = important ;
}
cleanup:
@@ -233,6 +190,7 @@ cr_declaration_parse_list_from_buf (const guchar *a_str, enum CREncoding a_enc)
CRDeclaration *result = NULL, *cur_decl = NULL ;
CRParser * parser = NULL ;
CRTknzr *tokenizer = NULL ;
+ gboolean important = FALSE ;
g_return_val_if_fail (a_str, NULL) ;
@@ -252,7 +210,7 @@ cr_declaration_parse_list_from_buf (const guchar *a_str, enum CREncoding a_enc)
goto cleanup ;
status = cr_parser_parse_declaration (parser, &property,
- &value) ;
+ &value, &important) ;
if (status != CR_OK || !property)
{
if (status != CR_OK)
@@ -264,6 +222,7 @@ cr_declaration_parse_list_from_buf (const guchar *a_str, enum CREncoding a_enc)
{
property = NULL ;
value = NULL ;
+ result->important = important ;
}
/*now, go parse the other declarations*/
for (;;)
@@ -285,9 +244,10 @@ cr_declaration_parse_list_from_buf (const guchar *a_str, enum CREncoding a_enc)
{
break ;
}
+ important = FALSE ;
cr_parser_try_to_skip_spaces_and_comments (parser) ;
status = cr_parser_parse_declaration (parser, &property,
- &value) ;
+ &value, &important) ;
if (status != CR_OK || !property)
{
if (status == CR_END_OF_INPUT_ERROR)
@@ -299,6 +259,7 @@ cr_declaration_parse_list_from_buf (const guchar *a_str, enum CREncoding a_enc)
cur_decl = cr_declaration_new (NULL, property, value) ;
if (cur_decl)
{
+ cur_decl->important = important ;
result = cr_declaration_append (result, cur_decl) ;
property = NULL ;
value = NULL ;
@@ -591,15 +552,17 @@ cr_declaration_to_string (CRDeclaration *a_this,
}
else
goto error ;
- }
+ }
+ if (a_this->important == TRUE)
+ {
+ g_string_append_printf (stringue, " %s", "!important") ;
+ }
}
-
if (stringue && stringue->str)
{
result = stringue->str ;
g_string_free (stringue, FALSE) ;
}
-
return result ;
error:
diff --git a/src/cr-declaration.h b/src/cr-declaration.h
index 3dd39c9..d12c1d9 100644
--- a/src/cr-declaration.h
+++ b/src/cr-declaration.h
@@ -64,7 +64,16 @@ struct _CRDeclaration
/*the previous one declaration*/
CRDeclaration *prev ;
+ /*does the declaration have the important keyword ?*/
+ gboolean important ;
+
glong ref_count ;
+
+ /*reserved for future usage*/
+ gpointer rfu0 ;
+ gpointer rfu1 ;
+ gpointer rfu2 ;
+ gpointer rfu3 ;
} ;
diff --git a/src/cr-doc-handler.h b/src/cr-doc-handler.h
index 9fda7bc..aa5ccd0 100644
--- a/src/cr-doc-handler.h
+++ b/src/cr-doc-handler.h
@@ -3,8 +3,6 @@
/*
* This file is part of The Croco Library
*
- * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2.1 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
@@ -18,6 +16,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
+ *
+ * See the COPYRIGHTS file for copyright information.
*/
#ifndef __CR_DOC_HANDLER_H__
@@ -159,8 +159,8 @@ struct _CRDocHandler
*/
void (*property) (CRDocHandler *a_this,
GString *a_name,
- CRTerm *a_expression) ;
-
+ CRTerm *a_expression,
+ gboolean a_is_important) ;
/**
*Is called to notify the start of a font face statement.
*The parser invokes this method at the beginning of every
diff --git a/src/cr-om-parser.c b/src/cr-om-parser.c
index 352c3c1..077ef37 100644
--- a/src/cr-om-parser.c
+++ b/src/cr-om-parser.c
@@ -64,7 +64,8 @@ error (CRDocHandler *a_this) ;
static void
property (CRDocHandler *a_this,
GString *a_name,
- CRTerm *a_expression) ;
+ CRTerm *a_expression,
+ gboolean a_important) ;
static void
end_selector (CRDocHandler *a_this,
@@ -669,7 +670,8 @@ end_selector (CRDocHandler *a_this,
static void
property (CRDocHandler *a_this,
GString *a_name,
- CRTerm *a_expression)
+ CRTerm *a_expression,
+ gboolean a_important)
{
enum CRStatus status = CR_OK ;
ParsingContext *ctxt = NULL ;
@@ -704,7 +706,7 @@ property (CRDocHandler *a_this,
str, a_expression) ;
g_return_if_fail (decl) ;
str = NULL ;
-
+ decl->important = a_important ;
/*
*add the new declaration to the current statement
*being build.
diff --git a/src/cr-parser.c b/src/cr-parser.c
index ba27009..6b1bb2a 100644
--- a/src/cr-parser.c
+++ b/src/cr-parser.c
@@ -3796,6 +3796,59 @@ cr_parser_parse_expr (CRParser *a_this, CRTerm **a_expr)
}
/**
+ *Parses a declaration priority as defined by
+ *the css2 grammar in appendix C:
+ *prio: IMPORTANT_SYM S*
+ *@param a_this the current instance of #CRParser.
+ *@param a_prio a string representing the priority.
+ *Today, only "!important" is returned as only this
+ *priority is defined by css2.
+ */
+enum CRStatus
+cr_parser_parse_prio (CRParser *a_this, GString **a_prio)
+{
+ enum CRStatus status = CR_ERROR ;
+ CRInputPos init_pos ;
+ CRToken *token = NULL ;
+
+ g_return_val_if_fail (a_this && PRIVATE (a_this)
+ && a_prio && *a_prio == NULL,
+ CR_BAD_PARAM_ERROR) ;
+
+ RECORD_INITIAL_POS (a_this, &init_pos) ;
+
+ status = cr_tknzr_get_next_token
+ (PRIVATE (a_this)->tknzr,
+ &token) ;
+ if (status == CR_END_OF_INPUT_ERROR)
+ {
+ goto error ;
+ }
+ ENSURE_PARSING_COND (status == CR_OK
+ && token
+ && token->type == IMPORTANT_SYM_TK) ;
+
+ cr_parser_try_to_skip_spaces_and_comments
+ (a_this) ;
+ *a_prio = g_string_new ("!important") ;
+ cr_token_destroy (token) ;
+ token = NULL ;
+ return CR_OK ;
+
+ error:
+ if (token)
+ {
+ cr_token_destroy (token) ;
+ token = NULL ;
+ }
+ cr_tknzr_set_cur_pos (PRIVATE (a_this)->tknzr, &init_pos) ;
+
+ return status ;
+}
+
+/**
+ *TODO: return the parsed priority, so that
+ *upper layers can take benefit from it.
*Parses a "declaration" as defined by the css2 spec in appendix D.1:
*declaration ::= [property ':' S* expr prio?]?
*
@@ -3808,15 +3861,17 @@ cr_parser_parse_expr (CRParser *a_this, CRTerm **a_expr)
*/
enum CRStatus
cr_parser_parse_declaration (CRParser *a_this, GString **a_property,
- CRTerm **a_expr)
+ CRTerm **a_expr, gboolean *a_important)
{
enum CRStatus status = CR_ERROR ;
CRInputPos init_pos ;
guint32 cur_char = 0 ;
CRTerm *expr = NULL ;
+ GString *prio = NULL ;
g_return_val_if_fail (a_this && PRIVATE (a_this)
- && a_property && a_expr,
+ && a_property && a_expr
+ && a_important,
CR_BAD_PARAM_ERROR) ;
RECORD_INITIAL_POS (a_this, &init_pos) ;
@@ -3849,8 +3904,21 @@ cr_parser_parse_declaration (CRParser *a_this, GString **a_property,
CHECK_PARSING_STATUS_ERR
(a_this, status, FALSE,
"while parsing declaration: next expression is malformed",
- CR_SYNTAX_ERROR) ;
+ CR_SYNTAX_ERROR) ;
+ cr_parser_try_to_skip_spaces_and_comments
+ (a_this) ;
+ status = cr_parser_parse_prio (a_this, &prio) ;
+ if (prio)
+ {
+ g_string_free (prio, TRUE) ;
+ prio = NULL ;
+ *a_important = TRUE ;
+ }
+ else
+ {
+ *a_important = FALSE ;
+ }
if (*a_expr)
{
cr_term_append_term (*a_expr, expr) ;
@@ -3966,7 +4034,7 @@ cr_parser_parse_ruleset (CRParser *a_this)
CRTerm *expr = NULL ;
CRSimpleSel * simple_sels = NULL ;
CRSelector *selector = NULL ;
- gboolean start_selector = FALSE ;
+ gboolean start_selector = FALSE, is_important = FALSE ;
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ;
@@ -3982,7 +4050,6 @@ cr_parser_parse_ruleset (CRParser *a_this)
"while parsing rulset: current char should be '{'",
CR_SYNTAX_ERROR) ;
-
if (PRIVATE (a_this)->sac_handler
&&PRIVATE (a_this)->sac_handler->start_selector)
{
@@ -4001,22 +4068,23 @@ cr_parser_parse_ruleset (CRParser *a_this)
}
cr_parser_try_to_skip_spaces_and_comments (a_this) ;
-
+
PRIVATE (a_this)->state = TRY_PARSE_RULESET_STATE ;
- status = cr_parser_parse_declaration (a_this, &property, &expr) ;
+ status = cr_parser_parse_declaration (a_this, &property,
+ &expr, &is_important) ;
if (expr)
{
cr_term_ref (expr) ;
}
-
- if ( status == CR_OK
+ if ( status == CR_OK
&& PRIVATE (a_this)->sac_handler
&& PRIVATE (a_this)->sac_handler->property)
{
PRIVATE (a_this)->sac_handler->property
- (PRIVATE (a_this)->sac_handler, property, expr) ;
+ (PRIVATE (a_this)->sac_handler, property, expr,
+ is_important) ;
}
if (status == CR_OK)
@@ -4038,7 +4106,6 @@ cr_parser_parse_ruleset (CRParser *a_this)
expr = NULL ;
}
}
-
CHECK_PARSING_STATUS_ERR
(a_this, status, FALSE,
"while parsing ruleset: next construction should be a declaration",
@@ -4055,35 +4122,31 @@ cr_parser_parse_ruleset (CRParser *a_this)
cr_parser_try_to_skip_spaces_and_comments (a_this) ;
status = cr_parser_parse_declaration (a_this, &property,
- &expr) ;
+ &expr, &is_important) ;
if (expr)
{
cr_term_ref (expr) ;
}
-
if (status == CR_OK
&& PRIVATE (a_this)->sac_handler
&& PRIVATE (a_this)->sac_handler->property)
{
PRIVATE (a_this)->sac_handler->property
(PRIVATE (a_this)->sac_handler,
- property, expr) ;
+ property, expr, is_important) ;
}
-
if (property)
{
g_string_free (property, TRUE) ;
property = NULL ;
}
-
if (expr)
{
cr_term_unref (expr) ;
expr = NULL ;
}
}
-
cr_parser_try_to_skip_spaces_and_comments (a_this) ;
READ_NEXT_CHAR (a_this, &cur_char) ;
@@ -4125,7 +4188,6 @@ cr_parser_parse_ruleset (CRParser *a_this)
return CR_OK ;
error:
-
if (start_selector == TRUE
&& PRIVATE (a_this)->sac_handler
&& PRIVATE (a_this)->sac_handler->error)
@@ -4133,24 +4195,20 @@ cr_parser_parse_ruleset (CRParser *a_this)
PRIVATE (a_this)->sac_handler->error
(PRIVATE (a_this)->sac_handler) ;
}
-
if (expr)
{
cr_term_unref (expr) ;
expr = NULL ;
}
-
if (simple_sels)
{
cr_simple_sel_destroy (simple_sels) ;
simple_sels = NULL ;
}
-
if (property)
{
g_string_free (property, TRUE) ;
}
-
if (selector)
{
cr_selector_unref (selector) ;
@@ -4555,7 +4613,8 @@ cr_parser_parse_page (CRParser *a_this)
GString *page_selector = NULL,
*page_pseudo_class = NULL,
*property = NULL ;
-
+ gboolean important = TRUE ;
+
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ;
RECORD_INITIAL_POS (a_this, &init_pos) ;
@@ -4587,12 +4646,11 @@ cr_parser_parse_page (CRParser *a_this)
cr_tknzr_unget_token (PRIVATE (a_this)->tknzr,
token) ;
token = NULL ;
- }
+ }
/*
*try to parse pseudo_page
*/
-
cr_parser_try_to_skip_spaces_and_comments (a_this) ;
status = cr_tknzr_get_next_token (PRIVATE (a_this)->tknzr,
&token) ;
@@ -4642,8 +4700,9 @@ cr_parser_parse_page (CRParser *a_this)
PRIVATE (a_this)->state = TRY_PARSE_PAGE_STATE ;
status = cr_parser_parse_declaration (a_this, &property,
- &css_expression) ;
- ENSURE_PARSING_COND (status == CR_OK)
+ &css_expression,
+ &important) ;
+ ENSURE_PARSING_COND (status == CR_OK) ;
/*
*call the relevant SAC handler here...
@@ -4656,21 +4715,17 @@ cr_parser_parse_page (CRParser *a_this)
PRIVATE (a_this)->sac_handler->property
(PRIVATE (a_this)->sac_handler,
- property,
- css_expression) ;
+ property, css_expression, important) ;
}
-
/*
*... and free the data structure passed to that last
*SAC handler.
*/
-
if (property)
{
g_string_free (property, TRUE) ;
property = NULL ;
}
-
if (css_expression)
{
cr_term_unref (css_expression) ;
@@ -4684,60 +4739,53 @@ cr_parser_parse_page (CRParser *a_this)
{
cr_token_destroy (token) ;
token = NULL ;
- }
-
+ }
status = cr_tknzr_get_next_token
(PRIVATE (a_this)->tknzr, &token) ;
ENSURE_PARSING_COND (status == CR_OK && token) ;
if (token->type != SEMICOLON_TK) break ;
-
+
cr_token_destroy (token) ;
token = NULL ;
-
cr_parser_try_to_skip_spaces_and_comments (a_this) ;
status = cr_parser_parse_declaration (a_this, &property,
- &css_expression) ;
+ &css_expression,
+ &important) ;
CHECK_PARSING_STATUS (status, FALSE) ;
/*
*call the relevant SAC handler here...
*/
-
if (PRIVATE (a_this)->sac_handler
&& PRIVATE (a_this)->sac_handler->property)
{
cr_term_ref (css_expression) ;
PRIVATE (a_this)->sac_handler->property
(PRIVATE (a_this)->sac_handler,
- property,
- css_expression) ;
+ property, css_expression,
+ important) ;
}
-
/*
*... and free the data structure passed to that last
*SAC handler.
*/
-
if (property)
{
g_string_free (property, TRUE) ;
property = NULL ;
}
-
if (css_expression)
{
cr_term_unref (css_expression) ;
css_expression = NULL ;
}
}
-
ENSURE_PARSING_COND (status == CR_OK
&& token
&& token->type == CBC_TK) ;
-
cr_token_destroy (token) ; token = NULL ;
@@ -4774,39 +4822,32 @@ cr_parser_parse_page (CRParser *a_this)
return CR_OK ;
error:
-
if (token)
{
cr_token_destroy (token) ;
token = NULL ;
}
-
if (page_selector)
{
g_string_free (page_selector, TRUE) ;
page_selector = NULL ;
}
-
if (page_pseudo_class)
{
g_string_free (page_pseudo_class, TRUE) ;
page_pseudo_class = NULL ;
}
-
if (property)
{
g_string_free (property, TRUE) ;
property = NULL ;
}
-
if (css_expression)
{
cr_term_destroy (css_expression) ;
css_expression = NULL ;
}
-
cr_tknzr_set_cur_pos (PRIVATE (a_this)->tknzr, &init_pos) ;
-
return status ;
}
@@ -4924,6 +4965,7 @@ cr_parser_parse_font_face (CRParser *a_this)
GString *property = NULL ;
CRTerm * css_expression = NULL ;
CRToken *token = NULL ;
+ gboolean important = FALSE ;
guint32 next_char = 0, cur_char = 0 ;
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ;
@@ -4937,82 +4979,68 @@ cr_parser_parse_font_face (CRParser *a_this)
&& token->type == FONT_FACE_SYM_TK) ;
cr_parser_try_to_skip_spaces_and_comments (a_this) ;
-
if (token)
{
cr_token_destroy (token) ;
token = NULL ;
}
-
status = cr_tknzr_get_next_token (PRIVATE (a_this)->tknzr,
&token) ;
ENSURE_PARSING_COND (status == CR_OK
&& token
&& token->type == CBO_TK) ;
-
-
if (token)
{
cr_token_destroy (token) ;
token = NULL ;
}
-
/*
*here, call the relevant SAC handler.
*/
-
if (PRIVATE (a_this)->sac_handler
&& PRIVATE (a_this)->sac_handler->start_font_face)
{
PRIVATE (a_this)->sac_handler->start_font_face
(PRIVATE (a_this)->sac_handler) ;
}
-
PRIVATE (a_this)->state = TRY_PARSE_FONT_FACE_STATE ;
-
/*
*and resume the parsing.
*/
- cr_parser_try_to_skip_spaces_and_comments (a_this) ;
-
-
- status = cr_parser_parse_declaration (a_this, &property,
- &css_expression) ;
-
+ cr_parser_try_to_skip_spaces_and_comments (a_this) ;
+ status = cr_parser_parse_declaration (a_this, &property,
+ &css_expression,
+ &important) ;
if (status == CR_OK)
{
/*
*here, call the relevant SAC handler.
*/
cr_term_ref (css_expression) ;
-
if (PRIVATE (a_this)->sac_handler &&
PRIVATE (a_this)->sac_handler->property)
{
PRIVATE (a_this)->sac_handler->property
(PRIVATE (a_this)->sac_handler,
- property, css_expression) ;
+ property, css_expression,
+ important) ;
}
ENSURE_PARSING_COND (css_expression && property) ;
}
-
/*free the data structures allocated during last parsing.*/
if (property)
{
g_string_free (property, TRUE) ;
property = NULL ;
}
-
if (css_expression)
{
cr_term_unref (css_expression) ;
css_expression = NULL ;
}
-
for (;;)
{
PEEK_NEXT_CHAR (a_this, &next_char) ;
-
if (next_char == ';')
{
READ_NEXT_CHAR (a_this, &cur_char) ;
@@ -5021,26 +5049,22 @@ cr_parser_parse_font_face (CRParser *a_this)
{
break ;
}
-
cr_parser_try_to_skip_spaces_and_comments (a_this) ;
-
status = cr_parser_parse_declaration (a_this, &property,
- &css_expression) ;
-
+ &css_expression,
+ &important) ;
if (status != CR_OK) break ;
-
/*
*here, call the relevant SAC handler.
*/
cr_term_ref (css_expression) ;
-
if (PRIVATE (a_this)->sac_handler->property)
{
PRIVATE (a_this)->sac_handler->property
(PRIVATE (a_this)->sac_handler,
- property, css_expression) ;
+ property, css_expression,
+ important) ;
}
-
/*
*Then, free the data structures allocated during
*last parsing.
@@ -5050,30 +5074,23 @@ cr_parser_parse_font_face (CRParser *a_this)
g_string_free (property, TRUE) ;
property = NULL ;
}
-
if (css_expression)
{
cr_term_unref (css_expression) ;
css_expression = NULL ;
}
}
-
cr_parser_try_to_skip_spaces_and_comments (a_this) ;
-
READ_NEXT_CHAR (a_this, &cur_char) ;
-
ENSURE_PARSING_COND (cur_char == '}') ;
-
/*
*here, call the relevant SAC handler.
*/
-
if (PRIVATE (a_this)->sac_handler->end_font_face)
{
PRIVATE (a_this)->sac_handler->end_font_face
(PRIVATE (a_this)->sac_handler) ;
}
-
cr_parser_try_to_skip_spaces_and_comments (a_this) ;
if (token)
@@ -5081,35 +5098,27 @@ cr_parser_parse_font_face (CRParser *a_this)
cr_token_destroy (token) ;
token = NULL ;
}
-
cr_parser_clear_errors (a_this) ;
-
PRIVATE (a_this)->state = FONT_FACE_PARSED_STATE ;
-
return CR_OK ;
error:
-
if (token)
{
cr_token_destroy (token) ;
token = NULL ;
}
-
if (property)
{
g_string_free (property, TRUE) ;
property = NULL ;
}
-
if (css_expression)
{
cr_term_destroy (css_expression) ;
css_expression = NULL ;
}
-
cr_tknzr_set_cur_pos (PRIVATE (a_this)->tknzr, &init_pos) ;
-
return status ;
}
diff --git a/src/cr-parser.h b/src/cr-parser.h
index 9339c9a..1729ff6 100644
--- a/src/cr-parser.h
+++ b/src/cr-parser.h
@@ -113,8 +113,12 @@ enum CRStatus
cr_parser_parse_expr (CRParser *a_this, CRTerm **a_expr) ;
enum CRStatus
+cr_parser_parse_prio (CRParser *a_this, GString **a_prio) ;
+
+enum CRStatus
cr_parser_parse_declaration (CRParser *a_this, GString **a_property,
- CRTerm **a_expr) ;
+ CRTerm **a_expr, gboolean *a_important) ;
+
enum CRStatus
cr_parser_parse_statement_core (CRParser *a_this) ;
diff --git a/src/cr-prop-list.c b/src/cr-prop-list.c
index 2016556..84d27bf 100644
--- a/src/cr-prop-list.c
+++ b/src/cr-prop-list.c
@@ -365,7 +365,7 @@ cr_prop_list_unlink (CRPropList *a_this,
{
if (next)
return next ;
- return a_this ;
+ return NULL ;
}
return a_this ;
}
diff --git a/src/cr-sel-eng.c b/src/cr-sel-eng.c
index 92de775..77933b0 100644
--- a/src/cr-sel-eng.c
+++ b/src/cr-sel-eng.c
@@ -1189,24 +1189,22 @@ put_css_properties_in_props_list (CRPropList **a_props,
*style sheets which override
*the default style sheet."
*/
- if (decl->parent_statement
+ if (decl->parent_statement
&& decl->parent_statement->parent_sheet
&& (decl->parent_statement->parent_sheet->origin
<
a_stmt->parent_sheet->origin))
{
- tmp_props = cr_prop_list_unlink
+ tmp_props = cr_prop_list_unlink
(props, pair) ;
- if (!tmp_props)
- {
- cr_utils_trace_info ("tmp_props != NULL failed") ;
- continue ;
- }
+ /*TODO: pair leaks here, fix it!!*/
props = tmp_props ;
tmp_props = NULL ;
- cr_prop_list_append2 (props,
- cur_decl->property,
- cur_decl) ;
+ props = cr_prop_list_append2
+ (props,
+ cur_decl->property,
+ cur_decl) ;
+
continue ;
}
else if (decl->parent_statement
diff --git a/src/cr-statement.c b/src/cr-statement.c
index 0eb2359..6c3ccc2 100644
--- a/src/cr-statement.c
+++ b/src/cr-statement.c
@@ -96,7 +96,8 @@ parse_font_face_unrecoverable_error_cb (CRDocHandler *a_this)
static void
parse_font_face_property_cb (CRDocHandler *a_this,
GString *a_name,
- CRTerm *a_value)
+ CRTerm *a_value,
+ gboolean a_important)
{
enum CRStatus status = CR_OK ;
GString *name = NULL ;
@@ -197,7 +198,8 @@ parse_page_unrecoverable_error_cb (CRDocHandler *a_this)
static void
parse_page_property_cb (CRDocHandler *a_this,
GString *a_name,
- CRTerm *a_expression)
+ CRTerm *a_expression,
+ gboolean a_important)
{
GString *name = NULL ;
CRStatement *stmt = NULL ;
@@ -212,7 +214,7 @@ parse_page_property_cb (CRDocHandler *a_this,
decl = cr_declaration_new (stmt, name, a_expression) ;
g_return_if_fail (decl) ;
-
+ decl->important = a_important ;
stmt->kind.page_rule->decl_list =
cr_declaration_append (stmt->kind.page_rule->decl_list,
decl) ;
@@ -311,7 +313,8 @@ parse_at_media_start_selector_cb (CRDocHandler *a_this,
static void
parse_at_media_property_cb (CRDocHandler *a_this,
- GString *a_name, CRTerm *a_value)
+ GString *a_name, CRTerm *a_value,
+ gboolean a_important)
{
enum CRStatus status = CR_OK ;
/*
@@ -319,6 +322,7 @@ parse_at_media_property_cb (CRDocHandler *a_this,
*current at-media being parsed.
*/
CRStatement *stmt = NULL;
+ CRDeclaration *decl = NULL ;
GString *name = NULL ;
g_return_if_fail (a_this && a_name) ;
@@ -330,11 +334,12 @@ parse_at_media_property_cb (CRDocHandler *a_this,
g_return_if_fail (status == CR_OK && stmt) ;
g_return_if_fail (stmt->type == RULESET_STMT) ;
- status = cr_statement_ruleset_append_decl2
- (stmt, name, a_value) ;
- g_return_if_fail (status == CR_OK) ;
-
-
+ decl = cr_declaration_new (stmt, name, a_value) ;
+ g_return_if_fail (decl) ;
+ decl->important = a_important ;
+ status = cr_statement_ruleset_append_decl
+ (stmt, decl) ;
+ g_return_if_fail (status == CR_OK) ;
}
static void
@@ -418,10 +423,13 @@ parse_ruleset_unrecoverable_error_cb (CRDocHandler *a_this)
static void
parse_ruleset_property_cb (CRDocHandler *a_this,
- GString *a_name, CRTerm *a_value)
+ GString *a_name,
+ CRTerm *a_value,
+ gboolean a_important)
{
enum CRStatus status = CR_OK ;
CRStatement *ruleset = NULL ;
+ CRDeclaration *decl = NULL ;
GString * stringue = NULL ;
g_return_if_fail (a_this && a_this->priv && a_name) ;
@@ -433,8 +441,11 @@ parse_ruleset_property_cb (CRDocHandler *a_this,
g_return_if_fail (status == CR_OK
&& ruleset && ruleset->type == RULESET_STMT) ;
- status = cr_statement_ruleset_append_decl2
- (ruleset, stringue, a_value) ;
+ decl = cr_declaration_new (ruleset, stringue, a_value) ;
+ g_return_if_fail (decl) ;
+ decl->important = a_important ;
+ status = cr_statement_ruleset_append_decl
+ (ruleset, decl) ;
g_return_if_fail (status == CR_OK) ;
}
diff --git a/tests/test-inputs/test4.1.css b/tests/test-inputs/test4.1.css
index 60500e3..01bd9d4 100644
--- a/tests/test-inputs/test4.1.css
+++ b/tests/test-inputs/test4.1.css
@@ -1,5 +1,5 @@
* {
- font-family: Verdana, Arial, Helvetica, sans-serif, monospace;
+ font-family: Verdana, Arial, Helvetica, sans-serif, monospace !important;
}
tutu:class1:class2 {
diff --git a/tests/test-output-refs/test4.1.css.out b/tests/test-output-refs/test4.1.css.out
index df3e4c8..0c3ce20 100644
--- a/tests/test-output-refs/test4.1.css.out
+++ b/tests/test-output-refs/test4.1.css.out
@@ -1,5 +1,5 @@
* {
- font-family : Verdana, Arial, Helvetica, sans-serif, monospace
+ font-family : Verdana, Arial, Helvetica, sans-serif, monospace !important
}
tutu:class1:class2 {
diff --git a/tests/test2-main.c b/tests/test2-main.c
index 1b060e9..b27967e 100644
--- a/tests/test2-main.c
+++ b/tests/test2-main.c
@@ -282,7 +282,8 @@ test_end_selector (CRDocHandler *a_handler,
static void
-test_property (CRDocHandler *a_handler, GString *a_name, CRTerm *a_expr)
+test_property (CRDocHandler *a_handler, GString *a_name,
+ CRTerm *a_expr, gboolean a_important)
{
g_return_if_fail (a_handler) ;
diff --git a/tests/test3-main.c b/tests/test3-main.c
index 6c8d77f..3b7f1ac 100644
--- a/tests/test3-main.c
+++ b/tests/test3-main.c
@@ -281,7 +281,8 @@ test_end_selector (CRDocHandler *a_handler,
static void
-test_property (CRDocHandler *a_handler, GString *a_name, CRTerm *a_expr)
+test_property (CRDocHandler *a_handler, GString *a_name,
+ CRTerm *a_expr, gboolean a_important)
{
g_return_if_fail (a_handler) ;