Bug 1657437 - Don't treat lone CRs as segment breaks. r=jfkthame

That prevents preceding whitespace from getting collapsed.

When there's a single lone CR (so `a\rb`) our behavior here diverges
from Chrome's but matches Safari's. We treat it as ZWSP.

That matches the initial resolution of [1], but then there have been
various doing and undoings of that resolution, so it's not totally clear
to me what the correct behavior per spec should be. I think "treat it as
other control character"? But I haven't dug into what that implies, so
for now I've just kept behavior there as-is.

[1]: https://github.com/w3c/csswg-drafts/issues/855

Differential Revision: https://phabricator.services.mozilla.com/D86188
This commit is contained in:
Emilio Cobos Álvarez 2020-08-08 16:21:35 +00:00
parent 6fb175caeb
commit e07d5eb564
3 changed files with 14 additions and 1 deletions

View File

@ -47,7 +47,7 @@ static bool IsDiscardable(uint8_t ch, nsTextFrameUtils::Flags* aFlags) {
return false;
}
static bool IsSegmentBreak(char16_t aCh) { return aCh == '\n' || aCh == '\r'; }
static bool IsSegmentBreak(char16_t aCh) { return aCh == '\n'; }
static bool IsSpaceOrTab(char16_t aCh) { return aCh == ' ' || aCh == '\t'; }

View File

@ -0,0 +1,3 @@
<!doctype html>
<title>CSS Test Reference</title>
<p>A B</p>

View File

@ -0,0 +1,10 @@
<!doctype html>
<title>Lone CR shouldn't cause previous spaces to collapse</title>
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
<link rel="author" href="https://mozilla.org" title="Mozilla">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1657437">
<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-rules">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/855#issuecomment-380435969">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/5410">
<link rel="match" href="lone-cr-001-ref.html">
<p>A &#013;B</p>