aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-02-18 14:51:10 +0100
committerSebastian Geerken <devnull@localhost>2014-02-18 14:51:10 +0100
commitbc44517d6c6c2f4674a9ce8ccc88ec947bb4e6d5 (patch)
tree5a525cb1929234b5d544bd2949118dc2791b05e0 /dw
parent405cd273df5299d5dff89158a6b19fee4280cbeb (diff)
Fixed ComparePosition::compare.
Diffstat (limited to 'dw')
-rw-r--r--dw/outofflowmgr.cc65
1 files changed, 31 insertions, 34 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc
index 42410407..afcce066 100644
--- a/dw/outofflowmgr.cc
+++ b/dw/outofflowmgr.cc
@@ -180,40 +180,37 @@ int OutOfFlowMgr::Float::ComparePosition::compare (Object *o1, Object *o2)
assert (oofm->wasAllocated (fl1->generatingBlock));
assert (oofm->wasAllocated (fl2->generatingBlock));
- if (fl1->generatingBlock != fl2->generatingBlock) {
- int y1 = oofm->getAllocation(fl1->generatingBlock)->y,
- y2 = oofm->getAllocation(fl2->generatingBlock)->y;
- DBG_OBJ_MSGF_O ("border", 2, oofm,
- "floats have different generators, %p and %p; "
- "y diff = %d - %d",
- fl1->generatingBlock, fl2->generatingBlock, y1, y2);
- r = y1 - y2;
- } else {
- // Floats may not yet been allocated (but the generators
- // are). Non-allocated floats do not have an effect yet.
- DBG_OBJ_MSGF_O ("border", 2, oofm, "floats have same generator, %p",
- fl1->generatingBlock);
-
- bool a1 = fl1->getWidget()->wasAllocated (),
- a2 = fl2->getWidget()->wasAllocated ();
-
- DBG_OBJ_MSGF_O ("border", 2, oofm,
- "float 1 allocated. %s; float 2 allocated: %s",
- a1 ? "yes" : "no", a2 ? "yes" : "no");
-
- if (a1 && a2) {
- r = fl1->getWidget()->getAllocation()->y
- - fl2->getWidget()->getAllocation()->y;
- DBG_OBJ_MSGF_O ("border", 2, oofm, "y diff = %d - %d",
- fl1->getWidget()->getAllocation()->y,
- fl2->getWidget()->getAllocation()->y);
- } else if (a1 && !a2)
- r = -1;
- else if (!a1 && a2)
- r = +1;
- else // if (!a1 && !a2)
- return 0;
- }
+ DBG_OBJ_MSGF_O ("border", 2, oofm, "generators are %p and %p",
+ fl1->generatingBlock, fl2->generatingBlock);
+
+ // (i) Floats may not yet been allocated (although the
+ // generators are). Non-allocated floats do not have an effect
+ // yet, they are considered "at the end" of the list.
+
+ // (ii) Float::widget for the key used for binary search. In
+ // this case, Float::yReal is used instead (which is set in
+ // SortedFloatsVector::find).
+
+ bool a1 = fl1->getWidget () ? fl1->getWidget()->wasAllocated () : true;
+ bool a2 = fl2->getWidget () ? fl2->getWidget()->wasAllocated () : true;
+
+ DBG_OBJ_MSGF_O ("border", 2, oofm,
+ "float 1 allocated: %s; float 2 allocated: %s",
+ a1 ? "yes" : "no", a2 ? "yes" : "no");
+
+ if (a1 && a2) {
+ int fly1 = fl1->getWidget() ? fl1->getWidget()->getAllocation()->y :
+ oofm->getAllocation(fl2->generatingBlock)->y + fl1->yReal;
+ int fly2 = fl2->getWidget() ? fl2->getWidget()->getAllocation()->y :
+ oofm->getAllocation(fl2->generatingBlock)->y + fl2->yReal;
+ DBG_OBJ_MSGF_O ("border", 2, oofm, "y diff = %d - %d", fly1, fly2);
+ r = fly1 - fly2;
+ } else if (a1 && !a2)
+ r = -1;
+ else if (!a1 && a2)
+ r = +1;
+ else // if (!a1 && !a2)
+ return 0;
DBG_OBJ_MSG_END_O (oofm);
}