static String truncatedStringForLookupMenuItem(const String& original) { if (original.isEmpty()) return original; // Truncate the string if it's too long. This is in consistency with AppKit. unsigned maxNumberOfGraphemeClustersInLookupMenuItem = 24; DEFINE_STATIC_LOCAL(String, ellipsis, (&horizontalEllipsis, 1)); String trimmed = original.stripWhiteSpace(); unsigned numberOfCharacters = numCharactersInGraphemeClusters(trimmed, maxNumberOfGraphemeClustersInLookupMenuItem); return numberOfCharacters == trimmed.length() ? trimmed : trimmed.left(numberOfCharacters) + ellipsis; }
String HTMLTextAreaElement::sanitizeUserInputValue(const String& proposedValue, unsigned maxLength) { return proposedValue.left(numCharactersInGraphemeClusters(proposedValue, maxLength)); }