Changeset 85551 in webkit
- Timestamp:
- May 2, 2011 4:43:37 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r85549 r85551 1 2011-05-02 Jia Pu <jpu@apple.com> 2 3 Reviewed by Alexey Proskuryakov. 4 5 [Mac] Need to truncate the string sent to "Look Up … " menu item, if it's too long. 6 https://bugs.webkit.org/show_bug.cgi?id=59836 7 <rdar://problem/9275983> 8 9 * platform/DefaultLocalizationStrategy.cpp: 10 (WebCore::truncatedStringForLookupMenuItem): 11 (WebCore::DefaultLocalizationStrategy::contextMenuItemTagLookUpInDictionary): 12 1 13 2011-05-02 Brady Eidson <beidson@apple.com> 2 14 -
trunk/Source/WebCore/platform/DefaultLocalizationStrategy.cpp
r85036 r85551 32 32 #include "LocalizedStrings.h" 33 33 #include "NotImplemented.h" 34 #include "PlatformString.h" 34 35 #include <wtf/MathExtras.h> 35 36 #include <wtf/text/CString.h> 37 #include <wtf/unicode/CharacterNames.h> 36 38 #include <wtf/UnusedParam.h> 37 39 … … 69 71 } 70 72 73 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) 74 static String truncatedStringForLookupMenuItem(const String& original) 75 { 76 if (original.isEmpty()) 77 return original; 78 79 // Truncate the string if it's too long. This is in consistency with AppKit. 80 unsigned maxNumberOfGraphemeClustersInLookupMenuItem = 24; 81 DEFINE_STATIC_LOCAL(String, ellipsis, (&horizontalEllipsis, 1)); 82 83 String trimmed = original.stripWhiteSpace(); 84 unsigned numberOfCharacters = numCharactersInGraphemeClusters(trimmed, maxNumberOfGraphemeClustersInLookupMenuItem); 85 return numberOfCharacters == trimmed.length() ? trimmed : trimmed.left(numberOfCharacters) + ellipsis; 86 } 87 #endif 88 71 89 DefaultLocalizationStrategy::DefaultLocalizationStrategy() 72 90 { … … 304 322 #else 305 323 #if USE(CF) 306 RetainPtr<CFStringRef> selectedCFString(AdoptCF, selectedString.createCFString());324 RetainPtr<CFStringRef> selectedCFString(AdoptCF, truncatedStringForLookupMenuItem(selectedString).createCFString()); 307 325 return formatLocalizedString(WEB_UI_STRING("Look Up “%@”", "Look Up context menu item with selected word"), selectedCFString.get()); 308 326 #else 309 return WEB_UI_STRING("Look Up “<selection>”", "Look Up context menu item with selected word").replace("<selection>", selectedString);327 return WEB_UI_STRING("Look Up “<selection>”", "Look Up context menu item with selected word").replace("<selection>", truncatedStringForLookupMenuItem(selectedString)); 310 328 #endif 311 329 #endif
Note: See TracChangeset
for help on using the changeset viewer.