aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/style.cc4
-rw-r--r--dw/style.hh2
-rw-r--r--dw/textblock.cc10
-rw-r--r--src/cssparser.cc2
-rw-r--r--src/styleengine.cc3
5 files changed, 18 insertions, 3 deletions
diff --git a/dw/style.cc b/dw/style.cc
index b876985b..205fa0b9 100644
--- a/dw/style.cc
+++ b/dw/style.cc
@@ -46,6 +46,7 @@ void StyleAttrs::initValues ()
valign = VALIGN_BASELINE;
backgroundColor = NULL;
width = height = lineHeight = LENGTH_AUTO;
+ textIndent = 0;
margin.setVal (0);
borderWidth.setVal (0);
padding.setVal (0);
@@ -122,6 +123,7 @@ bool StyleAttrs::equals (object::Object *other) {
width == otherAttrs->width &&
height == otherAttrs->height &&
lineHeight == otherAttrs->lineHeight &&
+ textIndent == otherAttrs->textIndent &&
margin.equals (&otherAttrs->margin) &&
borderWidth.equals (&otherAttrs->borderWidth) &&
padding.equals (&otherAttrs->padding) &&
@@ -159,6 +161,7 @@ int StyleAttrs::hashValue () {
width +
height +
lineHeight +
+ textIndent +
margin.hashValue () +
borderWidth.hashValue () +
padding.hashValue () +
@@ -249,6 +252,7 @@ void Style::copyAttrs (StyleAttrs *attrs)
width = attrs->width;
height = attrs->height;
lineHeight = attrs->lineHeight;
+ textIndent = attrs->textIndent;
margin = attrs->margin;
borderWidth = attrs->borderWidth;
padding = attrs->padding;
diff --git a/dw/style.hh b/dw/style.hh
index 7a401e7f..fe964dec 100644
--- a/dw/style.hh
+++ b/dw/style.hh
@@ -437,7 +437,7 @@ public:
char textAlignChar; /* In future, strings will be supported. */
int hBorderSpacing, vBorderSpacing, wordSpacing;
- Length width, height, lineHeight;
+ Length width, height, lineHeight, textIndent;
Box margin, borderWidth, padding;
BorderCollapse borderCollapse;
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 81fbcb69..af3d1cb0 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -890,7 +890,15 @@ void Textblock::wordWrap(int wordIndex)
line1Offset + word->size.width > availWidth) {
line1OffsetEff = 0;
} else {
- line1OffsetEff = line1Offset;
+ int indent = 0;
+
+ if (core::style::isPerLength(getStyle()->textIndent)) {
+ indent = misc::roundInt(this->availWidth *
+ core::style::perLengthVal (getStyle()->textIndent));
+ } else {
+ indent = core::style::absLengthVal (getStyle()->textIndent);
+ }
+ line1OffsetEff = line1Offset + indent;
}
}
diff --git a/src/cssparser.cc b/src/cssparser.cc
index e9de3aaf..66bf8340 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -218,7 +218,7 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = {
{"text-align", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_text_align_enum_vals},
{"text-decoration", {CSS_TYPE_MULTI_ENUM, CSS_TYPE_UNUSED},
Css_text_decoration_enum_vals},
- {"text-indent", {CSS_TYPE_UNUSED}, NULL},
+ {"text-indent", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL},
{"text-shadow", {CSS_TYPE_UNUSED}, NULL},
{"text-transform", {CSS_TYPE_UNUSED}, NULL},
{"top", {CSS_TYPE_UNUSED}, NULL},
diff --git a/src/styleengine.cc b/src/styleengine.cc
index a381b1c6..9a28f562 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -547,6 +547,9 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props) {
case CSS_PROPERTY_TEXT_DECORATION:
attrs->textDecoration |= p->value.intVal;
break;
+ case CSS_PROPERTY_TEXT_INDENT:
+ computeLength (&attrs->textIndent, p->value.intVal, attrs->font);
+ break;
case CSS_PROPERTY_VERTICAL_ALIGN:
attrs->valign = (VAlignType) p->value.intVal;
break;