Closed Bug 1476437 Opened 6 years ago Closed 6 years ago

auto-hyphenation ('hyphens: auto') hyphenates in the wrong place following a hyphen and whitespace collapsing

Categories

(Core :: Layout: Text and Fonts, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox-esr52 --- unaffected
firefox-esr60 --- wontfix
firefox61 --- wontfix
firefox62 --- wontfix
firefox63 --- fixed

People

(Reporter: dbaron, Assigned: jfkthame)

References

Details

(Keywords: css3, regression)

Attachments

(4 files, 1 obsolete file)

Attached file simplified testcase
I noticed this in the wild on https://drafts.csswg.org/css-logical-1/#logical-shorthand-keyword , which is probably one of a pretty small number of sites that use 'hyphens: auto'. In particular, what I observed was hyphenation as follows: first line: When the logical keyword is present in the value, the values that follow are assigned to the flow-r- second line: elative properties as follows: I simplified the testcase, and it seems like the key characteristic of the bug is that auto-hyphenation is happening at the incorrect position when it happens in an already hyphenated word that follows white-space collapsing. In the original, "flow-relative" is preceded by a CR and two spaces. Replacing the CR with a space (i.e., three spaces total) produces the same result, hyphenating as "flow-r-elative"; using four spaces leads to "flow-re-lative".
Flags: needinfo?(jfkthame)
Looks like this is a regression from bug 1056516. (Before that, we'd auto-hyphenate the second part of the already-hyphenated word, which we're not really supposed to do, but at least we'd do it in the right place.)
Blocks: 1056516
Flags: needinfo?(jfkthame)
Keywords: regression
Priority: -- → P2
Here's a reftest based on your testcase, which fails (hugely) with current trunk code.
Attachment #8993301 - Flags: review?(dbaron)
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
And this fixes the indexing into the original text when we're checking for explicit hyphens, which is what's going wrong here.
Attachment #8993303 - Flags: review?(dbaron)
Comment on attachment 8993301 [details] [diff] [review] Reftest for interaction between whitespace collapsing, explicit hyphen, and auto-hyphenation Letting all of the test items flow indepeendently between balanced columns is a bit gutsy, but it seems to work!
Attachment #8993301 - Flags: review?(dbaron) → review+
Comment on attachment 8993303 [details] [diff] [review] Correct original-text indexing when checking for explicit hyphens in text where auto-hyphenation is enabled Is there a simple explanation for why it's OK to throw away whatever the current position in mStart was? At least, it looks to me like that's what ConvertSkippedToOriginal does... which makes it seem like this is making two changes: (a) throwing away the initial position in mStart and just working from the start of the string (b) considering skipped characters after the beginning. Is it assumed that mStart is currently at a skipped offset of 0?
Flags: needinfo?(jfkthame)
Ah - you're right, this isn't quite correct; it works for the simple testcase here but may fail with more extensive examples, as it doesn't correctly check for explicit hyphens in continuations when mStart.GetSkippedOffset() was non-zero. We should be doing ConvertSkippedToOriginal(aRange.start + i), just like in the call to CanHyphenateBefore() a few lines below. I'll attach an additional reftest that exercises this; with the original patch here, it (correctly) gives the same result with or without collapsed whitespace, but the result (in both cases) incorrectly does auto-hyphenation in some cases where it should be inhibited because of an explicit hyphen in the word.
Flags: needinfo?(jfkthame)
Further reftest; this fails on current trunk, and still fails (somewhat differently) with the original patch above.
Attachment #8994835 - Flags: review?(dbaron)
And here's the updated patch that makes both reftests pass as expected.
Attachment #8994836 - Flags: review?(dbaron)
Attachment #8993303 - Attachment is obsolete: true
Attachment #8993303 - Flags: review?(dbaron)
Attachment #8994835 - Flags: review?(dbaron) → review+
Comment on attachment 8994836 [details] [diff] [review] Correct original-text indexing when checking for explicit hyphens in text where auto-hyphenation is enabled OK, the argument that this matches the CanHyphenateBefore call a few lines below seems reasonably convincing. It still seems like there's still an additional difference relative to the old code, which is that it seems like aRange is required to be a *subrange* of mStart to mLength (but not necessarily the whole thing), and if it doesn't start at mStart then the new behavior seems different as well. I still don't follow the whole thing -- it's rather complicated, and it feels like it would be nice if these various offsets were documented somewhere...
Attachment #8994836 - Flags: review?(dbaron) → review+
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/e17db916959e Reftest for interaction between whitespace collapsing, explicit hyphen, and auto-hyphenation. r=dbaron https://hg.mozilla.org/integration/mozilla-inbound/rev/280aff154491 Further reftest for multi-line content with whitespace/explicit-hyphen/autohyphenation. r=dbaron https://hg.mozilla.org/integration/mozilla-inbound/rev/d8d3c9e7b832 Correct original-text indexing when checking for explicit hyphens in text where auto-hyphenation is enabled. r=dbaron
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/af1cdd4b96b3 Reftest for interaction between whitespace collapsing, explicit hyphen, and auto-hyphenation. r=dbaron https://hg.mozilla.org/integration/mozilla-inbound/rev/fbb04354c2cf Further reftest for multi-line content with whitespace/explicit-hyphen/autohyphenation. r=dbaron https://hg.mozilla.org/integration/mozilla-inbound/rev/a05794e50453 Correct original-text indexing when checking for explicit hyphens in text where auto-hyphenation is enabled. r=dbaron
The failure was from the reftest in bug 1478574, pushed at the same time as this. Re-landed.
Flags: needinfo?(jfkthame)
Seems like we should probably just let this ride the trains.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: