Commit Graph

95 Commits

Author SHA1 Message Date
Guillaume Ayoub decdc0941e Handle content(first-letter) 2018-01-30 22:49:18 +01:00
Guillaume Ayoub d62bfec60b Keep track of removed collapsing spaces for wrap opportunities 2017-12-26 12:39:20 +01: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 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 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
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 f0912e4f2d Don't use no-break spaces to avoid text wrapping
Fix #189
2016-05-08 16:44:57 +02: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 c34221d215 2014. 2014-01-10 14:27:02 +00:00
Guillaume Ayoub 324e3f7867 Don't crash when root element is not displayed (fix #113) 2013-08-04 14:52:47 +02:00
Le-Stagiaire 72c9c02b64 Typo in bookmark label 2013-05-24 16:27:11 +02:00