1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-04 16:07:57 +03:00

Fix crashes.

* Some fixed boxes did not have any layout
* Validator for the 'float' property masked the builtin,
  float('inf') returned None.
This commit is contained in:
Simon Sapin 2012-06-29 17:13:10 +02:00
parent 80af286655
commit 694863ed62
3 changed files with 12 additions and 15 deletions

View File

@ -516,9 +516,9 @@ def display(keyword):
'table-row', 'table-column-group', 'table-column', 'table-cell')
@validator()
@validator('float')
@single_keyword
def float(keyword):
def float_(keyword): # XXX do not hide the "float" builtin
"""``float`` property validation."""
return keyword in ('left', 'right', 'none')

View File

@ -146,7 +146,11 @@ def absolute_height(box, document, containing_block):
translate_box_height = False
default_translate_y = cb_y - box.position_y
if top == bottom == height == 'auto':
pass # Keep the static position
# Keep the static position
if margin_t == 'auto':
box.margin_top = 0
if margin_b == 'auto':
box.margin_bottom = 0
elif top != 'auto' and bottom != 'auto' and height != 'auto':
height_for_margins = cb_height - (
top + bottom + paddings_plus_borders_y)

View File

@ -494,24 +494,17 @@ def make_page(document, root_box, page_type, resume_at, content_empty):
assert isinstance(root_box, boxes.BlockBox)
page_is_empty = True
adjoining_margins = []
absolute_boxes = []
fixed_boxes = []
positioned_boxes = [] # Mixed absolute and fixed
root_box, resume_at, next_page, _, _ = block_level_layout(
document, root_box, page_content_bottom, resume_at,
initial_containing_block, device_size, page_is_empty,
absolute_boxes, fixed_boxes, adjoining_margins)
positioned_boxes, positioned_boxes, adjoining_margins)
assert root_box
children = [root_box]
for absolute_box in absolute_boxes + fixed_boxes:
# Use an empty list as last argument because the fixed boxes in the
# fixed box has already been added to fixed_boxes, we don't want to get
# them again
absolute_layout(document, absolute_box, page, [])
page = page.copy_with_children(children)
for absolute_box in positioned_boxes:
absolute_layout(document, absolute_box, page, positioned_boxes)
page = page.copy_with_children([root_box])
if content_empty:
resume_at = previous_resume_at
return page, resume_at, next_page