TextIterator unnecessarily converts 8 bit strings to 16 bits
authormsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2012 05:27:34 +0000 (05:27 +0000)
committermsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2012 05:27:34 +0000 (05:27 +0000)
commit30b4e60ba8849c0c29d88b9f80da1447ee496906
tree2598cbf8a0e85cc019417ee3428d722049608f34
parent6b6fe9047db2d931c376b0103c2afd0d8092b05d
TextIterator unnecessarily converts 8 bit strings to 16 bits
https://bugs.webkit.org/show_bug.cgi?id=103295

Reviewed by Brent Fulgham.

Source/WebCore:

Changed TextIterator to use the contained string instead of calling characters() on that string.
Other sources of text, like emitCharacter() still use the contained UChar* buffer.
Added appendTextToStringBuilder() to append the text contents of the current iterator to a string builder
irrespective of the source of the text.

No new tests as functionality covered by existing tests.

* WebCore.exp.in: Updated plainText export and eliminated plainTextToMallocAllocatedBuffer export
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::stringForVisiblePositionRange): Updated to use TextIterator::appendTextToStringBuilder()
* editing/TextIterator.cpp:
(WebCore::TextIterator::characterAt): New function to return the indexed character of the current TextIterator
(WebCore::TextIterator::appendTextToStringBuilder): Added method to append whatever the current text to a StringBuilder
(WebCore::TextIterator::emitText): Eliminated accessing the character data via characters().
(WebCore::TextIterator::rangeFromLocationAndLength): Changed to use characterAt().
(WebCore::plainText): Combined with plainTextToMallocAllocatedBuffer().
* editing/TextIterator.h:
(WebCore::TextIterator::startOffset): New getter.
(WebCore::TextIterator::string): New getter.
(WebCore::TextIterator::characters): Updated to use correct test source.
* page/ContextMenuController.cpp:
(WebCore::selectionContainsPossibleWord): Changed to use characterAt().

Source/WebKit/mac:

Updated _stringForRange to use plainText() instead of removed plainTextToMallocAllocatedBuffer().

* WebView/WebFrame.mm:
(-[WebFrame _stringForRange:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/editing/TextIterator.h
Source/WebCore/page/ContextMenuController.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebFrame.mm