summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Neves <lcneves@gmail.com>2017-09-19 02:14:59 (GMT)
committer Lucas Neves <lcneves@gmail.com>2017-09-26 02:01:56 (GMT)
commitc20237e11cbb07dbc77b183c3a02e0aec81be8ad (patch)
treeb1f8fe92dc1175df38800ef408134a64ab850ddf
parentade466b349d580c90a9515d5949a8e0d272bf83a (diff)
downloadlibcss-c20237e11cbb07dbc77b183c3a02e0aec81be8ad.tar.gz
libcss-c20237e11cbb07dbc77b183c3a02e0aec81be8ad.tar.bz2
Parse: fixes order bitwise shift
-rw-r--r--src/parse/properties/Makefile1
-rw-r--r--src/parse/properties/order.c81
-rw-r--r--src/parse/properties/properties.gen2
-rw-r--r--src/select/properties/order.c4
-rw-r--r--test/data/select/tests1.dat168
5 files changed, 158 insertions, 98 deletions
diff --git a/src/parse/properties/Makefile b/src/parse/properties/Makefile
index 6461dda..74cd204 100644
--- a/src/parse/properties/Makefile
+++ b/src/parse/properties/Makefile
@@ -54,6 +54,7 @@ DIR_SOURCES := \
list_style_type.c \
margin.c \
opacity.c \
+ order.c \
outline.c \
overflow.c \
padding.c \
diff --git a/src/parse/properties/order.c b/src/parse/properties/order.c
new file mode 100644
index 0000000..9d617bc
--- a/dev/null
+++ b/src/parse/properties/order.c
@@ -0,0 +1,81 @@
+/*
+ * This file was generated by LibCSS gen_parser
+ *
+ * Generated from:
+ *
+ * order:CSS_PROP_ORDER IDENT:INHERIT NUMBER:( true:ORDER_SET NUMBER:)
+ *
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2010 The NetSurf Browser Project.
+ */
+
+#include <assert.h>
+#include <string.h>
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "parse/properties/properties.h"
+#include "parse/properties/utils.h"
+
+/**
+ * Parse order
+ *
+ * \param c Parsing context
+ * \param vector Vector of tokens to process
+ * \param ctx Pointer to vector iteration context
+ * \param result resulting style
+ * \return CSS_OK on success,
+ * CSS_NOMEM on memory exhaustion,
+ * CSS_INVALID if the input is not valid
+ *
+ * Post condition: \a *ctx is updated with the next token to process
+ * If the input is invalid, then \a *ctx remains unchanged.
+ */
+css_error css__parse_order(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result)
+{
+ int orig_ctx = *ctx;
+ css_error error;
+ const css_token *token;
+ bool match;
+
+ token = parserutils_vector_iterate(vector, ctx);
+ if ((token == NULL) || ((token->type != CSS_TOKEN_IDENT) && (token->type != CSS_TOKEN_NUMBER))) {
+ *ctx = orig_ctx;
+ return CSS_INVALID;
+ }
+
+ if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[INHERIT], &match) == lwc_error_ok && match)) {
+ error = css_stylesheet_style_inherit(result, CSS_PROP_ORDER);
+ } else if (token->type == CSS_TOKEN_NUMBER) {
+ css_fixed num = 0;
+ size_t consumed = 0;
+
+ /* Undo the <<10 shift, because this is an integer */
+ num = css__number_from_lwc_string(
+ token->idata, true, &consumed) >> 10;
+
+ /* Invalid if there are trailing characters */
+ if (consumed != lwc_string_length(token->idata)) {
+ *ctx = orig_ctx;
+ return CSS_INVALID;
+ }
+ error = css__stylesheet_style_appendOPV(result, CSS_PROP_ORDER, 0, ORDER_SET);
+ if (error != CSS_OK) {
+ *ctx = orig_ctx;
+ return error;
+ }
+
+ error = css__stylesheet_style_append(result, num);
+ } else {
+ error = CSS_INVALID;
+ }
+
+ if (error != CSS_OK)
+ *ctx = orig_ctx;
+
+ return error;
+}
+
diff --git a/src/parse/properties/properties.gen b/src/parse/properties/properties.gen
index c640a23..403fb36 100644
--- a/src/parse/properties/properties.gen
+++ b/src/parse/properties/properties.gen
@@ -235,5 +235,3 @@ flex_shrink:CSS_PROP_FLEX_SHRINK IDENT:INHERIT NUMBER:( true:FLEX_SHRINK_SET RAN
flex_wrap:CSS_PROP_FLEX_WRAP IDENT:( INHERIT: NOWRAP:0,FLEX_WRAP_NOWRAP WRAP_STRING:0,FLEX_WRAP_WRAP WRAP_REVERSE:0,FLEX_WRAP_WRAP_REVERSE IDENT:)
justify_content:CSS_PROP_JUSTIFY_CONTENT IDENT:( INHERIT: FLEX_START:0,JUSTIFY_CONTENT_FLEX_START FLEX_END:0,JUSTIFY_CONTENT_FLEX_END CENTER:0,JUSTIFY_CONTENT_CENTER SPACE_BETWEEN:0,JUSTIFY_CONTENT_SPACE_BETWEEN SPACE_AROUND:0,JUSTIFY_CONTENT_SPACE_AROUND SPACE_EVENLY:0,JUSTIFY_CONTENT_SPACE_EVENLY IDENT:)
-
-order:CSS_PROP_ORDER IDENT:INHERIT NUMBER:( true:ORDER_SET NUMBER:)
diff --git a/src/select/properties/order.c b/src/select/properties/order.c
index 377e95f..969492a 100644
--- a/src/select/properties/order.c
+++ b/src/select/properties/order.c
@@ -18,12 +18,12 @@ css_error css__cascade_order(uint32_t opv, css_style *style,
css_select_state *state)
{
uint16_t value = CSS_ORDER_INHERIT;
- int32_t order = 0;
+ css_fixed order = 0;
if (isInherit(opv) == false) {
value = CSS_ORDER_SET;
- order = *((int32_t *) style->bytecode);
+ order = *((css_fixed *) style->bytecode);
advance_bytecode(style, sizeof(order));
}
diff --git a/test/data/select/tests1.dat b/test/data/select/tests1.dat
index e13b974..db61e5d 100644
--- a/test/data/select/tests1.dat
+++ b/test/data/select/tests1.dat
@@ -8043,9 +8043,7 @@ z-index: auto
#tree
| div*
#ua
-div { flex-grow: 2; flex-basis: 20rem; }
-#user
-div { flex: none; }
+div { flex: 0 0 0; }
#errors
#expected:
align-content: stretch
@@ -8094,7 +8092,7 @@ cursor: auto
direction: ltr
display: inline
empty-cells: show
-flex-basis: auto
+flex-basis: 0px
flex-direction: row
flex-grow: 0.000
flex-shrink: 0.000
@@ -8153,10 +8151,10 @@ z-index: auto
#tree
| div*
-| p
#ua
-div { flex: 3 3 3%; }
-p { flex: inherit; }
+div { flex-grow: 2; flex-basis: 20rem; }
+#user
+div { flex: none; }
#errors
#expected:
align-content: stretch
@@ -8205,10 +8203,10 @@ cursor: auto
direction: ltr
display: inline
empty-cells: show
-flex-basis: 3%
+flex-basis: auto
flex-direction: row
-flex-grow: 3.000
-flex-shrink: 3.000
+flex-grow: 0.000
+flex-shrink: 0.000
flex-wrap: nowrap
float: none
font-family: sans-serif
@@ -8263,8 +8261,8 @@ z-index: auto
#reset
#tree
-| div
-| p*
+| div*
+| p
#ua
div { flex: 3 3 3%; }
p { flex: inherit; }
@@ -8374,9 +8372,11 @@ z-index: auto
#reset
#tree
-| div*
+| div
+| p*
#ua
-div { flex-flow: nowrap; }
+div { flex: 3 3 3%; }
+p { flex: inherit; }
#errors
#expected:
align-content: stretch
@@ -8425,10 +8425,10 @@ cursor: auto
direction: ltr
display: inline
empty-cells: show
-flex-basis: auto
+flex-basis: 3%
flex-direction: row
-flex-grow: 0.000
-flex-shrink: 1.000
+flex-grow: 3.000
+flex-shrink: 3.000
flex-wrap: nowrap
float: none
font-family: sans-serif
@@ -8485,7 +8485,7 @@ z-index: auto
#tree
| div*
#ua
-div { flex-flow: wrap; }
+div { flex-flow: nowrap; }
#errors
#expected:
align-content: stretch
@@ -8538,7 +8538,7 @@ flex-basis: auto
flex-direction: row
flex-grow: 0.000
flex-shrink: 1.000
-flex-wrap: wrap
+flex-wrap: nowrap
float: none
font-family: sans-serif
font-size: 12pt
@@ -8594,7 +8594,7 @@ z-index: auto
#tree
| div*
#ua
-div { flex-flow: wrap-reverse; }
+div { flex-flow: wrap; }
#errors
#expected:
align-content: stretch
@@ -8647,7 +8647,7 @@ flex-basis: auto
flex-direction: row
flex-grow: 0.000
flex-shrink: 1.000
-flex-wrap: wrap-reverse
+flex-wrap: wrap
float: none
font-family: sans-serif
font-size: 12pt
@@ -8703,7 +8703,7 @@ z-index: auto
#tree
| div*
#ua
-div { flex-flow: row; }
+div { flex-flow: wrap-reverse; }
#errors
#expected:
align-content: stretch
@@ -8756,7 +8756,7 @@ flex-basis: auto
flex-direction: row
flex-grow: 0.000
flex-shrink: 1.000
-flex-wrap: nowrap
+flex-wrap: wrap-reverse
float: none
font-family: sans-serif
font-size: 12pt
@@ -8812,7 +8812,7 @@ z-index: auto
#tree
| div*
#ua
-div { flex-flow: column; }
+div { flex-flow: row; }
#errors
#expected:
align-content: stretch
@@ -8862,7 +8862,7 @@ direction: ltr
display: inline
empty-cells: show
flex-basis: auto
-flex-direction: column
+flex-direction: row
flex-grow: 0.000
flex-shrink: 1.000
flex-wrap: nowrap
@@ -8921,7 +8921,7 @@ z-index: auto
#tree
| div*
#ua
-div { flex-flow: row-reverse; }
+div { flex-flow: column; }
#errors
#expected:
align-content: stretch
@@ -8971,7 +8971,7 @@ direction: ltr
display: inline
empty-cells: show
flex-basis: auto
-flex-direction: row-reverse
+flex-direction: column
flex-grow: 0.000
flex-shrink: 1.000
flex-wrap: nowrap
@@ -9030,7 +9030,7 @@ z-index: auto
#tree
| div*
#ua
-div { flex-flow: column-reverse; }
+div { flex-flow: row-reverse; }
#errors
#expected:
align-content: stretch
@@ -9080,7 +9080,7 @@ direction: ltr
display: inline
empty-cells: show
flex-basis: auto
-flex-direction: column-reverse
+flex-direction: row-reverse
flex-grow: 0.000
flex-shrink: 1.000
flex-wrap: nowrap
@@ -9139,7 +9139,7 @@ z-index: auto
#tree
| div*
#ua
-div { flex-flow: column-reverse wrap-reverse; }
+div { flex-flow: column-reverse; }
#errors
#expected:
align-content: stretch
@@ -9192,7 +9192,7 @@ flex-basis: auto
flex-direction: column-reverse
flex-grow: 0.000
flex-shrink: 1.000
-flex-wrap: wrap-reverse
+flex-wrap: nowrap
float: none
font-family: sans-serif
font-size: 12pt
@@ -9246,11 +9246,9 @@ z-index: auto
#reset
#tree
-| div
-| p*
+| div*
#ua
-div { flex-flow: column wrap; }
-p {flex-flow: inherit; }
+div { flex-flow: column-reverse wrap-reverse; }
#errors
#expected:
align-content: stretch
@@ -9300,10 +9298,10 @@ direction: ltr
display: inline
empty-cells: show
flex-basis: auto
-flex-direction: column
+flex-direction: column-reverse
flex-grow: 0.000
flex-shrink: 1.000
-flex-wrap: wrap
+flex-wrap: wrap-reverse
float: none
font-family: sans-serif
font-size: 12pt
@@ -9360,8 +9358,8 @@ z-index: auto
| div
| p*
#ua
-div { flex-flow: row-reverse wrap-reverse; }
-p { flex-direction: inherit; flex-wrap: inherit; }
+div { flex-flow: column wrap; }
+p {flex-flow: inherit; }
#errors
#expected:
align-content: stretch
@@ -9411,10 +9409,10 @@ direction: ltr
display: inline
empty-cells: show
flex-basis: auto
-flex-direction: row-reverse
+flex-direction: column
flex-grow: 0.000
flex-shrink: 1.000
-flex-wrap: wrap-reverse
+flex-wrap: wrap
float: none
font-family: sans-serif
font-size: 12pt
@@ -9468,11 +9466,11 @@ z-index: auto
#reset
#tree
-| div*
+| div
+| p*
#ua
-div { }
-#user
-div { }
+div { flex-flow: row-reverse wrap-reverse; }
+p { flex-direction: inherit; flex-wrap: inherit; }
#errors
#expected:
align-content: stretch
@@ -9522,10 +9520,10 @@ direction: ltr
display: inline
empty-cells: show
flex-basis: auto
-flex-direction: row
+flex-direction: row-reverse
flex-grow: 0.000
flex-shrink: 1.000
-flex-wrap: nowrap
+flex-wrap: wrap-reverse
float: none
font-family: sans-serif
font-size: 12pt
@@ -9581,9 +9579,7 @@ z-index: auto
#tree
| div*
#ua
-div { }
-#user
-div { }
+div { justify-content: flex-start; }
#errors
#expected:
align-content: stretch
@@ -9692,9 +9688,7 @@ z-index: auto
#tree
| div*
#ua
-div { }
-#user
-div { }
+div { justify-content: flex-end; }
#errors
#expected:
align-content: stretch
@@ -9755,7 +9749,7 @@ font-style: normal
font-variant: normal
font-weight: normal
height: auto
-justify-content: flex-start
+justify-content: flex-end
left: auto
letter-spacing: normal
line-height: normal
@@ -9803,9 +9797,7 @@ z-index: auto
#tree
| div*
#ua
-div { }
-#user
-div { }
+div { justify-content: center; }
#errors
#expected:
align-content: stretch
@@ -9866,7 +9858,7 @@ font-style: normal
font-variant: normal
font-weight: normal
height: auto
-justify-content: flex-start
+justify-content: center
left: auto
letter-spacing: normal
line-height: normal
@@ -9914,9 +9906,7 @@ z-index: auto
#tree
| div*
#ua
-div { }
-#user
-div { }
+div { justify-content: space-between; }
#errors
#expected:
align-content: stretch
@@ -9977,7 +9967,7 @@ font-style: normal
font-variant: normal
font-weight: normal
height: auto
-justify-content: flex-start
+justify-content: space-between
left: auto
letter-spacing: normal
line-height: normal
@@ -10025,9 +10015,7 @@ z-index: auto
#tree
| div*
#ua
-div { }
-#user
-div { }
+div { justify-content: space-around; }
#errors
#expected:
align-content: stretch
@@ -10088,7 +10076,7 @@ font-style: normal
font-variant: normal
font-weight: normal
height: auto
-justify-content: flex-start
+justify-content: space-around
left: auto
letter-spacing: normal
line-height: normal
@@ -10136,9 +10124,7 @@ z-index: auto
#tree
| div*
#ua
-div { }
-#user
-div { }
+div { justify-content: space-evenly; }
#errors
#expected:
align-content: stretch
@@ -10199,7 +10185,7 @@ font-style: normal
font-variant: normal
font-weight: normal
height: auto
-justify-content: flex-start
+justify-content: space-evenly
left: auto
letter-spacing: normal
line-height: normal
@@ -10247,9 +10233,9 @@ z-index: auto
#tree
| div*
#ua
-div { }
+div { justify-content: space-around; }
#user
-div { }
+div { justify-content: space-evenly; }
#errors
#expected:
align-content: stretch
@@ -10310,7 +10296,7 @@ font-style: normal
font-variant: normal
font-weight: normal
height: auto
-justify-content: flex-start
+justify-content: space-evenly
left: auto
letter-spacing: normal
line-height: normal
@@ -10356,11 +10342,11 @@ z-index: auto
#reset
#tree
-| div*
+| div
+| p*
#ua
-div { }
-#user
-div { }
+div { justify-content: center; }
+p { justify-content: inherit; }
#errors
#expected:
align-content: stretch
@@ -10421,7 +10407,7 @@ font-style: normal
font-variant: normal
font-weight: normal
height: auto
-justify-content: flex-start
+justify-content: center
left: auto
letter-spacing: normal
line-height: normal
@@ -10469,9 +10455,7 @@ z-index: auto
#tree
| div*
#ua
-div { }
-#user
-div { }
+div { order: 0; }
#errors
#expected:
align-content: stretch
@@ -10580,9 +10564,7 @@ z-index: auto
#tree
| div*
#ua
-div { }
-#user
-div { }
+div { order: 5; }
#errors
#expected:
align-content: stretch
@@ -10659,7 +10641,7 @@ max-width: none
min-height: 0px
min-width: 0px
opacity: 1.000
-order: 0
+order: 5
outline-color: invert
outline-style: none
outline-width: 2px
@@ -10691,9 +10673,7 @@ z-index: auto
#tree
| div*
#ua
-div { }
-#user
-div { }
+div { order: -5; }
#errors
#expected:
align-content: stretch
@@ -10770,7 +10750,7 @@ max-width: none
min-height: 0px
min-width: 0px
opacity: 1.000
-order: 0
+order: -5
outline-color: invert
outline-style: none
outline-width: 2px
@@ -10800,11 +10780,11 @@ z-index: auto
#reset
#tree
-| div*
+| div
+| p*
#ua
-div { }
-#user
-div { }
+div { order: 7; }
+p { order: inherit; }
#errors
#expected:
align-content: stretch
@@ -10881,7 +10861,7 @@ max-width: none
min-height: 0px
min-width: 0px
opacity: 1.000
-order: 0
+order: 7
outline-color: invert
outline-style: none
outline-width: 2px