Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

table-break: WIP page-breaks inside tables

  • Loading branch information...
commit 9c659684e74b9c65d8317eb86774496d0172473a 1 parent f814dc0
@plaes authored
Showing with 25 additions and 8 deletions.
  1. +2 −2 weasyprint/layout/blocks.py
  2. +23 −6 weasyprint/layout/tables.py
View
4 weasyprint/layout/blocks.py
@@ -41,8 +41,8 @@ def block_level_layout(document, box, max_position_y, skip_stack,
"""
if isinstance(box, boxes.TableBox):
- return table_layout(document, box, max_position_y, containing_block,
- device_size, page_is_empty)
+ return table_layout(document, box, max_position_y, skip_stack,
+ containing_block, device_size, page_is_empty)
elif isinstance(box, boxes.BlockBox):
if box.is_table_wrapper:
return block_table_wrapper(document, box, max_position_y,
View
29 weasyprint/layout/tables.py
@@ -29,8 +29,8 @@
from .percentages import resolve_percentages, resolve_one_percentage
-def table_layout(document, table, max_position_y, containing_block,
- device_size, page_is_empty):
+def table_layout(document, table, max_position_y, skip_stack,
+ containing_block, device_size, page_is_empty):
"""Layout for a table box.
For now only the fixed layout and separate border model are supported.
@@ -52,6 +52,13 @@ def table_layout(document, table, max_position_y, containing_block,
position_x += width
rows_width = position_x - rows_x
+ if skip_stack is None:
+ skip = 0
+ else:
+ skip, skip_stack = skip_stack
+
+ resume_at = None
+
# Layout for row groups, rows and cells
position_y = table.content_box_y() + border_spacing_y
initial_position_y = position_y
@@ -64,7 +71,8 @@ def table_layout(document, table, max_position_y, containing_block,
new_group_children = []
# For each rows, cells for which this is the last row (with rowspan)
ending_cells_by_row = [[] for row in group.children]
- for row in group.children:
+ force_page_break = False
+ for index, row in group.enumerate_skip(skip):
resolve_percentages(row, containing_block=table)
row.position_x = rows_x
row.position_y = position_y
@@ -163,7 +171,13 @@ def table_layout(document, table, max_position_y, containing_block,
else:
cell.padding_bottom += extra
- position_y += row.height + border_spacing_y
+ cur_pos_y = position_y + row.height + border_spacing_y
+ # Check whether we should handle page-break
+ if cur_pos_y > max_position_y:
+ force_page_break = True
+ break
+
+ position_y = cur_pos_y
group = group.copy_with_children(new_group_children)
new_table_children.append(group)
@@ -182,6 +196,11 @@ def table_layout(document, table, max_position_y, containing_block,
if group.children:
# The last border spacing is outside of the group.
group.height -= border_spacing_y
+
+ if force_page_break:
+ resume_at = (index, row)
+ break
+
table = table.copy_with_children(new_table_children)
# If the height property has a bigger value, just add blank space
@@ -210,13 +229,11 @@ def table_layout(document, table, max_position_y, containing_block,
group.width = last.position_x + last.width - first.position_x
group.height = columns_height
-
if ((table.position_y + table.margin_height()) > max_position_y
and not page_is_empty):
# If the table does not fit, put it on the next page.
# (No page break inside tables yet.)
table = None
- resume_at = None
next_page = 'any'
adjoining_margins = []
collapsing_through = False
Please sign in to comment.
Something went wrong with that request. Please try again.