Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd support for `pre-wrap` and `pre-line` values for `white-space`. #7951
Conversation
highfive
commented
Oct 10, 2015
| @@ -38,7 +38,7 @@ pub fn transform_text(text: &str, | |||
| output_text.push(ch); | |||
| } | |||
| } | |||
| text.len() > 0 && is_in_whitespace(text.char_at_reverse(0), mode) | |||
| false | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
eefriedman
Oct 10, 2015
Author
Contributor
This fixes https://github.com/servo/servo/blob/master/tests/wpt/css-tests/css21_dev/html4/white-space-mixed-002.htm and some related issues. The return value here basically means "should leading whitespace be discarded from the next fragment", and the answer is always no in white-space: pre or white-space: pre-wrap mode.
| white_space::T::normal | | ||
| white_space::T::pre_wrap | | ||
| white_space::T::pre_line => true, | ||
| } |
This comment has been minimized.
This comment has been minimized.
pcwalton
Oct 10, 2015
Contributor
Matches very similar to this are duplicated throughout the code. Maybe we should have a whitespace_is_pre_or_nowrap() kind of function?
This comment has been minimized.
This comment has been minimized.
pcwalton
Oct 10, 2015
Contributor
Actually, never mind, I see the matches are subtly different each time.
This comment has been minimized.
This comment has been minimized.
eefriedman
Oct 10, 2015
Author
Contributor
Hmm... there are basically three useful ways to divide up the values of white-space: "are spaces preserved", "are newlines preserved", and "is wrapping allowed". I could add helpers for all three, which might be useful for readability even if they don't have very many uses.
This comment has been minimized.
This comment has been minimized.
| pieces_processed_count += 1; | ||
| debug!("calculate_split_position_using_breaking_strategy: enlarging span"); | ||
| remaining_inline_size = remaining_inline_size - advance; | ||
| inline_start_range.extend_by(slice.range.length()); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
eefriedman
Oct 10, 2015
Author
Contributor
Like the debug! log said, the first branch would trim leading whitespace. That doesn't really work out very well in pre-wrap mode, where whitespace is supposed to be preserved.
I was going to add the condition that the fragment isn't using a whitespace-preserving mode... but then I realized we never actually end up in that situation: we strip leading whitespace before we reach this code.
|
Looks good other than these couple of questions I had. |
|
This needs at least some automated testing. If you know which csswg-test tests this causes to pass, feel free to submit references upstream and ask me to review. We can land this PR once I've integrated those references. |
|
Refactored the code a bit, and added some tests. |
|
@bors-servo: r+ |
|
|
|
Looks great, thanks! |
Add support for `pre-wrap` and `pre-line` values for `white-space`. This is mostly straightforward. I had to modify a couple of places which were accidentally discarding whitespace. Fixes #1513. This fixes some relevant tests from the CSS testsuite... but a lot of them are either manual, or don't pass because of unrelated issues. (For example, white-space-mixed-002 renders correctly, but white-space-mixed-002-ref doesn't because of a float bug.) I'd appreciate any suggestions for how to go about adding tests for this. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7951) <!-- Reviewable:end -->
|
|
|
Looks like a legitimate bug in my patch. |
|
Added a fix for newlines in |
|
@pcwalton Ping. This is ready to merge. |
|
Rebased. |
|
|
|
Rebased again. @pcwalton ping. |
|
@bors-servo: r+ |
|
|
Add support for `pre-wrap` and `pre-line` values for `white-space`. This is mostly straightforward. I had to modify a couple of places which were accidentally discarding whitespace. Fixes #1513. This fixes some relevant tests from the CSS testsuite... but a lot of them are either manual, or don't pass because of unrelated issues. (For example, white-space-mixed-002 renders correctly, but white-space-mixed-002-ref doesn't because of a float bug.) I'd appreciate any suggestions for how to go about adding tests for this. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7951) <!-- Reviewable:end -->
|
Sorry this fell through the cracks! |
|
|
eefriedman commentedOct 10, 2015
This is mostly straightforward. I had to modify a couple of places
which were accidentally discarding whitespace.
Fixes #1513.
This fixes some relevant tests from the CSS testsuite... but a lot of
them are either manual, or don't pass because of unrelated issues. (For
example, white-space-mixed-002 renders correctly, but
white-space-mixed-002-ref doesn't because of a float bug.)
I'd appreciate any suggestions for how to go about adding tests for this.