diff options
author | Sebastian Geerken <devnull@localhost> | 2014-04-11 23:54:03 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2014-04-11 23:54:03 +0200 |
commit | 37bf6f1cc340018b9639bb290f2eada9e87630ee (patch) | |
tree | 790b0b69aedf7e525f59f9d334ea3e4c40d0694d /dw/outofflowmgr.cc | |
parent | 5c6a11eadf8e490db851f4fb6763598d213946dd (diff) |
Corrected float allocation order again.
Diffstat (limited to 'dw/outofflowmgr.cc')
-rw-r--r-- | dw/outofflowmgr.cc | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc index 83de6dbd..bcca4a82 100644 --- a/dw/outofflowmgr.cc +++ b/dw/outofflowmgr.cc @@ -546,12 +546,21 @@ void OutOfFlowMgr::sizeAllocateStart (Textblock *caller, Allocation *allocation) getTextblock(caller)->wasAllocated = true; if (caller == containingBlock) { + // In the size allocation process, the *first* OOFM method + // called is sizeAllocateStart, with the containing block as an + // argument. So this is the correct point to initialize size + // allocation. + containingBlockAllocation = *allocation; containingBlockWasAllocated = true; // Move floats from GB lists to the one CB list. moveFromGBToCB (LEFT); moveFromGBToCB (RIGHT); + + // These attributes are used to keep track which floats have + // been allocated (referring to leftFloatsCB and rightFloatsCB). + lastAllocatedLeftFloat = lastAllocatedRightFloat = -1; } DBG_OBJ_MSG_END (); @@ -562,12 +571,24 @@ void OutOfFlowMgr::sizeAllocateEnd (Textblock *caller) DBG_OBJ_MSGF ("resize.oofm", 0, "<b>sizeAllocateEnd</b> (%p)", caller); DBG_OBJ_MSG_START (); - // Floats (and later absolutely positioned blocks) have to be allocated. - TBInfo *tbInfo = getTextblock (caller); - sizeAllocateFloats (tbInfo, LEFT); - sizeAllocateFloats (tbInfo, RIGHT); + // (Later, absolutely positioned blocks have to be allocated.) + + if (caller != containingBlock) { + // Allocate all floats "before" this textblock. + sizeAllocateFloats (LEFT, leftFloatsCB->findFloatIndex (caller, -1)); + sizeAllocateFloats (RIGHT, rightFloatsCB->findFloatIndex (caller, -1)); + } if (caller == containingBlock) { + // In the size allocation process, the *last* OOFM method called + // is sizeAllocateEnd, with the containing block as an + // argument. So this is the correct point to finish size + // allocation. + + // Allocate all remaining floats. + sizeAllocateFloats (LEFT, leftFloatsCB->size () - 1); + sizeAllocateFloats (RIGHT, rightFloatsCB->size () - 1); + // Check changes of both textblocks and floats allocation. (All // is checked by hasRelationChanged (...).) for (lout::container::typed::Iterator<TypedPointer <Textblock> > it = @@ -969,19 +990,27 @@ void OutOfFlowMgr::moveFromGBToCB (Side side) // printf (" %d: %s\n", i, dest->get(i)->toString()); } -void OutOfFlowMgr::sizeAllocateFloats (TBInfo *textblock, Side side) +void OutOfFlowMgr::sizeAllocateFloats (Side side, int newLastAllocatedFloat) { - SortedFloatsVector *list = side == LEFT ? - textblock->leftFloatsGB : textblock->rightFloatsGB; + SortedFloatsVector *list = side == LEFT ? leftFloatsCB : rightFloatsCB; + int *lastAllocatedFloat = + side == LEFT ? &lastAllocatedLeftFloat : &lastAllocatedRightFloat; + + DBG_OBJ_MSGF ("resize.oofm", 0, + "<b>sizeAllocateFloats</b> (%s, [%d ->] %d [size = %d])", + side == LEFT ? "LEFT" : "RIGHT", *lastAllocatedFloat, + newLastAllocatedFloat, list->size ()); + DBG_OBJ_MSG_START (); - Allocation *gba = &(textblock->allocation); Allocation *cba = &containingBlockAllocation; - int availWidth = textblock->getTextblock()->getAvailWidth(); - for (int i = 0; i < list->size(); i++) { + for (int i = *lastAllocatedFloat + 1; i <= newLastAllocatedFloat; i++) { Float *vloat = list->get(i); ensureFloatSize (vloat); + Allocation *gba = getAllocation (vloat->generatingBlock); + int availWidth = vloat->generatingBlock->getAvailWidth(); + Allocation childAllocation; childAllocation.x = cba->x + calcFloatX (vloat, side, gba->x - cba->x, gba->width, availWidth); @@ -992,6 +1021,10 @@ void OutOfFlowMgr::sizeAllocateFloats (TBInfo *textblock, Side side) vloat->getWidget()->sizeAllocate (&childAllocation); } + + *lastAllocatedFloat = newLastAllocatedFloat; + + DBG_OBJ_MSG_END (); } |