aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2010-04-20 16:04:24 +0000
committercorvid <corvid@lavabit.com>2010-04-20 16:04:24 +0000
commitbda22922f7ed5934a2c1cd9740836df1a22cbc30 (patch)
tree7e7713dcbca5bfa1bead72abe9bd0388bcadbc4e /src
parent7a6266b40e3b340883d1f7fb22c0099a8253cc88 (diff)
css word-spacing property
Diffstat (limited to 'src')
-rw-r--r--src/css.hh4
-rw-r--r--src/cssparser.cc7
-rw-r--r--src/styleengine.cc15
3 files changed, 25 insertions, 1 deletions
diff --git a/src/css.hh b/src/css.hh
index e0370085..69573fdf 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -263,6 +263,10 @@ typedef enum {
CSS_LETTER_SPACING_NORMAL
} CssLetterSpacingExtensions;
+typedef enum {
+ CSS_WORD_SPACING_NORMAL
+} CssWordSpacingExtensions;
+
/**
* \brief This class holds a CSS property and value pair.
diff --git a/src/cssparser.cc b/src/cssparser.cc
index f73c257b..00ba7428 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -118,6 +118,10 @@ static const char *const Css_white_space_vals[] = {
"normal", "pre", "nowrap", "pre-wrap", "pre-line", NULL
};
+static const char *const Css_word_spacing_enum_vals[] = {
+ "normal", NULL
+};
+
const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = {
{"background-attachment", {CSS_TYPE_UNUSED}, NULL},
{"background-color", {CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, NULL},
@@ -213,7 +217,8 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = {
{"visibility", {CSS_TYPE_UNUSED}, NULL},
{"white-space", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_white_space_vals},
{"width", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL},
- {"word-spacing", {CSS_TYPE_UNUSED}, NULL},
+ {"word-spacing", {CSS_TYPE_ENUM, CSS_TYPE_SIGNED_LENGTH, CSS_TYPE_UNUSED},
+ Css_word_spacing_enum_vals},
{"z-index", {CSS_TYPE_UNUSED}, NULL},
/* These are extensions, for internal used, and never parsed. */
diff --git a/src/styleengine.cc b/src/styleengine.cc
index 6691ba41..906f47ee 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -469,6 +469,21 @@ void StyleEngine::apply (StyleAttrs *attrs, CssPropertyList *props) {
case CSS_PROPERTY_HEIGHT:
computeLength (&attrs->height, p->value.intVal, attrs->font);
break;
+ case CSS_PROPERTY_WORD_SPACING:
+ if (p->type == CSS_TYPE_ENUM) {
+ if (p->value.intVal == CSS_WORD_SPACING_NORMAL) {
+ attrs->wordSpacing = 0;
+ }
+ } else {
+ computeValue(&attrs->wordSpacing, p->value.intVal, attrs->font);
+ }
+
+ /* Limit to reasonable values to avoid overflows */
+ if (attrs->wordSpacing > 1000)
+ attrs->wordSpacing = 1000;
+ else if (attrs->wordSpacing < -1000)
+ attrs->wordSpacing = -1000;
+ break;
case PROPERTY_X_LINK:
attrs->x_link = p->value.intVal;
break;