aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2013-08-28 15:23:06 +0200
committerSebastian Geerken <devnull@localhost>2013-08-28 15:23:06 +0200
commit07e8ade74e7470dfe45062ec33c5e50395caca2e (patch)
treea4fae3b9ee2934d396aaf0a71da45740eaf5e133
parentbefe895d2235de24d2c53797c44282f442b467ee (diff)
Floats must not exceed CB allocation. (First step, more follows.)
-rw-r--r--dw/outofflowmgr.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc
index e59d809f..09aa4456 100644
--- a/dw/outofflowmgr.cc
+++ b/dw/outofflowmgr.cc
@@ -624,19 +624,31 @@ void OutOfFlowMgr::sizeAllocateFloats (Side side)
ensureFloatSize (vloat);
Allocation *gbAllocation = getAllocation(vloat->generatingBlock);
+ Allocation *cbAllocation = getAllocation(containingBlock);
+ // In some cases, the actual (allocated) width is too large; we
+ // use the "available" width here.
+ int gbWidth =
+ min (gbAllocation->width, vloat->generatingBlock->getAvailWidth());
+
Allocation childAllocation;
+
switch (side) {
case LEFT:
+ // Left floats are always aligned on the left side of the
+ // generator (content, not allocation).
childAllocation.x = gbAllocation->x
+ vloat->generatingBlock->getStyle()->boxOffsetX();
break;
case RIGHT:
+ // Similar for right floats, but in this case, floats are
+ // shifted to the right when they are too big (instead of
+ // shifting the generator to the right).
childAllocation.x =
- gbAllocation->x
- + min (gbAllocation->width, vloat->generatingBlock->getAvailWidth())
- - vloat->size.width
- - vloat->generatingBlock->getStyle()->boxRestWidth();
+ max (gbAllocation->x + gbWidth - vloat->size.width
+ - vloat->generatingBlock->getStyle()->boxRestWidth(),
+ // Do not exceed CB allocation:
+ cbAllocation->x);
break;
}