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

344 Commits

Author SHA1 Message Date
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
Guillaume Ayoub
7fe5e43a2d Minor cleanups 2022-05-02 22:34:51 +02:00
aschmitz
2f207d13ab 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 21:50:31 +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
aa348dabe7 Add failing test about floats
Related to #1629.
2022-04-28 16:48:46 +02: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
67075b4c46 Merge branch '55.x' 2022-04-25 23:43:37 +02:00
Guillaume Ayoub
3ad6982f4e Fix available height for absolute boxes with "bottom" property set
Fix #1626.
2022-04-25 23:42:36 +02:00
Guillaume Ayoub
3802f8857a Fix the y position of split absolute boxes 2022-04-25 23:42:24 +02:00
Guillaume Ayoub
2a8ca143c0 Revert and test "Remove useless condition"
This reverts commit 34944e06c4.
2022-04-25 19:07:33 +02:00
Guillaume Ayoub
e5e6b88203 Reset the bottom space even when we don’t fill the columns 2022-04-25 19:07:23 +02:00
Guillaume Ayoub
964109867f Stop rendering when column content doesn’t fit in the page 2022-04-25 19:07:13 +02:00
Guillaume Ayoub
f5b970eb26 Revert and test "Remove useless condition"
This reverts commit 34944e06c4.
2022-04-25 19:05:53 +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
1e4fde4ee0 Clean font management 2022-04-19 00:01:50 +02:00
Guillaume Ayoub
709255bc44 Test overconstrained relative blocks 2022-04-18 14:43:22 +02:00
Guillaume Ayoub
1b8ba2c3ab Test string(…, start) 2022-04-18 13:08:32 +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
a869831740 Add drawing tests 2022-04-18 11:48:35 +02:00
Guillaume Ayoub
aa4df152e9 Remove more and more white backgrounds 2022-04-17 09:32:15 +02:00
Guillaume Ayoub
d4f3fcfd71 Clean, fix and test backgrounds 2022-04-17 09:22:13 +02:00
Guillaume Ayoub
ae8f3b4cc8 Clean expanders tests and code 2022-04-17 07:34:03 +02:00
Guillaume Ayoub
1cb02f03b5 Add tests for CSS prefixes 2022-04-16 15:49:14 +02:00
Guillaume Ayoub
f3763b8bfa Remove useless white backgrounds from tests 2022-04-16 13:54:07 +02:00
Guillaume Ayoub
20f8924dda Test border radius 2022-04-16 13:47:14 +02:00
Guillaume Ayoub
3ccbc8f077 Add more tests for leaders 2022-04-16 12:27:57 +02:00
Guillaume Ayoub
e544398b00 Mark tests as failing because of Ghostscript
See https://bugs.ghostscript.com/show_bug.cgi?id=705225.
2022-04-15 15:47:05 +02:00
Guillaume Ayoub
2e726a3965 Don’t generate PDF with 0-scale transformation matrices for text 2022-04-15 14:53:19 +02:00
Guillaume Ayoub
d49f93fcd2 Test skew for links 2022-04-15 12:19:42 +02:00
Guillaume Ayoub
e06e829b5d Try hard to follow break-inside: avoid-column 2022-04-13 23:03:50 +02:00
Guillaume Ayoub
79f7677a43 Fix test
Even if there are many unsupported cases, this one was a real bug in the test.

Related to #1621.
2022-04-13 10:21:19 +02:00
Guillaume Ayoub
af9a495177 Improve inheritance of text-decoration-* properties
The text-decoration-* properties are not inherited anymore, they are propagated
according to specific rules.

This commit removes the inheritance, but it doesn’t follow all the rules
defined by the specification. The new behavior is not perfect, but it should be
at least better than the previous code and opens the possibility to fix this
issue correctly in the future.

Failing tests have been added.

Fix #1621.
2022-04-13 09:39:09 +02:00
Guillaume Ayoub
20c91dcef5 Fix multiple text decorations drawing
Fix #1621.
2022-04-12 14:59:13 +02:00
Guillaume Ayoub
6ba031e8c7 Fix skip stacks for columns
Fix #984, fix #1604.
2022-04-09 08:51:51 +02:00
Guillaume Ayoub
eb997d1573 Draw borders around absolute images
Fix #1093.
2022-04-05 12:37:20 +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
3f3956844a Test SVG transforms 2022-03-27 22:26:53 +02:00
Guillaume Ayoub
ea50bc578a Add one SVG marker test 2022-03-27 21:46:43 +02:00
Guillaume Ayoub
7fd7413aa2 Test (and fix) SVG markers 2022-03-27 19:57:02 +02:00
Guillaume Ayoub
fe1f3d9e98 Fix and test broken absolutes in lines 2022-03-25 21:37:44 +01:00
Guillaume Ayoub
089ffa4480 Add tests for absolutes 2022-03-25 15:27:58 +01:00
Guillaume Ayoub
f39c5ab4b0 Add an improve tests for SVG 2022-03-25 15:20:22 +01:00
Guillaume Ayoub
0792c0d3a3 Clean docstrings in modules 2022-03-25 11:47:27 +01:00
Guillaume Ayoub
2f8d4999d7
Merge pull request #1613 from Kozea/fix_1512
ltr for absolute boxes
2022-03-24 18:10:59 +01:00
Lucie Anglade
b33cb3f26d Add some tests 2022-03-23 18:26:47 +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
Guillaume Ayoub
ea558e8b63
Merge pull request #1588 from aschmitz/absolutes-in-footnotes
fix: support position: absolute in footnotes
2022-03-07 16:02:27 +01:00
aschmitz
e7397c8b50 fix: support position: absolute in footnotes
Previously, this would throw an error because absolute_layout hadn't had
a chance to lay out the boxes. Now we do the block level layout for
footnotes *before* doing layout for absolute boxes (or fixed boxes) and
add any positioned boxes to positioned_boxes so they can be put onto the
page correctly.
2022-03-03 22:10:21 -06:00
Guillaume Ayoub
7034d67e07 Merge branch '54.x' 2022-03-02 21:07:31 +01:00
Guillaume Ayoub
c1178a559c Fix (and test) discarded text-align values
Fix #1586.
2022-03-02 20:57:26 +01:00
Guillaume Ayoub
a969ec1c64
Merge pull request #1570 from aschmitz/fix-repeat-unlayout
fix: more robustly handle unlayout'ing a footnote
2022-02-26 09:00:19 +01:00
aschmitz
9b0a672acd 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-20 14:42:48 +01: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
Guillaume Ayoub
cf0622128a Use the default value of decode/encode when possible 2022-02-14 10:55:47 +01:00
Guillaume Ayoub
0a6f86945b Don’t remove soft hyphens before drawing text 2022-02-14 08:55:09 +01:00
Guillaume Ayoub
c9871cf7fb Remove useless dels 2022-02-14 08:15:55 +01: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
Guillaume Ayoub
9003fd0490 Use utf-8 instead of utf8 2022-02-08 22:41:03 +01:00
Guillaume Ayoub
c3c5f08e91 Merge branch '54.x' 2022-02-08 12:19:41 +01:00
Guillaume Ayoub
562a2499a1 Fix line break when breaks occur between a nbsp and an inline block
This commit:

- fixes the trailing space detection, by handling all trailing spacing
  characters that could be ignored by Pango’s line break algorithm;
- tries harder to break waiting children when a line break occurs in an
  inline block that can’t be separated from the previous one.

Fix #1562.
2022-02-08 12:16:10 +01: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
7108a16f87 Add a test about text rotation
Related to #1554.
2022-01-30 14:30:57 +01:00
Guillaume Ayoub
8d19ab4157 Merge branch '54.x' 2022-01-25 15:58:36 +01: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
476a8f593b Uncomment passing test 2022-01-24 21:32:33 +01:00
Guillaume Ayoub
51f8a0dc52 Merge branch '54.x' 2022-01-24 16:14:25 +01:00
Guillaume Ayoub
0ae65b8297 Layout positioned boxes in page margins
Fix #1540.
2022-01-24 16:11:18 +01:00
Guillaume Ayoub
d06ad070d5
Merge pull request #1534 from aschmitz/wrap-improvements
Fix `overflow-wrap`, support `word-break: break-all`
2022-01-16 09:31: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
a10032c987 Don’t crash with absolute flex boxes
Fix #1536.
2022-01-10 14:31:09 +01:00
aschmitz
480a6ed3bf feat: support word-break: break-all
This adds support for the `break-all` value for `word-break`. The
`keep-all` and `break-word` properties are not yet supported.
2022-01-04 19:08:16 -06:00
aschmitz
439e129561 fix: don't wrap overflow-wrap: anywhere unnecessarily
Previously, if `overflow-wrap: anywhere` (or `break-word`) was set on an
inline element (like an `<a>` or `<span>`) whose first word occurred
towards the end of a line, it would have broken that word, even if doing
so wasn't necessary (and wouldn't have happened were it not for the
wrapping element).

This pipes through a `is_line_start` argument to `split_text_box` that
only allows the break on a word if it's the first word in a line.
2022-01-04 19:03:48 -06:00
Guillaume Ayoub
467748ad0e Handle text-align: inherit 2021-12-28 18:19:29 +01:00
Guillaume Ayoub
810e75b5f4 Handle flex: inherit 2021-12-28 18:09:25 +01:00
Guillaume Ayoub
d4895edae0 Handle flex-flow: inherit 2021-12-28 17:50:58 +01:00
Guillaume Ayoub
6aa5bc8dc1 Handle line-clamp: inherit 2021-12-28 17:48:17 +01:00
Guillaume Ayoub
df28018e92 Handle page-break-inside: inherit 2021-12-28 17:42:13 +01:00
Guillaume Ayoub
86176384fd Handle border-radius: inherit 2021-12-28 17:38:47 +01:00
Guillaume Ayoub
f915ca2938 Handle page-break-after/before: inherit 2021-12-28 17:20:34 +01:00
Guillaume Ayoub
385bb77819 Merge branch 'master' into inherit 2021-12-21 13:08:35 +01:00
Christoph Kepper
bc22f29cb5 #1007 Make 'inherit' value work correctly for word-wrap and overflow-wrap properties 2021-12-21 12:27:46 +01:00
Guillaume Ayoub
8d2c549a82 Update y position when table cells are broken
Fix #1523.
2021-12-20 21:03:58 +01:00
Guillaume Ayoub
ea317e5b94 Fix split tables with border collapse 2021-12-20 14:44:43 +01:00
Guillaume Ayoub
587f235647 Comment failing bug 2021-12-18 20:03:15 +01:00
Guillaume Ayoub
e61422ef72 Remove decorations at the top of broken tables 2021-12-14 15:49:42 +01:00
Guillaume Ayoub
b18b67a241 Handle 'inherit' value in text-decoration
Related to #1007.
2021-12-14 11:30:45 +01:00
Guillaume Ayoub
7a5c285c87 Don’t remove inline block’s trailing space twice
When we calculate the minimum width of an inline block, the size of the
trailing space is already removed by split_first_line. There’s no need to
remove it twice.

We should probably fix split_first_line to remove the trailing space only when
it’s been asked to. But there’s no obvious situation when we want the minimum
width to include trailing spaces, as the minimum size requires line breaks
everywhere, including after each space.

At least, this commit doesn’t remove trailing spaces twice.

Related to #1520.
2021-12-13 13:08:01 +01:00
Guillaume Ayoub
a65ca19bed Add (failing) tests about minimum width with trailing spaces
Related to #1520.
2021-12-13 12:10:48 +01:00
Guillaume Ayoub
6fb0269a36 Add overflow-wrap tests with trailing spaces 2021-12-13 11:20:39 +01:00