diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/css.hh | 4 | ||||
-rw-r--r-- | src/cssparser.cc | 7 | ||||
-rw-r--r-- | src/styleengine.cc | 15 |
3 files changed, 25 insertions, 1 deletions
@@ -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; |