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 30597af2..48f98ef8 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);
@@ -120,6 +121,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) &&
@@ -155,6 +157,7 @@ int StyleAttrs::hashValue () {
width +
height +
lineHeight +
+ textIndent +
margin.hashValue () +
borderWidth.hashValue () +
padding.hashValue () +
@@ -243,6 +246,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 33d42c29..9dbdfc46 100644
--- a/dw/style.hh
+++ b/dw/style.hh
@@ -432,7 +432,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;
struct { Color *top, *right, *bottom, *left; } borderColor;
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 23085352..233d3956 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -213,7 +213,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 62ba60d7..bb86ce4d 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -544,6 +544,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;