summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/outofflowmgr.cc36
-rw-r--r--dw/outofflowmgr.hh2
-rw-r--r--dw/textblock_linebreaking.cc7
-rw-r--r--src/cssparser.cc6
-rw-r--r--src/styleengine.cc3
5 files changed, 38 insertions, 16 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc
index 1e3067d7..2cbf5e9c 100644
--- a/dw/outofflowmgr.cc
+++ b/dw/outofflowmgr.cc
@@ -1364,19 +1364,25 @@ bool OutOfFlowMgr::hasFloat (Textblock *textblock, Side side, int y, int h,
return list->findFirst (textblock, y, h, lastGB, lastExtIndex) != -1;
}
-int OutOfFlowMgr::getClearPosition (Textblock *tb, core::style::ClearType clear)
-{
- bool left = false, right = false;
- switch (clear) {
- case core::style::CLEAR_NONE: break;
- case core::style::CLEAR_LEFT: left = true; break;
- case core::style::CLEAR_RIGHT: right = true; break;
- case core::style::CLEAR_BOTH: left = right = true; break;
- default: assertNotReached ();
- }
-
- return max (left ? getClearPosition (tb, LEFT) : 0,
- right ? getClearPosition (tb, RIGHT) : 0);
+/**
+ * Returns position relative to the textblock "tb".
+ */
+int OutOfFlowMgr::getClearPosition (Textblock *tb)
+{
+ if (tb->getStyle()) {
+ bool left = false, right = false;
+ switch (tb->getStyle()->clear) {
+ case core::style::CLEAR_NONE: break;
+ case core::style::CLEAR_LEFT: left = true; break;
+ case core::style::CLEAR_RIGHT: right = true; break;
+ case core::style::CLEAR_BOTH: left = right = true; break;
+ default: assertNotReached ();
+ }
+
+ return max (left ? getClearPosition (tb, LEFT) : 0,
+ right ? getClearPosition (tb, RIGHT) : 0);
+ } else
+ return 0;
}
int OutOfFlowMgr::getClearPosition (Textblock *tb, Side side)
@@ -1404,7 +1410,9 @@ int OutOfFlowMgr::getClearPosition (Textblock *tb, Side side)
vloat = list->get(i);
ensureFloatSize (vloat);
- return vloat->yReal + vloat->size.ascent + vloat->size.descent;
+ return
+ vloat->yReal + vloat->size.ascent + vloat->size.descent -
+ getAllocation(tb)->y;
}
void OutOfFlowMgr::ensureFloatSize (Float *vloat)
diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh
index a97af4b9..69f39471 100644
--- a/dw/outofflowmgr.hh
+++ b/dw/outofflowmgr.hh
@@ -342,7 +342,7 @@ public:
bool hasFloatRight (Textblock *textblock, int y, int h, Textblock *lastGB,
int lastExtIndex);
- int getClearPosition (Textblock *tb, core::style::ClearType clear);
+ int getClearPosition (Textblock *tb);
inline static bool isRefOutOfFlow (int ref)
{ return ref != -1 && (ref & 1) != 0; }
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc
index 3f06cb6d..328dd448 100644
--- a/dw/textblock_linebreaking.cc
+++ b/dw/textblock_linebreaking.cc
@@ -1438,6 +1438,13 @@ void Textblock::initNewLine ()
// method is called, containingBlock is not yet defined.
if (containingBlock && containingBlock->outOfFlowMgr) {
+ if (lines->size () == 0) {
+ int clearPosition =
+ containingBlock->outOfFlowMgr->getClearPosition (this);
+ printf ("%p: %d -> %d\n", this, getStyle()->clear, clearPosition);
+ verticalOffset = misc::max (clearPosition, 0);
+ }
+
int y = topOfPossiblyMissingLine (lines->size ());
int h = heightOfPossiblyMissingLine (lines->size ());
int lastRef = lines->size() > 0 ? lines->getLastRef()->lastWord : -1;
diff --git a/src/cssparser.cc b/src/cssparser.cc
index 3caa62c1..67d8ff54 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -64,6 +64,10 @@ static const char *const Css_border_width_enum_vals[] = {
"thin", "medium", "thick", NULL
};
+static const char *const Css_clear_enum_vals[] = {
+ "left", "right", "both", "none", NULL
+};
+
static const char *const Css_cursor_enum_vals[] = {
"crosshair", "default", "pointer", "move", "e-resize", "ne-resize",
"nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize",
@@ -181,7 +185,7 @@ const CssPropertyInfo Css_property_info[CSS_PROPERTY_LAST] = {
Css_border_width_enum_vals},
{"bottom", {CSS_TYPE_LENGTH_PERCENTAGE, CSS_TYPE_UNUSED}, NULL},
{"caption-side", {CSS_TYPE_UNUSED}, NULL},
- {"clear", {CSS_TYPE_UNUSED}, NULL},
+ {"clear", {CSS_TYPE_ENUM, CSS_TYPE_UNUSED}, Css_clear_enum_vals},
{"clip", {CSS_TYPE_UNUSED}, NULL},
{"color", {CSS_TYPE_COLOR, CSS_TYPE_UNUSED}, NULL},
{"content", {CSS_TYPE_STRING, CSS_TYPE_UNUSED}, NULL},
diff --git a/src/styleengine.cc b/src/styleengine.cc
index 890f6bcb..7a76d18a 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -498,6 +498,9 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props) {
case CSS_PROPERTY_BOTTOM:
computeLength (&attrs->bottom, p->value.intVal, attrs->font);
break;
+ case CSS_PROPERTY_CLEAR:
+ attrs->clear = (ClearType) p->value.intVal;
+ break;
case CSS_PROPERTY_COLOR:
attrs->color = Color::create (layout, p->value.intVal);
break;