diff options
author | Sebastian Geerken <devnull@localhost> | 2014-05-01 21:19:22 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2014-05-01 21:19:22 +0200 |
commit | 413e63c3527d29d9a762a56a076ec55f244ebb57 (patch) | |
tree | 78da6d3cd033ba81a0d168b26147ff7a9242c2d2 | |
parent | 8afd0e5a02887e72fb2c947c074fb499658af95f (diff) |
Fixed OutOfFlowMgr::getClearPosition(Textblock*, Side), and so an endless resize cycle.
-rw-r--r-- | dw/outofflowmgr.cc | 63 | ||||
-rw-r--r-- | dw/textblock.cc | 7 |
2 files changed, 48 insertions, 22 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc index dd462caf..57e6fd09 100644 --- a/dw/outofflowmgr.cc +++ b/dw/outofflowmgr.cc @@ -1935,6 +1935,11 @@ bool OutOfFlowMgr::hasFloat (Textblock *textblock, Side side, int y, int h, */ int OutOfFlowMgr::getClearPosition (Textblock *tb) { + DBG_OBJ_MSGF ("resize.oofm", 0, "<b>getClearPosition</b> (%p)", tb); + DBG_OBJ_MSG_START (); + + int pos; + if (tb->getStyle()) { bool left = false, right = false; switch (tb->getStyle()->clear) { @@ -1945,40 +1950,54 @@ int OutOfFlowMgr::getClearPosition (Textblock *tb) default: assertNotReached (); } - return max (left ? getClearPosition (tb, LEFT) : 0, - right ? getClearPosition (tb, RIGHT) : 0); + pos = max (left ? getClearPosition (tb, LEFT) : 0, + right ? getClearPosition (tb, RIGHT) : 0); } else - return 0; + pos = 0; + + DBG_OBJ_MSGF ("resize.oofm", 1, "=> %d", pos); + DBG_OBJ_MSG_END (); + + return pos; } int OutOfFlowMgr::getClearPosition (Textblock *tb, Side side) { + DBG_OBJ_MSGF ("resize.oofm", 0, "<b>getClearPosition</b> (%p, %s)", + tb, side == LEFT ? "LEFT" : "RIGHT"); + DBG_OBJ_MSG_START (); + + int pos; + if (!wasAllocated (tb)) // There is no relation yet to floats generated by other // textblocks, and this textblocks floats are unimportant for // the "clear" property. - return 0; - - SortedFloatsVector *list = side == LEFT ? leftFloatsCB : rightFloatsCB; + pos = 0; + else { + SortedFloatsVector *list = side == LEFT ? leftFloatsCB : rightFloatsCB; - int i = list->findFloatIndex (tb, 0); - if (i < 0) - return 0; + // Search the last float before (therfore -1) this textblock. + int i = list->findFloatIndex (tb, -1); + if (i < 0) { + pos = 0; + DBG_OBJ_MSG ("resize.oofm", 1, "no float"); + } else { + Float *vloat = list->get(i); + assert (vloat->generatingBlock != tb); + ensureFloatSize (vloat); + pos = vloat->yReal + vloat->size.ascent + vloat->size.descent - + getAllocation(tb)->y; + DBG_OBJ_MSGF ("resize.oofm", 1, "float %p => %d + (%d + %d) - %d", + vloat->getWidget (), vloat->yReal, vloat->size.ascent, + vloat->size.descent, getAllocation(tb)->y); + } + } - Float *vloat = list->get(i); - // We pass this texblock and 0 (first word, or smallest external - // index, respectively), but search for the last float before this - // position. Therefore this check. - if (vloat->generatingBlock== tb) - i--; - if (i < 0) - return 0; + DBG_OBJ_MSGF ("resize.oofm", 1, "=> %d", pos); + DBG_OBJ_MSG_END (); - vloat = list->get(i); - ensureFloatSize (vloat); - return - vloat->yReal + vloat->size.ascent + vloat->size.descent - - getAllocation(tb)->y; + return pos; } void OutOfFlowMgr::ensureFloatSize (Float *vloat) diff --git a/dw/textblock.cc b/dw/textblock.cc index 540df6a9..99ba6d06 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -275,6 +275,7 @@ Textblock::Textblock (bool limitTextWidth) DBG_OBJ_SET_NUM ("availDescent", availDescent); verticalOffset = 0; + DBG_OBJ_SET_NUM ("verticalOffset", verticalOffset); this->limitTextWidth = limitTextWidth; @@ -2766,11 +2767,17 @@ void Textblock::queueDrawRange (int index1, int index2) void Textblock::setVerticalOffset (int verticalOffset) { + DBG_OBJ_MSGF ("resize", 0, "<b>setVerticalOffset</b> (%d)", verticalOffset); + DBG_OBJ_MSG_START (); + if (this->verticalOffset != verticalOffset) { this->verticalOffset = verticalOffset; + DBG_OBJ_SET_NUM ("verticalOffset", verticalOffset); mustQueueResize = true; queueDraw (); // Could perhaps be optimized. } + + DBG_OBJ_MSG_END (); } /** |