diff options
Diffstat (limited to 'dw/outofflowmgr.cc')
-rw-r--r-- | dw/outofflowmgr.cc | 86 |
1 files changed, 24 insertions, 62 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc index 6fc1c325..251a25f0 100644 --- a/dw/outofflowmgr.cc +++ b/dw/outofflowmgr.cc @@ -1875,78 +1875,40 @@ void OutOfFlowMgr::getFloatsExtremes (Extremes *cbExtr, Side side, for (int i = 0; i < list->size(); i++) { Float *vloat = list->get(i); - int leftDiff, rightDiff; - if (getFloatDiffToCB (vloat, &leftDiff, &rightDiff)) { + DBG_OBJ_MSGF ("resize.oofm", 1, + "float %p has generator %p (container is %p)", + vloat->getWidget (), vloat->generatingBlock, + containingBlock); + + if (vloat->generatingBlock == containingBlock || + wasAllocated (vloat->generatingBlock)) { Extremes extr; vloat->getWidget()->getExtremes (&extr); + int x; - DBG_OBJ_MSGF ("resize.oofm", 1, - "considering float %p generated by %p: %d / %d", - vloat->getWidget (), vloat->generatingBlock, - extr.minWidth, extr.maxWidth); - - // TODO: Or zero (instead of rightDiff) for right floats? - *minWidth = - max (*minWidth, - extr.minWidth + (side == LEFT ? leftDiff : rightDiff)); - *maxWidth = max (*maxWidth, extr.maxWidth + leftDiff + rightDiff); - - DBG_OBJ_MSGF ("resize.oofm", 1, " => %d / %d", *minWidth, *maxWidth); + if (vloat->generatingBlock == containingBlock) + x = side == LEFT ? + vloat->generatingBlock->getStyle()->boxOffsetX() : 0; + else { + Allocation *gba = getAllocation(vloat->generatingBlock); + x = calcFloatX (vloat, side, + gba->x - containingBlockAllocation.x, gba->width, + vloat->generatingBlock->getLineBreakWidth ()); + } + + *minWidth = max (*minWidth, x + extr.minWidth); + *maxWidth = max (*maxWidth, x + extr.maxWidth); + + DBG_OBJ_MSGF ("resize.oofm", 1, "%d + %d / %d => %d * %d", + x, extr.minWidth, extr.maxWidth, *minWidth, *maxWidth); } else - DBG_OBJ_MSGF ("resize.oofm", 1, - "considering float %p generated by %p: not allocated", - vloat->getWidget (), vloat->generatingBlock); + DBG_OBJ_MSG ("resize.oofm", 1, "not allocated"); } DBG_OBJ_LEAVE (); } -// Returns "false" when borders cannot yet determined; *leftDiff and -// *rightDiff are undefined in this case. -bool OutOfFlowMgr::getFloatDiffToCB (Float *vloat, int *leftDiff, - int *rightDiff) -{ - DBG_OBJ_ENTER ("resize.oofm", 0, "getDiffToCB", - "float %p [generated by %p], ...", - vloat->getWidget (), vloat->generatingBlock); - - bool result; - - if (vloat->generatingBlock == containingBlock) { - *leftDiff = vloat->generatingBlock->getStyle()->boxOffsetX(); - *rightDiff = vloat->generatingBlock->getStyle()->boxRestWidth(); - result = true; - DBG_OBJ_MSGF ("resize.oofm", 1, - "GB == CB => leftDiff = %d, rightDiff = %d", - *leftDiff, *rightDiff); - } else if (wasAllocated (vloat->generatingBlock)) { - Allocation *gba = getAllocation(vloat->generatingBlock); - *leftDiff = gba->x - containingBlockAllocation.x - + vloat->generatingBlock->getStyle()->boxOffsetX(); - *rightDiff = - (containingBlockAllocation.x + containingBlockAllocation.width) - - (gba->x + gba->width) - + vloat->generatingBlock->getStyle()->boxRestWidth(); - result = true; - DBG_OBJ_MSGF ("resize.oofm", 1, - "GB != CB => leftDiff = %d - %d + %d = %d, " - "rightDiff = (%d + %d) - (%d + %d) + %d = %d", - gba->x, containingBlockAllocation.x, - vloat->generatingBlock->getStyle()->boxOffsetX(), - *leftDiff, containingBlockAllocation.x, - containingBlockAllocation.width, gba->x, gba->width, - vloat->generatingBlock->getStyle()->boxRestWidth(), - *rightDiff); - } else { - DBG_OBJ_MSG ("resize.oofm", 1, "GB != CB, and float not allocated"); - result = false; - } - - DBG_OBJ_LEAVE (); - return result; -} - OutOfFlowMgr::TBInfo *OutOfFlowMgr::getTextblock (Textblock *textblock) { TypedPointer<Textblock> key (textblock); |