From 1b13f81b8259f4416df7b3063cb280cb977722d7 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 29 Jan 2011 17:53:22 +0000 Subject: Centralise handling of transparent colours. Add support for currentColor svn path=/trunk/libcss/; revision=11525 --- test/data/parse/colours.dat | 10 +- test/data/parse/properties.dat | 34 +++++- test/data/parse2/bg.dat | 24 ++++ test/data/parse2/border.dat | 38 ++++++ test/data/parse2/outline.dat | 20 ++++ test/data/select/tests1.dat | 262 +++++++++++++++++++++++++++-------------- test/dump.h | 17 +++ test/dump_computed.h | 33 ++---- 8 files changed, 322 insertions(+), 116 deletions(-) (limited to 'test') diff --git a/test/data/parse/colours.dat b/test/data/parse/colours.dat index 67d5427..0ca7a31 100644 --- a/test/data/parse/colours.dat +++ b/test/data/parse/colours.dat @@ -45,7 +45,15 @@ #errors #expected | 1 * -| 0x02000018 0x00000000 +| 0x00000018 +#reset + +#data +* { color: currentColor } +#errors +#expected +| 1 * +| 0x00040018 #reset ## Out-of-range rgb() parameters diff --git a/test/data/parse/properties.dat b/test/data/parse/properties.dat index ac038e5..29b5eb6 100644 --- a/test/data/parse/properties.dat +++ b/test/data/parse/properties.dat @@ -233,6 +233,14 @@ | 0x00000002 #reset +#data +* { background-color: currentColor } +#errors +#expected +| 1 * +| 0x00040002 +#reset + ## ## 03 - background-image ## @@ -493,6 +501,14 @@ | 0x0000000b #reset +#data +* { border-left-color: currentColor } +#errors +#expected +| 1 * +| 0x0004000b +#reset + ## ## 0c - border-top-style ## 0d - border-right-style @@ -2283,7 +2299,7 @@ p:before { content: open-quote url('http://picodrive.acornarcade.com/') " : " at #errors #expected | 1 * -| 0x00000039 +| 0x00080039 #reset #data @@ -2294,6 +2310,22 @@ p:before { content: open-quote url('http://picodrive.acornarcade.com/') " : " at | 0x02000039 0xffbbbbcc #reset +#data +* { outline-color: currentColor } +#errors +#expected +| 1 * +| 0x00040039 +#reset + +#data +* { outline-color: transparent } +#errors +#expected +| 1 * +| 0x00000039 +#reset + ## ## 3a - outline-style ## diff --git a/test/data/parse2/bg.dat b/test/data/parse2/bg.dat index 50c7340..0ad6444 100644 --- a/test/data/parse2/bg.dat +++ b/test/data/parse2/bg.dat @@ -10,6 +10,30 @@ | background-repeat: repeat #reset +#data +* { background: transparent } +#errors +#expected +| * +| background-attachment: scroll +| background-color: transparent +| background-image: none +| background-position: left top +| background-repeat: repeat +#reset + +#data +* { background: currentColor } +#errors +#expected +| * +| background-attachment: scroll +| background-color: currentColor +| background-image: none +| background-position: left top +| background-repeat: repeat +#reset + #data * { background: url("chess.png") gray 40% repeat fixed; } #errors diff --git a/test/data/parse2/border.dat b/test/data/parse2/border.dat index daecf3b..cd9ab13 100644 --- a/test/data/parse2/border.dat +++ b/test/data/parse2/border.dat @@ -36,6 +36,44 @@ | border-left-width: medium #reset +#data +* { border: transparent; } +#errors +#expected +| * +| border-top-color: transparent +| border-top-style: none +| border-top-width: medium +| border-right-color: transparent +| border-right-style: none +| border-right-width: medium +| border-bottom-color: transparent +| border-bottom-style: none +| border-bottom-width: medium +| border-left-color: transparent +| border-left-style: none +| border-left-width: medium +#reset + +#data +* { border: currentColor; } +#errors +#expected +| * +| border-top-color: currentColor +| border-top-style: none +| border-top-width: medium +| border-right-color: currentColor +| border-right-style: none +| border-right-width: medium +| border-bottom-color: currentColor +| border-bottom-style: none +| border-bottom-width: medium +| border-left-color: currentColor +| border-left-style: none +| border-left-width: medium +#reset + #data * { border: solid; } #errors diff --git a/test/data/parse2/outline.dat b/test/data/parse2/outline.dat index e39fa41..363b5d9 100644 --- a/test/data/parse2/outline.dat +++ b/test/data/parse2/outline.dat @@ -18,6 +18,26 @@ | outline-width: medium #reset +#data +* { outline: transparent; } +#errors +#expected +| * +| outline-color: transparent +| outline-style: none +| outline-width: medium +#reset + +#data +* { outline: currentColor; } +#errors +#expected +| * +| outline-color: currentColor +| outline-style: none +| outline-width: medium +#reset + #data * { outline: solid; } #errors diff --git a/test/data/select/tests1.dat b/test/data/select/tests1.dat index e25ac82..0e44641 100644 --- a/test/data/select/tests1.dat +++ b/test/data/select/tests1.dat @@ -14,15 +14,15 @@ div#foo { float: right; } #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none @@ -89,15 +89,15 @@ div p.green { float: left !important; } #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none @@ -164,15 +164,15 @@ div.moose > div + div { border-top-style: solid; } #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none @@ -238,15 +238,15 @@ div.moose > div + div { border-top-style: solid; } #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: solid border-right-style: none border-bottom-style: none @@ -304,7 +304,7 @@ div { display: inline; } #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat @@ -381,6 +381,90 @@ word-spacing: normal z-index: auto #reset +#tree all +| div* +#author +div { color: currentColor; } +#errors +#expected +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 +caption_side: top +clear: none +clip: auto +color: #ff000000 +content: normal +counter-increment: none +counter-reset: none +cursor: auto +direction: ltr +display: inline +empty-cells: show +float: none +font-family: sans-serif +font-size: 12pt +font-style: normal +font-variant: normal +font-weight: normal +height: auto +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 +outline-color: invert +outline-style: none +outline-width: 2px +overflow: 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 +z-index: auto +#reset + #tree all | div* #author @@ -479,10 +563,10 @@ background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none @@ -538,7 +622,7 @@ div { quotes: "a" "b" } #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat @@ -627,15 +711,15 @@ div p + p { background-attachment: fixed; } #errors #expected background-attachment: fixed -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none @@ -696,15 +780,15 @@ div p + p { background-attachment: fixed; } #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none @@ -766,15 +850,15 @@ div p + p { background-attachment: fixed; } #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none @@ -839,15 +923,15 @@ div p + p { background-image: url("Sonic_the_Hedgehog.png"); background-position #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: url('Sonic_the_Hedgehog.png') background-position: 100% 100% background-repeat: repeat-y border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none @@ -911,15 +995,15 @@ div p + p { background-image: url("Sonic_the_Hedgehog.png"); background-repeat: #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: url('Sonic_the_Hedgehog.png') background-position: 50% 20% background-repeat: repeat border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none @@ -989,15 +1073,15 @@ td,th {display:table-cell;} #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none @@ -1067,15 +1151,15 @@ td,th {display:table-cell;} #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none @@ -1145,15 +1229,15 @@ td,th {display:table-cell;} #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none @@ -1220,14 +1304,14 @@ tr {display:table-row;} td,th {display:table-cell;} #user #author -.hedgehog tr > td {border-color:transparent;} +.hedgehog tr > td {border-color:#00000000;} #sonic tr > td {border-top-color:#fff;border-right-color:#8040ff;border-bottom-color:black;border-left-color:rgb(255,0,255);} td,th {border-top-style: none;border-right-style: hidden;border-bottom-style: dotted;border-left-style: dashed} tr > td {border-top-width: thin;border-right-width: medium;border-bottom-width: thick;border-left-width: 2px;} #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat @@ -1302,21 +1386,21 @@ tr {display:table-row;} td,th {display:table-cell;} #user #author -.hedgehog tr > td {border-color:transparent;} +.hedgehog tr > td {border-color:#000000;} td,th {border-top-style: solid;border-right-style: double;border-bottom-style: groove;border-left-style: ridge} tr > td {border-top-width: 0;border-right-width: 2em;border-bottom-width: thick;border-left-width: -2px;} #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 0px 0px -border-top-color: transparent -border-right-color: transparent -border-bottom-color: transparent -border-left-color: transparent +border-top-color: #ff000000 +border-right-color: #ff000000 +border-bottom-color: #ff000000 +border-left-color: #ff000000 border-top-style: solid border-right-style: double border-bottom-style: groove @@ -1387,15 +1471,15 @@ td,th {display:table-cell;} #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 0px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: inset border-right-style: outset border-bottom-style: inset @@ -1465,15 +1549,15 @@ td,th {display:table-cell;} #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 2px 2px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none @@ -1543,15 +1627,15 @@ td,th {display:table-cell;} #errors #expected background-attachment: scroll -background-color: transparent +background-color: #00000000 background-image: none background-position: 0% 0% background-repeat: repeat border-spacing: 2px 0px -border-top-color: initial -border-right-color: initial -border-bottom-color: initial -border-left-color: initial +border-top-color: currentColor +border-right-color: currentColor +border-bottom-color: currentColor +border-left-color: currentColor border-top-style: none border-right-style: none border-bottom-style: none diff --git a/test/dump.h b/test/dump.h index 36f4278..b35832c 100644 --- a/test/dump.h +++ b/test/dump.h @@ -723,6 +723,8 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) case CSS_PROP_BACKGROUND_COLOR: assert(BACKGROUND_COLOR_TRANSPARENT == BORDER_COLOR_TRANSPARENT); + assert(BACKGROUND_COLOR_CURRENT_COLOR == + BORDER_COLOR_CURRENT_COLOR); assert(BACKGROUND_COLOR_SET == BORDER_COLOR_SET); @@ -730,6 +732,9 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) case BACKGROUND_COLOR_TRANSPARENT: *ptr += sprintf(*ptr, "transparent"); break; + case BACKGROUND_COLOR_CURRENT_COLOR: + *ptr += sprintf(*ptr, "currentColor"); + break; case BACKGROUND_COLOR_SET: { uint32_t colour = @@ -1076,6 +1081,12 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) break; case CSS_PROP_COLOR: switch (value) { + case COLOR_TRANSPARENT: + *ptr += sprintf(*ptr, "transparent"); + break; + case COLOR_CURRENT_COLOR: + *ptr += sprintf(*ptr, "currentColor"); + break; case COLOR_SET: { uint32_t colour = @@ -1706,6 +1717,12 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth) break; case CSS_PROP_OUTLINE_COLOR: switch (value) { + case OUTLINE_COLOR_TRANSPARENT: + *ptr += sprintf(*ptr, "transparent"); + break; + case OUTLINE_COLOR_CURRENT_COLOR: + *ptr += sprintf(*ptr, "currentColor"); + break; case OUTLINE_COLOR_SET: { uint32_t colour = diff --git a/test/dump_computed.h b/test/dump_computed.h index d6a45ba..c76b17b 100644 --- a/test/dump_computed.h +++ b/test/dump_computed.h @@ -172,9 +172,6 @@ static void dump_computed_style(const css_computed_style *style, char *buf, /* background-color */ val = css_computed_background_color(style, &color); switch (val) { - case CSS_BACKGROUND_COLOR_TRANSPARENT: - wrote = snprintf(ptr, *len, "background-color: transparent\n"); - break; case CSS_BACKGROUND_COLOR_COLOR: wrote = snprintf(ptr, *len, "background-color: #%08x\n", color); break; @@ -289,11 +286,8 @@ static void dump_computed_style(const css_computed_style *style, char *buf, /* border-top-color */ val = css_computed_border_top_color(style, &color); switch (val) { - case CSS_BORDER_COLOR_INITIAL: - wrote = snprintf(ptr, *len, "border-top-color: initial\n"); - break; - case CSS_BORDER_COLOR_TRANSPARENT: - wrote = snprintf(ptr, *len, "border-top-color: transparent\n"); + case CSS_BORDER_COLOR_CURRENT_COLOR: + wrote = snprintf(ptr, *len, "border-top-color: currentColor\n"); break; case CSS_BORDER_COLOR_COLOR: wrote = snprintf(ptr, *len, "border-top-color: #%08x\n", color); @@ -308,12 +302,8 @@ static void dump_computed_style(const css_computed_style *style, char *buf, /* border-right-color */ val = css_computed_border_right_color(style, &color); switch (val) { - case CSS_BORDER_COLOR_INITIAL: - wrote = snprintf(ptr, *len, "border-right-color: initial\n"); - break; - case CSS_BORDER_COLOR_TRANSPARENT: - wrote = snprintf(ptr, *len, - "border-right-color: transparent\n"); + case CSS_BORDER_COLOR_CURRENT_COLOR: + wrote = snprintf(ptr, *len, "border-right-color: currentColor\n"); break; case CSS_BORDER_COLOR_COLOR: wrote = snprintf(ptr, *len, @@ -329,12 +319,8 @@ static void dump_computed_style(const css_computed_style *style, char *buf, /* border-bottom-color */ val = css_computed_border_bottom_color(style, &color); switch (val) { - case CSS_BORDER_COLOR_INITIAL: - wrote = snprintf(ptr, *len, "border-bottom-color: initial\n"); - break; - case CSS_BORDER_COLOR_TRANSPARENT: - wrote = snprintf(ptr, *len, - "border-bottom-color: transparent\n"); + case CSS_BORDER_COLOR_CURRENT_COLOR: + wrote = snprintf(ptr, *len, "border-bottom-color: currentColor\n"); break; case CSS_BORDER_COLOR_COLOR: wrote = snprintf(ptr, *len, @@ -350,11 +336,8 @@ static void dump_computed_style(const css_computed_style *style, char *buf, /* border-left-color */ val = css_computed_border_left_color(style, &color); switch (val) { - case CSS_BORDER_COLOR_INITIAL: - wrote = snprintf(ptr, *len, "border-left-color: initial\n"); - break; - case CSS_BORDER_COLOR_TRANSPARENT: - wrote = snprintf(ptr, *len, "border-left-color: transparent\n"); + case CSS_BORDER_COLOR_CURRENT_COLOR: + wrote = snprintf(ptr, *len, "border-left-color: currentColor\n"); break; case CSS_BORDER_COLOR_COLOR: wrote = snprintf(ptr, *len, -- cgit v1.2.3