Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propose fix for issue #1278 #1884

Merged
merged 26 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ecc7941
Add test case for table with border-collapse in page margins
kygoh May 21, 2023
93e77a4
Backup border properties before setting to transparent borders
kygoh May 21, 2023
a9d0191
Restore original border properties before resolving border conflicts …
kygoh May 21, 2023
345d1f1
Coding style fix for lines exceeding 79 characters
kygoh May 21, 2023
4427d9f
Retain border width only when resolving collapsed borders
kygoh May 23, 2023
9e59b20
Store harmonized border-{...}-width in computed value collapse_border…
kygoh May 25, 2023
800a683
Set collapse_border_{...}_width as border_{...}_width used values in …
kygoh May 25, 2023
d87034f
Calculate margin width using collapse_border_{left,right}_width for c…
kygoh May 25, 2023
d4a79bc
Fix check for collapsed-borders mode in preferred margin width
kygoh May 25, 2023
fd1dbc7
Move collapsed-borders conflict resolution logic to layout.table module
kygoh May 26, 2023
0c9a6a1
Resolve border-{...}-width used values during collapsed-borders confl…
kygoh May 26, 2023
68f3486
Keep source updated
kygoh May 26, 2023
b3bdff8
Rename function to set used values for collapsed-borders width
kygoh May 26, 2023
16f8410
Sync source with upstream
kygoh May 31, 2023
bb382b5
Add references to computing table measures spec
kygoh May 31, 2023
5976f6d
Move collapse border test cases to layout
kygoh May 31, 2023
af141ba
Fix coding style
kygoh May 31, 2023
b18bbb3
Sync fix with master
kygoh Sep 3, 2023
6fc2eef
Test drawing for border collapse
liZe Sep 10, 2023
2a3747a
Mark extra test as xfail
liZe Sep 10, 2023
ce46dbe
Restore collapsed-borders conflict resolution to formatting_structure…
kygoh Sep 11, 2023
ce42883
Sync fix with master
kygoh Sep 18, 2023
d09ab65
Restore unit tests for collapsed borders conflict resolution logic
kygoh Sep 18, 2023
a9f719c
Merge branch 'main' into fix_issue_1278
liZe Jan 26, 2024
ad63510
Clean imports
liZe Jan 26, 2024
f11fcc4
Don’t store extra attributes only for tests
liZe Jan 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 219 additions & 0 deletions tests/draw/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1298,3 +1298,222 @@ def test_tables_23(assert_pixels):
<table>
<thead><tr><td>abcde</td><td>abcde</td></tr></thead>
<tbody><tr><td>abc abc</td><td></td></tr></tbody>''')


@assert_no_logs
def test_running_elements_table_border_collapse(assert_pixels):
assert_pixels(2 * '''
KK_____________
KK_____________
_______________
_______________
_______________
KKKKKKK________
KRRKRRK________
KRRKRRK________
KKKKKKK________
KRRKRRK________
KRRKRRK________
KKKKKKK________
_______________
_______________
_______________
''', '''
<style>
@font-face { src: url(weasyprint.otf); font-family: weasyprint }
@page {
margin: 0 0 10px 0;
size: 15px;
@bottom-left { content: element(table) }
}
body { font: 2px/1 weasyprint }
table {
border: 1px solid black;
border-collapse: collapse;
color: red;
position: running(table);
}
td { border: 1px solid black }
div { page-break-after: always }
</style>
<table>
<tr> <td>A</td> <td>B</td> </tr>
<tr> <td>C</td> <td>D</td> </tr>
</table>
<div>1</div>
<div>2</div>
''')


@assert_no_logs
def test_running_elements_table_border_collapse_empty(assert_pixels):
assert_pixels(2 * '''
KK________
KK________
__________
__________
__________
__________
__________
__________
__________
__________
''', '''
<style>
@font-face { src: url(weasyprint.otf); font-family: weasyprint }
@page {
margin: 0 0 5px 0;
size: 10px;
@bottom-left { content: element(table) }
}
body { font: 2px/1 weasyprint }
table {
border: 1px solid black;
border-collapse: collapse;
color: red;
position: running(table);
}
td { border: 1px solid black }
div { page-break-after: always }
</style>
<table></table>
<div>1</div>
<div>2</div>
''')


@pytest.mark.xfail
@assert_no_logs
def test_running_elements_table_border_collapse_border_style(assert_pixels):
assert_pixels(2 * '''
KK_____________
KK_____________
_______________
_______________
_______________
KKKZ___________
KRR_RR_________
KRR_RR_________
KKKK__Z________
KRRKRRK________
KRRKRRK________
KKKKKKK________
_______________
_______________
_______________
''', '''
<style>
@font-face { src: url(weasyprint.otf); font-family: weasyprint }
@page {
margin: 0 0 10px 0;
size: 15px;
@bottom-left { content: element(table) }
}
body { font: 2px/1 weasyprint }
table {
border: 1px solid black;
border-collapse: collapse;
color: red;
position: running(table);
}
td { border: 1px solid black }
div { page-break-after: always }
</style>
<table>
<tr> <td>A</td> <td style="border-style: hidden">B</td> </tr>
<tr> <td>C</td> <td style="border-style: none">D</td> </tr>
</table>
<div>1</div>
<div>2</div>
''')


@assert_no_logs
def test_running_elements_table_border_collapse_span(assert_pixels):
assert_pixels(2 * '''
KK_____________
KK_____________
_______________
_______________
_______________
KKKKKKKKKK_____
KRRKRRKRRK_____
KRRKRRKRRK_____
K__KKKKKKK_____
K__KRR___K_____
K__KRR___K_____
KKKKKKKKKK_____
_______________
_______________
_______________
''', '''
<style>
@font-face { src: url(weasyprint.otf); font-family: weasyprint }
@page {
margin: 0 0 10px 0;
size: 15px;
@bottom-left { content: element(table) }
}
body { font: 2px/1 weasyprint }
table {
border: 1px solid black;
border-collapse: collapse;
color: red;
position: running(table);
}
td { border: 1px solid black }
div { page-break-after: always }
</style>
<table>
<tr> <td rowspan=2>A</td> <td>B</td> <td>C</td> </tr>
<tr> <td colspan=2>D</td> </tr>
</table>
<div>1</div>
<div>2</div>
''')


@assert_no_logs
def test_running_elements_table_border_collapse_margin(assert_pixels):
assert_pixels(2 * '''
KK_____________
KK_____________
_______________
_______________
_______________
_______________
____KKKKKKK____
____KRRKRRK____
____KRRKRRK____
____KKKKKKK____
____KRRKRRK____
____KRRKRRK____
____KKKKKKK____
_______________
_______________
''', '''
<style>
@font-face { src: url(weasyprint.otf); font-family: weasyprint }
@page {
margin: 0 0 10px 0;
size: 15px;
@bottom-center { content: element(table); width: 100% }
}
body { font: 2px/1 weasyprint }
table {
border: 1px solid black;
border-collapse: collapse;
color: red;
margin: 1px auto;
position: running(table);
}
td { border: 1px solid black }
div { page-break-after: always }
</style>
<table>
<tr> <td>A</td> <td>B</td> </tr>
<tr> <td>C</td> <td>D</td> </tr>
</table>
<div>1</div>
<div>2</div>
''')
65 changes: 0 additions & 65 deletions tests/layout/test_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -1549,68 +1549,3 @@ def test_running_float():
Hello!
</footer>
''')


def _get_grid(table_wrapper):
table, = table_wrapper.children
return tuple(
[[(style, width, color) if width else None
for _score, (style, width, color) in column]
for column in grid]
for grid in table.collapsed_border_grid)


black = (0, 0, 0, 1)
red = (1, 0, 0, 1)
black_3 = ('solid', 3, black)
red_1 = ('solid', 1, red)


@assert_no_logs
def test_running_elements_table_border_collapse():
page0, page1 = render_pages('''
<style>
@page {
margin: 50px;
size: 200px;
@bottom-center { content: element(table) }
}
table { position: running(table) }
td { border: 1px solid red }
.content {
page-break-after:always;
}
</style>
<table style="border-collapse: collapse; border: 3px solid black">
<tr> <td>A</td> <td>B</td> </tr>
<tr> <td>C</td> <td>D</td> </tr>
</table>
<div class="content">page0</div>
<div class="content">page1</div>
''')

page0_html, page0_center = page0.children
page0_table = page0_center.children[0]
page0_vertical_borders, page0_horizontal_borders = _get_grid(page0_table)
assert page0_vertical_borders == [
[black_3, red_1, black_3],
[black_3, red_1, black_3],
]
assert page0_horizontal_borders == [
[black_3, black_3],
[red_1, red_1],
[black_3, black_3],
]

page1_html, page1_center = page1.children
page1_table = page1_center.children[0]
page1_vertical_borders, page1_horizontal_borders = _get_grid(page1_table)
assert page1_vertical_borders == [
[black_3, red_1, black_3],
[black_3, red_1, black_3],
]
assert page1_horizontal_borders == [
[black_3, black_3],
[red_1, red_1],
[black_3, black_3],
]
Loading