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

108 Commits

Author SHA1 Message Date
Guillaume Ayoub
4c81663305 Fix layout when all footnotes are removed from the footnote area 2024-06-11 15:55:58 +02:00
Guillaume Ayoub
40d8394199 Fix a rounding error when detecting overflows
Fix #2100.
2024-03-18 09:18:43 +01:00
Guillaume Ayoub
c6468e5395 Fix "pages" counter in non-root absolute boxes
These boxes were not available through the "descendants" function, because they
are represented by placeholders. They are also not available in the list of
absolute boxes of the page, because they’re not relative to the root page.

The new "placeholders" parameter of "descendants" goes through placeholders and
gets all the absolute children.

Putting "descendants" and "children" in all boxes, not just parents, avoids
useless checks and special cases.

Fix #2029.
2024-01-29 15:51:16 +01:00
Guillaume Ayoub
7bcfb14998 Use dictionary to store API options
This commit uses an "option" dictionary to store various API options that were
used as arguments in many public and private functions. This change allows to
easily document default values, to reduce the number of arguments and to avoid
many repetitions in documentation and signatures.

The changes to the public API are minimal, and should only have an impact for
users who passed unnamed arguments.
2023-04-13 19:34:22 +02:00
Guillaume Ayoub
3fefe88cff Take care of bottom margin when calculating footnote area overflow 2022-09-13 11:39:02 +02:00
Guillaume Ayoub
5ff90ba5fe Correctly handle footnotes in columns 2022-08-19 16:46:11 +02:00
Guillaume Ayoub
e1093d36ea Clean comment 2022-08-15 11:26:00 +02:00
Guillaume Ayoub
0a21cf9ffe Merge branch '56.x' 2022-07-13 22:48:06 +02:00
Guillaume Ayoub
c4bf165d3e Follow max-height on footnote area
This solution is by far the cleanest I’ve found to follow max-height without
changing everything. Contrary to my previous tries, it keeps the original style
untouched, doesn’t add dirty properties on the box and only assumes that the
overflowing children are caused by the max-height set on the area. This last
condition is probably true in real-life cases, but we’ll sure find soon that
other users don’t have the real life we expect them to have.

It also has the side effect of following the height attribute too. There’s
nothing in the specification about which properties are allowed in @footnote
rules, only a classical "How would one describe this in the grammar of
CSS3-Page?", so … who cares? We’ll sure find soon that other users actually
care more than the W3C.

The existing tests pass, that’s good news, but we’ll need solid new tests.

Related to #1674.
2022-07-11 22:24:18 +02:00
Guillaume Ayoub
902bde7d9c Take care of floats when removing placeholders
Removing placeholders is something we have to do when we must discard a part of
the layout that has already been done. It currently removes absolutely
positioned placeholders and footnotes.

The same has to be done with split floats, that’s what this commit is about.

We have to change the structure of the broken_out_of_flow attribute, as we have
to get a reliable way to reach the saved data using from the real element in
the tree. The new structure is thus a dictionary whose keys are the boxes in
the tree (placeholder for absolutes, partial elements for floats) and whose
values are the original_box+parent+resume_at.

Fix #1669.
2022-06-30 15:29:50 +02:00
Guillaume Ayoub
5d9e5f7040 Update and fix URLs in comments and documentation 2022-06-28 15:59:06 +02:00
Guillaume Ayoub
ae83010c83 Set default values for block_level_layout 2022-06-20 15:55:00 +02:00
Guillaume Ayoub
d06e5ea5bb Initial and partial support of nested line-clamp 2022-06-13 16:35:51 +02:00
Guillaume Ayoub
7d0987e19d Initial support of break-*: avoid-column 2022-03-25 10:25:48 +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
Guillaume Ayoub
fe3e3b992f Avoid floating points errors (almost) everywhere
Related to #1559.
2022-02-20 14:41:08 +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
e17e5368f7 Update and clean docstrings. 2022-02-14 07:11:30 +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
b62d5a3f26 Use explicit attributes instead of hasattr function 2022-01-24 11:11:06 +01:00
Guillaume Ayoub
f5d6d54cca Split absolute boxes
Fix #36.
2021-12-12 18:58:04 +01:00
Guillaume Ayoub
21484fafba Merge branch 'master' into footnotes 2021-12-11 17:05:33 +01:00
Guillaume Ayoub
3f596ce21f Fix footnotes for repaginated documents 2021-12-10 17:51:10 +01:00
Guillaume Ayoub
313a09d10e Handle footnote-display
Handling footnote-display requires the footnote area children to be recreated
each time one footnote is added: as footnotes can be blocks or inlines, we have
to create anonymous boxes each time, and thus to do the whole footnote area
layout.
2021-12-07 15:58:27 +01:00
Guillaume Ayoub
232d9eff3b Don’t test twice that footnotes are in the list 2021-12-07 15:14:37 +01:00
Guillaume Ayoub
6a9dac4861 Replace max_position_y by bottom_space
As the bottom of the page is now dynamic (because it changes with footnotes),
passing the max_position_y is difficult: it would require the value to be
passed to layout functions, and returned (possibly updated) by these functions.

The new solution is to store the page bottom in the context, and to update it
when a footnote is included. The new max position y is calculated when needed,
using the updated position of the page bottom.

To handle extra bottom spaces (bottom padding/border/margin of a parent box for
example), a bottom_space parameter is given when needed. This value can be set
to -inf when we don’t want to take care of the page bottom (that’s equivalent
to max_position_y=inf).
2021-11-27 17:01:16 +01:00
Guillaume Ayoub
a3b7f7fa71 Display footnotes on the next page when they don’t fit 2021-11-27 14:42:09 +01:00
Guillaume Ayoub
2da0a6c9cf Update vertical max position when displaying footnotes 2021-11-23 16:18:52 +01:00
Guillaume Ayoub
fe5fa64f57 Display footnotes at the bottom of the page 2021-11-23 13:37:53 +01:00
Guillaume Ayoub
1c3fd972bd Store footnotes in the layout context 2021-11-19 11:39:47 +01:00
Guillaume Ayoub
dbec957f5c Handle parallel flows for floats in simple cases 2021-11-02 21:22:39 +01:00
Guillaume Ayoub
35fa9037fd Rename layout files to follow "display" values 2021-09-13 15:37:29 +02:00
Guillaume Ayoub
3aca9f1f84 Change the resume_at and skip_stack structure
Many operations, including page breaks, require a pointer to a specific
position of the box tree. For example, we used to have this structure to point
to the beginning of the first child of the second child:

(1, (2, None))

We now use:

{1: {2: None}}

This change is the first step to handle parallel flows (see #36). It doesn’t
change anything to the layout for now, but it allows us to store multiple
pointers in the same structure.

The next step is to handle multiple pointers in skip_stack during boxes layout.
It means that most of the *_layout() function need an extra for-loop to manage
multiple skip stacks.

We’ll then need to split new types of boxes: table cells, floats, absolutes…
2021-08-22 12:10:48 +02:00
Guillaume Ayoub
89b6fe39fc Fix page break value comparison 2021-08-21 19:56:21 +02:00
Guillaume Ayoub
66d2b4da3c First SVG text test 2021-04-14 16:56:30 +02:00
Guillaume Ayoub
12999bded8 Merge branch 'master' into pydyf 2020-10-23 12:36:03 +02:00
Tontyna
4c67371f32 Prevent repetition of bookmarks
Remove duplicate bookmark-labes when pagination is finished.
The box.element helps detecting them.

Resolves #1145
2020-06-19 13:22:40 +02:00
Tontyna
ad564d78c1 Copy bookmark-labels after (re)pagination
box.string_set is a pointer and is updated automatically when
parse_again() is called for page based counters and target-*.

box.bookmark_label is just a string an we must copy it explicitly
from the re-evaluated original boxes to the page's children.
2020-06-18 22:36:26 +02:00
Guillaume Ayoub
9372b94e8d Clean formatted strings 2020-05-30 15:55:44 +02:00
Guillaume Ayoub
bf2b21b6e0 First steps to replace cairo with pydyf 2020-04-18 00:19:35 +02:00
Guillaume Ayoub
b40ad461be Remove repeated copyright assignments in files
Everything is replaced by a more explicit message in the COPYRIGHT file.

Inspired by rust-lang/rust#43498 and rust-lang/rust#57108.
2020-01-02 14:10:09 +01:00
Guillaume Ayoub
47ec97bcaf Remove useless explicit object inheritance 2020-01-02 12:06:58 +01:00
Guillaume Ayoub
a036fe8f4b Remove counters.py 2019-12-24 15:18:10 +01:00
Guillaume Ayoub
14a8a2bb9e Fix first-except value for element() and string()
On pages where the string was defined, the returned value was the entry value
instead of being the empty string. It doesn’t change anything on pages where
the value is defined for the first time, but it was different otherwise.
2019-12-22 17:45:25 +01:00
Guillaume Ayoub
916e34f637 Handle the second argument of element() 2019-12-22 15:52:48 +01:00
Guillaume Ayoub
eca2a6b4fa Remove useless u'…' in comments 2019-12-19 15:21:55 +01:00
Guillaume Ayoub
0a403d9d16 Remove RunningPlaceholder 2019-09-27 11:53:30 +02:00
Holger Brunn
b30ffb1694
[ADD] position: running(); content: element(); 2019-09-22 23:21:31 +02:00
Raphael Gaschignard
afc7dabc1b Refactor LayoutContext building
this will provide a simpler API for testing context-using functions inside tests
2019-07-23 14:12:08 +09:00
Guillaume Ayoub
be6c46ce86 Minor fixes 2019-04-02 11:35:23 +02:00