1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 00:21:15 +03:00

Don't crash with floats with percents in positions

Fix #263
This commit is contained in:
Guillaume Ayoub 2016-05-16 14:56:34 +02:00
parent 35ea72b3f6
commit 50ebc20b97
2 changed files with 11 additions and 5 deletions

View File

@ -556,6 +556,7 @@ def block_container_layout(context, box, max_position_y, skip_stack,
# TODO: See corner cases in
# http://www.w3.org/TR/CSS21/visudet.html#normal-block
# TODO: See float.float_layout
if new_box.height == 'auto':
new_box.height = position_y - new_box.content_box_y()

View File

@ -33,9 +33,15 @@ def float_layout(context, box, containing_block, device_size, absolute_boxes,
from .blocks import block_container_layout
from .inlines import inline_replaced_box_width_height
resolve_percentages(box, (containing_block.width, containing_block.height))
resolve_position_percentages(
box, (containing_block.width, containing_block.height))
cb_width, cb_height = (containing_block.width, containing_block.height)
# TODO: This is only handled later in blocks.block_container_layout
# http://www.w3.org/TR/CSS21/visudet.html#normal-block
if cb_height == 'auto':
cb_height = (
containing_block.position_y - containing_block.content_box_y())
resolve_percentages(box, (cb_width, cb_height))
resolve_position_percentages(box, (cb_width, cb_height))
if box.margin_left == 'auto':
box.margin_left = 0
@ -56,8 +62,7 @@ def float_layout(context, box, containing_block, device_size, absolute_boxes,
float_width(box, context, containing_block)
if box.is_table_wrapper:
table_wrapper_width(
context, box, (containing_block.width, containing_block.height))
table_wrapper_width(context, box, (cb_width, cb_height))
if isinstance(box, boxes.BlockBox):
context.create_block_formatting_context()