Skip to content
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

Add support for `pre-wrap` and `pre-line` values for `white-space`. #7951

Merged
merged 1 commit into from Oct 20, 2015

Conversation

@eefriedman
Copy link
Contributor

eefriedman commented Oct 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.

Review on Reviewable

@highfive
Copy link

highfive commented Oct 10, 2015

warning Warning warning

  • These commits modify layout code, but no reftests are modified. Please consider adding a reftest!
@nox nox closed this Oct 10, 2015
@nox nox reopened this Oct 10, 2015
@nox nox added the A-content/css label 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.

@pcwalton

pcwalton Oct 10, 2015

Contributor

Why this change?

This comment has been minimized.

@eefriedman

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.

@pcwalton

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.

@pcwalton

pcwalton Oct 10, 2015

Contributor

Actually, never mind, I see the matches are subtly different each time.

This comment has been minimized.

@eefriedman

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.

@pcwalton

pcwalton Oct 10, 2015

Contributor

Yeah, I agree those would be useful distinctions for readability.

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.

@pcwalton

pcwalton Oct 10, 2015

Contributor

Why unconditionally adjust remaining_inline_size now?

This comment has been minimized.

@eefriedman

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.

@pcwalton
Copy link
Contributor

pcwalton commented Oct 10, 2015

Looks good other than these couple of questions I had.

@Ms2ger
Copy link
Contributor

Ms2ger commented Oct 11, 2015

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.

@eefriedman eefriedman force-pushed the eefriedman:white-space branch from 4093c9d to 9202ebc Oct 11, 2015
@eefriedman
Copy link
Contributor Author

eefriedman commented Oct 11, 2015

Refactored the code a bit, and added some tests.

@pcwalton
Copy link
Contributor

pcwalton commented Oct 13, 2015

@bors-servo
Copy link
Contributor

bors-servo commented Oct 13, 2015

📌 Commit 9202ebc has been approved by pcwalton

@pcwalton
Copy link
Contributor

pcwalton commented Oct 13, 2015

Looks great, thanks!

@bors-servo
Copy link
Contributor

bors-servo commented Oct 13, 2015

Testing commit 9202ebc with merge 477440c...

bors-servo pushed a commit that referenced this pull request Oct 13, 2015
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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Oct 13, 2015

💔 Test failed - linux-dev

@eefriedman
Copy link
Contributor Author

eefriedman commented Oct 13, 2015

Looks like a legitimate bug in my patch.

@eefriedman eefriedman force-pushed the eefriedman:white-space branch from 9202ebc to c1655d6 Oct 13, 2015
@eefriedman
Copy link
Contributor Author

eefriedman commented Oct 13, 2015

Added a fix for newlines in white-space: pre mode. (See https://github.com/servo/servo/pull/7951/files#diff-013814e2f277c3fe9e1b72e33bd8ad2aL621) Patch should be good to go now.

@eefriedman
Copy link
Contributor Author

eefriedman commented Oct 15, 2015

@pcwalton Ping. This is ready to merge.

@jdm jdm removed the S-needs-tests label Oct 15, 2015
@eefriedman eefriedman force-pushed the eefriedman:white-space branch from c1655d6 to 79109df Oct 19, 2015
@eefriedman
Copy link
Contributor Author

eefriedman commented Oct 19, 2015

Rebased.

@bors-servo
Copy link
Contributor

bors-servo commented Oct 20, 2015

The latest upstream changes (presumably #8088) made this pull request unmergeable. Please resolve the merge conflicts.

This is mostly straightforward.  I had to modify a couple of places
which were accidentally discarding whitespace.

Fixes #1513.
@eefriedman eefriedman force-pushed the eefriedman:white-space branch from 79109df to 3a451ff Oct 20, 2015
@eefriedman
Copy link
Contributor Author

eefriedman commented Oct 20, 2015

Rebased again.

@pcwalton ping.

@pcwalton
Copy link
Contributor

pcwalton commented Oct 20, 2015

@bors-servo
Copy link
Contributor

bors-servo commented Oct 20, 2015

📌 Commit 3a451ff has been approved by pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Oct 20, 2015

Testing commit 3a451ff with merge c3ab711...

bors-servo pushed a commit that referenced this pull request Oct 20, 2015
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 -->
@pcwalton
Copy link
Contributor

pcwalton commented Oct 20, 2015

Sorry this fell through the cracks!

@bors-servo
Copy link
Contributor

bors-servo commented Oct 20, 2015

@bors-servo bors-servo merged commit 3a451ff into servo:master Oct 20, 2015
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@jdm jdm mentioned this pull request Oct 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

7 participants
You can’t perform that action at this time.