1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 00:21:15 +03:00
Commit Graph

255 Commits

Author SHA1 Message Date
Tontyna
fed74d1175 cleanup code to pass Travis CI check 2018-02-16 14:56:25 +01:00
Tontyna
4519ba5bee introduce TARGET_COLLECTOR for target-counter, -counters and -text 2018-02-11 22:42:26 +01:00
Guillaume Ayoub
2ef988ca20 Fix string-set logic 2018-01-23 01:55:16 +01:00
Guillaume Ayoub
6caec1ab4f Use content(first-letter) as defined for ::first-letter 2018-01-23 00:52:49 +01:00
Guillaume Ayoub
838933f428 Handle content(first-letter) 2018-01-23 00:45:28 +01:00
Guillaume Ayoub
c6e54d77f0 Remove pylint comments 2018-01-14 01:52:49 +01:00
Guillaume Ayoub
16e8186568 Drop Python 2 support 2018-01-14 01:48:17 +01:00
Guillaume Ayoub
ad11edfff2 Remove StyleDict objects 2018-01-13 17:41:08 +01:00
Guillaume Ayoub
724565f27a Don't allow attribute access to StyleDict objects 2018-01-13 17:05:23 +01:00
Guillaume Ayoub
359d42c641 Remove style's anonymous attribute 2018-01-13 16:34:14 +01:00
Guillaume Ayoub
0821148124 Handle align-items and align-self 2018-01-11 23:40:14 +01:00
Guillaume Ayoub
ce342cf0a2 Don't strip non-breaking spaces during flex layout 2018-01-11 00:45:42 +01:00
Guillaume Ayoub
f868abfdb2 Handle floats and inline-level boxes in flex boxes 2018-01-09 00:41:07 +01:00
Guillaume Ayoub
e9fdb0d843 Don't consider the flex container box as a block container box 2018-01-09 00:40:06 +01:00
Guillaume Ayoub
4f60ba9173 Initial support of baseline alignments for flex layout 2017-12-29 01:23:41 +01:00
Guillaume Ayoub
3027417f88 Merge branch 'master' into flexbox 2017-12-27 01:07:27 +01:00
Guillaume Ayoub
d62bfec60b Keep track of removed collapsing spaces for wrap opportunities 2017-12-26 12:39:20 +01:00
Guillaume Ayoub
69b64d2bd0 First working version of flex layout 2017-12-23 00:19:32 +01:00
Guillaume Ayoub
878cc41c51 Add a keywoard to translate boxes ignoring floating children 2017-12-12 18:20:00 +01:00
Guillaume Ayoub
ce70354488 Don't cross the whole tree when translating boxes by (0, 0) 2017-12-12 18:18:18 +01:00
lucien
34b825033d WIP: Flexbox - Step 1 and 2 of flexbox layout 2017-12-07 17:34:28 +01:00
Guillaume Ayoub
d4357e5a4a Copy styles for split boxes
This fixes blocks split between pages and inlines boxes split by block boxes.

Increases memory usage, related to #70.
2017-08-17 07:54:14 +02:00
Guillaume Ayoub
c41b55eb93 Don't crash when there's no displayed root element 2017-08-14 14:11:20 +02:00
Guillaume Ayoub
9a44e2f469 Copy the style of the wrapper as it will be modified
Sould be needed where the style is inherited and modified
2017-08-14 14:10:24 +02:00
Guillaume Ayoub
86be0e9287 Return the next page value in block_level_page_break 2017-08-04 11:51:35 +02:00
Guillaume Ayoub
84bdee14c3 Revert "Change table and table-* elements' style before creating StyleDicts"
This reverts commit ca8bc3e578.

The main change is the creation of StyleDicts removed from style_for, for
memory consumption problems.
2017-08-02 20:21:34 +02:00
Guillaume Ayoub
c779977271 Unfreeze StyleDict 2017-08-02 16:32:37 +02:00
Guillaume Ayoub
033f4738ab Remove first-letter style being calculated twice 2017-08-02 13:21:15 +02:00
Guillaume Ayoub
4aa7bb49f7 Change the signature of root_style_for 2017-08-02 13:18:58 +02:00
Guillaume Ayoub
f7903925fd Use a separate variable for justification spacing 2017-08-01 10:07:36 +02:00
Guillaume Ayoub
ca8bc3e578 Change table and table-* elements' style before creating StyleDicts 2017-07-31 13:48:58 +02:00
Guillaume Ayoub
0dc1bf6f8c Remove useless margin for inline markers 2017-07-31 11:28:23 +02:00
Guillaume Ayoub
b3865c811c Re-add a copy method for StyleDict 2017-07-28 22:28:29 +02:00
Guillaume Ayoub
56f27885f4 Remove StyleDict mutations and copies 2017-07-28 19:56:14 +02:00
Guillaume Ayoub
a2a29d7b6f Clean the way the anonymous attribute is set to tables and wrappers 2017-07-28 18:59:43 +02:00
Guillaume Ayoub
a3e2c474f0 Transform StyleDict into a kind of frozen dict
This forces to use a copy when changes are needed. Internal mutable structures
have also been changed into immutable ones (i.e. lists have been turned into
tuples).

This change is a really useful first step to greatly optimize memory and time
needed to render large documents, as allows us to cache style dicts more
safely. It's been already done in StyleDict.inherit_from, with a ~5-10% memory
benefice.
2017-07-28 13:35:06 +02:00
Guillaume Ayoub
344cb08f60 Don't copy styles when copying boxes, improve memory management
Style is not copied anymore when boxes are duplicated. Style dicts are not
modified anymore during the layout, as it was before for some properties:

- margins, borders and paddings when the box was split between two
  pages (useless as these computed values are stored directly in the box),
- top borders were changed in tables (useless for the same reason),
- bookmark labels and string sets are now stored in the box.

This commit can introduce very subtle bugs that are hard to debug. In the
future, we should try to freeze the style dicts before the layout.

Related to #70.
2017-07-22 13:51:03 +02:00
Guillaume Ayoub
ba26fa34a9 Use ElementTree's elements as much as possible 2017-07-03 15:19:05 +02:00
Guillaume Ayoub
df50204f3e Remove unsupported source lines 2017-07-01 00:28:14 +02:00
Guillaume Ayoub
4a5fa84f9f Use cssselect2 instead of cssselect 2017-06-30 17:54:02 +02:00
Guillaume Ayoub
b4a95c1fbe Why did isort decide to become this intolerant? 2017-06-03 16:05:33 +02:00
Guillaume Ayoub
10ee68d432 Fix imports for this crazy nazisort 2017-06-03 15:46:37 +02:00
Hugh Secker-Walker
376bf0fd73 Fix mutable default-argument in MarginBox constructor 2017-05-01 17:54:03 -04:00
Simon Sapin
0aa62e249e Switch to tinycss2 2017-03-26 18:44:21 +02:00
Guillaume Ayoub
4f4b4ed598 Use isort in tests 2017-03-25 00:33:36 +01:00
Guillaume Ayoub
ae040e1c71 Respect flake8 everywhere 2017-03-25 00:24:27 +01:00
Guillaume Ayoub
5c9a07bf1a Create first-letter box after white space handling
As ::first-letter depends on white space handling, we must create the
box after collapsing spaces, not during the build of the box tree.

This commit makes WeasyPrint pass most of the W3C tests related to
first-letter (and never crash). Known problems left include:

- list markers are considered as the first letter,
- lines may break between the first letter and the rest of the text
  (see #163 and #301),
- the CSS attributes are all kept, some should probably be removed (the
  spec doesn't give a whole list).

Even if W3C tests makes me quite confident (some of them are crazy),
tests must be added in WeasyPrint too.
2017-01-02 13:23:42 +01:00
Guillaume Ayoub
b9699688f6 Don't pass skip_stack to insert_first_letter 2016-12-04 16:55:29 +01:00
Guillaume Ayoub
4e8379cb90 Always use two colons for pseudo-elements
Tests now mix one and two colons in CSS, but the user agent stylesheet
and internal representation of the pseudo-elements now awlays use two
colons.
2016-12-04 16:43:49 +01:00
Guillaume Ayoub
5fa966bb42 Carefully check first-letter's char category
Use only the punctuation categories listed in the spec.
2016-12-04 16:33:03 +01:00
Guillaume Ayoub
c2cc15fd6a Initial support of ::first-letter
The pseudo-element is currently added at the end of the build, but it
should be done during the layout as the whitespaces at the beginning of
the tags may be skipped.
2016-12-04 16:12:22 +01:00
Guillaume Ayoub
05d5e7d726 Don't always copy boxes 2016-11-01 04:31:15 +01:00
Guillaume Ayoub
45c815870b Don't always copy style when copying boxes 2016-11-01 03:35:36 +01:00
Guillaume Ayoub
8b5d426625 Remove useless copies 2016-11-01 02:38:34 +01:00
Guillaume Ayoub
9abc034773 Change StyleDict into a real dict
This commit has a really good impact on speed (+15~30%) but a really bad
impact on memory usage (+30~40%).
2016-11-01 02:32:06 +01:00
Guillaume Ayoub
a0dc9d9272 Support text-transform: full-witdh 2016-08-21 00:47:13 +02:00
Guillaume Ayoub
f0912e4f2d Don't use no-break spaces to avoid text wrapping
Fix #189
2016-05-08 16:44:57 +02:00
Guillaume Ayoub
3f7c2fa109 Fix background drawing for table rows and columns
The background of table rows, rows groups, columns and columns groups
must only be draw behind cells.

Fix #151.
2016-01-16 17:33:52 +01:00
Guillaume Ayoub
3aa22479e4 Merge branch 'master' into tables 2016-01-15 13:18:03 +01:00
Guillaume Ayoub
da96902bda Fix many PEP8 errors and warnings
- Put line breaks after operators (that's OK)
- Don't assign lambdas, use functions (well, that's really explicit in
  PEP8, it's really verbose but why not)
- Put imports at the beginning of the file (only special cases for us)
2016-01-15 12:48:25 +01:00
Guillaume Ayoub
9b58dd7bde Fix comment about table group spans 2016-01-14 18:15:36 +01:00
Guillaume Ayoub
72e214ae2e Use David Baron's draft for auto table layout 2016-01-11 04:30:38 +01:00
Alex Eftimie
93f497bf11 Replace utf8 with utf-8 for gettext compatibility 2015-11-25 09:38:01 +02:00
Guillaume Ayoub
492619662f Fix some wrong conflict resolutions for table borders with inset and outset styles 2015-05-31 10:09:34 +02:00
Guillaume Ayoub
2d7f68e8a1 Use the same simple code for bookmark-labels and string-sets 2015-05-01 21:14:10 +02:00
Guillaume Ayoub
f0889c2589 Fix attr() and allow counters in string-set and bookmark-label 2015-05-01 20:28:42 +02:00
Guillaume Ayoub
862c334036 Don't try to compute attr() as it's been already replaced in computed_values 2015-05-01 11:14:24 +02:00
Guillaume Ayoub
273506d0ad Allow attr() in bookmark-label and string-set 2015-05-01 11:06:54 +02:00
Guillaume Ayoub
f78eb3763e Use the <content-list> defined in GCPM for string-set and bookmark-label
In this content-list, here are the possibilities:
- string: implemented
- counter/counters: not implemented, but easily possible
- content: implemented (but what's exactly the "string value of an element"?)
- attr: not implemented (I don't know how to do this)
2015-04-30 21:54:19 +02:00
Mike Z. Salem
d4ce068854 More changes for named string support
Reinstate support for psuedo elements as an arugument to `content()`
Have to check if a box is a `ParentBox` when using `decendants()` in `TEXT_CONTENT_EXTRACTORS` for psuedo elements because it was returning the value twice in a row (ex. "stringstring")
2015-03-21 18:54:14 -04:00
Mike Z. Salem
6e48c2e878 Set string-set default to 'none', altered validation & resolution [do nothing in that case]
Added validation to the second argument to `string()`
More info./discussion here: https://github.com/Kozea/WeasyPrint/pull/246#issuecomment-83994925
2015-03-21 00:08:12 -04:00
Mike Z. Salem
7db9be4005 Remove support of string set using psuedo elements. Was unsure of the change to the function in build.TEXT_CONTENT_EXTRACTORS. That would be part of the text anyways.
Combined test functions to conform to coding style of other tests.
2015-03-19 23:03:57 -04:00
Mike Z. Salem
8ef012fca8 Bug fix for string-set validation not accepting no argument (default should be 'text')
Alter TEXT_CONTENT_EXTRACTORS so that string-set can use ::before/::after
 - Don't allow empty string to be assigned to string set (happends with psuedo elements)
Added some documentation to explain string function resolution
2015-03-18 22:46:51 -04:00
Mike Z. Salem
bc51dec015 Basic support for named strings. String-set limited to one value. 2015-03-08 23:02:51 -04:00
Simon Sapin
43d1e73e65 Fix code formatting. (Clean flake8!) 2014-04-27 12:29:55 +01:00
Simon Sapin
c34221d215 2014. 2014-01-10 14:27:02 +00:00
Guillaume Ayoub
b0c7dd5e4e Update columns posititions when tables are translated (fix #82) 2013-12-27 17:06:31 +01:00
Guillaume Ayoub
4f904a955e Fix sign error for rounded content box 2013-12-10 18:29:58 +01:00
Simon Sapin
c346f8b061 border-radius: Fix overlapping curves with the used radii 2013-12-10 14:49:34 +00:00
Guillaume Ayoub
effb7d339a Use any() instead of +/or mix (see #80) 2013-12-10 15:09:43 +01:00
Guillaume Ayoub
0e02a170af Fix rounded content box (see #80) 2013-12-10 15:08:16 +01:00
Guillaume Ayoub
b850d613fe Add TODOs 2013-12-10 13:33:17 +01:00
Guillaume Ayoub
e7687785fd Fix background-clip for rounded corners (see #80) 2013-12-10 13:17:18 +01:00
Guillaume Ayoub
3e3accd619 Merge branch 'master' into border3 2013-08-14 12:50:32 +02:00
Guillaume Ayoub
324e3f7867 Don't crash when root element is not displayed (fix #113) 2013-08-04 14:52:47 +02:00
Guillaume Ayoub
eb22847dd2 Fix min and max calls 2013-06-07 19:21:02 +02:00
Guillaume Ayoub
aca98d7d38 Fix a couple of things again 2013-06-07 17:19:10 +02:00
Guillaume Ayoub
1bb50557bf Fix a couple of little things 2013-06-07 17:14:32 +02:00
Guillaume Ayoub
1e226cd88a Fix overlapping curves 2013-06-07 17:05:58 +02:00
Guillaume Ayoub
3256eebad1 Use better names for variables and methods about rounded boxes 2013-06-06 16:21:56 +02:00
Guillaume Ayoub
f0b8b755bd Draw solid and double borders 2013-06-06 15:58:00 +02:00
Guillaume Ayoub
0345af4d3d First commit about border-radius, works for the background 2013-06-05 18:56:57 +02:00
Le-Stagiaire
72c9c02b64 Typo in bookmark label 2013-05-24 16:27:11 +02:00
Simon Sapin
25bab1dc6c Fix #76: repeating <thead> and <tfoot> on every page with border-collapse. 2013-04-30 10:56:43 +02:00
Simon Sapin
302eae25b0 Have position: fixed elements repeated on every page. 2013-04-23 15:32:08 +02:00
Guillaume Ayoub
d406ad6eee Simplify 'white-space: nowrap' handling, fix corner cases. 2013-04-16 14:27:14 +02:00
Guillaume Ayoub
cae9f8cc00 Don't keep leading and trailing spaces in nowrap texts 2013-04-15 01:29:18 +02:00
Guillaume Ayoub
a2f8aada42 Fix 'white-space: nowrap' and add tests about this 2013-04-12 01:48:58 +02:00
Simon Sapin
1d1bf9cdc9 Flake8. 2013-04-11 12:08:53 +02:00
Simon Sapin
d53f091b17 Prepare for multiple background-image types. 2013-04-05 12:23:29 +02:00
Simon Sapin
171438f48e 2013 2013-04-03 16:23:48 +02:00
Simon Sapin
c49f060c9f Add support for -weasy-hyphens: none, cache hyphenation dictionaries 2013-02-27 13:44:57 +01:00
Simon Sapin
829c758788 Keep currentColor as a computed value, resolve in used value
According to the css3-color errata:
http://www.w3.org/Style/2011/REC-css3-color-20110607-errata.html
2013-01-23 16:52:47 +01:00
Simon Sapin
cfe59387e9 Whitespace fixes. 2013-01-23 16:41:46 +01:00
Guillaume Ayoub
145027536b Collapse consecutive text boxes 2012-12-26 16:42:45 +01:00
Guillaume Ayoub
488178c6ab Typo 2012-12-26 14:47:33 +01:00
Simon Sapin
28cb59fc8b Pre-compute transformation matricies.
… so that they are available when getting meta-data.
2012-10-06 11:26:55 +02:00
Simon Sapin
ae26c87bfd Handle background images at the end of layout 2012-09-13 10:41:22 +02:00
Simon Sapin
463a33c1af Fetch background images early
This removes the need to have a reference to the image cache
in draw.py
2012-09-12 18:36:00 +02:00
Simon Sapin
d1971b6e63 Remove unused imports. 2012-08-03 13:32:42 +02:00
Simon Sapin
30a5708373 Kill Document in formatting_structure/build.py and html.py 2012-07-12 15:54:22 +02:00
Simon Sapin
d038708b8b Kill Document in css/__init__.py 2012-07-12 15:21:37 +02:00
Simon Sapin
e955781b91 Fix border-collapse on multiple pages 2012-07-11 19:23:41 +02:00
Simon Sapin
34fc003c57 Paint collapsed table borders 2012-07-11 18:21:20 +02:00
Simon Sapin
fd96c0df0a Ignore margins on internal table boxes: fix #888
Also ignore padding on table with border-collapse
2012-07-11 16:39:17 +02:00
Simon Sapin
1deb3c3b43 Add border conflict resolution for border-collapse
(No layout or painting yet.)
2012-07-11 14:11:26 +02:00
Simon Sapin
22cb02c01a Update page sizing to the current ED
Namely:

* The size sets the page’s containing block
* 'auto' margins are now supported
* The width, min-width, max-width, height, min-height
  and max-height properties are now supported.
2012-07-03 14:54:15 +02:00
Simon Sapin
f0b04a8e37 Merge branch 'master' into float 2012-06-28 13:30:23 +02:00
Simon Sapin
f65619f452 Fix whitespace collapsing across not-in-normal-flow boxes. 2012-06-28 13:29:12 +02:00
Guillaume Ayoub
e12880b113 Handle float in inline as almost normal boxes 2012-06-21 16:03:29 +02:00
Guillaume Ayoub
36a6b6b6f3 Pass the fixed_boxes argument instead of using current_page
Cherry-picked from 043d71dc29

Conflicts:
	weasyprint/layout/absolute.py
	weasyprint/layout/blocks.py
	weasyprint/layout/float.py
	weasyprint/layout/inlines.py
2012-06-19 18:00:50 +02:00
Guillaume Ayoub
f9e7c40ca2 Fix the drawing order of fixed boxes
Cherry-picked from 568e0aeb70

Conflicts:
	weasyprint/layout/blocks.py
	weasyprint/layout/inlines.py
2012-06-19 17:42:15 +02:00
Guillaume Ayoub
d71ad36580 Merge branch 'master' into float 2012-06-19 14:53:40 +02:00
Guillaume Ayoub
4fe56316f6 Finally fix margin collapsing for blocks with clearance 2012-06-19 14:52:30 +02:00
Simon Sapin
f7d765e0c1 Bug fixes and tests on floats… 2012-06-15 17:59:15 +02:00
Simon Sapin
8497a7fc90 Fix the tests on PDF links 2012-06-14 22:06:30 +02:00
Simon Sapin
fd6c5451e0 Merge branch 'master' into float 2012-06-08 17:16:31 +02:00
Simon Sapin
d0a5a0b8f1 Fix borders on inline boxes split by a block inside. 2012-06-06 13:27:50 +02:00
Guillaume Ayoub
043d71dc29 Pass the fixed_boxes argument instead of using current_page 2012-06-06 12:04:09 +02:00
Guillaume Ayoub
568e0aeb70 Fix the drawing order of fixed boxes 2012-06-06 09:49:56 +02:00
Simon Sapin
5dde5d47e5 Handle degerate rowspan values.
Previously, such values crashed the layout.
2012-06-02 09:02:24 +02:00
Simon Sapin
2179957e4a Fix lines vs. anonymous blocks in precence of floats. 2012-06-01 17:08:54 +02:00
Simon Sapin
a30996c30a Fix counter-increment interference with display: list-item 2012-06-01 09:56:19 +02:00
Guillaume Ayoub
35363cefee Add a test about counter scopes 2012-05-29 17:56:46 +02:00
Simon Sapin
e88401f333 Get bookmark labels after white-space processing. 2012-05-24 15:29:42 +02:00
Simon Sapin
866efdf62c Do not repeat bookmarks on a fragmented box
Also a better way not to repeat margin/padding/border and list markers.
2012-05-21 14:22:32 +02:00
Guillaume Ayoub
111932edf5 Add first-level bookmarks, use floats for XY positions, fix little things 2012-05-15 19:29:54 +02:00
Guillaume Ayoub
475a924e89 Fix the stacking contexts 2012-05-11 14:10:11 +02:00
Guillaume Ayoub
994e6a933a Handle not-in-flow elements in inline boxes 2012-05-09 17:08:23 +02:00
Simon Sapin
0671b499dd Repeat table headers and footers on every page. 2012-05-04 17:05:16 +02:00
Simon Sapin
074e8884c8 Implement inline tables. 2012-04-12 17:20:57 +02:00
Guillaume Ayoub
3a86c1e679 Add the functions for preferred sizes of tables 2012-04-10 14:38:18 +02:00
Simon Sapin
61bf188290 Merge branch 'master' into shrinktofit
Conflicts:
	weasyprint/layout/blocks.py
	weasyprint/layout/inlines.py
2012-04-05 12:38:42 +02:00
Guillaume Ayoub
58fb02dcbb Don't collapse spaces across atomic inline blocks 2012-04-03 18:58:55 +02:00
Simon Sapin
88c027117c Do not keep tokens for percentages after validation.
Make (value, unit) namedtuples instead.
Pixel values that could be percentages are not plain numbers anymore.
2012-04-03 16:12:25 +02:00
Simon Sapin
46b1d225c7 Tests n’ fixes. Lots of them. 2012-04-03 11:34:29 +02:00
Simon Sapin
dcacf9eed0 Switch the licence to BSD and rewrite module docstrings/headers 2012-03-21 23:26:58 +01:00
Simon Sapin
26de362b99 Add proper attribution in AUTHORS 2012-03-21 18:40:38 +01:00
Simon Sapin
9875f76995 Hello 2012 2012-03-21 18:40:38 +01:00
Simon Sapin
953493733f Margin collapsing: not on the root element. 2012-02-28 14:54:20 +01:00