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

58 Commits

Author SHA1 Message Date
Guillaume Ayoub
6fb4c08e49 Fix top-margin of out-of-flow elements at the top of pages
We were already trying to get the correct top margin of the child, but we
didn’t include subtleties introduced by unforced page breaks. The logic is
still duplicated, it already was, but at least now the copy-paste is correctly
done.

Fix #1058.
2022-09-21 18:17:46 +02:00
Guillaume Ayoub
c64eec81cc Correctly detect reported footnotes for repagination
Fix #1700.
2022-08-15 12:26:06 +02:00
Guillaume Ayoub
0a21cf9ffe Merge branch '56.x' 2022-07-13 22:48:06 +02:00
Guillaume Ayoub
adec43adc4 Fix code and tests for max-height set on footnotes
The bug in the code was caused by the page_is_empty variable. It’s useless to
test this variable here because we know that we rendered at least the current
line. It’s not updated earlier, but if it were it would always be True.

This commit also fixes minor bugs in the tests.

Fix #1674.
2022-07-13 22:45:26 +02:00
Lucie Anglade
8f5bee1d51 Some tests for max-height on footnote area.
Related to #1674.
2022-07-13 22:10:12 +02:00
Guillaume Ayoub
5d9e5f7040 Update and fix URLs in comments and documentation 2022-06-28 15:59:06 +02:00
Guillaume Ayoub
e212c83b50 Remove useless parameters from testing utils 2022-05-23 23:09:32 +02:00
Guillaume Ayoub
a001af7c33 Remove useless parameters from tests helpers 2022-05-23 12:01:11 +02:00
Guillaume Ayoub
96f26504ce Use the original box when breaking waiting children
Before this commit, when we had to break previously rendered waiting children
in a line, we re-rendered the already-rendered children. That was bad, because
the tree of the children that were already rendered were different from the
original tree, that may include leading spaces for example. It also required a
complex mix of the original resume-at with the original skip-stack.

This new solution includes both the original child (to render it from a fresh
start) and the already-rendered child (to get the previous positions). The
skip-stack mix is now useless, removing a lot of complex code.

This change is scary and will probably break some corner cases. But tests pass,
and a new one has been added to avoid future regressions.

Fix #1638.
2022-05-09 22:39:31 +02:00
Guillaume Ayoub
a4d52533ec Add and improve tests for the "html" module 2022-05-05 15:47:43 +02:00
Guillaume Ayoub
733815c96b Test invalid images 2022-05-04 16:01:40 +02:00
Guillaume Ayoub
491503c482 Handle "footnote-policy: auto" footnotes correctly 2022-05-03 09:48:17 +02:00
Guillaume Ayoub
eb489e5847 Minor cleanups 2022-05-03 09:33:14 +02:00
aschmitz
29bd8f932f fix: sequential footnotes could disappear when overflowing
Previously, if a footnote triggered an overflow (that is, it was too
large for the containing space), but footnote-policy didn't make us push
down the line containing it, any subsequent footnotes in the same
linebox would not be set into a footnote area, because they would never
be passed to layout_footnote and report_footnote. (Their call sites
would be set, but their content would not be.)

This also fixes a potential infinite loop where using footnote-policy
could have forced the first line of a page to be pushed to the next
page: that will just result in an infinite loop, so instead we set the
line and move on if we are on the first line of a page. (This behavior
is not specified in GCPM, but no other behavior seems practical: the
only alternative would be to expand the page, which is almost certainly
less desirable.)
2022-05-02 14:27:51 -05:00
Guillaume Ayoub
bc1770f97b Rename tests 2022-04-28 16:48:46 +02:00
Lucie Anglade
185ea5380f Make test pass indenpently of default font size 2022-04-28 12:12:09 +02:00
Guillaume Ayoub
e1de59af96 Reset the bottom space even when we don’t fill the columns 2022-04-25 18:30:27 +02:00
Guillaume Ayoub
6bd5a59a04 Stop rendering when column content doesn’t fit in the page 2022-04-25 18:26:04 +02:00
Guillaume Ayoub
709255bc44 Test overconstrained relative blocks 2022-04-18 14:43:22 +02:00
Guillaume Ayoub
ee19c6af9c Test break-before: page on root boxes 2022-04-18 12:51:21 +02:00
Guillaume Ayoub
c2b2457f54 Test reset page counters 2022-04-18 12:06:36 +02:00
Guillaume Ayoub
aa4df152e9 Remove more and more white backgrounds 2022-04-17 09:32:15 +02:00
Guillaume Ayoub
f3763b8bfa Remove useless white backgrounds from tests 2022-04-16 13:54:07 +02:00
Guillaume Ayoub
e06e829b5d Try hard to follow break-inside: avoid-column 2022-04-13 23:03:50 +02:00
Guillaume Ayoub
6ba031e8c7 Fix skip stacks for columns
Fix #984, fix #1604.
2022-04-09 08:51:51 +02:00
Guillaume Ayoub
56f0d4adb0 Deactivate orphans and widows for tests
The default "2" value for orphans and widows is really useful for real
documents, but it can be very disturbing for tests and introduce false
negatives and false positives.
2022-04-03 16:42:11 +02:00
Guillaume Ayoub
04b0f45e50
Merge pull request #1619 from Kozea/break-column
Initial support of column breaks
2022-04-03 15:54:18 +02:00
Guillaume Ayoub
48f784e718 Add and improve tests for breaks in columns 2022-04-03 13:41:23 +02:00
Guillaume Ayoub
9e1b1560af Add missing asserts in tests 2022-04-02 18:54:23 +02:00
Guillaume Ayoub
0792c0d3a3 Clean docstrings in modules 2022-03-25 11:47:27 +01:00
aschmitz
ad6e0d729f perf: improve column handling speed, fix infinite loops
The primary change here is that the column calculation algorithm now
attempts to render columns as if they were the full remaining height on
the page, rather than to render the entire content regardless of how
long the page is.

The worst-case behavior is effectively the same as that of the previous
algorithm (as at least one additional pass would be required to
determine how high balanced columns should be, but this applies in both
cases), but if content would not fit on the page, this can bail and set
the page immediately, rather than continuing significantly more
calculations.

As an associated benefit, this closes #1020, as we now handle multiple
column breaks (which would force a page break) correctly. A test for
this behavior is included.
2022-03-17 00:32:02 -05:00
aschmitz
1d7ddfdf38 fix: more robustly handle unlayout'ing a footnote
This fixes a bug accidentally introduced in #1566, where we would try to
unlayout a footnote that had not yet been laid out, if the algorithm
decided that there would be insufficient space on a page before laying
out a further footnote.
2022-02-14 17:51:28 -06:00
aschmitz
f953fb8de0 fix: don't output footnotes before their call sites
If a footnote has been output but we then decide to cancel the line it
was output on, we should cancel the output of the footnote itself.

This requires a bit of extra bookkeeping, so we know which footnotes are
relevant, but otherwise largely works using the existing
remove_placeholders code.

Includes a minor refactor of footnote area management in LayoutContext,
and a new testing utility: `tree_position`.

Closes #1564.
2022-02-10 01:02:21 -06:00
aschmitz
7f8545c560 fix: handle float rounding when extending boxes over page breaks
When a box would break over the edge of a page, its height is extended
to the bottom of that page (per
https://www.w3.org/TR/css-break-3/#box-splitting , primarily to allow
backgrounds and borders to continue to the end of the page).

When this happened, sometimes the values that would be calculated for
the height of the extended element would be rounded *over* the
calculated height that remained on the page, forcing the entire
containing box to wrap to the next page.

Rather than trying to carefully manage the order of operations to try to
be safe in IEEE floats for directions, we apply a small "fudge factor":
if an element fits very nearly (within a thousandth of a pixel) into the
remaining space, it is still accepted.
2022-02-01 18:13:39 -06:00
Guillaume Ayoub
563ee6f98c Handle break-inside: avoid in tr
Fix #1547.
2022-01-25 15:57:58 +01:00
Guillaume Ayoub
4f434343ba Avoid infinite loops with td with break-inside: avoid
Related to #1547.
2022-01-25 12:35:59 +01:00
Guillaume Ayoub
0ae65b8297 Layout positioned boxes in page margins
Fix #1540.
2022-01-24 16:11:18 +01:00
Lucie Anglade
cd8a4637aa Related to #1540.
Regression test
2022-01-14 15:26:03 +01:00
Lucie Anglade
f8c9747962 Don’t crash when running elements aren’t ParentBoxes 2022-01-14 15:19:26 +01:00
Guillaume Ayoub
72d05e319f Don’t crash with absolute flex boxes
Fix #1536.
2022-01-10 14:31:49 +01:00
Guillaume Ayoub
3f596ce21f Fix footnotes for repaginated documents 2021-12-10 17:51:10 +01:00
Guillaume Ayoub
8cc6b258a0 Handle footnote-policy 2021-12-09 16:20:39 +01:00
Guillaume Ayoub
f54da35dc7 Report footnotes when previous footnotes are already reported 2021-12-08 21:00:21 +01:00
Guillaume Ayoub
7126f1b804 Remove useless color from tests 2021-12-08 20:29:31 +01:00
Lucie Anglade
7c8c291d96 Add reported footnote test 2021-12-08 17:43:19 +01:00
Guillaume Ayoub
5e6b21cec8 Fix last tests for footnotes 2021-12-08 15:35:54 +01:00
Guillaume Ayoub
ed0916d55c Fix more tests for footnotes 2021-12-08 15:16:45 +01:00
Guillaume Ayoub
a702292a1a Fix inline footnotes test 2021-12-08 15:02:46 +01:00
Guillaume Ayoub
6f190a2f20 Add missing underlines and empty strings 2021-12-07 14:46:07 +01:00
Lucie Anglade
c5f03c2c89 More footnotes tests 2021-11-30 11:24:25 +01:00