RESOLVED FIXED 130889
Fix recently-introduced off-by-one error in centerTruncateToBuffer
https://bugs.webkit.org/show_bug.cgi?id=130889
Summary Fix recently-introduced off-by-one error in centerTruncateToBuffer
Darin Adler
Reported 2014-03-27 23:42:35 PDT
Fix recently-introduced off-by-one error in centerTruncateToBuffer
Attachments
Patch (13.02 KB, patch)
2014-03-28 00:36 PDT, Darin Adler
ap: review+
Darin Adler
Comment 1 2014-03-28 00:14:38 PDT
I finished the fix about an hour ago, but I decided to add unit tests for WebStringTruncator, which is taking me a little time.
Darin Adler
Comment 2 2014-03-28 00:36:55 PDT
Darin Adler
Comment 3 2014-03-28 00:37:49 PDT
I originally thought this was Mac-only, but it seems this code is used on other platforms as well.
Alexey Proskuryakov
Comment 4 2014-03-28 10:07:56 PDT
Comment on attachment 228030 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=228030&action=review > Source/WebKit/mac/ChangeLog:12 > + (+[WebStringTruncator initialize]): Added threading initialization, needed for main > + thread assertions in string truncator code. I'm confused about how this worked before - you didn't add any new assertions in this patch. Is something like this needed on iOS too?
Conrad Shultz
Comment 5 2014-03-28 11:58:31 PDT
Would it be worth adding some non-ASCII inputs to the unit tests?
Darin Adler
Comment 6 2014-03-28 17:44:21 PDT
Comment on attachment 228030 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=228030&action=review > Source/WebKit/mac/Misc/WebStringTruncator.mm:67 > +#if PLATFORM(MAC) As Alexey and I discussed, we don’t need this #if since this file is already Mac-only (has NSFont).
Darin Adler
Comment 7 2014-03-28 20:18:50 PDT
Alexey Proskuryakov
Comment 8 2014-03-29 22:49:16 PDT
The regression test fails on Mountain Lion: /Volumes/Data/slave/mountainlion-debug/build/Tools/TestWebKitAPI/Tests/mac/StringTruncator.mm:36: Failure Value of: "abcdef…tuvwxyz" Expected: [[WebStringTruncator centerTruncateString:@"abcdefghijklmnopqrstuvwxyz" toWidth:100 withFont:[NSFont fontWithName:@"Helvetica" size:12]] UTF8String] Which is: "abcdefg…tuvwxyz"
Alexey Proskuryakov
Comment 9 2014-03-29 22:59:13 PDT
Updated expectation for 10.8 in <http://trac.webkit.org/r166458>.
Note You need to log in before you can comment on or make changes to this bug.