Source/WebCore: Fix recently-introduced off-by-one error in centerTruncateToBuffer
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Mar 2014 03:18:27 +0000 (03:18 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Mar 2014 03:18:27 +0000 (03:18 +0000)
commit0f9e1da57fa70f5ac51e2956eec1828257f0b817
tree4aeb2155da608d9099a80072073c28f3544a71d3
parentee25708deebdac753d2c25dde776078c4d07634f
Source/WebCore: Fix recently-introduced off-by-one error in centerTruncateToBuffer
https://bugs.webkit.org/show_bug.cgi?id=130889
<rdar://problem/16408694>

Reviewed by Alexey Proskuryakov.

* platform/graphics/StringTruncator.cpp:
(WebCore::centerTruncateToBuffer): Simplified expression that computes truncatedLength.
Removed incorrect "+ 1" from computation of where to write characters.

Source/WebKit/mac: Fix recently-introduced off-by-one error in centerTruncateToBuffer
https://bugs.webkit.org/show_bug.cgi?id=130889

Reviewed by Alexey Proskuryakov.

* Misc/WebStringTruncator.mm:
(defaultMenuFont): Changed to use NeverDestroyed since I had to touch this file anyway.
(fontFromNSFont): Ditto. Also improved variable names a bit.
(+[WebStringTruncator initialize]): Added threading initialization, needed for main
thread assertions in string truncator code.

Tools: Fix recently-introduced off-by-one error in centerTruncateToBuffer
https://bugs.webkit.org/show_bug.cgi?id=130889

Reviewed by Alexey Proskuryakov.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added StringTruncator.mm.
* TestWebKitAPI/Tests/mac/StringTruncator.mm: Added. One test for each of the
WebStringTruncator methods; should be good for a start. These are dependent on the
metrics of Helvetica 12, but I am hoping that will be consistent across OS X machines.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166448 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/StringTruncator.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Misc/WebStringTruncator.mm
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/mac/StringTruncator.mm [new file with mode: 0644]