summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Neves <lcneves@gmail.com>2017-08-31 21:19:01 (GMT)
committer Lucas Neves <lcneves@gmail.com>2017-09-26 02:00:25 (GMT)
commitfa30e183c9ccf52ac8300a659466f5a438936630 (patch)
treea78882e47725890dff32bf53716f68890e4149ae
parent0990b37aa1f6d753a03178309391118e645c08d0 (diff)
downloadlibcss-fa30e183c9ccf52ac8300a659466f5a438936630.tar.gz
libcss-fa30e183c9ccf52ac8300a659466f5a438936630.tar.bz2
Several bug fixes
Select: fixes order of dispatch methods
-rw-r--r--src/parse/properties/Makefile2
-rw-r--r--src/parse/properties/flex.c36
-rw-r--r--src/parse/properties/flex_flow.c132
-rw-r--r--src/parse/properties/properties.gen2
-rw-r--r--src/parse/propstrings.c1
-rw-r--r--src/parse/propstrings.h6
-rw-r--r--src/select/dispatch.c100
7 files changed, 81 insertions, 198 deletions
diff --git a/src/parse/properties/Makefile b/src/parse/properties/Makefile
index b3ce886..6461dda 100644
--- a/src/parse/properties/Makefile
+++ b/src/parse/properties/Makefile
@@ -46,7 +46,7 @@ DIR_SOURCES := \
cursor.c \
elevation.c \
flex.c \
- flex-flow.c \
+ flex_flow.c \
font.c \
font_family.c \
font_weight.c \
diff --git a/src/parse/properties/flex.c b/src/parse/properties/flex.c
index 54c4560..9b590ed 100644
--- a/src/parse/properties/flex.c
+++ b/src/parse/properties/flex.c
@@ -28,9 +28,16 @@
* If the input is invalid, then \a *ctx remains unchanged.
*/
-css_error css__parse_flex_basis(css_language *c,
+css_error flex_grow_helper(const css_token *token, css_fixed *number);
+css_error flex_basis_helper(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_fixed *basis_length, css_fixed *basis_unit,
+ css_fixed *basis_length, uint32_t *basis_unit,
+ opcode_t *basis_op);
+
+
+css_error flex_basis_helper(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_fixed *basis_length, uint32_t *basis_unit,
opcode_t *basis_op)
{
css_error error;
@@ -49,7 +56,7 @@ css_error css__parse_flex_basis(css_language *c,
return error;
}
-css_error css__parse_flex_grow(const css_token *token, css_fixed *number)
+css_error flex_grow_helper(const css_token *token, css_fixed *number)
{
if (token->type != CSS_TOKEN_NUMBER)
return CSS_INVALID;
@@ -116,7 +123,10 @@ css_error css__parse_flex(css_language *c,
/* Attempt to parse the various longhand properties */
*ctx = orig_ctx;
size_t length;
- parserutils_vector_get_length(vector, &length);
+
+ /* Method parserutils_vector_get_length not expecting const */
+ parserutils_vector *vec = (parserutils_vector *) vector;
+ parserutils_vector_get_length(vec, &length);
switch (length) {
case 1:
@@ -152,7 +162,7 @@ css_error css__parse_flex(css_language *c,
/* Token must be either flex-basis or flex-grow */
else {
*ctx = orig_ctx;
- error = css__parse_flex_basis(c, vector, ctx,
+ error = flex_basis_helper(c, vector, ctx,
&basis_length, &basis_unit,
&basis_op);
@@ -161,7 +171,7 @@ css_error css__parse_flex(css_language *c,
* flex: <positive number> 1 0; */
*ctx = orig_ctx;
token = parserutils_vector_iterate(vector, ctx);
- error = css__parse_flex_grow(
+ error = flex_grow_helper(
token, &grow_number);
if (error != CSS_OK) {
*ctx = orig_ctx;
@@ -175,7 +185,7 @@ css_error css__parse_flex(css_language *c,
case 2:
/* First value must be flex-grow */
token = parserutils_vector_iterate(vector, ctx);
- error = css__parse_flex_grow(
+ error = flex_grow_helper(
token, &grow_number);
if (error != CSS_OK) {
*ctx = orig_ctx;
@@ -184,7 +194,7 @@ css_error css__parse_flex(css_language *c,
/* Second value must be either flex-basis or flex-shrink */
int prev_ctx = *ctx;
- error = css__parse_flex_basis(c, vector, ctx,
+ error = flex_basis_helper(c, vector, ctx,
&basis_length, &basis_unit, &basis_op);
if (error != CSS_OK) {
@@ -192,7 +202,7 @@ css_error css__parse_flex(css_language *c,
* flex: <number_1> <number_2> 0; */
*ctx = prev_ctx;
token = parserutils_vector_iterate(vector, ctx);
- error = css__parse_flex_grow(
+ error = flex_grow_helper(
token, &shrink_number);
if (error != CSS_OK) {
*ctx = orig_ctx;
@@ -205,7 +215,7 @@ css_error css__parse_flex(css_language *c,
case 3:
/* First value must be flex-grow */
token = parserutils_vector_iterate(vector, ctx);
- error = css__parse_flex_grow(
+ error = flex_grow_helper(
token, &grow_number);
if (error != CSS_OK) {
*ctx = orig_ctx;
@@ -214,7 +224,7 @@ css_error css__parse_flex(css_language *c,
/* Second value must be flex-shrink */
token = parserutils_vector_iterate(vector, ctx);
- error = css__parse_flex_grow(
+ error = flex_grow_helper(
token, &shrink_number);
if (error != CSS_OK) {
*ctx = orig_ctx;
@@ -222,7 +232,7 @@ css_error css__parse_flex(css_language *c,
}
/* Third value must be flex-basis */
- error = css__parse_flex_basis(c, vector, ctx,
+ error = flex_basis_helper(c, vector, ctx,
&basis_length, &basis_unit, &basis_op);
if (error != CSS_OK) {
*ctx = orig_ctx;
@@ -279,7 +289,7 @@ css_error css__parse_flex(css_language *c,
if (error != CSS_OK)
goto css__parse_flex_flow_cleanup;
- if (basis_op == FLEX_BASIS_SET) {
+ if (basis_op == (opcode_t) FLEX_BASIS_SET) {
error = css__stylesheet_style_append(basis_style, basis_length);
if (error != CSS_OK)
goto css__parse_flex_flow_cleanup;
diff --git a/src/parse/properties/flex_flow.c b/src/parse/properties/flex_flow.c
index 843b186..b2d0bdc 100644
--- a/src/parse/properties/flex_flow.c
+++ b/src/parse/properties/flex_flow.c
@@ -28,134 +28,6 @@
* If the input is invalid, then \a *ctx remains unchanged.
*/
-css_error css__parse_flex_flow_direction_value(
- css_language *c, const css_token *ident, uint16_t *value)
-{
- bool match;
-
- /* IDENT (row, column, row-reverse, column-reverse) */
- if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[ROW],
- &match) == lwc_error_ok && match)) {
- *value = FLEX_DIRECTION_ROW;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[COLUMN],
- &match) == lwc_error_ok && match)) {
- *value = FLEX_DIRECTION_COLUMN;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[ROW_REVERSE],
- &match) == lwc_error_ok && match)) {
- *value = FLEX_DIRECTION_ROW_REVERSE;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[COLUMN_REVERSE],
- &match) == lwc_error_ok && match)) {
- *value = FLEX_DIRECTION_COLUMN_REVERSE;
- } else
- return CSS_INVALID;
-
- return CSS_OK;
-}
-
-css_error css__parse_flex_flow_wrap_value(
- css_language *c, const css_token *ident, uint16_t *value)
-{
- bool match;
-
- /* IDENT (nowrap, wrap, wrap-reverse) */
- if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[NOWRAP],
- &match) == lwc_error_ok && match)) {
- *value = FLEX_WRAP_NOWRAP;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[WRAP],
- &match) == lwc_error_ok && match)) {
- *value = FLEX_WRAP_WRAP;
- } else if ((lwc_string_caseless_isequal(
- ident->idata, c->strings[WRAP_REVERSE],
- &match) == lwc_error_ok && match)) {
- *value = FLEX_DIRECTION_WRAP_REVERSE;
- } else
- return CSS_INVALID;
-
- return CSS_OK;
-}
-
-css_error css__parse_flex_flow_direction(css_language *c,
- const parserutils_vector *vector, int *ctx,
- css_style *result)
-{
- int orig_ctx = *ctx;
- css_error error;
- const css_token *ident;
- uint8_t flags = 0;
- uint16_t value = 0;
- bool match;
-
- ident = parserutils_vector_iterate(vector, ctx);
- if (ident == NULL || ident->type != CSS_TOKEN_IDENT) {
- *ctx = orig_ctx;
- return CSS_INVALID;
- }
-
- if ((lwc_string_caseless_isequal(
- ident->idata, c->[INHERIT],
- &match) == lwc_error_ok && match)) {
- flags |= FLAG_INHERIT
- } else {
- error = css__parse_flex_flow_direction_value(c, ident, &value);
- if (error != CSS_OK) {
- *ctx = orig_ctx;
- return error;
- }
- }
-
- error = css__stylesheet_style_appendOPV(result, CSS_PROP_FLEX_DIRECTION,
- flags, value);
-
- if (error != CSS_OK)
- *ctx = orig_ctx;
-
- return error;
-}
-
-css_error css__parse_flex_flow_wrap(css_language *c,
- const parserutils_vector *vector, int *ctx,
- css_style *result)
-{
- int orig_ctx = *ctx;
- css_error error;
- const css_token *ident;
- uint8_t flags = 0;
- uint16_t value = 0;
- bool match;
-
- ident = parserutils_vector_iterate(vector, ctx);
- if (ident == NULL || ident->type != CSS_TOKEN_IDENT) {
- *ctx = orig_ctx;
- return CSS_INVALID;
- }
-
- if ((lwc_string_caseless_isequal(
- ident->idata, c->[INHERIT],
- &match) == lwc_error_ok && match)) {
- flags |= FLAG_INHERIT
- } else {
- error = css__parse_flex_flow_wrap_value(c, ident, &value);
- if (error != CSS_OK) {
- *ctx = orig_ctx;
- return error;
- }
- }
-
- error = css__stylesheet_style_appendOPV(result, CSS_PROP_FLEX_WRAP,
- flags, value);
-
- if (error != CSS_OK)
- *ctx = orig_ctx;
-
- return error;
-}
-
css_error css__parse_flex_flow(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result)
@@ -213,11 +85,11 @@ css_error css__parse_flex_flow(css_language *c,
}
if ((wrap) &&
- (error = css__parse_flex_flow_wrap(c, vector,
+ (error = css__parse_flex_wrap(c, vector,
ctx, wrap_style)) == CSS_OK) {
wrap = false;
} else if ((direction) &&
- (error = css__parse_flex_flow_direction(c, vector,
+ (error = css__parse_flex_direction(c, vector,
ctx, direction_style)) == CSS_OK) {
direction = false;
}
diff --git a/src/parse/properties/properties.gen b/src/parse/properties/properties.gen
index e9167c8..c640a23 100644
--- a/src/parse/properties/properties.gen
+++ b/src/parse/properties/properties.gen
@@ -232,7 +232,7 @@ flex_grow:CSS_PROP_FLEX_GROW IDENT:INHERIT NUMBER:( true:FLEX_GROW_SET RANGE:num
flex_shrink:CSS_PROP_FLEX_SHRINK IDENT:INHERIT NUMBER:( true:FLEX_SHRINK_SET RANGE:num<0 NUMBER:)
-flex_wrap:CSS_PROP_FLEX_WRAP IDENT:( INHERIT: NOWRAP:0,FLEX_WRAP_NOWRAP WRAP:0,FLEX_WRAP_WRAP WRAP_REVERSE:0,FLEX_WRAP_WRAP_REVERSE IDENT:)
+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:)
diff --git a/src/parse/propstrings.c b/src/parse/propstrings.c
index f698f06..bfd2965 100644
--- a/src/parse/propstrings.c
+++ b/src/parse/propstrings.c
@@ -428,6 +428,7 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "content-box", SLEN("content-box") },
{ "border-box", SLEN("border-box") },
{ "stretch", SLEN("stretch") },
+ { "inline-flex", SLEN("inline-flex") },
{ "flex-start", SLEN("flex-start") },
{ "flex-end", SLEN("flex-end") },
{ "space-between", SLEN("space-between") },
diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h
index 1c07c13..67eaa5f 100644
--- a/src/parse/propstrings.h
+++ b/src/parse/propstrings.h
@@ -99,9 +99,9 @@ enum {
LIBCSS_RIGHT, CURRENTCOLOR, ODD, EVEN, SRC, LOCAL, INITIAL,
FORMAT, WOFF, TRUETYPE, OPENTYPE, EMBEDDED_OPENTYPE, SVG, COLUMN,
AVOID_PAGE, AVOID_COLUMN, BALANCE, HORIZONTAL_TB, VERTICAL_RL,
- VERTICAL_LR, CONTENT_BOX, BORDER_BOX, STRETCH, FLEX_START, FLEX_END,
- SPACE_BETWEEN, SPACE_AROUND, SPACE_EVENLY, ROW, ROW_REVERSE,
- COLUMN_REVERSE, WRAP, WRAP_REVERSE
+ VERTICAL_LR, CONTENT_BOX, BORDER_BOX, STRETCH, INLINE_FLEX, FLEX_START,
+ FLEX_END, SPACE_BETWEEN, SPACE_AROUND, SPACE_EVENLY, ROW, ROW_REVERSE,
+ COLUMN_REVERSE, WRAP_STRING, WRAP_REVERSE,
/* Named colours */
FIRST_COLOUR,
diff --git a/src/select/dispatch.c b/src/select/dispatch.c
index a65afbc..ab36cff 100644
--- a/src/select/dispatch.c
+++ b/src/select/dispatch.c
@@ -19,21 +19,6 @@
struct prop_table prop_dispatch[CSS_N_PROPERTIES] = {
{
- PROPERTY_FUNCS(align_content),
- 0,
- GROUP_NORMAL
- },
- {
- PROPERTY_FUNCS(align_items),
- 0,
- GROUP_NORMAL
- },
- {
- PROPERTY_FUNCS(align_self),
- 0,
- GROUP_NORMAL
- },
- {
PROPERTY_FUNCS(azimuth),
1,
GROUP_AURAL
@@ -209,31 +194,6 @@ struct prop_table prop_dispatch[CSS_N_PROPERTIES] = {
GROUP_NORMAL
},
{
- PROPERTY_FUNCS(flex_basis),
- 0,
- GROUP_NORMAL
- },
- {
- PROPERTY_FUNCS(flex_direction),
- 0,
- GROUP_NORMAL
- },
- {
- PROPERTY_FUNCS(flex_grow),
- 0,
- GROUP_NORMAL
- },
- {
- PROPERTY_FUNCS(flex_shrink),
- 0,
- GROUP_NORMAL
- },
- {
- PROPERTY_FUNCS(flex_wrap),
- 0,
- GROUP_NORMAL
- },
- {
PROPERTY_FUNCS(float),
0,
GROUP_NORMAL
@@ -269,11 +229,6 @@ struct prop_table prop_dispatch[CSS_N_PROPERTIES] = {
GROUP_NORMAL
},
{
- PROPERTY_FUNCS(justify_content),
- 0,
- GROUP_NORMAL
- },
- {
PROPERTY_FUNCS(left),
0,
GROUP_NORMAL
@@ -344,11 +299,6 @@ struct prop_table prop_dispatch[CSS_N_PROPERTIES] = {
GROUP_NORMAL
},
{
- PROPERTY_FUNCS(order),
- 0,
- GROUP_NORMAL
- },
- {
PROPERTY_FUNCS(orphans),
1,
GROUP_PAGE
@@ -637,5 +587,55 @@ struct prop_table prop_dispatch[CSS_N_PROPERTIES] = {
PROPERTY_FUNCS(box_sizing),
0,
GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(align_content),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(align_items),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(align_self),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(flex_basis),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(flex_direction),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(flex_grow),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(flex_shrink),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(flex_wrap),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(justify_content),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(order),
+ 0,
+ GROUP_NORMAL
}
};