-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve page break related to inline(-block) elements #2497
Conversation
I have added one more commit that should improve auto-width calculation for inline-block and floating elements by sticking more closely to the spec. |
3a0340a
to
48b7e88
Compare
Added another commit to trim trailing whitespace after line breaks in more cases, notably after inline and inline-block frames. |
For a sample of the scenarios the commits here intend to fix, see the test cases included and listed in #2510. |
c9eb295
to
ce04cf4
Compare
Lots to review here, in the meantime when running through my standard test bed I noticed two issues. I haven't had a chance to look and see what's going on yet, so here's the errors. First, input buttons render with no width:
Second, rendering http://eclecticgeek.com/dompdf/core_tests/encoding_utf-8_all.html throws the following exception:
|
ce04cf4
to
4298661
Compare
The second error is due I have pushed an update to resolve the error by explicitly retaining the current behavior: Effectively returning the empty string in case of a |
By the way, there is a broken |
Input buttons rendering without width is probably related to the change to use shrink-to-fit width resolution for float and inline-block elements. Generated content is only set right before reflowing the generated-content frame, so it is not yet set when calling |
I don't see a straight-forward way for handling the generated content right now, so I am going to split up the PR. |
For simplicity, return a `float` value consistently. The `get_break_margins` method was unused.
Also, add type declarations to `_collapse_white_space`.
Consistent argument names and more type declarations.
Always evaluated to `0` before, because their style's height is always `auto`. The new method is a copy of the one in `FrameDecorator/Text`. Woud be nice to refactor this in the future.
The original code would: * Not position inline frames properly, which lead to erroneous interaction with page breaks * Break inline frames to early, if the first word in the frame was not the longest one (unless in a fixed-position parent) * Not split inline frames properly, if they had text-node children after other children * Never move inline-block frames to a new line * Never allow page breaks before inline-block frames
Fixes backgrounds or borders bleeding into the page margins at page- break locations. This is achieved by fixing and using the existing `remove_frames_from_line` method.
Originally introduced in commit 542483a for calculating auto widths for float and inline-block frames.
Move the logic for trimming trailing whitespace after a line break to the `add_line` method of `BlockFrameDecorator`, so it is always applied when a new line box is added. This now also trims trailing whitespace if a text frame is used in block formatting context, but this may even be desirable. Also, restore trailing whitespace removed in this way after a split to address issues such as dompdf#2250.
The condition is wrong, as an `auto` width can resolve to more than 100% if the minimum width of the content is larger.
Per spec, `min-width` overrules `max-width`. https://www.w3.org/TR/CSS21/visudet.html#min-max-widths
4298661
to
b1499a3
Compare
heh, yes thanks |
Are those replacements for this PR or in addition to it? Should I go ahead and finish reviewing this one before I move on to those? |
Those PRs replace this one completely, so no need to continue reviewing here. |
Nested inline frames with margin, border, or padding still cause bugs at line breaks, because they are added to the text children on-the-fly. To properly fix these cases, it would probably be best to refactor the code in such a way that margin, border, and padding are properly handled on the inline frame itself, instead of being added to first resp. last child. It might be even worth considering always containing text frames in an anonymous inline box if needed; that could allow handling these properties consistently while simplifying the code. But the changes should improve the situation for now, nonetheless.
I have a few test cases in preparation that will demonstrate several broken scenarios that are fixed by this PR.