aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-12-18 22:23:30 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-12-18 22:23:30 +0100
commited284d8d579e2ac580d81e1977cd8aa9bea5b1e4 (patch)
treefc1776fa844019c31518267352d42772994d319d /src
parent83c0cf6af8df3d6603d05dca469ff86102349f48 (diff)
support border-width: thin | medium | thick
Diffstat (limited to 'src')
-rw-r--r--src/css.hh6
-rw-r--r--src/cssparser.cc16
-rw-r--r--src/styleengine.cc33
-rw-r--r--src/styleengine.hh2
4 files changed, 45 insertions, 12 deletions
diff --git a/src/css.hh b/src/css.hh
index 79ba302b..e4041445 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -230,6 +230,12 @@ typedef union {
} CssPropertyValue;
typedef enum {
+ CSS_BORDER_WIDTH_THIN,
+ CSS_BORDER_WIDTH_MEDIUM,
+ CSS_BORDER_WIDTH_THICK,
+} CssBorderWidthExtensions;
+
+typedef enum {
CSS_FONT_WEIGHT_BOLD,
CSS_FONT_WEIGHT_BOLDER,
CSS_FONT_WEIGHT_LIGHT,
diff --git a/src/cssparser.cc b/src/cssparser.cc
index 5f5bde08..3a22da9a 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -52,6 +52,10 @@ static const char *const Css_border_style_enum_vals[] = {
"ridge", "inset", "outset", NULL
};
+static const char *const Css_border_width_enum_vals[] = {
+ "thin", "medium", "thick", NULL
+};
+
static const char *const Css_cursor_enum_vals[] = {
"crosshair", "default", "pointer", "move", "e-resize", "ne-resize",
"nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize",
@@ -118,21 +122,25 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = {
{"border-bottom-color", {CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, NULL},
{"border-bottom-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED},
Css_border_style_enum_vals},
- {"border-bottom-width", {CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, NULL},
+ {"border-bottom-width", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED},
+ Css_border_width_enum_vals},
{"border-collapse", {CSS_TYPE_UNUSED}, NULL},
{"border-left-color", {CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, NULL},
{"border-left-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED},
Css_border_style_enum_vals},
- {"border-left-width", {CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, NULL},
+ {"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-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED},
Css_border_style_enum_vals},
- {"border-right-width", {CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, NULL},
+ {"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-style", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED},
Css_border_style_enum_vals},
- {"border-top-width", {CSS_TYPE_LENGTH, CSS_TYPE_UNUSED}, NULL},
+ {"border-top-width", {CSS_TYPE_ENUM, CSS_TYPE_LENGTH, CSS_TYPE_UNUSED},
+ Css_border_width_enum_vals},
{"bottom", {CSS_TYPE_UNUSED}, NULL},
{"caption-side", {CSS_TYPE_UNUSED}, NULL},
{"clear", {CSS_TYPE_UNUSED}, NULL},
diff --git a/src/styleengine.cc b/src/styleengine.cc
index c5d44906..cf61044b 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -386,20 +386,16 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) {
attrs->borderStyle.top = (BorderStyle) p->value.intVal;
break;
case CSS_PROPERTY_BORDER_BOTTOM_WIDTH:
- computeValue (&attrs->borderWidth.bottom, p->value.intVal,
- attrs->font);
+ computeBorderWidth (&attrs->borderWidth.bottom, p, attrs->font);
break;
case CSS_PROPERTY_BORDER_LEFT_WIDTH:
- computeValue (&attrs->borderWidth.left, p->value.intVal,
- attrs->font);
+ computeBorderWidth (&attrs->borderWidth.left, p, attrs->font);
break;
case CSS_PROPERTY_BORDER_RIGHT_WIDTH:
- computeValue (&attrs->borderWidth.right, p->value.intVal,
- attrs->font);
+ computeBorderWidth (&attrs->borderWidth.right, p, attrs->font);
break;
case CSS_PROPERTY_BORDER_TOP_WIDTH:
- computeValue (&attrs->borderWidth.top, p->value.intVal,
- attrs->font);
+ computeBorderWidth (&attrs->borderWidth.top, p, attrs->font);
break;
case CSS_PROPERTY_BORDER_SPACING:
computeValue (&attrs->hBorderSpacing, p->value.intVal,attrs->font);
@@ -552,6 +548,27 @@ bool StyleEngine::computeLength (dw::core::style::Length *dest,
return false;
}
+void StyleEngine::computeBorderWidth (int *dest, CssProperty *p,
+ dw::core::style::Font *font) {
+ if (p->type == CSS_TYPE_ENUM) {
+ switch (p->value.intVal) {
+ case CSS_BORDER_WIDTH_THIN:
+ *dest = 1;
+ break;
+ case CSS_BORDER_WIDTH_MEDIUM:
+ *dest = 2;
+ break;
+ case CSS_BORDER_WIDTH_THICK:
+ *dest = 3;
+ break;
+ default:
+ assert(false);
+ }
+ } else {
+ computeValue (dest, p->value.intVal, font);
+ }
+}
+
/**
* \brief Similar to StyleEngine::style(), but with backgroundColor set.
* A normal style might have backgroundColor == NULL to indicate a transparent
diff --git a/src/styleengine.hh b/src/styleengine.hh
index e50ba35a..8b5dd1fd 100644
--- a/src/styleengine.hh
+++ b/src/styleengine.hh
@@ -42,6 +42,8 @@ class StyleEngine : public Doctree {
dw::core::style::Font *font, int percentageBase);
bool computeLength (dw::core::style::Length *dest, CssLength value,
dw::core::style::Font *font);
+ void computeBorderWidth (int *dest, CssProperty *p,
+ dw::core::style::Font *font);
public:
StyleEngine (dw::core::Layout *layout);