diff --git a/weasyprint/draw.py b/weasyprint/draw.py index ed3a53008..ee57e083a 100644 --- a/weasyprint/draw.py +++ b/weasyprint/draw.py @@ -896,21 +896,19 @@ def draw_collapsed_borders(context, table, enable_hinting): body_rows_offset = skipped_rows - header_rows else: body_rows_offset = 0 - if header_rows == 0: - header_rows = -1 - if footer_rows: - first_footer_row = grid_height - footer_rows - 1 - else: - first_footer_row = grid_height + 1 original_grid_height = len(vertical_borders) footer_rows_offset = original_grid_height - grid_height def row_number(y, horizontal): - if y < (header_rows + int(horizontal)): + # Examples in comments for 2 headers rows, 5 body rows, 3 footer rows + if header_rows and y < header_rows + int(horizontal): + # Row in header: y < 2 for vertical, y < 3 for horizontal return y - elif y >= (first_footer_row + int(horizontal)): + elif footer_rows and y >= grid_height - footer_rows - int(horizontal): + # Row in footer: y >= 7 for vertical, y >= 6 for horizontal return y + footer_rows_offset else: + # Row in body: 2 >= y > 7 for vertical, 3 >= y > 6 for horizontal return y + body_rows_offset segments = [] diff --git a/weasyprint/tests/test_draw/test_table.py b/weasyprint/tests/test_draw/test_table.py index 2883699bc..b92e687df 100644 --- a/weasyprint/tests/test_draw/test_table.py +++ b/weasyprint/tests/test_draw/test_table.py @@ -1048,3 +1048,59 @@ def test_tables_14(): x-col { background: red } x-td { padding: 0; width: 1px; height: 8px } '''}) + + +@assert_no_logs +@requires('cairo', (1, 12, 0)) +def test_tables_15(): + # Regression test for colspan in last body line with footer + # https://github.com/Kozea/WeasyPrint/issues/1250 + assert_pixels('colspan_last_row', 22, 36, ''' + ______________________ + __RRRRRRRRRRRRRRRRRR__ + __R_____R____R_____R__ + __R_____R____R_____R__ + __R_____R____R_____R__ + __RRRRRRRRRRRRRRRRRR__ + __R_____R____R_____R__ + __R_____R____R_____R__ + _BBBBBBBBBBBBBBBBBBBB_ + _BBBBBBBBBBBBBBBBBBBB_ + _BBB____R____R____BBB_ + _BBB____R____R____BBB_ + _BBB____R____R____BBB_ + _BBBBBBBBBBBBBBBBBBBB_ + _BBBBBBBBBBBBBBBBBBBB_ + ______________________ + ______________________ + ______________________ + ______________________ + __RRRRRRRRRRRRRRRRRR__ + __R________________R__ + __R________________R__ + __R________________R__ + _BBBBBBBBBBBBBBBBBBBB_ + _BBBBBBBBBBBBBBBBBBBB_ + _BBB____R____R____BBB_ + _BBB____R____R____BBB_ + _BBB____R____R____BBB_ + _BBBBBBBBBBBBBBBBBBBB_ + _BBBBBBBBBBBBBBBBBBBB_ + ______________________ + ______________________ + ______________________ + ______________________ + ______________________ + ______________________ + ''', ''' + + + + + + ''')