aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--dw/style.cc4
-rw-r--r--dw/style.hh2
-rw-r--r--dw/textblock.cc3
-rw-r--r--dw/textblock.hh6
-rw-r--r--src/css.hh4
-rw-r--r--src/cssparser.cc7
-rw-r--r--src/styleengine.cc15
8 files changed, 36 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 3074a16f..8ab4de43 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,7 @@ dillo-2.2.1 [not released yet]
- Follow most specific matching rule in cookiesrc.
- Fix segfault with form inputs and repush for stylesheets.
- Handle white-space: pre-wrap and pre-line.
+ - Support for the word-spacing property.
Patches: corvid
+- Implement line-height.
Patch: Johannes Hofmann, corvid
diff --git a/dw/style.cc b/dw/style.cc
index 65c51f89..cc58ce28 100644
--- a/dw/style.cc
+++ b/dw/style.cc
@@ -53,6 +53,7 @@ void StyleAttrs::initValues ()
setBorderStyle (BORDER_NONE);
hBorderSpacing = 0;
vBorderSpacing = 0;
+ wordSpacing = 0;
display = DISPLAY_INLINE;
whiteSpace = WHITE_SPACE_NORMAL;
@@ -115,6 +116,7 @@ bool StyleAttrs::equals (object::Object *other) {
textAlignChar == otherAttrs->textAlignChar &&
hBorderSpacing == otherAttrs->hBorderSpacing &&
vBorderSpacing == otherAttrs->vBorderSpacing &&
+ wordSpacing == otherAttrs->wordSpacing &&
width == otherAttrs->width &&
height == otherAttrs->height &&
lineHeight == otherAttrs->lineHeight &&
@@ -149,6 +151,7 @@ int StyleAttrs::hashValue () {
textAlignChar +
hBorderSpacing +
vBorderSpacing +
+ wordSpacing +
width +
height +
lineHeight +
@@ -236,6 +239,7 @@ void Style::copyAttrs (StyleAttrs *attrs)
textAlignChar = attrs->textAlignChar;
hBorderSpacing = attrs->hBorderSpacing;
vBorderSpacing = attrs->vBorderSpacing;
+ wordSpacing = attrs->wordSpacing;
width = attrs->width;
height = attrs->height;
lineHeight = attrs->lineHeight;
diff --git a/dw/style.hh b/dw/style.hh
index af55bb87..04a5e22e 100644
--- a/dw/style.hh
+++ b/dw/style.hh
@@ -426,7 +426,7 @@ public:
VAlignType valign;
char textAlignChar; /* In future, strings will be supported. */
- int hBorderSpacing, vBorderSpacing;
+ int hBorderSpacing, vBorderSpacing, wordSpacing;
Length width, height, lineHeight;
Box margin, borderWidth, padding;
diff --git a/dw/textblock.cc b/dw/textblock.cc
index b2772084..cc743252 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -1722,7 +1722,8 @@ void Textblock::addSpace (core::style::Style *style)
if (!word->content.space) {
word->content.space = true;
- word->effSpace = word->origSpace = style->font->spaceWidth;
+ word->effSpace = word->origSpace = style->font->spaceWidth +
+ style->wordSpacing;
//DBG_OBJ_ARRSET_NUM (page, "words.%d.orig_space", nw,
// page->words[nw].orig_space);
diff --git a/dw/textblock.hh b/dw/textblock.hh
index 88351dbb..d05c87e2 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -163,9 +163,9 @@ protected:
/* TODO: perhaps add a xLeft? */
core::Requisition size;
/* Space after the word, only if it's not a break: */
- unsigned short origSpace; /* from font, set by addSpace */
- unsigned short effSpace; /* effective space, set by wordWrap,
- * used for drawing etc. */
+ short origSpace; /* from font, set by addSpace */
+ short effSpace; /* effective space, set by wordWrap,
+ * used for drawing etc. */
core::Content content;
core::style::Style *style;
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;