diff options
author | Sebastian Geerken <devnull@localhost> | 2015-01-02 00:24:43 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2015-01-02 00:24:43 +0100 |
commit | 86e780e73a11e8b9d1d57cb5f283c4fee6ca68e8 (patch) | |
tree | 1a64180d007c4aaf85c7f7f9e6553ca4d8ff61df | |
parent | 0d0a2370f560e046bc420529d5a9234246f3a560 (diff) |
Floats: extremes now similar to floats; fixes a CPU hogging bug.
-rw-r--r-- | dw/outofflowmgr.cc | 86 | ||||
-rw-r--r-- | dw/outofflowmgr.hh | 1 |
2 files changed, 24 insertions, 63 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); diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh index 24607bad..ea86bcd3 100644 --- a/dw/outofflowmgr.hh +++ b/dw/outofflowmgr.hh @@ -294,7 +294,6 @@ private: int *height); void getFloatsExtremes (core::Extremes *cbExtr, Side side, int *minWidth, int *maxWidth); - bool getFloatDiffToCB (Float *vloat, int *leftDiff, int *rightDiff); TBInfo *getTextblock (Textblock *textblock); int getBorder (Textblock *textblock, Side side, int y, int h, |