changeset 1779:7822a753c004

border-color: transparent
author corvid <corvid@lavabit.com>
date Tue, 14 Dec 2010 21:29:02 +0000
parents 2acc97e5de21
children faddcef45d5f
files src/cssparser.cc src/styleengine.cc
diffstat 2 files changed, 29 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/cssparser.cc	Mon Dec 13 07:18:45 2010 +0000
+++ b/src/cssparser.cc	Tue Dec 14 21:29:02 2010 +0000
@@ -51,6 +51,10 @@
    "separate", "collapse", NULL
 };
 
+static const char *const Css_border_color_enum_vals[] = {
+   "transparent", NULL
+};
+
 static const char *const Css_border_style_enum_vals[] = {
    "none", "hidden", "dotted", "dashed", "solid", "double", "groove",
    "ridge", "inset", "outset", NULL
@@ -136,25 +140,29 @@
    {"background-image", {CSS_TYPE_UNUSED}, NULL},
    {"background-position", {CSS_TYPE_UNUSED}, NULL},
    {"background-repeat", {CSS_TYPE_UNUSED}, NULL},
-   {"border-bottom-color", {CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, NULL},
+   {"border-bottom-color", {CSS_TYPE_ENUM, CSS_TYPE_COLOR, CSS_TYPE_UNUSED},
+    Css_border_color_enum_vals},
    {"border-bottom-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED},
     Css_border_style_enum_vals},
    {"border-bottom-width", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED},
     Css_border_width_enum_vals},
    {"border-collapse", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED},
     Css_border_collapse_enum_vals},
-   {"border-left-color", {CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, NULL},
+   {"border-left-color", {CSS_TYPE_ENUM, CSS_TYPE_COLOR, CSS_TYPE_UNUSED},
+    Css_border_color_enum_vals},
    {"border-left-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED},
     Css_border_style_enum_vals},
    {"border-left-width", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED},
     Css_border_width_enum_vals},
-   {"border-right-color", {CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, NULL},
+   {"border-right-color", {CSS_TYPE_ENUM, CSS_TYPE_COLOR, CSS_TYPE_UNUSED},
+    Css_border_color_enum_vals},
    {"border-right-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED},
     Css_border_style_enum_vals},
    {"border-rigth-width", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED},
     Css_border_width_enum_vals},
    {"border-spacing", {CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, NULL},
-   {"border-top-color", {CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, NULL},
+   {"border-top-color", {CSS_TYPE_ENUM, CSS_TYPE_COLOR, CSS_TYPE_UNUSED},
+    Css_border_color_enum_vals},
    {"border-top-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED},
     Css_border_style_enum_vals},
    {"border-top-width", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED},
--- a/src/styleengine.cc	Mon Dec 13 07:18:45 2010 +0000
+++ b/src/styleengine.cc	Tue Dec 14 21:29:02 2010 +0000
@@ -234,6 +234,10 @@
 
       attrs->valign = stack->getRef (stack->size () - 2)->style->valign;
    }
+   attrs->borderColor.top = (Color *) -1;
+   attrs->borderColor.bottom = (Color *) -1;
+   attrs->borderColor.left = (Color *) -1;
+   attrs->borderColor.right = (Color *) -1;
    /* initial value of border-width is 'medium' */
    attrs->borderWidth.top = 2;
    attrs->borderWidth.bottom = 2;
@@ -242,14 +246,14 @@
 }
 
 void StyleEngine::postprocessAttrs (dw::core::style::StyleAttrs *attrs) {
-   /* if border-color is not specified use color as computed value */
-   if (attrs->borderColor.top == NULL)
+   /* if border-color is not specified, use color as computed value */
+   if (attrs->borderColor.top == (Color *) -1)
       attrs->borderColor.top = attrs->color;
-   if (attrs->borderColor.bottom == NULL)
+   if (attrs->borderColor.bottom == (Color *) -1)
       attrs->borderColor.bottom = attrs->color;
-   if (attrs->borderColor.left == NULL)
+   if (attrs->borderColor.left == (Color *) -1)
       attrs->borderColor.left = attrs->color;
-   if (attrs->borderColor.right == NULL)
+   if (attrs->borderColor.right == (Color *) -1)
       attrs->borderColor.right = attrs->color;
    /* computed value of border-width is 0 if border-style
       is 'none' or 'hidden' */
@@ -438,20 +442,20 @@
             attrs->borderCollapse = (BorderCollapse) p->value.intVal;
             break;
          case CSS_PROPERTY_BORDER_TOP_COLOR:
-            attrs->borderColor.top =
-              Color::create (layout, p->value.intVal);
+            attrs->borderColor.top = (p->type == CSS_TYPE_ENUM) ? NULL :
+                                     Color::create (layout, p->value.intVal);
             break;
          case CSS_PROPERTY_BORDER_BOTTOM_COLOR:
-            attrs->borderColor.bottom =
-              Color::create (layout, p->value.intVal);
+            attrs->borderColor.bottom = (p->type == CSS_TYPE_ENUM) ? NULL :
+                                       Color::create (layout, p->value.intVal);
             break;
          case CSS_PROPERTY_BORDER_LEFT_COLOR:
-            attrs->borderColor.left =
-              Color::create (layout, p->value.intVal);
+            attrs->borderColor.left = (p->type == CSS_TYPE_ENUM) ? NULL :
+                                      Color::create (layout, p->value.intVal);
             break;
          case CSS_PROPERTY_BORDER_RIGHT_COLOR:
-            attrs->borderColor.right =
-              Color::create (layout, p->value.intVal);
+            attrs->borderColor.right = (p->type == CSS_TYPE_ENUM) ? NULL :
+                                       Color::create (layout, p->value.intVal);
             break;
          case CSS_PROPERTY_BORDER_BOTTOM_STYLE:
             attrs->borderStyle.bottom = (BorderStyle) p->value.intVal;