diff --git a/weasyprint/layout/__init__.py b/weasyprint/layout/__init__.py index ff4937ff8..7c3814253 100644 --- a/weasyprint/layout/__init__.py +++ b/weasyprint/layout/__init__.py @@ -245,9 +245,13 @@ def __init__(self, style_for, get_image_from_uri, font_config, self.dictionaries = {} def overflows_page(self, bottom_space, position_y): + return self.overflows(self.page_bottom - bottom_space, position_y) + + @staticmethod + def overflows(bottom, position_y): # Use a small fudge factor to avoid floating numbers errors. # The 1e-9 value comes from PEP 485. - return position_y > (self.page_bottom - bottom_space) * (1 + 1e-9) + return position_y > bottom * (1 + 1e-9) def create_block_formatting_context(self): self.excluded_shapes = [] diff --git a/weasyprint/layout/block.py b/weasyprint/layout/block.py index 6f8770a78..252677f20 100644 --- a/weasyprint/layout/block.py +++ b/weasyprint/layout/block.py @@ -742,7 +742,7 @@ def block_container_layout(context, box, bottom_space, skip_stack, max_lines) elif stop: if box.height != 'auto': - if position_y > box.position_y + box.height: + if context.overflows(box.position_y + box.height, position_y): # Box heigh is fixed and it doesn’t overflow page, forget # overflowing children. resume_at = None