summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Neves <lcneves@gmail.com>2017-09-18 23:43:39 (GMT)
committer Lucas Neves <lcneves@gmail.com>2017-09-26 02:01:56 (GMT)
commit161f7044bd198397fd1a8fa61e0bf0a11e6e43a4 (patch)
tree0193ce2c2841bec71ca7a097a9ec5181c2a47730
parentdf4542814b4d217f31768d007b7fb513dc9c46ac (diff)
downloadlibcss-161f7044bd198397fd1a8fa61e0bf0a11e6e43a4.tar.gz
libcss-161f7044bd198397fd1a8fa61e0bf0a11e6e43a4.tar.bz2
Fixes flex-grow propget index
-rw-r--r--src/parse/properties/flex.c24
-rw-r--r--src/select/propget.h2
-rw-r--r--test/data/select/tests1.dat273
3 files changed, 266 insertions, 33 deletions
diff --git a/src/parse/properties/flex.c b/src/parse/properties/flex.c
index dfec5bf..2442507 100644
--- a/src/parse/properties/flex.c
+++ b/src/parse/properties/flex.c
@@ -51,12 +51,12 @@ css_error css__parse_flex(css_language *c,
if (is_css_inherit(c, token)) {
error = css_stylesheet_style_inherit(result,
- CSS_PROP_FLEX_SHRINK);
+ CSS_PROP_FLEX_GROW);
if (error != CSS_OK)
return error;
error = css_stylesheet_style_inherit(result,
- CSS_PROP_FLEX_GROW);
+ CSS_PROP_FLEX_SHRINK);
if (error != CSS_OK)
return error;
@@ -211,10 +211,26 @@ css_error css__parse_flex(css_language *c,
}
if (basis) {
- error = css__stylesheet_style_appendOPV(basis_style,
- CSS_PROP_FLEX_BASIS, 0, FLEX_BASIS_AUTO);
+ /* Default is auto, but zero if grow or shrink are set */
+ if (!grow || !shrink) {
+ error = css__stylesheet_style_appendOPV(basis_style,
+ CSS_PROP_FLEX_BASIS, 0,
+ FLEX_BASIS_SET);
+ if (error != CSS_OK)
+ goto css__parse_flex_cleanup;
+
+ error = css__stylesheet_style_vappend(
+ basis_style, 2, 0, UNIT_PX);
if (error != CSS_OK)
goto css__parse_flex_cleanup;
+
+ } else {
+ error = css__stylesheet_style_appendOPV(basis_style,
+ CSS_PROP_FLEX_BASIS, 0,
+ FLEX_BASIS_AUTO);
+ if (error != CSS_OK)
+ goto css__parse_flex_cleanup;
+ }
}
error = css__stylesheet_merge_style(result, grow_style);
diff --git a/src/select/propget.h b/src/select/propget.h
index d5370a1..0621ec1 100644
--- a/src/select/propget.h
+++ b/src/select/propget.h
@@ -2281,7 +2281,7 @@ static inline uint8_t get_flex_shrink(
#undef FLEX_SHRINK_SHIFT
#undef FLEX_SHRINK_INDEX
-#define FLEX_GROW_INDEX 21
+#define FLEX_GROW_INDEX 20
#define FLEX_GROW_SHIFT 0
#define FLEX_GROW_MASK 0x1
static inline uint8_t get_flex_grow(
diff --git a/test/data/select/tests1.dat b/test/data/select/tests1.dat
index a8b527d..b58d25a 100644
--- a/test/data/select/tests1.dat
+++ b/test/data/select/tests1.dat
@@ -7164,7 +7164,7 @@ z-index: auto
#tree
| div*
#ua
-div { flex: none }
+div { flex: none; }
#user
#errors
#expected:
@@ -7274,7 +7274,7 @@ z-index: auto
#tree
| div*
#ua
-div { flex: 0 }
+div { flex: 0; }
#user
#errors
#expected:
@@ -7324,7 +7324,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: 1.000
@@ -7384,7 +7384,7 @@ z-index: auto
#tree
| div*
#ua
-div { flex: 3 }
+div { flex: 3; }
#user
#errors
#expected:
@@ -7434,7 +7434,7 @@ cursor: auto
direction: ltr
display: inline
empty-cells: show
-flex-basis: auto
+flex-basis: 0px
flex-direction: row
flex-grow: 3.000
flex-shrink: 1.000
@@ -7494,9 +7494,7 @@ z-index: auto
#tree
| div*
#ua
-div { flex: 3px }
-#user
-div { }
+div { flex: 3px; }
#errors
#expected:
align-content: stretch
@@ -7714,9 +7712,7 @@ z-index: auto
#tree
| div*
#ua
-div { }
-#user
-div { }
+div { flex: 20 30; }
#errors
#expected:
align-content: stretch
@@ -7765,10 +7761,10 @@ cursor: auto
direction: ltr
display: inline
empty-cells: show
-flex-basis: auto
+flex-basis: 0px
flex-direction: row
-flex-grow: 0.000
-flex-shrink: 1.000
+flex-grow: 20.000
+flex-shrink: 30.000
flex-wrap: nowrap
float: none
font-family: sans-serif
@@ -7825,9 +7821,9 @@ z-index: auto
#tree
| div*
#ua
-div { }
+div { flex: 2 2 2px; }
#user
-div { }
+div { flex: 3 3; }
#errors
#expected:
align-content: stretch
@@ -7876,10 +7872,10 @@ cursor: auto
direction: ltr
display: inline
empty-cells: show
-flex-basis: auto
+flex-basis: 0px
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
@@ -7936,9 +7932,9 @@ z-index: auto
#tree
| div*
#ua
-div { }
+div { flex: 2 2 2px; }
#user
-div { }
+div { flex-grow: 3; flex-shrink: 3; flex-basis: 3px; }
#errors
#expected:
align-content: stretch
@@ -7987,10 +7983,10 @@ cursor: auto
direction: ltr
display: inline
empty-cells: show
-flex-basis: auto
+flex-basis: 3px
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
@@ -8047,9 +8043,9 @@ z-index: auto
#tree
| div*
#ua
-div { }
+div { flex-grow: 2; flex-basis: 20rem; }
#user
-div { }
+div { flex: none; }
#errors
#expected:
align-content: stretch
@@ -8101,7 +8097,229 @@ empty-cells: show
flex-basis: auto
flex-direction: row
flex-grow: 0.000
-flex-shrink: 1.000
+flex-shrink: 0.000
+flex-wrap: nowrap
+float: none
+font-family: sans-serif
+font-size: 12pt
+font-style: normal
+font-variant: normal
+font-weight: normal
+height: auto
+justify-content: flex-start
+left: auto
+letter-spacing: normal
+line-height: normal
+list-style-image: none
+list-style-position: outside
+list-style-type: disc
+margin-top: 0px
+margin-right: 0px
+margin-bottom: 0px
+margin-left: 0px
+max-height: none
+max-width: none
+min-height: 0px
+min-width: 0px
+opacity: 1.000
+order: 0
+outline-color: invert
+outline-style: none
+outline-width: 2px
+overflow-x: visible
+overflow-y: visible
+padding-top: 0px
+padding-right: 0px
+padding-bottom: 0px
+padding-left: 0px
+position: static
+quotes: none
+right: auto
+table-layout: auto
+text-align: default
+text-decoration: none
+text-indent: 0px
+text-transform: none
+top: auto
+unicode-bidi: normal
+vertical-align: baseline
+visibility: visible
+white-space: normal
+width: auto
+word-spacing: normal
+writing-mode: horizontal-tb
+z-index: auto
+#reset
+
+#tree
+| div*
+| p
+#ua
+div { flex: 3 3 3%; }
+p { flex: inherit; }
+#errors
+#expected:
+align-content: stretch
+align-items: stretch
+align-self: auto
+background-attachment: scroll
+background-color: #00000000
+background-image: none
+background-position: 0% 0%
+background-repeat: repeat
+border-collapse: separate
+border-spacing: 0px 0px
+border-top-color: #ff000000
+border-right-color: #ff000000
+border-bottom-color: #ff000000
+border-left-color: #ff000000
+border-top-style: none
+border-right-style: none
+border-bottom-style: none
+border-left-style: none
+border-top-width: 2px
+border-right-width: 2px
+border-bottom-width: 2px
+border-left-width: 2px
+bottom: auto
+box-sizing: content-box
+break-after: auto
+break-before: auto
+break-inside: auto
+caption-side: top
+clear: none
+clip: auto
+color: #ff000000
+column-count: auto
+column-fill: balance
+column-gap: normal
+column-rule-color: #ff000000
+column-rule-style: none
+column-rule-width: 2px
+column-span: none
+column-width: auto
+content: normal
+counter-increment: none
+counter-reset: none
+cursor: auto
+direction: ltr
+display: inline
+empty-cells: show
+flex-basis: 3%
+flex-direction: row
+flex-grow: 3.000
+flex-shrink: 3.000
+flex-wrap: nowrap
+float: none
+font-family: sans-serif
+font-size: 12pt
+font-style: normal
+font-variant: normal
+font-weight: normal
+height: auto
+justify-content: flex-start
+left: auto
+letter-spacing: normal
+line-height: normal
+list-style-image: none
+list-style-position: outside
+list-style-type: disc
+margin-top: 0px
+margin-right: 0px
+margin-bottom: 0px
+margin-left: 0px
+max-height: none
+max-width: none
+min-height: 0px
+min-width: 0px
+opacity: 1.000
+order: 0
+outline-color: invert
+outline-style: none
+outline-width: 2px
+overflow-x: visible
+overflow-y: visible
+padding-top: 0px
+padding-right: 0px
+padding-bottom: 0px
+padding-left: 0px
+position: static
+quotes: none
+right: auto
+table-layout: auto
+text-align: default
+text-decoration: none
+text-indent: 0px
+text-transform: none
+top: auto
+unicode-bidi: normal
+vertical-align: baseline
+visibility: visible
+white-space: normal
+width: auto
+word-spacing: normal
+writing-mode: horizontal-tb
+z-index: auto
+#reset
+
+#tree
+| div
+| p*
+#ua
+div { flex: 3 3 3%; }
+p { flex: inherit; }
+#errors
+#expected:
+align-content: stretch
+align-items: stretch
+align-self: auto
+background-attachment: scroll
+background-color: #00000000
+background-image: none
+background-position: 0% 0%
+background-repeat: repeat
+border-collapse: separate
+border-spacing: 0px 0px
+border-top-color: #ff000000
+border-right-color: #ff000000
+border-bottom-color: #ff000000
+border-left-color: #ff000000
+border-top-style: none
+border-right-style: none
+border-bottom-style: none
+border-left-style: none
+border-top-width: 2px
+border-right-width: 2px
+border-bottom-width: 2px
+border-left-width: 2px
+bottom: auto
+box-sizing: content-box
+break-after: auto
+break-before: auto
+break-inside: auto
+caption-side: top
+clear: none
+clip: auto
+color: #ff000000
+column-count: auto
+column-fill: balance
+column-gap: normal
+column-rule-color: #ff000000
+column-rule-style: none
+column-rule-width: 2px
+column-span: none
+column-width: auto
+content: normal
+counter-increment: none
+counter-reset: none
+cursor: auto
+direction: ltr
+display: inline
+empty-cells: show
+flex-basis: 3%
+flex-direction: row
+flex-grow: 3.000
+flex-shrink: 3.000
flex-wrap: nowrap
float: none
font-family: sans-serif
@@ -8931,4 +9149,3 @@ word-spacing: normal
writing-mode: horizontal-tb
z-index: auto
#reset
-