diff options
author | Sebastian Geerken <devnull@localhost> | 2013-08-21 13:44:00 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2013-08-21 13:44:00 +0200 |
commit | 1eadbc7adf57405730f8b5efbb4c4c8b19d2f1d6 (patch) | |
tree | 2bab24cc907b7046ac1726cf09c6fc2f3f7fbd82 | |
parent | 1b9c7e87a56398814be78adea71e935f8a75b3cd (diff) |
"clear" attribute, mostly.
-rw-r--r-- | dw/outofflowmgr.cc | 36 | ||||
-rw-r--r-- | dw/outofflowmgr.hh | 2 | ||||
-rw-r--r-- | dw/textblock_linebreaking.cc | 7 | ||||
-rw-r--r-- | src/cssparser.cc | 6 | ||||
-rw-r--r-- | src/styleengine.cc | 3 |
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; |