Gitweb links:

...log 
http://git.netsurf-browser.org/libcss.git/shortlog/a4d73071ae2d810107defe8c209687b12dac003a
...commit 
http://git.netsurf-browser.org/libcss.git/commit/a4d73071ae2d810107defe8c209687b12dac003a
...tree 
http://git.netsurf-browser.org/libcss.git/tree/a4d73071ae2d810107defe8c209687b12dac003a

The branch, tlsa/jmb/mq has been updated
  discards  f1d2dfec8a0ffe90171c547b912613388538f273 (commit)
       via  a4d73071ae2d810107defe8c209687b12dac003a (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (f1d2dfec8a0ffe90171c547b912613388538f273)
            \
             N -- N -- N (a4d73071ae2d810107defe8c209687b12dac003a)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/libcss.git/commit/?id=a4d73071ae2d810107defe8c209687b12dac003a
commit a4d73071ae2d810107defe8c209687b12dac003a
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    Media Queries: Implement parsing <general-enclosed>.

diff --git a/src/parse/mq.c b/src/parse/mq.c
index 719e129..6692651 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -433,14 +433,111 @@ static css_error mq_parse_media_feature(css_language *c,
        return CSS_OK;
 }
 
+/*
+ * Consume any value
+ *
+ * CSS Syntax Module Level 3: 8.2
+ */
+static css_error mq_parse_consume_any_value(css_language *c,
+               const parserutils_vector *vector, int *ctx,
+               bool until, const char until_char)
+{
+       const css_token *token;
+       css_error error;
+
+       while (true) {
+               consumeWhitespace(vector, ctx);
+
+               token = parserutils_vector_iterate(vector, ctx);
+               if (token == NULL) {
+                       return CSS_INVALID;
+               }
+
+               switch (token->type) {
+               case CSS_TOKEN_INVALID_STRING:
+                       return CSS_INVALID;
+
+               case CSS_TOKEN_CHAR:
+                       if (until && tokenIsChar(token, until_char)) {
+                               /* Found matching close bracket */
+                               return CSS_OK;
+
+                       } else if (tokenIsChar(token, ')') ||
+                                  tokenIsChar(token, ']') ||
+                                  tokenIsChar(token, '}')) {
+                               /* Non-matching close bracket */
+                               return CSS_INVALID;
+                       }
+                       if (tokenIsChar(token, '(')) {
+                               /* Need to consume until matching bracket. */
+                               error = mq_parse_consume_any_value(
+                                               c, vector, ctx, true, ')');
+                               if (error != CSS_OK) {
+                                       return error;
+                               }
+                       } else if (tokenIsChar(token, '[')) {
+                               /* Need to consume until matching bracket. */
+                               error = mq_parse_consume_any_value(
+                                               c, vector, ctx, true, ']');
+                               if (error != CSS_OK) {
+                                       return error;
+                               }
+                       } else if (tokenIsChar(token, '{')) {
+                               /* Need to consume until matching bracket. */
+                               error = mq_parse_consume_any_value(
+                                               c, vector, ctx, true, '}');
+                               if (error != CSS_OK) {
+                                       return error;
+                               }
+                       }
+                       break;
+
+               default:
+                       break;
+               }
+       }
+
+       return CSS_OK;
+}
+
 static css_error mq_parse_general_enclosed(css_language *c,
                const parserutils_vector *vector, int *ctx)
 {
+       const css_token *token;
+       css_error error;
+
        /* <general-enclosed> = [ <function-token> <any-value> ) ]
         *                    | ( <ident> <any-value> )
         */
 
-       /* TODO: implement */
+       token = parserutils_vector_iterate(vector, ctx);
+       if (token == NULL) {
+               return CSS_INVALID;
+       }
+
+       switch (token->type) {
+       case CSS_TOKEN_FUNCTION:
+               error = mq_parse_consume_any_value(c, vector, ctx, true, ')');
+               if (error != CSS_OK) {
+                       return error;
+               }
+
+               token = parserutils_vector_peek(vector, *ctx);
+               if (!tokenIsChar(token, ')')) {
+                       return CSS_INVALID;
+               }
+               break;
+
+       case CSS_TOKEN_IDENT:
+               error = mq_parse_consume_any_value(c, vector, ctx, false, '\0');
+               if (error != CSS_OK) {
+                       return error;
+               }
+               break;
+
+       default:
+               return CSS_INVALID;
+       }
 
        return CSS_OK;
 }


-----------------------------------------------------------------------

Summary of changes:
 src/parse/mq.c |   39 ++++++++++++++++-----------------------
 1 file changed, 16 insertions(+), 23 deletions(-)

diff --git a/src/parse/mq.c b/src/parse/mq.c
index 172b618..6692651 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -440,7 +440,7 @@ static css_error mq_parse_media_feature(css_language *c,
  */
 static css_error mq_parse_consume_any_value(css_language *c,
                const parserutils_vector *vector, int *ctx,
-               const char *until_char)
+               bool until, const char until_char)
 {
        const css_token *token;
        css_error error;
@@ -458,39 +458,34 @@ static css_error mq_parse_consume_any_value(css_language 
*c,
                        return CSS_INVALID;
 
                case CSS_TOKEN_CHAR:
-                       if (until_char != NULL) {
-                               if (tokenIsChar(token, *until_char)) {
-                                       /* Found matching close bracket */
-                                       return CSS_OK;
-
-                               } else if (tokenIsChar(token, ')') ||
-                                          tokenIsChar(token, ']') ||
-                                          tokenIsChar(token, '}')) {
-                                       /* Non-matching close bracket */
-                                       return CSS_INVALID;
-                               } else if (tokenIsChar(token, ';')) {
-                                       /* Non-top-level semi-colon */
-                                       return CSS_INVALID;
-                               }
+                       if (until && tokenIsChar(token, until_char)) {
+                               /* Found matching close bracket */
+                               return CSS_OK;
+
+                       } else if (tokenIsChar(token, ')') ||
+                                  tokenIsChar(token, ']') ||
+                                  tokenIsChar(token, '}')) {
+                               /* Non-matching close bracket */
+                               return CSS_INVALID;
                        }
                        if (tokenIsChar(token, '(')) {
                                /* Need to consume until matching bracket. */
                                error = mq_parse_consume_any_value(
-                                               c, vector, ctx, ")");
+                                               c, vector, ctx, true, ')');
                                if (error != CSS_OK) {
                                        return error;
                                }
                        } else if (tokenIsChar(token, '[')) {
                                /* Need to consume until matching bracket. */
                                error = mq_parse_consume_any_value(
-                                               c, vector, ctx, "]");
+                                               c, vector, ctx, true, ']');
                                if (error != CSS_OK) {
                                        return error;
                                }
                        } else if (tokenIsChar(token, '{')) {
                                /* Need to consume until matching bracket. */
                                error = mq_parse_consume_any_value(
-                                               c, vector, ctx, "}");
+                                               c, vector, ctx, true, '}');
                                if (error != CSS_OK) {
                                        return error;
                                }
@@ -522,21 +517,19 @@ static css_error mq_parse_general_enclosed(css_language 
*c,
 
        switch (token->type) {
        case CSS_TOKEN_FUNCTION:
-               error = mq_parse_consume_any_value(c, vector, ctx, NULL);
+               error = mq_parse_consume_any_value(c, vector, ctx, true, ')');
                if (error != CSS_OK) {
                        return error;
                }
 
-               consumeWhitespace(vector, ctx);
-
-               token = parserutils_vector_iterate(vector, ctx);
+               token = parserutils_vector_peek(vector, *ctx);
                if (!tokenIsChar(token, ')')) {
                        return CSS_INVALID;
                }
                break;
 
        case CSS_TOKEN_IDENT:
-               error = mq_parse_consume_any_value(c, vector, ctx, NULL);
+               error = mq_parse_consume_any_value(c, vector, ctx, false, '\0');
                if (error != CSS_OK) {
                        return error;
                }


-- 
Cascading Style Sheets library

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to