summaryrefslogtreecommitdiff
path: root/source/html/css-apply.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2014-11-18 14:22:39 +0100
committerTor Andersson <tor.andersson@artifex.com>2014-12-03 12:25:52 +0100
commitd88d131bae7d516b1b8ad9c94706d0813bbb1497 (patch)
tree8db58cf62e02b938062e1a6e72216a497f16d283 /source/html/css-apply.c
parent3ba9c348795b3923ff65e917c23b454470698489 (diff)
downloadmupdf-d88d131bae7d516b1b8ad9c94706d0813bbb1497.tar.xz
html: Border shorthand css parsing.
Diffstat (limited to 'source/html/css-apply.c')
-rw-r--r--source/html/css-apply.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/source/html/css-apply.c b/source/html/css-apply.c
index d642d98c..eecb8111 100644
--- a/source/html/css-apply.c
+++ b/source/html/css-apply.c
@@ -381,6 +381,19 @@ match_selector(struct selector *sel, fz_xml *node)
* Annotating nodes with properties and expanding shorthand forms.
*/
+static const char *border_width_kw[] = {
+ "thin", "medium", "thick",
+};
+
+static const char *border_style_kw[] = {
+ "none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset",
+};
+
+static const char *color_kw[] = {
+ "transparent", "maroon", "red", "orange", "yellow", "olive", "purple", "fuchsia", "white",
+ "lime", "green", "navy", "blue", "aqua", "teal", "black", "silver", "gray",
+};
+
static int
count_values(struct value *value)
{
@@ -546,6 +559,54 @@ add_shorthand_border_width(struct style *style, struct value *value, int spec)
static void
add_shorthand_border(struct style *style, struct value *value, int spec)
{
+ int i;
+
+ while (value)
+ {
+ if (value->type == CSS_COLOR)
+ {
+ add_property(style, "border-color", value, spec);
+ }
+ else if (value->type == CSS_KEYWORD)
+ {
+ for (i = 0; i < nelem(border_width_kw); ++i)
+ {
+ if (!strcmp(value->data, border_width_kw[i]))
+ {
+ add_property(style, "border-width-top", value, spec);
+ add_property(style, "border-width-right", value, spec);
+ add_property(style, "border-width-bottom", value, spec);
+ add_property(style, "border-width-left", value, spec);
+ goto next;
+ }
+ }
+ for (i = 0; i < nelem(border_style_kw); ++i)
+ {
+ if (!strcmp(value->data, border_style_kw[i]))
+ {
+ add_property(style, "border-style", value, spec);
+ goto next;
+ }
+ }
+ for (i = 0; i < nelem(color_kw); ++i)
+ {
+ if (!strcmp(value->data, color_kw[i]))
+ {
+ add_property(style, "border-color", value, spec);
+ goto next;
+ }
+ }
+ }
+ else
+ {
+ add_property(style, "border-width-top", value, spec);
+ add_property(style, "border-width-right", value, spec);
+ add_property(style, "border-width-bottom", value, spec);
+ add_property(style, "border-width-left", value, spec);
+ }
+next:
+ value = value->next;
+ }
}
static void