Gitweb links:

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

The branch, master has been updated
       via  35ab0a4e9406f9eeb29ca261680d911c423e4f90 (commit)
      from  00cafe488273eab18e9c93bf59191efaa722fc3b (commit)

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=35ab0a4e9406f9eeb29ca261680d911c423e4f90
commit 35ab0a4e9406f9eeb29ca261680d911c423e4f90
Author: Michael Drake <Michael Drake [email protected]>
Commit: Michael Drake <Michael Drake [email protected]>

    Media queries: Simplify parsed mq data structure slightly.

diff --git a/src/parse/mq.c b/src/parse/mq.c
index 2e817d1..fb32b38 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -39,21 +39,13 @@ static void css__mq_feature_destroy(css_mq_feature *feature)
 static void css__mq_cond_or_feature_destroy(
                css_mq_cond_or_feature *cond_or_feature);
 
-static void css__mq_cond_parts_destroy(css_mq_cond_parts *cond_parts)
-{
-       if (cond_parts != NULL) {
-               for (uint32_t i = 0; i < cond_parts->nparts; i++) {
-                       css__mq_cond_or_feature_destroy(cond_parts->parts[i]);
-               }
-               free(cond_parts->parts);
-               free(cond_parts);
-       }
-}
-
 static void css__mq_cond_destroy(css_mq_cond *cond)
 {
        if (cond != NULL) {
-               css__mq_cond_parts_destroy(cond->parts);
+               for (uint32_t i = 0; i < cond->nparts; i++) {
+                       css__mq_cond_or_feature_destroy(cond->parts[i]);
+               }
+               free(cond->parts);
                free(cond);
        }
 }
@@ -790,12 +782,6 @@ static css_error mq_parse_condition(lwc_string **strings,
                return CSS_NOMEM;
        }
        memset(result, 0, sizeof(*result));
-       result->parts = malloc(sizeof(*result->parts));
-       if (result->parts == NULL) {
-               free(result);
-               return CSS_NOMEM;
-       }
-       memset(result->parts, 0, sizeof(*result->parts));
 
        if (tokenIsChar(token, '(') == false) {
                /* Must be "not" */
@@ -810,14 +796,14 @@ static css_error mq_parse_condition(lwc_string **strings,
                }
 
                result->negate = 1;
-               result->parts->nparts = 1;
-               result->parts->parts = malloc(sizeof(*result->parts->parts));
-               if (result->parts->parts == NULL) {
+               result->nparts = 1;
+               result->parts = malloc(sizeof(*result->parts));
+               if (result->parts == NULL) {
                        css__mq_cond_or_feature_destroy(cond_or_feature);
                        css__mq_cond_destroy(result);
                        return CSS_NOMEM;
                }
-               result->parts->parts[0] = cond_or_feature;
+               result->parts[0] = cond_or_feature;
 
                *cond = result;
 
@@ -834,16 +820,16 @@ static css_error mq_parse_condition(lwc_string **strings,
                        return CSS_INVALID;
                }
 
-               parts = realloc(result->parts->parts,
-                               
(result->parts->nparts+1)*sizeof(*result->parts->parts));
+               parts = realloc(result->parts,
+                               (result->nparts+1)*sizeof(*result->parts));
                if (parts == NULL) {
                        css__mq_cond_or_feature_destroy(cond_or_feature);
                        css__mq_cond_destroy(result);
                        return CSS_NOMEM;
                }
-               parts[result->parts->nparts] = cond_or_feature;
-               result->parts->parts = parts;
-               result->parts->nparts++;
+               parts[result->nparts] = cond_or_feature;
+               result->parts = parts;
+               result->nparts++;
 
                consumeWhitespace(vector, ctx);
 
diff --git a/src/parse/mq.h b/src/parse/mq.h
index 0e2f845..7a51578 100644
--- a/src/parse/mq.h
+++ b/src/parse/mq.h
@@ -57,14 +57,10 @@ typedef struct {
 typedef struct css_mq_cond_or_feature css_mq_cond_or_feature;
 
 typedef struct {
-       uint32_t nparts;
-       css_mq_cond_or_feature **parts;
-} css_mq_cond_parts;
-
-typedef struct {
        uint32_t negate : 1, /* set if "not" */
                 op     : 1; /* clear if "and", set if "or" */
-       css_mq_cond_parts *parts;
+       uint32_t nparts;
+       css_mq_cond_or_feature **parts;
 } css_mq_cond;
 
 struct css_mq_cond_or_feature {
diff --git a/src/select/mq.h b/src/select/mq.h
index f51d0db..c01144b 100644
--- a/src/select/mq.h
+++ b/src/select/mq.h
@@ -222,17 +222,15 @@ static inline bool mq_match_condition(
 {
        bool matched = !cond->op;
 
-       for (uint32_t i = 0; i < cond->parts->nparts; i++) {
+       for (uint32_t i = 0; i < cond->nparts; i++) {
                bool part_matched;
-               if (cond->parts->parts[i]->type == CSS_MQ_FEATURE) {
+               if (cond->parts[i]->type == CSS_MQ_FEATURE) {
                        part_matched = mq_match_feature(
-                                       cond->parts->parts[i]->data.feat,
-                                       media);
+                                       cond->parts[i]->data.feat, media);
                } else {
-                       assert(cond->parts->parts[i]->type == CSS_MQ_COND);
+                       assert(cond->parts[i]->type == CSS_MQ_COND);
                        part_matched = mq_match_condition(
-                                       cond->parts->parts[i]->data.cond,
-                                       media);
+                                       cond->parts[i]->data.cond, media);
                }
 
                if (cond->op) {


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

Summary of changes:
 src/parse/mq.c  |   40 +++++++++++++---------------------------
 src/parse/mq.h  |    8 ++------
 src/select/mq.h |   12 +++++-------
 3 files changed, 20 insertions(+), 40 deletions(-)

diff --git a/src/parse/mq.c b/src/parse/mq.c
index 2e817d1..fb32b38 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -39,21 +39,13 @@ static void css__mq_feature_destroy(css_mq_feature *feature)
 static void css__mq_cond_or_feature_destroy(
                css_mq_cond_or_feature *cond_or_feature);
 
-static void css__mq_cond_parts_destroy(css_mq_cond_parts *cond_parts)
-{
-       if (cond_parts != NULL) {
-               for (uint32_t i = 0; i < cond_parts->nparts; i++) {
-                       css__mq_cond_or_feature_destroy(cond_parts->parts[i]);
-               }
-               free(cond_parts->parts);
-               free(cond_parts);
-       }
-}
-
 static void css__mq_cond_destroy(css_mq_cond *cond)
 {
        if (cond != NULL) {
-               css__mq_cond_parts_destroy(cond->parts);
+               for (uint32_t i = 0; i < cond->nparts; i++) {
+                       css__mq_cond_or_feature_destroy(cond->parts[i]);
+               }
+               free(cond->parts);
                free(cond);
        }
 }
@@ -790,12 +782,6 @@ static css_error mq_parse_condition(lwc_string **strings,
                return CSS_NOMEM;
        }
        memset(result, 0, sizeof(*result));
-       result->parts = malloc(sizeof(*result->parts));
-       if (result->parts == NULL) {
-               free(result);
-               return CSS_NOMEM;
-       }
-       memset(result->parts, 0, sizeof(*result->parts));
 
        if (tokenIsChar(token, '(') == false) {
                /* Must be "not" */
@@ -810,14 +796,14 @@ static css_error mq_parse_condition(lwc_string **strings,
                }
 
                result->negate = 1;
-               result->parts->nparts = 1;
-               result->parts->parts = malloc(sizeof(*result->parts->parts));
-               if (result->parts->parts == NULL) {
+               result->nparts = 1;
+               result->parts = malloc(sizeof(*result->parts));
+               if (result->parts == NULL) {
                        css__mq_cond_or_feature_destroy(cond_or_feature);
                        css__mq_cond_destroy(result);
                        return CSS_NOMEM;
                }
-               result->parts->parts[0] = cond_or_feature;
+               result->parts[0] = cond_or_feature;
 
                *cond = result;
 
@@ -834,16 +820,16 @@ static css_error mq_parse_condition(lwc_string **strings,
                        return CSS_INVALID;
                }
 
-               parts = realloc(result->parts->parts,
-                               
(result->parts->nparts+1)*sizeof(*result->parts->parts));
+               parts = realloc(result->parts,
+                               (result->nparts+1)*sizeof(*result->parts));
                if (parts == NULL) {
                        css__mq_cond_or_feature_destroy(cond_or_feature);
                        css__mq_cond_destroy(result);
                        return CSS_NOMEM;
                }
-               parts[result->parts->nparts] = cond_or_feature;
-               result->parts->parts = parts;
-               result->parts->nparts++;
+               parts[result->nparts] = cond_or_feature;
+               result->parts = parts;
+               result->nparts++;
 
                consumeWhitespace(vector, ctx);
 
diff --git a/src/parse/mq.h b/src/parse/mq.h
index 0e2f845..7a51578 100644
--- a/src/parse/mq.h
+++ b/src/parse/mq.h
@@ -57,14 +57,10 @@ typedef struct {
 typedef struct css_mq_cond_or_feature css_mq_cond_or_feature;
 
 typedef struct {
-       uint32_t nparts;
-       css_mq_cond_or_feature **parts;
-} css_mq_cond_parts;
-
-typedef struct {
        uint32_t negate : 1, /* set if "not" */
                 op     : 1; /* clear if "and", set if "or" */
-       css_mq_cond_parts *parts;
+       uint32_t nparts;
+       css_mq_cond_or_feature **parts;
 } css_mq_cond;
 
 struct css_mq_cond_or_feature {
diff --git a/src/select/mq.h b/src/select/mq.h
index f51d0db..c01144b 100644
--- a/src/select/mq.h
+++ b/src/select/mq.h
@@ -222,17 +222,15 @@ static inline bool mq_match_condition(
 {
        bool matched = !cond->op;
 
-       for (uint32_t i = 0; i < cond->parts->nparts; i++) {
+       for (uint32_t i = 0; i < cond->nparts; i++) {
                bool part_matched;
-               if (cond->parts->parts[i]->type == CSS_MQ_FEATURE) {
+               if (cond->parts[i]->type == CSS_MQ_FEATURE) {
                        part_matched = mq_match_feature(
-                                       cond->parts->parts[i]->data.feat,
-                                       media);
+                                       cond->parts[i]->data.feat, media);
                } else {
-                       assert(cond->parts->parts[i]->type == CSS_MQ_COND);
+                       assert(cond->parts[i]->type == CSS_MQ_COND);
                        part_matched = mq_match_condition(
-                                       cond->parts->parts[i]->data.cond,
-                                       media);
+                                       cond->parts[i]->data.cond, media);
                }
 
                if (cond->op) {


-- 
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