<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[163712] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/163712">163712</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2014-02-08 08:32:05 -0800 (Sat, 08 Feb 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Change TextIterator to use StringView, preparing to wean it from deprecatedCharacters
https://bugs.webkit.org/show_bug.cgi?id=128233
Reviewed by Anders Carlsson.
Source/WebCore:
* accessibility/AccessibilityNodeObject.cpp: Removed unneeded TextIterator.h include.
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::hasMisspelling): Updated to use StringView for checkSpelling.
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(AXAttributeStringSetSpelling): Changed to take a StringView.
(AXAttributedStringAppendText): Ditto.
(-[WebAccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:]): Pass StringView.
* editing/Editor.cpp:
(WebCore::Editor::misspelledWordAtCaretOrRange): Pass StringView.
(WebCore::Editor::misspelledSelectionString): Ditto.
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): Ditto.
* editing/TextCheckingHelper.cpp:
(WebCore::findGrammaticalErrors): Renamed this function. Changed to use StringView.
(WebCore::findMisspellings): Use StringView.
(WebCore::TextCheckingHelper::findFirstMisspelling): Ditto. Also separated out assertions
that were asserting multiple things with &&.
(WebCore::TextCheckingHelper::findFirstMisspellingOrBadGrammar): Ditto.
(WebCore::TextCheckingHelper::findFirstGrammarDetail): Ditto.
(WebCore::TextCheckingHelper::findFirstBadGrammar): Ditto.
(WebCore::TextCheckingHelper::isUngrammatical): Ditto.
(WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange): Ditto.
(WebCore::checkTextOfParagraph): Ditto.
* editing/TextCheckingHelper.h: Made TextCheckingParagraph::text public. Deleted
TextCheckingParagraph::textDeprecatedCharacters. Added comments about additional
TextCheckingParagraph refinements. Changed checkTextOfParagraph to take a client
reference instead of pointer and StringView instead of characters pointer with length.
* editing/TextIterator.cpp:
(WebCore::TextIterator::appendTextToStringBuilder): Use data members directly,
rather than using functions, since we already checked m_textCharacters for null.
(WebCore::CharacterIterator::string): Use text() instead of characters().
(WebCore::WordAwareIterator::WordAwareIterator): Removed initialization of
m_previousText now that it's a StringView rather than a pointer.
(WebCore::WordAwareIterator::advance): Use TextIterator::text instead of
TextIterator::characters. Also added a FIXME about a fundamental problem
with the implementation of this class!
(WebCore::WordAwareIterator::length): Updated for m_previousText change.
(WebCore::WordAwareIterator::text): Replaced WordAwareIterator::characters with this.
(WebCore::SearchBuffer::append): Changed to take a StringView.
(WebCore::SearchBuffer::prependContext): Ditto.
(WebCore::SearchBuffer::isWordStartMatch): Use StringView.
(WebCore::SearchBuffer::search): Ditto.
(WebCore::findPlainText): Ditto.
* editing/TextIterator.h: Added TextIterator::text that returns a StringView, and
renamed TextIterator::characters to TextIterator::deprecatedTextIteratorCharacters
(easy to search for in source code). Added SimplifiedBackwardsTextIterator::text
and removed SimplifiedBackwardsTextIterator::characters. Added CharacterIterator::text,
and removed CharacterIterator::characters. Added WordAwareIterator::text and removed
WorkdAwareIterator::characters. Changed WordAwareIterator data members to use StringView.
* editing/VisibleSelection.cpp:
(WebCore::VisibleSelection::appendTrailingWhitespace): Use TextIterator::text instead
of TextIterator::characters.
* editing/VisibleUnits.cpp:
(WebCore::previousBoundary): Updated to use StringView.
(WebCore::nextBoundary): Ditto.
(WebCore::startWordBoundary): Ditto.
(WebCore::startOfWord): Ditto.
(WebCore::endWordBoundary): Ditto.
(WebCore::endOfWord): Fixed formatting.
(WebCore::previousWordPositionBoundary): Updated to use StringView.
(WebCore::previousWordPosition): Fixed formatting and got rid of local variable.
(WebCore::nextWordPositionBoundary): Updated to use StringView.
(WebCore::nextWordPosition): Fixed formatting and got rid of local variable.
(WebCore::inSameLine): Fixed formatting.
(WebCore::isStartOfLine): Ditto.
(WebCore::isEndOfLine): Ditto.
(WebCore::absoluteLineDirectionPointToLocalPointInBlock): Changed to take a reference.
(WebCore::previousLinePosition): Fixed formatting chand changed to pass a reference.
(WebCore::nextLinePosition): Ditto.
(WebCore::startSentenceBoundary): Updated to use StringView and got rid of a local.
(WebCore::startOfSentence): Fixed formatting.
(WebCore::endSentenceBoundary): Updated to use StringView and got rid of a local.
(WebCore::endOfSentence): Fixed formatting.
(WebCore::previousSentencePositionBoundary): Updated to use StringView and got rid of
a local.
(WebCore::previousSentencePosition): Ditto.
(WebCore::nextSentencePositionBoundary): Ditto.
(WebCore::nextSentencePosition): Fixed formatting.
(WebCore::endOfParagraph): Ditto.
(WebCore::inSameParagraph): Ditto.
(WebCore::isStartOfParagraph): Ditto.
(WebCore::isEndOfParagraph): Ditto.
(WebCore::inSameBlock): Ditto.
(WebCore::isStartOfBlock): Ditto.
(WebCore::isEndOfBlock): Ditto.
(WebCore::startOfDocument): Ditto.
(WebCore::endOfDocument): Ditto.
(WebCore::inSameDocument): Ditto.
(WebCore::isStartOfDocument): Ditto.
(WebCore::isEndOfDocument): Ditto.
(WebCore::isEndOfEditableOrNonEditableContent): Ditto.
* loader/EmptyClients.h: Use StringView.
* platform/mac/HTMLConverter.mm:
(+[WebHTMLConverter editingAttributedStringFromRange:]): Use StringView.
* platform/text/TextBoundaries.cpp:
(WebCore::endOfFirstWordBoundaryContext): Use StringView and unsigned.
(WebCore::startOfLastWordBoundaryContext): Ditto.
* platform/text/TextBoundaries.h: Change interfaces to use StringView,
and in some cases, unsigned instead of int. All call sites were better off
with unsigned.
* platform/text/TextCheckerClient.h: Use StringView.
* platform/text/mac/TextBoundaries.mm: Changed conditionals to say
USE(APPKIT) instead of PLATFORM(IOS), since that's the real issue.
(WebCore::isSkipCharacter): Tweaked formatting.
(WebCore::isWhitespaceCharacter): Ditto.
(WebCore::isWordDelimitingCharacter): Ditto, also removed local variable.
(WebCore::isSymbolCharacter): Ditto.
(WebCore::tokenizerForString): Ditto.
(WebCore::findSimpleWordBoundary): Use StringView. Also changed to mostly
use unsigned instead of int.
(WebCore::findComplexWordBoundary): Use StringView. Also restructured to
be much more readable, with early returns and such.
(WebCore::findWordBoundary): Use StringView and unsigned.
(WebCore::findEndWordBoundary): Removed redudant copy of the findWordBoundary
function and changed this to just call findWordBoundary. The reason this
function exists is to optimize this case for some non-Mac, non-iOS platforms.
We can always do that for Mac and/or iOS later if we like.
(WebCore::findNextWordFromIndex): Use StringView. Also use wordBreakIterator
instead of using UBreakIterator directly so we get a cached iterator instead
of creating and destroying a new one each time this function is called.
* bindings/objc/DOMUIKitExtensions.mm: Removed unneeded includes.
* dom/Element.cpp: Ditto.
* dom/PositionIterator.cpp: Ditto.
* editing/ApplyBlockElementCommand.cpp: Ditto.
* editing/IndentOutdentCommand.cpp: Ditto.
* editing/InsertListCommand.cpp: Ditto.
* editing/markup.cpp: Ditto.
* html/HTMLElement.cpp: Ditto.
* html/HTMLTextAreaElement.cpp: Ditto.
* page/Frame.cpp: Ditto.
* rendering/RenderTextControl.cpp: Ditto.
Source/WebKit/efl:
* WebCoreSupport/EditorClientEfl.cpp:
(WebCore::EditorClientEfl::checkSpellingOfString): Use StringView.
(WebCore::EditorClientEfl::checkGrammarOfString): Ditto.
* WebCoreSupport/EditorClientEfl.h: Ditto.
Source/WebKit/gtk:
* WebCoreSupport/TextCheckerClientGtk.cpp:
(WebKit::TextCheckerClientGtk::checkSpellingOfString): Use StringView.
(WebKit::TextCheckerClientGtk::checkGrammarOfString): Ditto.
* WebCoreSupport/TextCheckerClientGtk.h: Ditto.
Source/WebKit/mac:
* WebCoreSupport/WebEditorClient.h: Made most data members private. Moved inlines
for iOS out of the class definition. Fixed formatting. Added missing virtual keyword.
Changed interfaces to use StringView.
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::checkTextOfParagraph): Use the new StringView::createNSStringWithoutCopying
function instead of a similar function that was local in this file.
(WebEditorClient::ignoreWordInSpellDocument): Tweaked formatting.
(WebEditorClient::checkSpellingOfString): Changed to take a StringView.
(WebEditorClient::checkGrammarOfString): Ditto.
* WebView/WebTextIterator.mm:
(-[WebTextIterator currentTextPointer]): Call TextIterator::deprecatedTextIteratorCharacters.
(-[WebTextIterator currentText]): Convert a the text to an NSString with TextIterator::text
instead of with TextIterator::characters/length.
Source/WebKit/win:
* WebCoreSupport/WebEditorClient.cpp:
(WebEditorClient::checkSpellingOfString): Use StringView.
(WebEditorClient::checkGrammarOfString): Ditto.
* WebCoreSupport/WebEditorClient.h: Ditto.
Source/WebKit/wince:
* WebCoreSupport/EditorClientWinCE.cpp:
(WebKit::EditorClientWinCE::checkSpellingOfString): Use StringView.
(WebKit::EditorClientWinCE::checkGrammarOfString): Ditto.
* WebCoreSupport/EditorClientWinCE.h: Ditto.
Source/WebKit2:
* WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm:
(-[WKDOMTextIterator currentTextPointer]): Call TextIterator::deprecatedTextIteratorCharacters.
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::checkSpellingOfString): Use StringView.
(WebKit::WebEditorClient::checkGrammarOfString): Ditto.
* WebProcess/WebCoreSupport/WebEditorClient.h: Ditto.
Source/WTF:
* WTF.xcodeproj/project.pbxproj: Added new source files.
* wtf/text/StringView.h: Added operator[], createCFStringWithoutCopying, and
createNSStringWithoutCopying.
* wtf/text/cf/StringViewCF.cpp:
(WTF::StringView::createCFStringWithoutCopying): Added.
* wtf/text/mac/StringViewObjC.mm:
(WTF::StringView::createNSString): Added.
(WTF::StringView::createNSStringWithoutCopying): Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWTFwtftextStringViewh">trunk/Source/WTF/wtf/text/StringView.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAccessibilityNodeObjectcpp">trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAccessibilityObjectcpp">trunk/Source/WebCore/accessibility/AccessibilityObject.cpp</a></li>
<li><a href="#trunkSourceWebCoreaccessibilitymacWebAccessibilityObjectWrapperMacmm">trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm</a></li>
<li><a href="#trunkSourceWebCorebindingsobjcDOMUIKitExtensionsmm">trunk/Source/WebCore/bindings/objc/DOMUIKitExtensions.mm</a></li>
<li><a href="#trunkSourceWebCoredomElementcpp">trunk/Source/WebCore/dom/Element.cpp</a></li>
<li><a href="#trunkSourceWebCoredomPositionIteratorcpp">trunk/Source/WebCore/dom/PositionIterator.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingApplyBlockElementCommandcpp">trunk/Source/WebCore/editing/ApplyBlockElementCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorcpp">trunk/Source/WebCore/editing/Editor.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingIndentOutdentCommandcpp">trunk/Source/WebCore/editing/IndentOutdentCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingInsertListCommandcpp">trunk/Source/WebCore/editing/InsertListCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingTextCheckingHelpercpp">trunk/Source/WebCore/editing/TextCheckingHelper.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingTextCheckingHelperh">trunk/Source/WebCore/editing/TextCheckingHelper.h</a></li>
<li><a href="#trunkSourceWebCoreeditingTextIteratorcpp">trunk/Source/WebCore/editing/TextIterator.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingTextIteratorh">trunk/Source/WebCore/editing/TextIterator.h</a></li>
<li><a href="#trunkSourceWebCoreeditingVisibleSelectioncpp">trunk/Source/WebCore/editing/VisibleSelection.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingVisibleUnitscpp">trunk/Source/WebCore/editing/VisibleUnits.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingmarkupcpp">trunk/Source/WebCore/editing/markup.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLElementcpp">trunk/Source/WebCore/html/HTMLElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLTextAreaElementcpp">trunk/Source/WebCore/html/HTMLTextAreaElement.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderEmptyClientsh">trunk/Source/WebCore/loader/EmptyClients.h</a></li>
<li><a href="#trunkSourceWebCorepageFramecpp">trunk/Source/WebCore/page/Frame.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmacHTMLConvertermm">trunk/Source/WebCore/platform/mac/HTMLConverter.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformtextTextBoundariescpp">trunk/Source/WebCore/platform/text/TextBoundaries.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformtextTextBoundariesh">trunk/Source/WebCore/platform/text/TextBoundaries.h</a></li>
<li><a href="#trunkSourceWebCoreplatformtextTextCheckerClienth">trunk/Source/WebCore/platform/text/TextCheckerClient.h</a></li>
<li><a href="#trunkSourceWebCoreplatformtextmacTextBoundariesmm">trunk/Source/WebCore/platform/text/mac/TextBoundaries.mm</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTextControlcpp">trunk/Source/WebCore/rendering/RenderTextControl.cpp</a></li>
<li><a href="#trunkSourceWebKiteflChangeLog">trunk/Source/WebKit/efl/ChangeLog</a></li>
<li><a href="#trunkSourceWebKiteflWebCoreSupportEditorClientEflcpp">trunk/Source/WebKit/efl/WebCoreSupport/EditorClientEfl.cpp</a></li>
<li><a href="#trunkSourceWebKiteflWebCoreSupportEditorClientEflh">trunk/Source/WebKit/efl/WebCoreSupport/EditorClientEfl.h</a></li>
<li><a href="#trunkSourceWebKitgtkChangeLog">trunk/Source/WebKit/gtk/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitgtkWebCoreSupportTextCheckerClientGtkcpp">trunk/Source/WebKit/gtk/WebCoreSupport/TextCheckerClientGtk.cpp</a></li>
<li><a href="#trunkSourceWebKitgtkWebCoreSupportTextCheckerClientGtkh">trunk/Source/WebKit/gtk/WebCoreSupport/TextCheckerClientGtk.h</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebEditorClienth">trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebEditorClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebTextIteratormm">trunk/Source/WebKit/mac/WebView/WebTextIterator.mm</a></li>
<li><a href="#trunkSourceWebKitwinChangeLog">trunk/Source/WebKit/win/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitwinWebCoreSupportWebEditorClientcpp">trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp</a></li>
<li><a href="#trunkSourceWebKitwinWebCoreSupportWebEditorClienth">trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.h</a></li>
<li><a href="#trunkSourceWebKitwinceChangeLog">trunk/Source/WebKit/wince/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitwinceWebCoreSupportEditorClientWinCEcpp">trunk/Source/WebKit/wince/WebCoreSupport/EditorClientWinCE.cpp</a></li>
<li><a href="#trunkSourceWebKitwinceWebCoreSupportEditorClientWinCEh">trunk/Source/WebKit/wince/WebCoreSupport/EditorClientWinCE.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPImacWKDOMTextIteratormm">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClienth">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtftextcfStringViewCFcpp">trunk/Source/WTF/wtf/text/cf/StringViewCF.cpp</a></li>
<li><a href="#trunkSourceWTFwtftextmacStringViewObjCmm">trunk/Source/WTF/wtf/text/mac/StringViewObjC.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WTF/ChangeLog        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2014-02-08 Darin Adler <darin@apple.com>
+
+ Change TextIterator to use StringView, preparing to wean it from deprecatedCharacters
+ https://bugs.webkit.org/show_bug.cgi?id=128233
+
+ Reviewed by Anders Carlsson.
+
+ * WTF.xcodeproj/project.pbxproj: Added new source files.
+
+ * wtf/text/StringView.h: Added operator[], createCFStringWithoutCopying, and
+ createNSStringWithoutCopying.
+ * wtf/text/cf/StringViewCF.cpp:
+ (WTF::StringView::createCFStringWithoutCopying): Added.
+ * wtf/text/mac/StringViewObjC.mm:
+ (WTF::StringView::createNSString): Added.
+ (WTF::StringView::createNSStringWithoutCopying): Added.
+
</ins><span class="cx"> 2014-02-06 Andreas Kling <akling@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove unused ENABLE(REPAINT_THROTTLING) flag.
</span></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -71,6 +71,8 @@
</span><span class="cx">                 7E29C33E15FFD79B00516D61 /* ObjcRuntimeExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */; };
</span><span class="cx">                 8134013815B092FD001FF0B8 /* Base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8134013615B092FD001FF0B8 /* Base64.cpp */; };
</span><span class="cx">                 8134013915B092FD001FF0B8 /* Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 8134013715B092FD001FF0B8 /* Base64.h */; };
</span><ins>+                93934BD318A1E8C300D0D6A1 /* StringViewObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93934BD218A1E8C300D0D6A1 /* StringViewObjC.mm */; };
+                93934BD518A1F16900D0D6A1 /* StringViewCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */; };
</ins><span class="cx">                 93AC91A818942FC400244939 /* LChar.h in Headers */ = {isa = PBXBuildFile; fileRef = 93AC91A718942FC400244939 /* LChar.h */; };
</span><span class="cx">                 93B1AA80180E5AF3004A2F05 /* PassRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B1AA7F180E5AF3004A2F05 /* PassRef.h */; };
</span><span class="cx">                 974CFC8E16A4F327006D5404 /* WeakPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 974CFC8D16A4F327006D5404 /* WeakPtr.h */; };
</span><span class="lines">@@ -344,6 +346,8 @@
</span><span class="cx">                 7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjcRuntimeExtras.h; sourceTree = "<group>"; };
</span><span class="cx">                 8134013615B092FD001FF0B8 /* Base64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Base64.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 8134013715B092FD001FF0B8 /* Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base64.h; sourceTree = "<group>"; };
</span><ins>+                93934BD218A1E8C300D0D6A1 /* StringViewObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = StringViewObjC.mm; path = mac/StringViewObjC.mm; sourceTree = "<group>"; };
+                93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringViewCF.cpp; path = cf/StringViewCF.cpp; sourceTree = "<group>"; };
</ins><span class="cx">                 93AC91A718942FC400244939 /* LChar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LChar.h; sourceTree = "<group>"; };
</span><span class="cx">                 93B1AA7F180E5AF3004A2F05 /* PassRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PassRef.h; sourceTree = "<group>"; };
</span><span class="cx">                 974CFC8D16A4F327006D5404 /* WeakPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakPtr.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -620,6 +624,7 @@
</span><span class="cx">                 A5BA15F11824339F00A82E69 /* mac */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                93934BD218A1E8C300D0D6A1 /* StringViewObjC.mm */,
</ins><span class="cx">                                 A5BA15F41824348000A82E69 /* StringImplMac.mm */,
</span><span class="cx">                                 A5BA15F2182433A900A82E69 /* StringMac.mm */,
</span><span class="cx">                         );
</span><span class="lines">@@ -632,6 +637,7 @@
</span><span class="cx">                                 A5BA15F7182435A600A82E69 /* AtomicStringCF.cpp */,
</span><span class="cx">                                 A5BA15F8182435A600A82E69 /* StringCF.cpp */,
</span><span class="cx">                                 A5BA15F9182435A600A82E69 /* StringImplCF.cpp */,
</span><ins>+                                93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */,
</ins><span class="cx">                         );
</span><span class="cx">                         name = cf;
</span><span class="cx">                         sourceTree = "<group>";
</span><span class="lines">@@ -1226,7 +1232,6 @@
</span><span class="cx">                                 A8A473BC151A825B004123FF /* DynamicAnnotations.cpp in Sources */,
</span><span class="cx">                                 A8A473B3151A825B004123FF /* fast-dtoa.cc in Sources */,
</span><span class="cx">                                 A8A473C3151A825B004123FF /* FastMalloc.cpp in Sources */,
</span><del>-                                A5BA15FC182435A600A82E69 /* StringImplCF.cpp in Sources */,
</del><span class="cx">                                 A5BA15FA182435A600A82E69 /* AtomicStringCF.cpp in Sources */,
</span><span class="cx">                                 E15556F518A0CC18006F48FB /* CryptographicUtilities.cpp in Sources */,
</span><span class="cx">                                 0F9D3360165DBA73005AD387 /* FilePrintStream.cpp in Sources */,
</span><span class="lines">@@ -1245,25 +1250,28 @@
</span><span class="cx">                                 A8A47400151A825B004123FF /* PageAllocationAligned.cpp in Sources */,
</span><span class="cx">                                 A8A47402151A825B004123FF /* PageBlock.cpp in Sources */,
</span><span class="cx">                                 0F9D3362165DBA73005AD387 /* PrintStream.cpp in Sources */,
</span><del>-                                A5BA15F51824348000A82E69 /* StringImplMac.mm in Sources */,
</del><span class="cx">                                 143F611F1565F0F900DB514A /* RAMSize.cpp in Sources */,
</span><span class="cx">                                 A8A47414151A825B004123FF /* RandomNumber.cpp in Sources */,
</span><span class="cx">                                 A8A4741A151A825B004123FF /* RefCountedLeakCounter.cpp in Sources */,
</span><span class="cx">                                 2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */,
</span><span class="cx">                                 2CDED0EF18115C38004DBA70 /* RunLoopCF.cpp in Sources */,
</span><span class="cx">                                 1469419316EAAF6D0024E146 /* RunLoopTimerCF.cpp in Sources */,
</span><ins>+                                A8A47421151A825B004123FF /* SHA1.cpp in Sources */,
</ins><span class="cx">                                 1469419916EAB0410024E146 /* SchedulePairCF.cpp in Sources */,
</span><del>-                                A5BA15F3182433A900A82E69 /* StringMac.mm in Sources */,
</del><span class="cx">                                 1469419716EAAFF80024E146 /* SchedulePairMac.mm in Sources */,
</span><del>-                                A8A47421151A825B004123FF /* SHA1.cpp in Sources */,
</del><span class="cx">                                 A748745217A0BDAE00FA04CB /* SixCharacterHash.cpp in Sources */,
</span><span class="cx">                                 A8A47425151A825B004123FF /* SizeLimits.cpp in Sources */,
</span><span class="cx">                                 A8A47427151A825B004123FF /* StackBounds.cpp in Sources */,
</span><span class="cx">                                 FEDACD3D1630F83F00C69634 /* StackStats.cpp in Sources */,
</span><span class="cx">                                 A8A4743C151A825B004123FF /* StringBuilder.cpp in Sources */,
</span><span class="cx">                                 A8A47440151A825B004123FF /* StringImpl.cpp in Sources */,
</span><ins>+                                A5BA15FC182435A600A82E69 /* StringImplCF.cpp in Sources */,
+                                A5BA15F51824348000A82E69 /* StringImplMac.mm in Sources */,
+                                A5BA15F3182433A900A82E69 /* StringMac.mm in Sources */,
</ins><span class="cx">                                 0FDDBFA71666DFA300C55FEF /* StringPrintStream.cpp in Sources */,
</span><span class="cx">                                 A8A47443151A825B004123FF /* StringStatics.cpp in Sources */,
</span><ins>+                                93934BD518A1F16900D0D6A1 /* StringViewCF.cpp in Sources */,
+                                93934BD318A1E8C300D0D6A1 /* StringViewObjC.mm in Sources */,
</ins><span class="cx">                                 A8A473B7151A825B004123FF /* strtod.cc in Sources */,
</span><span class="cx">                                 A8A47431151A825B004123FF /* TCSystemAlloc.cpp in Sources */,
</span><span class="cx">                                 A8A47448151A825B004123FF /* ThreadIdentifierDataPthreads.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWTFwtftextStringViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/StringView.h (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/StringView.h        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WTF/wtf/text/StringView.h        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -127,6 +127,25 @@
</span><span class="cx"> return StringImpl::createWithoutCopying(characters16(), length());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ UChar operator[](unsigned index) const
+ {
+ ASSERT(index < length());
+ if (is8Bit())
+ return characters8()[index];
+ return characters16()[index];
+ }
+
+#if USE(CF)
+ // This function converts null strings to empty strings.
+ WTF_EXPORT_STRING_API RetainPtr<CFStringRef> createCFStringWithoutCopying() const;
+#endif
+
+#ifdef __OBJC__
+ // These functions convert null strings to empty strings.
+ WTF_EXPORT_STRING_API RetainPtr<NSString> createNSString() const;
+ WTF_EXPORT_STRING_API RetainPtr<NSString> createNSStringWithoutCopying() const;
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx"> void initialize(const LChar* characters, unsigned length)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWTFwtftextcfStringViewCFcppfromrev163711trunkSourceWebKit2WebProcessInjectedBundleAPImacWKDOMTextIteratormm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WTF/wtf/text/cf/StringViewCF.cpp (from rev 163711, trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm) (0 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/cf/StringViewCF.cpp         (rev 0)
+++ trunk/Source/WTF/wtf/text/cf/StringViewCF.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "StringView.h"
+
+#import "RetainPtr.h"
+
+namespace WTF {
+
+RetainPtr<CFStringRef> StringView::createCFStringWithoutCopying() const
+{
+ if (is8Bit())
+ return adoptCF(CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, characters8(), length(), kCFStringEncodingISOLatin1, false, kCFAllocatorNull));
+
+ return adoptCF(CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, characters16(), length(), kCFAllocatorNull));
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWTFwtftextmacStringViewObjCmmfromrev163711trunkSourceWebKit2WebProcessInjectedBundleAPImacWKDOMTextIteratormm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WTF/wtf/text/mac/StringViewObjC.mm (from rev 163711, trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm) (0 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/mac/StringViewObjC.mm         (rev 0)
+++ trunk/Source/WTF/wtf/text/mac/StringViewObjC.mm        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "StringView.h"
+
+#import "RetainPtr.h"
+
+namespace WTF {
+
+RetainPtr<NSString> StringView::createNSString() const
+{
+ if (is8Bit())
+ return adoptNS([[NSString alloc] initWithBytes:const_cast<LChar*>(characters8()) length:length() encoding:NSISOLatin1StringEncoding]);
+
+ return adoptNS([[NSString alloc] initWithCharacters:const_cast<UChar*>(characters16()) length:length()]);
+}
+
+RetainPtr<NSString> StringView::createNSStringWithoutCopying() const
+{
+ if (is8Bit())
+ return adoptNS([[NSString alloc] initWithBytesNoCopy:const_cast<LChar*>(characters8()) length:length() encoding:NSISOLatin1StringEncoding freeWhenDone:NO]);
+
+ return adoptNS([[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(characters16()) length:length() freeWhenDone:NO]);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/ChangeLog        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,3 +1,157 @@
</span><ins>+2014-02-08 Darin Adler <darin@apple.com>
+
+ Change TextIterator to use StringView, preparing to wean it from deprecatedCharacters
+ https://bugs.webkit.org/show_bug.cgi?id=128233
+
+ Reviewed by Anders Carlsson.
+
+ * accessibility/AccessibilityNodeObject.cpp: Removed unneeded TextIterator.h include.
+
+ * accessibility/AccessibilityObject.cpp:
+ (WebCore::AccessibilityObject::hasMisspelling): Updated to use StringView for checkSpelling.
+
+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+ (AXAttributeStringSetSpelling): Changed to take a StringView.
+ (AXAttributedStringAppendText): Ditto.
+ (-[WebAccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:]): Pass StringView.
+
+ * editing/Editor.cpp:
+ (WebCore::Editor::misspelledWordAtCaretOrRange): Pass StringView.
+ (WebCore::Editor::misspelledSelectionString): Ditto.
+ (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): Ditto.
+
+ * editing/TextCheckingHelper.cpp:
+ (WebCore::findGrammaticalErrors): Renamed this function. Changed to use StringView.
+ (WebCore::findMisspellings): Use StringView.
+ (WebCore::TextCheckingHelper::findFirstMisspelling): Ditto. Also separated out assertions
+ that were asserting multiple things with &&.
+ (WebCore::TextCheckingHelper::findFirstMisspellingOrBadGrammar): Ditto.
+ (WebCore::TextCheckingHelper::findFirstGrammarDetail): Ditto.
+ (WebCore::TextCheckingHelper::findFirstBadGrammar): Ditto.
+ (WebCore::TextCheckingHelper::isUngrammatical): Ditto.
+ (WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange): Ditto.
+ (WebCore::checkTextOfParagraph): Ditto.
+
+ * editing/TextCheckingHelper.h: Made TextCheckingParagraph::text public. Deleted
+ TextCheckingParagraph::textDeprecatedCharacters. Added comments about additional
+ TextCheckingParagraph refinements. Changed checkTextOfParagraph to take a client
+ reference instead of pointer and StringView instead of characters pointer with length.
+
+ * editing/TextIterator.cpp:
+ (WebCore::TextIterator::appendTextToStringBuilder): Use data members directly,
+ rather than using functions, since we already checked m_textCharacters for null.
+ (WebCore::CharacterIterator::string): Use text() instead of characters().
+ (WebCore::WordAwareIterator::WordAwareIterator): Removed initialization of
+ m_previousText now that it's a StringView rather than a pointer.
+ (WebCore::WordAwareIterator::advance): Use TextIterator::text instead of
+ TextIterator::characters. Also added a FIXME about a fundamental problem
+ with the implementation of this class!
+ (WebCore::WordAwareIterator::length): Updated for m_previousText change.
+ (WebCore::WordAwareIterator::text): Replaced WordAwareIterator::characters with this.
+ (WebCore::SearchBuffer::append): Changed to take a StringView.
+ (WebCore::SearchBuffer::prependContext): Ditto.
+ (WebCore::SearchBuffer::isWordStartMatch): Use StringView.
+ (WebCore::SearchBuffer::search): Ditto.
+ (WebCore::findPlainText): Ditto.
+
+ * editing/TextIterator.h: Added TextIterator::text that returns a StringView, and
+ renamed TextIterator::characters to TextIterator::deprecatedTextIteratorCharacters
+ (easy to search for in source code). Added SimplifiedBackwardsTextIterator::text
+ and removed SimplifiedBackwardsTextIterator::characters. Added CharacterIterator::text,
+ and removed CharacterIterator::characters. Added WordAwareIterator::text and removed
+ WorkdAwareIterator::characters. Changed WordAwareIterator data members to use StringView.
+
+ * editing/VisibleSelection.cpp:
+ (WebCore::VisibleSelection::appendTrailingWhitespace): Use TextIterator::text instead
+ of TextIterator::characters.
+
+ * editing/VisibleUnits.cpp:
+ (WebCore::previousBoundary): Updated to use StringView.
+ (WebCore::nextBoundary): Ditto.
+ (WebCore::startWordBoundary): Ditto.
+ (WebCore::startOfWord): Ditto.
+ (WebCore::endWordBoundary): Ditto.
+ (WebCore::endOfWord): Fixed formatting.
+ (WebCore::previousWordPositionBoundary): Updated to use StringView.
+ (WebCore::previousWordPosition): Fixed formatting and got rid of local variable.
+ (WebCore::nextWordPositionBoundary): Updated to use StringView.
+ (WebCore::nextWordPosition): Fixed formatting and got rid of local variable.
+ (WebCore::inSameLine): Fixed formatting.
+ (WebCore::isStartOfLine): Ditto.
+ (WebCore::isEndOfLine): Ditto.
+ (WebCore::absoluteLineDirectionPointToLocalPointInBlock): Changed to take a reference.
+ (WebCore::previousLinePosition): Fixed formatting chand changed to pass a reference.
+ (WebCore::nextLinePosition): Ditto.
+ (WebCore::startSentenceBoundary): Updated to use StringView and got rid of a local.
+ (WebCore::startOfSentence): Fixed formatting.
+ (WebCore::endSentenceBoundary): Updated to use StringView and got rid of a local.
+ (WebCore::endOfSentence): Fixed formatting.
+ (WebCore::previousSentencePositionBoundary): Updated to use StringView and got rid of
+ a local.
+ (WebCore::previousSentencePosition): Ditto.
+ (WebCore::nextSentencePositionBoundary): Ditto.
+ (WebCore::nextSentencePosition): Fixed formatting.
+ (WebCore::endOfParagraph): Ditto.
+ (WebCore::inSameParagraph): Ditto.
+ (WebCore::isStartOfParagraph): Ditto.
+ (WebCore::isEndOfParagraph): Ditto.
+ (WebCore::inSameBlock): Ditto.
+ (WebCore::isStartOfBlock): Ditto.
+ (WebCore::isEndOfBlock): Ditto.
+ (WebCore::startOfDocument): Ditto.
+ (WebCore::endOfDocument): Ditto.
+ (WebCore::inSameDocument): Ditto.
+ (WebCore::isStartOfDocument): Ditto.
+ (WebCore::isEndOfDocument): Ditto.
+ (WebCore::isEndOfEditableOrNonEditableContent): Ditto.
+
+ * loader/EmptyClients.h: Use StringView.
+
+ * platform/mac/HTMLConverter.mm:
+ (+[WebHTMLConverter editingAttributedStringFromRange:]): Use StringView.
+
+ * platform/text/TextBoundaries.cpp:
+ (WebCore::endOfFirstWordBoundaryContext): Use StringView and unsigned.
+ (WebCore::startOfLastWordBoundaryContext): Ditto.
+
+ * platform/text/TextBoundaries.h: Change interfaces to use StringView,
+ and in some cases, unsigned instead of int. All call sites were better off
+ with unsigned.
+
+ * platform/text/TextCheckerClient.h: Use StringView.
+
+ * platform/text/mac/TextBoundaries.mm: Changed conditionals to say
+ USE(APPKIT) instead of PLATFORM(IOS), since that's the real issue.
+ (WebCore::isSkipCharacter): Tweaked formatting.
+ (WebCore::isWhitespaceCharacter): Ditto.
+ (WebCore::isWordDelimitingCharacter): Ditto, also removed local variable.
+ (WebCore::isSymbolCharacter): Ditto.
+ (WebCore::tokenizerForString): Ditto.
+ (WebCore::findSimpleWordBoundary): Use StringView. Also changed to mostly
+ use unsigned instead of int.
+ (WebCore::findComplexWordBoundary): Use StringView. Also restructured to
+ be much more readable, with early returns and such.
+ (WebCore::findWordBoundary): Use StringView and unsigned.
+ (WebCore::findEndWordBoundary): Removed redudant copy of the findWordBoundary
+ function and changed this to just call findWordBoundary. The reason this
+ function exists is to optimize this case for some non-Mac, non-iOS platforms.
+ We can always do that for Mac and/or iOS later if we like.
+ (WebCore::findNextWordFromIndex): Use StringView. Also use wordBreakIterator
+ instead of using UBreakIterator directly so we get a cached iterator instead
+ of creating and destroying a new one each time this function is called.
+
+ * bindings/objc/DOMUIKitExtensions.mm: Removed unneeded includes.
+ * dom/Element.cpp: Ditto.
+ * dom/PositionIterator.cpp: Ditto.
+ * editing/ApplyBlockElementCommand.cpp: Ditto.
+ * editing/IndentOutdentCommand.cpp: Ditto.
+ * editing/InsertListCommand.cpp: Ditto.
+ * editing/markup.cpp: Ditto.
+ * html/HTMLElement.cpp: Ditto.
+ * html/HTMLTextAreaElement.cpp: Ditto.
+ * page/Frame.cpp: Ditto.
+ * rendering/RenderTextControl.cpp: Ditto.
+
</ins><span class="cx"> 2014-02-08 Andreas Kling <akling@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove two unused function declarations.
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAccessibilityNodeObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -74,7 +74,6 @@
</span><span class="cx"> #include "SVGNames.h"
</span><span class="cx"> #include "Text.h"
</span><span class="cx"> #include "TextControlInnerElements.h"
</span><del>-#include "TextIterator.h"
</del><span class="cx"> #include "UserGestureIndicator.h"
</span><span class="cx"> #include "VisibleUnits.h"
</span><span class="cx"> #include "Widget.h"
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAccessibilityObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -59,7 +59,6 @@
</span><span class="cx"> #include "Settings.h"
</span><span class="cx"> #include "TextCheckerClient.h"
</span><span class="cx"> #include "TextCheckingHelper.h"
</span><del>-#include "TextIterator.h"
</del><span class="cx"> #include "UserGestureIndicator.h"
</span><span class="cx"> #include "VisibleUnits.h"
</span><span class="cx"> #include "htmlediting.h"
</span><span class="lines">@@ -330,13 +329,11 @@
</span><span class="cx"> if (!textChecker)
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- const UChar* chars = stringValue().deprecatedCharacters();
- int charsLength = stringValue().length();
</del><span class="cx"> bool isMisspelled = false;
</span><span class="cx">
</span><span class="cx"> if (unifiedTextCheckerEnabled(frame)) {
</span><span class="cx"> Vector<TextCheckingResult> results;
</span><del>- checkTextOfParagraph(textChecker, chars, charsLength, TextCheckingTypeSpelling, results);
</del><ins>+ checkTextOfParagraph(*textChecker, stringValue(), TextCheckingTypeSpelling, results);
</ins><span class="cx"> if (!results.isEmpty())
</span><span class="cx"> isMisspelled = true;
</span><span class="cx"> return isMisspelled;
</span><span class="lines">@@ -344,7 +341,7 @@
</span><span class="cx">
</span><span class="cx"> int misspellingLength = 0;
</span><span class="cx"> int misspellingLocation = -1;
</span><del>- textChecker->checkSpellingOfString(chars, charsLength, &misspellingLocation, &misspellingLength);
</del><ins>+ textChecker->checkSpellingOfString(stringValue(), &misspellingLocation, &misspellingLength);
</ins><span class="cx"> if (misspellingLength || misspellingLocation != -1)
</span><span class="cx"> isMisspelled = true;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilitymacWebAccessibilityObjectWrapperMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -853,7 +853,7 @@
</span><span class="cx"> [attrString removeAttribute:NSAccessibilityBlockQuoteLevelAttribute range:range];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void AXAttributeStringSetSpelling(NSMutableAttributedString* attrString, Node* node, const UChar* chars, int charLength, NSRange range)
</del><ins>+static void AXAttributeStringSetSpelling(NSMutableAttributedString* attrString, Node* node, StringView text, NSRange range)
</ins><span class="cx"> {
</span><span class="cx"> if (unifiedTextCheckerEnabled(node->document().frame())) {
</span><span class="cx"> // Check the spelling directly since document->markersForNode() does not store the misspelled marking when the cursor is in a word.
</span><span class="lines">@@ -861,7 +861,7 @@
</span><span class="cx">
</span><span class="cx"> // checkTextOfParagraph is the only spelling/grammar checker implemented in WK1 and WK2
</span><span class="cx"> Vector<TextCheckingResult> results;
</span><del>- checkTextOfParagraph(checker, chars, charLength, TextCheckingTypeSpelling, results);
</del><ins>+ checkTextOfParagraph(*checker, text, TextCheckingTypeSpelling, results);
</ins><span class="cx">
</span><span class="cx"> size_t size = results.size();
</span><span class="cx"> NSNumber* trueValue = [NSNumber numberWithBool:YES];
</span><span class="lines">@@ -874,15 +874,11 @@
</span><span class="cx"> }
</span><span class="cx"> return;
</span><span class="cx"> }
</span><del>-
- int currentPosition = 0;
- while (charLength > 0) {
- const UChar* charData = chars + currentPosition;
- TextCheckerClient* checker = node->document().frame()->editor().textChecker();
-
</del><ins>+
+ for (unsigned currentPosition = 0; currentPosition < text.length(); ) {
</ins><span class="cx"> int misspellingLocation = -1;
</span><span class="cx"> int misspellingLength = 0;
</span><del>- checker->checkSpellingOfString(charData, charLength, &misspellingLocation, &misspellingLength);
</del><ins>+ node->document().frame()->editor().textChecker()->checkSpellingOfString(text.substring(currentPosition), &misspellingLocation, &misspellingLength);
</ins><span class="cx"> if (misspellingLocation == -1 || !misspellingLength)
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="lines">@@ -891,8 +887,8 @@
</span><span class="cx"> #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
</span><span class="cx"> AXAttributeStringSetNumber(attrString, NSAccessibilityMarkedMisspelledTextAttribute, [NSNumber numberWithBool:YES], spellRange);
</span><span class="cx"> #endif
</span><del>- charLength -= (misspellingLocation + misspellingLength);
- currentPosition += (misspellingLocation + misspellingLength);
</del><ins>+
+ currentPosition += misspellingLocation + misspellingLength;
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -945,17 +941,17 @@
</span><span class="cx"> [attrString removeAttribute:attribute range:range];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void AXAttributedStringAppendText(NSMutableAttributedString* attrString, Node* node, const UChar* chars, int length)
</del><ins>+static void AXAttributedStringAppendText(NSMutableAttributedString* attrString, Node* node, StringView text)
</ins><span class="cx"> {
</span><span class="cx"> // skip invisible text
</span><span class="cx"> if (!node->renderer())
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // easier to calculate the range before appending the string
</span><del>- NSRange attrStringRange = NSMakeRange([attrString length], length);
</del><ins>+ NSRange attrStringRange = NSMakeRange([attrString length], text.length());
</ins><span class="cx">
</span><span class="cx"> // append the string from this node
</span><del>- [[attrString mutableString] appendString:[NSString stringWithCharacters:chars length:length]];
</del><ins>+ [[attrString mutableString] appendString:text.createNSStringWithoutCopying().get()];
</ins><span class="cx">
</span><span class="cx"> // add new attributes and remove irrelevant inherited ones
</span><span class="cx"> // NOTE: color attributes are handled specially because -[NSMutableAttributedString addAttribute: value: range:] does not merge
</span><span class="lines">@@ -976,7 +972,7 @@
</span><span class="cx"> AXAttributeStringSetElement(attrString, NSAccessibilityLinkTextAttribute, AccessibilityObject::anchorElementForNode(node), attrStringRange);
</span><span class="cx">
</span><span class="cx"> // do spelling last because it tends to break up the range
</span><del>- AXAttributeStringSetSpelling(attrString, node, chars, length, attrStringRange);
</del><ins>+ AXAttributeStringSetSpelling(attrString, node, text, attrStringRange);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static NSString* nsStringForReplacedNode(Node* replacedNode)
</span><span class="lines">@@ -1028,9 +1024,8 @@
</span><span class="cx"> // Add the text of the list marker item if necessary.
</span><span class="cx"> String listMarkerText = m_object->listMarkerTextForNodeAndPosition(node, VisiblePosition(it.range()->startPosition()));
</span><span class="cx"> if (!listMarkerText.isEmpty())
</span><del>- AXAttributedStringAppendText(attrString, node, listMarkerText.deprecatedCharacters(), listMarkerText.length());
-
- AXAttributedStringAppendText(attrString, node, it.characters(), it.length());
</del><ins>+ AXAttributedStringAppendText(attrString, node, listMarkerText);
+ AXAttributedStringAppendText(attrString, node, it.text());
</ins><span class="cx"> } else {
</span><span class="cx"> Node* replacedNode = node->childNode(offset);
</span><span class="cx"> NSString *attachmentString = nsStringForReplacedNode(replacedNode);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsobjcDOMUIKitExtensionsmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/objc/DOMUIKitExtensions.mm (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/objc/DOMUIKitExtensions.mm        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/bindings/objc/DOMUIKitExtensions.mm        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -63,7 +63,6 @@
</span><span class="cx"> #import "RenderText.h"
</span><span class="cx"> #import "ResourceBuffer.h"
</span><span class="cx"> #import "SharedBuffer.h"
</span><del>-#import "TextIterator.h"
</del><span class="cx"> #import "VisiblePosition.h"
</span><span class="cx"> #import "VisibleUnits.h"
</span><span class="cx">
</span><span class="lines">@@ -87,7 +86,6 @@
</span><span class="cx"> using WebCore::RenderStyle;
</span><span class="cx"> using WebCore::RenderText;
</span><span class="cx"> using WebCore::RootInlineBox;
</span><del>-using WebCore::TextIterator;
</del><span class="cx"> using WebCore::VisiblePosition;
</span><span class="cx">
</span><span class="cx"> @implementation DOMRange (UIKitExtensions)
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/dom/Element.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -73,7 +73,6 @@
</span><span class="cx"> #include "Settings.h"
</span><span class="cx"> #include "StyleProperties.h"
</span><span class="cx"> #include "StyleResolver.h"
</span><del>-#include "TextIterator.h"
</del><span class="cx"> #include "VoidCallback.h"
</span><span class="cx"> #include "WheelEvent.h"
</span><span class="cx"> #include "XMLNSNames.h"
</span></span></pre></div>
<a id="trunkSourceWebCoredomPositionIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/PositionIterator.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/PositionIterator.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/dom/PositionIterator.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -29,7 +29,6 @@
</span><span class="cx"> #include "HTMLNames.h"
</span><span class="cx"> #include "RenderBlock.h"
</span><span class="cx"> #include "RenderText.h"
</span><del>-#include "TextIterator.h"
</del><span class="cx"> #include "htmlediting.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingApplyBlockElementCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/ApplyBlockElementCommand.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ApplyBlockElementCommand.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/editing/ApplyBlockElementCommand.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -32,7 +32,6 @@
</span><span class="cx"> #include "RenderElement.h"
</span><span class="cx"> #include "RenderStyle.h"
</span><span class="cx"> #include "Text.h"
</span><del>-#include "TextIterator.h"
</del><span class="cx"> #include "VisibleUnits.h"
</span><span class="cx"> #include "htmlediting.h"
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/editing/Editor.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -2107,7 +2107,7 @@
</span><span class="cx"> int wordLength = word.length();
</span><span class="cx"> int misspellingLocation = -1;
</span><span class="cx"> int misspellingLength = 0;
</span><del>- textChecker()->checkSpellingOfString(word.deprecatedCharacters(), wordLength, &misspellingLocation, &misspellingLength);
</del><ins>+ textChecker()->checkSpellingOfString(word, &misspellingLocation, &misspellingLength);
</ins><span class="cx">
</span><span class="cx"> return misspellingLength == wordLength ? word : String();
</span><span class="cx"> }
</span><span class="lines">@@ -2121,7 +2121,7 @@
</span><span class="cx">
</span><span class="cx"> int misspellingLocation = -1;
</span><span class="cx"> int misspellingLength = 0;
</span><del>- textChecker()->checkSpellingOfString(selectedString.deprecatedCharacters(), length, &misspellingLocation, &misspellingLength);
</del><ins>+ textChecker()->checkSpellingOfString(selectedString, &misspellingLocation, &misspellingLength);
</ins><span class="cx">
</span><span class="cx"> // The selection only counts as misspelled if the selected text is exactly one misspelled word
</span><span class="cx"> if (misspellingLength != length)
</span><span class="lines">@@ -2423,14 +2423,13 @@
</span><span class="cx"> RefPtr<SpellCheckRequest> request = SpellCheckRequest::create(resolveTextCheckingTypeMask(textCheckingOptions), TextCheckingProcessIncremental, asynchronous ? paragraphRange : rangeToCheck, paragraphRange);
</span><span class="cx">
</span><span class="cx"> if (asynchronous) {
</span><del>- m_spellChecker->requestCheckingFor(request);
</del><ins>+ m_spellChecker->requestCheckingFor(request.release());
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Vector<TextCheckingResult> results;
</span><del>- checkTextOfParagraph(textChecker(), paragraphToCheck.textDeprecatedCharacters(), paragraphToCheck.textLength(),
- resolveTextCheckingTypeMask(textCheckingOptions), results);
- markAndReplaceFor(request, results);
</del><ins>+ checkTextOfParagraph(*textChecker(), paragraphToCheck.text(), resolveTextCheckingTypeMask(textCheckingOptions), results);
+ markAndReplaceFor(request.release(), results);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static bool isAutomaticTextReplacementType(TextCheckingType type)
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingIndentOutdentCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/IndentOutdentCommand.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/IndentOutdentCommand.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/editing/IndentOutdentCommand.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -35,7 +35,6 @@
</span><span class="cx"> #include "RenderObject.h"
</span><span class="cx"> #include "SplitElementCommand.h"
</span><span class="cx"> #include "Text.h"
</span><del>-#include "TextIterator.h"
</del><span class="cx"> #include "VisibleUnits.h"
</span><span class="cx"> #include "htmlediting.h"
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingInsertListCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/InsertListCommand.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/InsertListCommand.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/editing/InsertListCommand.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -24,14 +24,15 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> #include "config.h"
</span><ins>+#include "InsertListCommand.h"
+
</ins><span class="cx"> #include "Element.h"
</span><span class="cx"> #include "ElementTraversal.h"
</span><del>-#include "InsertListCommand.h"
</del><span class="cx"> #include "ExceptionCodePlaceholder.h"
</span><span class="cx"> #include "htmlediting.h"
</span><span class="cx"> #include "HTMLElement.h"
</span><span class="cx"> #include "HTMLNames.h"
</span><del>-#include "TextIterator.h"
</del><ins>+#include "Range.h"
</ins><span class="cx"> #include "VisibleUnits.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTextCheckingHelpercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TextCheckingHelper.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TextCheckingHelper.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/editing/TextCheckingHelper.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006, 2007, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
</span><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -43,61 +43,68 @@
</span><span class="cx"> #if !USE(UNIFIED_TEXT_CHECKING)
</span><span class="cx">
</span><span class="cx"> #if USE(GRAMMAR_CHECKING)
</span><del>-static void findBadGrammars(TextCheckerClient* client, const UChar* text, int start, int length, Vector<TextCheckingResult>& results)
</del><ins>+
+static void findGrammaticalErrors(TextCheckerClient& client, StringView text, Vector<TextCheckingResult>& results)
</ins><span class="cx"> {
</span><del>- int checkLocation = start;
- int checkLength = length;
-
- while (0 < checkLength) {
</del><ins>+ for (unsigned checkLocation = 0; checkLocation < text.length(); ) {
</ins><span class="cx"> int badGrammarLocation = -1;
</span><span class="cx"> int badGrammarLength = 0;
</span><span class="cx"> Vector<GrammarDetail> badGrammarDetails;
</span><del>- client->checkGrammarOfString(text + checkLocation, checkLength, badGrammarDetails, &badGrammarLocation, &badGrammarLength);
</del><ins>+ client.checkGrammarOfString(text.substring(checkLocation), badGrammarDetails, &badGrammarLocation, &badGrammarLength);
</ins><span class="cx"> if (!badGrammarLength)
</span><span class="cx"> break;
</span><del>- ASSERT(0 <= badGrammarLocation && badGrammarLocation <= checkLength);
- ASSERT(0 < badGrammarLength && badGrammarLocation + badGrammarLength <= checkLength);
</del><ins>+
+ ASSERT(badGrammarLocation >= 0);
+ ASSERT(static_cast<unsigned>(badGrammarLocation) <= text.length() - checkLocation);
+ ASSERT(badGrammarLength > 0);
+ ASSERT(static_cast<unsigned>(badGrammarLength) <= text.length() - checkLocation - badGrammarLocation);
+
</ins><span class="cx"> TextCheckingResult badGrammar;
</span><span class="cx"> badGrammar.type = TextCheckingTypeGrammar;
</span><span class="cx"> badGrammar.location = checkLocation + badGrammarLocation;
</span><span class="cx"> badGrammar.length = badGrammarLength;
</span><del>- badGrammar.details.swap(badGrammarDetails);
</del><ins>+ badGrammar.details = std::move(badGrammarDetails);
</ins><span class="cx"> results.append(badGrammar);
</span><span class="cx">
</span><del>- checkLocation += (badGrammarLocation + badGrammarLength);
- checkLength -= (badGrammarLocation + badGrammarLength);
</del><ins>+ checkLocation += badGrammarLocation + badGrammarLength;
</ins><span class="cx"> }
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>-static void findMisspellings(TextCheckerClient* client, const UChar* text, int length, Vector<TextCheckingResult>& results)
</del><ins>+static void findMisspellings(TextCheckerClient& client, StringView text, Vector<TextCheckingResult>& results)
</ins><span class="cx"> {
</span><del>- TextBreakIterator* iterator = wordBreakIterator(StringView(text, length));
</del><ins>+ TextBreakIterator* iterator = wordBreakIterator(text);
</ins><span class="cx"> if (!iterator)
</span><span class="cx"> return;
</span><del>- int wordStart = textBreakCurrent(iterator);
- while (0 <= wordStart) {
</del><ins>+ for (int wordStart = textBreakCurrent(iterator); wordStart > 0; ) {
</ins><span class="cx"> int wordEnd = textBreakNext(iterator);
</span><span class="cx"> if (wordEnd < 0)
</span><span class="cx"> break;
</span><ins>+
</ins><span class="cx"> int wordLength = wordEnd - wordStart;
</span><span class="cx"> int misspellingLocation = -1;
</span><span class="cx"> int misspellingLength = 0;
</span><del>- client->checkSpellingOfString(text + wordStart, wordLength, &misspellingLocation, &misspellingLength);
- if (0 < misspellingLength) {
- ASSERT(0 <= misspellingLocation && misspellingLocation <= wordLength);
- ASSERT(0 < misspellingLength && misspellingLocation + misspellingLength <= wordLength);
</del><ins>+ client.checkSpellingOfString(text.substring(wordStart, wordLength), &misspellingLocation, &misspellingLength);
+
+ if (misspellingLength > 0) {
+ ASSERT(misspellingLocation >= 0);
+ ASSERT(misspellingLocation <= wordLength);
+ ASSERT(misspellingLength > 0);
+ ASSERT(misspellingLocation + misspellingLength <= wordLength);
+
</ins><span class="cx"> TextCheckingResult misspelling;
</span><span class="cx"> misspelling.type = TextCheckingTypeSpelling;
</span><span class="cx"> misspelling.location = wordStart + misspellingLocation;
</span><span class="cx"> misspelling.length = misspellingLength;
</span><del>- misspelling.replacement = client->getAutoCorrectSuggestionForMisspelledWord(String(text + misspelling.location, misspelling.length));
</del><ins>+ misspelling.replacement = client.getAutoCorrectSuggestionForMisspelledWord(text.substring(misspelling.location, misspelling.length).toStringWithoutCopying());
</ins><span class="cx"> results.append(misspelling);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> wordStart = wordEnd;
</span><span class="cx"> }
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> static PassRefPtr<Range> expandToParagraphBoundary(PassRefPtr<Range> range)
</span><span class="lines">@@ -234,6 +241,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if !PLATFORM(IOS)
</span><ins>+
</ins><span class="cx"> String TextCheckingHelper::findFirstMisspelling(int& firstMisspellingOffset, bool markAll, RefPtr<Range>& firstMisspellingRange)
</span><span class="cx"> {
</span><span class="cx"> WordAwareIterator it(m_range.get());
</span><span class="lines">@@ -243,15 +251,14 @@
</span><span class="cx"> int currentChunkOffset = 0;
</span><span class="cx">
</span><span class="cx"> while (!it.atEnd()) {
</span><del>- const UChar* chars = it.characters();
- int len = it.length();
-
</del><ins>+ StringView text = it.text();
+ int textLength = text.length();
+
</ins><span class="cx"> // Skip some work for one-space-char hunks
</span><del>- if (!(len == 1 && chars[0] == ' ')) {
-
</del><ins>+ if (textLength == 1 && text[0] == ' ') {
</ins><span class="cx"> int misspellingLocation = -1;
</span><span class="cx"> int misspellingLength = 0;
</span><del>- m_client->textChecker()->checkSpellingOfString(chars, len, &misspellingLocation, &misspellingLength);
</del><ins>+ m_client->textChecker()->checkSpellingOfString(text, &misspellingLocation, &misspellingLength);
</ins><span class="cx">
</span><span class="cx"> // 5490627 shows that there was some code path here where the String constructor below crashes.
</span><span class="cx"> // We don't know exactly what combination of bad input caused this, so we're making this much
</span><span class="lines">@@ -259,19 +266,18 @@
</span><span class="cx"> ASSERT(misspellingLength >= 0);
</span><span class="cx"> ASSERT(misspellingLocation >= -1);
</span><span class="cx"> ASSERT(!misspellingLength || misspellingLocation >= 0);
</span><del>- ASSERT(misspellingLocation < len);
- ASSERT(misspellingLength <= len);
- ASSERT(misspellingLocation + misspellingLength <= len);
-
- if (misspellingLocation >= 0 && misspellingLength > 0 && misspellingLocation < len && misspellingLength <= len && misspellingLocation + misspellingLength <= len) {
-
</del><ins>+ ASSERT(misspellingLocation < textLength);
+ ASSERT(misspellingLength <= textLength);
+ ASSERT(misspellingLocation + misspellingLength <= textLength);
+
+ if (misspellingLocation >= 0 && misspellingLength > 0 && misspellingLocation < textLength && misspellingLength <= textLength && misspellingLocation + misspellingLength <= textLength) {
</ins><span class="cx"> // Compute range of misspelled word
</span><span class="cx"> RefPtr<Range> misspellingRange = TextIterator::subrange(m_range.get(), currentChunkOffset + misspellingLocation, misspellingLength);
</span><span class="cx">
</span><span class="cx"> // Remember first-encountered misspelling and its offset.
</span><span class="cx"> if (!firstMisspelling) {
</span><span class="cx"> firstMisspellingOffset = currentChunkOffset + misspellingLocation;
</span><del>- firstMisspelling = String(chars + misspellingLocation, misspellingLength);
</del><ins>+ firstMisspelling = text.substring(misspellingLocation, misspellingLength).toString();
</ins><span class="cx"> firstMisspellingRange = misspellingRange;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -284,7 +290,7 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- currentChunkOffset += len;
</del><ins>+ currentChunkOffset += textLength;
</ins><span class="cx"> it.advance();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -345,26 +351,29 @@
</span><span class="cx">
</span><span class="cx"> Vector<TextCheckingResult> results;
</span><span class="cx"> TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckingTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling;
</span><del>- checkTextOfParagraph(m_client->textChecker(), paragraphString.deprecatedCharacters(), paragraphString.length(), checkingTypes, results);
</del><ins>+ checkTextOfParagraph(*m_client->textChecker(), paragraphString, checkingTypes, results);
</ins><span class="cx">
</span><span class="cx"> for (unsigned i = 0; i < results.size(); i++) {
</span><span class="cx"> const TextCheckingResult* result = &results[i];
</span><span class="cx"> if (result->type == TextCheckingTypeSpelling && result->location >= currentStartOffset && result->location + result->length <= currentEndOffset) {
</span><del>- ASSERT(result->length > 0 && result->location >= 0);
</del><ins>+ ASSERT(result->length > 0);
+ ASSERT(result->location >= 0);
</ins><span class="cx"> spellingLocation = result->location;
</span><span class="cx"> misspelledWord = paragraphString.substring(result->location, result->length);
</span><span class="cx"> ASSERT(misspelledWord.length());
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> if (checkGrammar && result->type == TextCheckingTypeGrammar && result->location < currentEndOffset && result->location + result->length > currentStartOffset) {
</span><del>- ASSERT(result->length > 0 && result->location >= 0);
</del><ins>+ ASSERT(result->length > 0);
+ ASSERT(result->location >= 0);
</ins><span class="cx"> // We can't stop after the first grammar result, since there might still be a spelling result after
</span><span class="cx"> // it begins but before the first detail in it, but we can stop if we find a second grammar result.
</span><span class="cx"> if (foundGrammar)
</span><span class="cx"> break;
</span><span class="cx"> for (unsigned j = 0; j < result->details.size(); j++) {
</span><span class="cx"> const GrammarDetail* detail = &result->details[j];
</span><del>- ASSERT(detail->length > 0 && detail->location >= 0);
</del><ins>+ ASSERT(detail->length > 0);
+ ASSERT(detail->location >= 0);
</ins><span class="cx"> if (result->location + detail->location >= currentStartOffset && result->location + detail->location + detail->length <= currentEndOffset && (!foundGrammar || result->location + detail->location < grammarDetailLocation)) {
</span><span class="cx"> grammarDetailIndex = j;
</span><span class="cx"> grammarDetailLocation = result->location + detail->location;
</span><span class="lines">@@ -414,9 +423,11 @@
</span><span class="cx"> }
</span><span class="cx"> return firstFoundItem;
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #endif // !PLATFORM(IOS)
</span><span class="cx">
</span><span class="cx"> #if USE(GRAMMAR_CHECKING)
</span><ins>+
</ins><span class="cx"> int TextCheckingHelper::findFirstGrammarDetail(const Vector<GrammarDetail>& grammarDetails, int badGrammarPhraseLocation, int startOffset, int endOffset, bool markAll) const
</span><span class="cx"> {
</span><span class="cx"> // Found some bad grammar. Find the earliest detail range that starts in our search range (if any).
</span><span class="lines">@@ -425,7 +436,8 @@
</span><span class="cx"> int earliestDetailIndex = -1;
</span><span class="cx"> for (unsigned i = 0; i < grammarDetails.size(); i++) {
</span><span class="cx"> const GrammarDetail* detail = &grammarDetails[i];
</span><del>- ASSERT(detail->length > 0 && detail->location >= 0);
</del><ins>+ ASSERT(detail->length > 0);
+ ASSERT(detail->location >= 0);
</ins><span class="cx">
</span><span class="cx"> int detailStartOffsetInParagraph = badGrammarPhraseLocation + detail->location;
</span><span class="cx">
</span><span class="lines">@@ -469,12 +481,11 @@
</span><span class="cx"> TextCheckingParagraph paragraph(m_range);
</span><span class="cx">
</span><span class="cx"> // Start checking from beginning of paragraph, but skip past results that occur before the start of the original search range.
</span><del>- int startOffset = 0;
- while (startOffset < paragraph.checkingEnd()) {
</del><ins>+ for (int startOffset = 0; startOffset < paragraph.checkingEnd(); ) {
</ins><span class="cx"> Vector<GrammarDetail> grammarDetails;
</span><span class="cx"> int badGrammarPhraseLocation = -1;
</span><span class="cx"> int badGrammarPhraseLength = 0;
</span><del>- m_client->textChecker()->checkGrammarOfString(paragraph.textDeprecatedCharacters() + startOffset, paragraph.textLength() - startOffset, grammarDetails, &badGrammarPhraseLocation, &badGrammarPhraseLength);
</del><ins>+ m_client->textChecker()->checkGrammarOfString(StringView(paragraph.text()).substring(startOffset), grammarDetails, &badGrammarPhraseLocation, &badGrammarPhraseLength);
</ins><span class="cx">
</span><span class="cx"> if (!badGrammarPhraseLength) {
</span><span class="cx"> ASSERT(badGrammarPhraseLocation == -1);
</span><span class="lines">@@ -484,7 +495,6 @@
</span><span class="cx"> ASSERT(badGrammarPhraseLocation >= 0);
</span><span class="cx"> badGrammarPhraseLocation += startOffset;
</span><span class="cx">
</span><del>-
</del><span class="cx"> // Found some bad grammar. Find the earliest detail range that starts in our search range (if any).
</span><span class="cx"> int badGrammarIndex = findFirstGrammarDetail(grammarDetails, badGrammarPhraseLocation, paragraph.checkingStart(), paragraph.checkingEnd(), markAll);
</span><span class="cx"> if (badGrammarIndex >= 0) {
</span><span class="lines">@@ -511,7 +521,6 @@
</span><span class="cx"> return firstBadGrammarPhrase;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-
</del><span class="cx"> bool TextCheckingHelper::isUngrammatical() const
</span><span class="cx"> {
</span><span class="cx"> if (!m_client)
</span><span class="lines">@@ -535,9 +544,10 @@
</span><span class="cx"> // Bad grammar, but phrase (e.g. sentence) starts beyond start of range.
</span><span class="cx"> if (grammarPhraseOffset > 0)
</span><span class="cx"> return false;
</span><del>-
- ASSERT(grammarDetail.location >= 0 && grammarDetail.length > 0);
-
</del><ins>+
+ ASSERT(grammarDetail.location >= 0);
+ ASSERT(grammarDetail.length > 0);
+
</ins><span class="cx"> // Bad grammar, but start of detail (e.g. ungrammatical word) doesn't match start of range
</span><span class="cx"> if (grammarDetail.location + grammarPhraseOffset)
</span><span class="cx"> return false;
</span><span class="lines">@@ -554,8 +564,9 @@
</span><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><del>-#endif
</del><span class="cx">
</span><ins>+#endif // USE(GRAMMAR_CHECKING)
+
</ins><span class="cx"> Vector<String> TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange(bool checkGrammar, bool& misspelled, bool& ungrammatical) const
</span><span class="cx"> {
</span><span class="cx"> if (!unifiedTextCheckerEnabled())
</span><span class="lines">@@ -575,7 +586,7 @@
</span><span class="cx">
</span><span class="cx"> Vector<TextCheckingResult> results;
</span><span class="cx"> TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckingTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling;
</span><del>- checkTextOfParagraph(m_client->textChecker(), paragraph.textDeprecatedCharacters(), paragraph.textLength(), checkingTypes, results);
</del><ins>+ checkTextOfParagraph(*m_client->textChecker(), paragraph.text(), checkingTypes, results);
</ins><span class="cx">
</span><span class="cx"> for (unsigned i = 0; i < results.size(); i++) {
</span><span class="cx"> const TextCheckingResult* result = &results[i];
</span><span class="lines">@@ -597,7 +608,8 @@
</span><span class="cx"> if (result->type == TextCheckingTypeGrammar && paragraph.isCheckingRangeCoveredBy(result->location, result->length)) {
</span><span class="cx"> for (unsigned j = 0; j < result->details.size(); j++) {
</span><span class="cx"> const GrammarDetail* detail = &result->details[j];
</span><del>- ASSERT(detail->length > 0 && detail->location >= 0);
</del><ins>+ ASSERT(detail->length > 0);
+ ASSERT(detail->location >= 0);
</ins><span class="cx"> if (paragraph.checkingRangeMatches(result->location + detail->location, detail->length)) {
</span><span class="cx"> String badGrammarPhrase = paragraph.textSubstring(result->location, result->length);
</span><span class="cx"> ASSERT(badGrammarPhrase.length());
</span><span class="lines">@@ -613,8 +625,8 @@
</span><span class="cx"> return guesses;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if !PLATFORM(IOS)
</ins><span class="cx">
</span><del>-#if !PLATFORM(IOS)
</del><span class="cx"> void TextCheckingHelper::markAllMisspellings(RefPtr<Range>& firstMisspellingRange)
</span><span class="cx"> {
</span><span class="cx"> // Use the "markAll" feature of findFirstMisspelling. Ignore the return value and the "out parameter";
</span><span class="lines">@@ -633,6 +645,7 @@
</span><span class="cx"> findFirstBadGrammar(ignoredGrammarDetail, ignoredOffset, true);
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><ins>+
</ins><span class="cx"> #endif // !PLATFORM(IOS)
</span><span class="cx">
</span><span class="cx"> bool TextCheckingHelper::unifiedTextCheckerEnabled() const
</span><span class="lines">@@ -640,40 +653,33 @@
</span><span class="cx"> return m_range && WebCore::unifiedTextCheckerEnabled(m_range->ownerDocument().frame());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void checkTextOfParagraph(TextCheckerClient* client, const UChar* text, int length,
- TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results)
</del><ins>+void checkTextOfParagraph(TextCheckerClient& client, StringView text, TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results)
</ins><span class="cx"> {
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>- results = client->checkTextOfParagraph(StringView(text, length), checkingTypes);
</del><ins>+ results = client.checkTextOfParagraph(text, checkingTypes);
</ins><span class="cx"> #else
</span><del>- Vector<TextCheckingResult> spellingResult;
</del><ins>+ Vector<TextCheckingResult> mispellings;
</ins><span class="cx"> if (checkingTypes & TextCheckingTypeSpelling)
</span><del>- findMisspellings(client, text, length, spellingResult);
</del><ins>+ findMisspellings(client, text, mispellings);
</ins><span class="cx">
</span><span class="cx"> #if USE(GRAMMAR_CHECKING)
</span><del>- Vector<TextCheckingResult> grammarResult;
</del><ins>+ // Look for grammatical errors that occur before the first misspelling.
+ Vector<TextCheckingResult> grammaticalErrors;
</ins><span class="cx"> if (checkingTypes & TextCheckingTypeGrammar) {
</span><del>- // Only checks grammartical error before the first misspellings
- int grammarCheckLength = length;
- for (size_t i = 0; i < spellingResult.size(); ++i) {
- if (spellingResult[i].location < grammarCheckLength)
- grammarCheckLength = spellingResult[i].location;
- }
-
- findBadGrammars(client, text, 0, grammarCheckLength, grammarResult);
</del><ins>+ unsigned grammarCheckLength = text.length();
+ for (auto& mispelling : mispellings)
+ grammarCheckLength = std::min<unsigned>(grammarCheckLength, mispelling.location);
+ findGrammaticalErrors(client, text.substring(0, grammarCheckLength), grammaticalErrors);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- if (grammarResult.size())
- results.swap(grammarResult);
</del><ins>+ results = std::move(grammaticalErrors);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- if (spellingResult.size()) {
- if (results.isEmpty())
- results.swap(spellingResult);
- else
- results.appendVector(spellingResult);
- }
-#endif
</del><ins>+ if (results.isEmpty())
+ results = std::move(mispellings);
+ else
+ results.appendVector(mispellings);
+#endif // USE(UNIFIED_TEXT_CHECKING)
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool unifiedTextCheckerEnabled(const Frame* frame)
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTextCheckingHelperh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TextCheckingHelper.h (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TextCheckingHelper.h        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/editing/TextCheckingHelper.h        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006, 2007, 2008, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
</span><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="lines">@@ -43,13 +43,16 @@
</span><span class="cx"> int offsetTo(const Position&, ExceptionCode&) const;
</span><span class="cx"> void expandRangeToNextEnd();
</span><span class="cx">
</span><ins>+ // FIXME: Consider changing this to return a StringView.
+ const String& text() const;
+
+ // FIXME: Consider removing these and just having the caller use text() directly.
</ins><span class="cx"> int textLength() const { return text().length(); }
</span><span class="cx"> String textSubstring(unsigned pos, unsigned len = UINT_MAX) const { return text().substring(pos, len); }
</span><del>- const UChar* textDeprecatedCharacters() const { return text().deprecatedCharacters(); }
</del><span class="cx"> UChar textCharAt(int index) const { return text()[static_cast<unsigned>(index)]; }
</span><ins>+ bool isTextEmpty() const { return text().isEmpty(); }
</ins><span class="cx">
</span><span class="cx"> bool isEmpty() const;
</span><del>- bool isTextEmpty() const { return text().isEmpty(); }
</del><span class="cx"> bool isRangeEmpty() const { return checkingStart() >= checkingEnd(); }
</span><span class="cx">
</span><span class="cx"> int checkingStart() const;
</span><span class="lines">@@ -66,7 +69,6 @@
</span><span class="cx"> void invalidateParagraphRangeValues();
</span><span class="cx"> PassRefPtr<Range> checkingRange() const { return m_checkingRange; }
</span><span class="cx"> PassRefPtr<Range> offsetAsRange() const;
</span><del>- const String& text() const;
</del><span class="cx">
</span><span class="cx"> RefPtr<Range> m_checkingRange;
</span><span class="cx"> mutable RefPtr<Range> m_paragraphRange;
</span><span class="lines">@@ -103,8 +105,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx">
</span><del>-void checkTextOfParagraph(TextCheckerClient*, const UChar* text, int length,
- TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results);
</del><ins>+void checkTextOfParagraph(TextCheckerClient&, StringView, TextCheckingTypeMask, Vector<TextCheckingResult>&);
</ins><span class="cx">
</span><span class="cx"> bool unifiedTextCheckerEnabled(const Frame*);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTextIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TextIterator.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TextIterator.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/editing/TextIterator.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2004-2014 Apple Inc. All rights reserved.
</ins><span class="cx"> * Copyright (C) 2005 Alexey Proskuryakov.
</span><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -76,9 +76,9 @@
</span><span class="cx"> ~SearchBuffer();
</span><span class="cx">
</span><span class="cx"> // Returns number of characters appended; guaranteed to be in the range [1, length].
</span><del>- size_t append(const UChar*, size_t length);
</del><ins>+ size_t append(StringView);
</ins><span class="cx"> bool needsMoreContext() const;
</span><del>- void prependContext(const UChar*, size_t length);
</del><ins>+ void prependContext(StringView);
</ins><span class="cx"> void reachedBreak();
</span><span class="cx">
</span><span class="cx"> // Result is the size in characters of what was found.
</span><span class="lines">@@ -480,7 +480,7 @@
</span><span class="cx"> return 0;
</span><span class="cx">
</span><span class="cx"> if (!m_textCharacters)
</span><del>- return string()[startOffset() + index];
</del><ins>+ return m_text[m_positionStartOffset + index];
</ins><span class="cx">
</span><span class="cx"> return m_textCharacters[index];
</span><span class="cx"> }
</span><span class="lines">@@ -488,9 +488,9 @@
</span><span class="cx"> void TextIterator::appendTextToStringBuilder(StringBuilder& builder) const
</span><span class="cx"> {
</span><span class="cx"> if (!m_textCharacters)
</span><del>- builder.append(string(), startOffset(), length());
</del><ins>+ builder.append(m_text, m_positionStartOffset, m_textLength);
</ins><span class="cx"> else
</span><del>- builder.append(characters(), length());
</del><ins>+ builder.append(m_textCharacters, m_textLength);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool TextIterator::handleTextNode()
</span><span class="lines">@@ -1484,13 +1484,22 @@
</span><span class="cx"> m_runOffset = 0;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void append(Vector<UChar>& buffer, StringView string)
+{
+ unsigned oldSize = buffer.size();
+ unsigned length = string.length();
+ buffer.grow(oldSize + length);
+ for (unsigned i = 0; i < length; ++i)
+ buffer[oldSize + i] = string[i];
+}
+
</ins><span class="cx"> String CharacterIterator::string(int numChars)
</span><span class="cx"> {
</span><span class="cx"> Vector<UChar> result;
</span><span class="cx"> result.reserveInitialCapacity(numChars);
</span><span class="cx"> while (numChars > 0 && !atEnd()) {
</span><span class="cx"> int runSize = std::min(numChars, length());
</span><del>- result.append(characters(), runSize);
</del><ins>+ append(result, text().substring(0, runSize));
</ins><span class="cx"> numChars -= runSize;
</span><span class="cx"> advance(runSize);
</span><span class="cx"> }
</span><span class="lines">@@ -1580,8 +1589,7 @@
</span><span class="cx"> // --------
</span><span class="cx">
</span><span class="cx"> WordAwareIterator::WordAwareIterator(const Range* r)
</span><del>- : m_previousText(0)
- , m_didLookAhead(true) // so we consider the first chunk from the text iterator
</del><ins>+ : m_didLookAhead(true) // so we consider the first chunk from the text iterator
</ins><span class="cx"> , m_textIterator(r)
</span><span class="cx"> {
</span><span class="cx"> advance(); // get in position over the first chunk of text
</span><span class="lines">@@ -1602,7 +1610,7 @@
</span><span class="cx">
</span><span class="cx"> void WordAwareIterator::advance()
</span><span class="cx"> {
</span><del>- m_previousText = 0;
</del><ins>+ m_previousText = StringView();
</ins><span class="cx"> m_buffer.clear(); // toss any old buffer we built up
</span><span class="cx">
</span><span class="cx"> // If last time we did a look-ahead, start with that looked-ahead chunk now
</span><span class="lines">@@ -1622,30 +1630,32 @@
</span><span class="cx">
</span><span class="cx"> while (1) {
</span><span class="cx"> // If this chunk ends in whitespace we can just use it as our chunk.
</span><del>- if (isSpaceOrNewline(m_textIterator.characters()[m_textIterator.length() - 1]))
</del><ins>+ if (isSpaceOrNewline(m_textIterator.text()[m_textIterator.length() - 1]))
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // If this is the first chunk that failed, save it in previousText before look ahead
</span><span class="cx"> if (m_buffer.isEmpty()) {
</span><del>- m_previousText = m_textIterator.characters();
- m_previousLength = m_textIterator.length();
</del><ins>+ // FIXME: It's not safe to keep a StringView alive to the previous text once the
+ // TextIterator advances. In cases where the TextIterator synthesizes a character,
+ // the pointer is no longer valid once we call advance. To fix this, we might need
+ // to add a new function to TextIterator to handle those cases.
+ m_previousText = m_textIterator.text();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Look ahead to next chunk. If it is whitespace or a break, we can use the previous stuff
</span><span class="cx"> m_textIterator.advance();
</span><del>- if (m_textIterator.atEnd() || m_textIterator.length() == 0 || isSpaceOrNewline(m_textIterator.characters()[0])) {
</del><ins>+ if (m_textIterator.atEnd() || !m_textIterator.length() || isSpaceOrNewline(m_textIterator.text()[0])) {
</ins><span class="cx"> m_didLookAhead = true;
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (m_buffer.isEmpty()) {
</span><span class="cx"> // Start gobbling chunks until we get to a suitable stopping point
</span><del>- m_buffer.append(m_previousText, m_previousLength);
- m_previousText = 0;
</del><ins>+ append(m_buffer, m_previousText);
+ m_previousText = StringView();
</ins><span class="cx"> }
</span><del>- m_buffer.append(m_textIterator.characters(), m_textIterator.length());
- int exception = 0;
- m_range->setEnd(m_textIterator.range()->endContainer(), m_textIterator.range()->endOffset(), exception);
</del><ins>+ append(m_buffer, m_textIterator.text());
+ m_range->setEnd(m_textIterator.range()->endContainer(), m_textIterator.range()->endOffset());
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1654,17 +1664,17 @@
</span><span class="cx"> if (!m_buffer.isEmpty())
</span><span class="cx"> return m_buffer.size();
</span><span class="cx"> if (m_previousText)
</span><del>- return m_previousLength;
</del><ins>+ return m_previousText.length();
</ins><span class="cx"> return m_textIterator.length();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-const UChar* WordAwareIterator::characters() const
</del><ins>+StringView WordAwareIterator::text() const
</ins><span class="cx"> {
</span><span class="cx"> if (!m_buffer.isEmpty())
</span><del>- return m_buffer.data();
</del><ins>+ return StringView(m_buffer.data(), m_buffer.size());
</ins><span class="cx"> if (m_previousText)
</span><span class="cx"> return m_previousText;
</span><del>- return m_textIterator.characters();
</del><ins>+ return m_textIterator.text();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // --------
</span><span class="lines">@@ -2062,9 +2072,9 @@
</span><span class="cx"> unlockSearcher();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-inline size_t SearchBuffer::append(const UChar* characters, size_t length)
</del><ins>+inline size_t SearchBuffer::append(StringView text)
</ins><span class="cx"> {
</span><del>- ASSERT(length);
</del><ins>+ ASSERT(text.length());
</ins><span class="cx">
</span><span class="cx"> if (m_atBreak) {
</span><span class="cx"> m_buffer.shrink(0);
</span><span class="lines">@@ -2077,9 +2087,11 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> size_t oldLength = m_buffer.size();
</span><del>- size_t usableLength = std::min(m_buffer.capacity() - oldLength, length);
</del><ins>+ size_t usableLength = std::min<size_t>(m_buffer.capacity() - oldLength, text.length());
</ins><span class="cx"> ASSERT(usableLength);
</span><del>- m_buffer.append(characters, usableLength);
</del><ins>+ m_buffer.grow(oldLength + usableLength);
+ for (unsigned i = 0; i < usableLength; ++i)
+ m_buffer[oldLength + i] = text[i];
</ins><span class="cx"> foldQuoteMarksAndSoftHyphens(m_buffer.data() + oldLength, usableLength);
</span><span class="cx"> return usableLength;
</span><span class="cx"> }
</span><span class="lines">@@ -2089,24 +2101,24 @@
</span><span class="cx"> return m_needsMoreContext;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-inline void SearchBuffer::prependContext(const UChar* characters, size_t length)
</del><ins>+inline void SearchBuffer::prependContext(StringView text)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(m_needsMoreContext);
</span><span class="cx"> ASSERT(m_prefixLength == m_buffer.size());
</span><span class="cx">
</span><del>- if (!length)
</del><ins>+ if (!text.length())
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> m_atBreak = false;
</span><span class="cx">
</span><del>- size_t wordBoundaryContextStart = length;
</del><ins>+ size_t wordBoundaryContextStart = text.length();
</ins><span class="cx"> if (wordBoundaryContextStart) {
</span><del>- U16_BACK_1(characters, 0, wordBoundaryContextStart);
- wordBoundaryContextStart = startOfLastWordBoundaryContext(characters, wordBoundaryContextStart);
</del><ins>+ U16_BACK_1(text, 0, wordBoundaryContextStart);
+ wordBoundaryContextStart = startOfLastWordBoundaryContext(text.substring(0, wordBoundaryContextStart));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- size_t usableLength = std::min(m_buffer.capacity() - m_prefixLength, length - wordBoundaryContextStart);
- m_buffer.insert(0, characters + length - usableLength, usableLength);
</del><ins>+ size_t usableLength = std::min(m_buffer.capacity() - m_prefixLength, text.length() - wordBoundaryContextStart);
+ WebCore::append(m_buffer, text.substring(text.length() - usableLength, usableLength));
</ins><span class="cx"> m_prefixLength += usableLength;
</span><span class="cx">
</span><span class="cx"> if (wordBoundaryContextStart || m_prefixLength == m_buffer.capacity())
</span><span class="lines">@@ -2234,7 +2246,7 @@
</span><span class="cx">
</span><span class="cx"> size_t wordBreakSearchStart = start + length;
</span><span class="cx"> while (wordBreakSearchStart > start)
</span><del>- wordBreakSearchStart = findNextWordFromIndex(m_buffer.data(), m_buffer.size(), wordBreakSearchStart, false /* backwards */);
</del><ins>+ wordBreakSearchStart = findNextWordFromIndex(StringView(m_buffer.data(), m_buffer.size()), wordBreakSearchStart, false /* backwards */);
</ins><span class="cx"> return wordBreakSearchStart == start;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2275,9 +2287,9 @@
</span><span class="cx"> if (m_options & AtWordStarts) {
</span><span class="cx"> // Ensure that there is sufficient context before matchStart the next time around for
</span><span class="cx"> // determining if it is at a word boundary.
</span><del>- int wordBoundaryContextStart = matchStart;
</del><ins>+ unsigned wordBoundaryContextStart = matchStart;
</ins><span class="cx"> U16_BACK_1(m_buffer.data(), 0, wordBoundaryContextStart);
</span><del>- wordBoundaryContextStart = startOfLastWordBoundaryContext(m_buffer.data(), wordBoundaryContextStart);
</del><ins>+ wordBoundaryContextStart = startOfLastWordBoundaryContext(StringView(m_buffer.data(), wordBoundaryContextStart));
</ins><span class="cx"> overlap = std::min(size - 1, std::max(overlap, size - wordBoundaryContextStart));
</span><span class="cx"> }
</span><span class="cx"> memcpy(m_buffer.data(), m_buffer.data() + size - overlap, overlap * sizeof(UChar));
</span><span class="lines">@@ -2601,14 +2613,14 @@
</span><span class="cx"> RefPtr<Range> beforeStartRange = startRange->ownerDocument().createRange();
</span><span class="cx"> beforeStartRange->setEnd(startRange->startContainer(), startRange->startOffset(), IGNORE_EXCEPTION);
</span><span class="cx"> for (SimplifiedBackwardsTextIterator backwardsIterator(beforeStartRange.get()); !backwardsIterator.atEnd(); backwardsIterator.advance()) {
</span><del>- buffer.prependContext(backwardsIterator.characters(), backwardsIterator.length());
</del><ins>+ buffer.prependContext(backwardsIterator.text());
</ins><span class="cx"> if (!buffer.needsMoreContext())
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> while (!it.atEnd()) {
</span><del>- it.advance(buffer.append(it.characters(), it.length()));
</del><ins>+ it.advance(buffer.append(it.text()));
</ins><span class="cx"> tryAgain:
</span><span class="cx"> size_t matchStartOffset;
</span><span class="cx"> if (size_t newMatchLength = buffer.search(matchStartOffset)) {
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTextIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TextIterator.h (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TextIterator.h        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/editing/TextIterator.h        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2004, 2006, 2009, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include "FindOptions.h"
</span><span class="cx"> #include "Range.h"
</span><span class="cx"> #include <wtf/Vector.h>
</span><ins>+#include <wtf/text/StringView.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -93,8 +94,11 @@
</span><span class="cx"> bool atEnd() const { return !m_positionNode || m_shouldStop; }
</span><span class="cx"> void advance();
</span><span class="cx">
</span><ins>+ StringView text() const { return m_textCharacters ? StringView(m_textCharacters, m_textLength) : StringView(m_text).substring(m_positionStartOffset, m_textLength); }
</ins><span class="cx"> int length() const { return m_textLength; }
</span><del>- const UChar* characters() const { return m_textCharacters ? m_textCharacters : m_text.deprecatedCharacters() + startOffset(); }
</del><ins>+
+ const UChar* deprecatedTextIteratorCharacters() const { return m_textCharacters ? m_textCharacters : m_text.deprecatedCharacters() + m_positionStartOffset; }
+
</ins><span class="cx"> UChar characterAt(unsigned index) const;
</span><span class="cx"> void appendTextToStringBuilder(StringBuilder&) const;
</span><span class="cx">
</span><span class="lines">@@ -107,8 +111,6 @@
</span><span class="cx"> static PassRefPtr<Range> subrange(Range* entireRange, int characterOffset, int characterCount);
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- int startOffset() const { return m_positionStartOffset; }
- const String& string() const { return m_text; }
</del><span class="cx"> void exitNode();
</span><span class="cx"> bool shouldRepresentNodeOffsetZero();
</span><span class="cx"> bool shouldEmitSpaceBeforeAndAfterNode(Node*);
</span><span class="lines">@@ -209,9 +211,10 @@
</span><span class="cx"> void advance();
</span><span class="cx">
</span><span class="cx"> Node* node() const { return m_node; }
</span><ins>+
+ StringView text() const { return StringView(m_textCharacters, m_textLength); }
</ins><span class="cx"> int length() const { return m_textLength; }
</span><del>- const UChar* characters() const { return m_textCharacters; }
-
</del><ins>+
</ins><span class="cx"> PassRefPtr<Range> range() const;
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="lines">@@ -279,13 +282,14 @@
</span><span class="cx"> bool atBreak() const { return m_atBreak; }
</span><span class="cx"> bool atEnd() const { return m_textIterator.atEnd(); }
</span><span class="cx">
</span><ins>+ StringView text() const { return m_textIterator.text().substring(m_runOffset); }
</ins><span class="cx"> int length() const { return m_textIterator.length() - m_runOffset; }
</span><del>- const UChar* characters() const { return m_textIterator.characters() + m_runOffset; }
- String string(int numChars);
</del><ins>+
+ String string(int numCharacters);
</ins><span class="cx">
</span><span class="cx"> int characterOffset() const { return m_offset; }
</span><span class="cx"> PassRefPtr<Range> range() const;
</span><del>-
</del><ins>+
</ins><span class="cx"> private:
</span><span class="cx"> int m_offset;
</span><span class="cx"> int m_runOffset;
</span><span class="lines">@@ -323,20 +327,18 @@
</span><span class="cx"> void advance();
</span><span class="cx">
</span><span class="cx"> int length() const;
</span><del>- const UChar* characters() const;
-
- // Range of the text we're currently returning
</del><ins>+
+ StringView text() const;
</ins><span class="cx"> PassRefPtr<Range> range() const { return m_range; }
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- // text from the previous chunk from the textIterator
- const UChar* m_previousText;
- int m_previousLength;
</del><ins>+ // Text from the previous chunk from the text iterator.
+ StringView m_previousText;
</ins><span class="cx">
</span><del>- // many chunks from textIterator concatenated
</del><ins>+ // Many chunks from text iterator concatenated.
</ins><span class="cx"> Vector<UChar> m_buffer;
</span><span class="cx">
</span><del>- // Did we have to look ahead in the textIterator to confirm the current chunk?
</del><ins>+ // Did we have to look ahead in the text iterator to confirm the current chunk?
</ins><span class="cx"> bool m_didLookAhead;
</span><span class="cx">
</span><span class="cx"> RefPtr<Range> m_range;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingVisibleSelectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/VisibleSelection.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/VisibleSelection.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/editing/VisibleSelection.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -237,7 +237,7 @@
</span><span class="cx"> CharacterIterator charIt(searchRange.get(), TextIteratorEmitsCharactersBetweenAllVisiblePositions);
</span><span class="cx">
</span><span class="cx"> for (; charIt.length(); charIt.advance(1)) {
</span><del>- UChar c = charIt.characters()[0];
</del><ins>+ UChar c = charIt.text()[0];
</ins><span class="cx"> if ((!isSpaceOrNewline(c) && c != noBreakSpace) || c == '\n')
</span><span class="cx"> break;
</span><span class="cx"> m_end = charIt.range()->endPosition();
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingVisibleUnitscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/VisibleUnits.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -55,13 +55,13 @@
</span><span class="cx"> return node;
</span><span class="cx"> node = previousLeafNode(node);
</span><span class="cx"> }
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static Node* nextLeafWithSameEditability(Node* node, EditableType editableType = ContentIsEditable)
</span><span class="cx"> {
</span><span class="cx"> if (!node)
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><span class="cx"> bool editable = node->hasEditableStyle(editableType);
</span><span class="cx"> node = nextLeafNode(node);
</span><span class="lines">@@ -70,7 +70,7 @@
</span><span class="cx"> return node;
</span><span class="cx"> node = nextLeafNode(node);
</span><span class="cx"> }
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // FIXME: consolidate with code in previousLinePosition.
</span><span class="lines">@@ -142,7 +142,7 @@
</span><span class="cx"> const InlineBox* CachedLogicallyOrderedLeafBoxes::previousTextOrLineBreakBox(const RootInlineBox* root, const InlineTextBox* box)
</span><span class="cx"> {
</span><span class="cx"> if (!root)
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><span class="cx"> collectBoxes(root);
</span><span class="cx">
</span><span class="lines">@@ -157,13 +157,13 @@
</span><span class="cx"> return box;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> const InlineBox* CachedLogicallyOrderedLeafBoxes::nextTextOrLineBreakBox(const RootInlineBox* root, const InlineTextBox* box)
</span><span class="cx"> {
</span><span class="cx"> if (!root)
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><span class="cx"> collectBoxes(root);
</span><span class="cx">
</span><span class="lines">@@ -179,7 +179,7 @@
</span><span class="cx"> return box;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> const Vector<InlineBox*>& CachedLogicallyOrderedLeafBoxes::collectBoxes(const RootInlineBox* root)
</span><span class="lines">@@ -444,8 +444,44 @@
</span><span class="cx">
</span><span class="cx"> enum BoundarySearchContextAvailability { DontHaveMoreContext, MayHaveMoreContext };
</span><span class="cx">
</span><del>-typedef unsigned (*BoundarySearchFunction)(const UChar*, unsigned length, unsigned offset, BoundarySearchContextAvailability, bool& needMoreContext);
</del><ins>+typedef unsigned (*BoundarySearchFunction)(StringView, unsigned offset, BoundarySearchContextAvailability, bool& needMoreContext);
</ins><span class="cx">
</span><ins>+static void prepend(Vector<UChar, 1024>& buffer, StringView string)
+{
+ unsigned oldSize = buffer.size();
+ unsigned length = string.length();
+ buffer.grow(oldSize + length);
+ memmove(buffer.data() + length, buffer.data(), oldSize * sizeof(UChar));
+ for (unsigned i = 0; i < length; ++i)
+ buffer[i] = string[i];
+}
+
+static void prependRepeatedCharacter(Vector<UChar, 1024>& buffer, UChar character, unsigned count)
+{
+ unsigned oldSize = buffer.size();
+ buffer.grow(oldSize + count);
+ memmove(buffer.data() + count, buffer.data(), oldSize * sizeof(UChar));
+ for (unsigned i = 0; i < count; ++i)
+ buffer[i] = character;
+}
+
+static void append(Vector<UChar, 1024>& buffer, StringView string)
+{
+ unsigned oldSize = buffer.size();
+ unsigned length = string.length();
+ buffer.grow(oldSize + length);
+ for (unsigned i = 0; i < length; ++i)
+ buffer[oldSize + i] = string[i];
+}
+
+static void appendRepeatedCharacter(Vector<UChar, 1024>& buffer, UChar character, unsigned count)
+{
+ unsigned oldSize = buffer.size();
+ buffer.grow(oldSize + count);
+ for (unsigned i = 0; i < count; ++i)
+ buffer[oldSize + i] = character;
+}
+
</ins><span class="cx"> static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearchFunction searchFunction)
</span><span class="cx"> {
</span><span class="cx"> Position pos = c.deepEquivalent();
</span><span class="lines">@@ -468,12 +504,11 @@
</span><span class="cx"> forwardsScanRange->setStart(end.deprecatedNode(), end.deprecatedEditingOffset(), ec);
</span><span class="cx"> TextIterator forwardsIterator(forwardsScanRange.get());
</span><span class="cx"> while (!forwardsIterator.atEnd()) {
</span><del>- const UChar* characters = forwardsIterator.characters();
- int length = forwardsIterator.length();
- int i = endOfFirstWordBoundaryContext(characters, length);
- string.append(characters, i);
</del><ins>+ StringView text = forwardsIterator.text();
+ unsigned i = endOfFirstWordBoundaryContext(text);
+ append(string, text.substring(0, i));
</ins><span class="cx"> suffixLength += i;
</span><del>- if (i < length)
</del><ins>+ if (i < text.length())
</ins><span class="cx"> break;
</span><span class="cx"> forwardsIterator.advance();
</span><span class="cx"> }
</span><span class="lines">@@ -493,26 +528,22 @@
</span><span class="cx"> bool inTextSecurityMode = it.node() && it.node()->renderer() && it.node()->renderer()->style().textSecurity() != TSNONE;
</span><span class="cx"> // iterate to get chunks until the searchFunction returns a non-zero value.
</span><span class="cx"> if (!inTextSecurityMode)
</span><del>- string.insert(0, it.characters(), it.length());
</del><ins>+ prepend(string, it.text());
</ins><span class="cx"> else {
</span><span class="cx"> // Treat bullets used in the text security mode as regular characters when looking for boundaries
</span><del>- String iteratorString(it.characters(), it.length());
-#if PLATFORM(IOS)
- iteratorString = iteratorString.impl()->fill('x');
-#else
- iteratorString.fill('x');
-#endif
- string.insert(0, iteratorString.deprecatedCharacters(), iteratorString.length());
</del><ins>+ prependRepeatedCharacter(string, 'x', it.length());
</ins><span class="cx"> }
</span><del>- next = searchFunction(string.data(), string.size(), string.size() - suffixLength, MayHaveMoreContext, needMoreContext);
- if (next > 1) // FIXME: This is a work around for https://webkit.org/b/115070. We need to provide more contexts in general case.
- break;
</del><ins>+ if (string.size() > suffixLength) {
+ next = searchFunction(StringView(string.data(), string.size()), string.size() - suffixLength, MayHaveMoreContext, needMoreContext);
+ if (next > 1) // FIXME: This is a work around for https://webkit.org/b/115070. We need to provide more contexts in general case.
+ break;
+ }
</ins><span class="cx"> it.advance();
</span><span class="cx"> }
</span><del>- if (needMoreContext) {
</del><ins>+ if (needMoreContext && string.size() > suffixLength) {
</ins><span class="cx"> // The last search returned the beginning of the buffer and asked for more context,
</span><span class="cx"> // but there is no earlier text. Force a search with what's available.
</span><del>- next = searchFunction(string.data(), string.size(), string.size() - suffixLength, DontHaveMoreContext, needMoreContext);
</del><ins>+ next = searchFunction(StringView(string.data(), string.size()), string.size() - suffixLength, DontHaveMoreContext, needMoreContext);
</ins><span class="cx"> ASSERT(!needMoreContext);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -550,11 +581,10 @@
</span><span class="cx"> backwardsScanRange->setEnd(start.deprecatedNode(), start.deprecatedEditingOffset(), IGNORE_EXCEPTION);
</span><span class="cx"> SimplifiedBackwardsTextIterator backwardsIterator(backwardsScanRange.get());
</span><span class="cx"> while (!backwardsIterator.atEnd()) {
</span><del>- const UChar* characters = backwardsIterator.characters();
- int length = backwardsIterator.length();
- int i = startOfLastWordBoundaryContext(characters, length);
- string.insert(0, characters + i, length - i);
- prefixLength += length - i;
</del><ins>+ StringView text = backwardsIterator.text();
+ int i = startOfLastWordBoundaryContext(text);
+ prepend(string, text.substring(i));
+ prefixLength += text.length() - i;
</ins><span class="cx"> if (i > 0)
</span><span class="cx"> break;
</span><span class="cx"> backwardsIterator.advance();
</span><span class="lines">@@ -571,39 +601,35 @@
</span><span class="cx"> // Keep asking the iterator for chunks until the search function
</span><span class="cx"> // returns an end value not equal to the length of the string passed to it.
</span><span class="cx"> if (!inTextSecurityMode)
</span><del>- string.append(it.characters(), it.length());
</del><ins>+ append(string, it.text());
</ins><span class="cx"> else {
</span><span class="cx"> // Treat bullets used in the text security mode as regular characters when looking for boundaries
</span><del>- String iteratorString(it.characters(), it.length());
-#if PLATFORM(IOS)
- iteratorString = iteratorString.impl()->fill('x');
-#else
- iteratorString.fill('x');
-#endif
- string.append(iteratorString.deprecatedCharacters(), iteratorString.length());
</del><ins>+ appendRepeatedCharacter(string, 'x', it.length());
</ins><span class="cx"> }
</span><del>- next = searchFunction(string.data(), string.size(), prefixLength, MayHaveMoreContext, needMoreContext);
- if (next != string.size())
- break;
</del><ins>+ if (string.size() > prefixLength) {
+ next = searchFunction(StringView(string.data(), string.size()), prefixLength, MayHaveMoreContext, needMoreContext);
+ if (next != string.size())
+ break;
+ }
</ins><span class="cx"> it.advance();
</span><span class="cx"> }
</span><del>- if (needMoreContext) {
</del><ins>+ if (needMoreContext && string.size() > prefixLength) {
</ins><span class="cx"> // The last search returned the end of the buffer and asked for more context,
</span><span class="cx"> // but there is no further text. Force a search with what's available.
</span><del>- next = searchFunction(string.data(), string.size(), prefixLength, DontHaveMoreContext, needMoreContext);
</del><ins>+ next = searchFunction(StringView(string.data(), string.size()), prefixLength, DontHaveMoreContext, needMoreContext);
</ins><span class="cx"> ASSERT(!needMoreContext);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (it.atEnd() && next == string.size()) {
</del><ins>+ if (it.atEnd() && next == string.size())
</ins><span class="cx"> pos = it.range()->startPosition();
</span><del>- } else if (next != prefixLength) {
</del><ins>+ else if (next > prefixLength) {
</ins><span class="cx"> // Use the character iterator to translate the next value into a DOM position.
</span><span class="cx"> CharacterIterator charIt(searchRange.get(), TextIteratorEmitsCharactersBetweenAllVisiblePositions);
</span><span class="cx"> charIt.advance(next - prefixLength - 1);
</span><span class="cx"> RefPtr<Range> characterRange = charIt.range();
</span><span class="cx"> pos = characterRange->endPosition();
</span><span class="cx">
</span><del>- if (*charIt.characters() == '\n') {
</del><ins>+ if (charIt.text()[0] == '\n') {
</ins><span class="cx"> // FIXME: workaround for collapsed range (where only start position is correct) emitted for some emitted newlines (see rdar://5192593)
</span><span class="cx"> VisiblePosition visPos = VisiblePosition(pos);
</span><span class="cx"> if (visPos == VisiblePosition(characterRange->startPosition())) {
</span><span class="lines">@@ -619,21 +645,21 @@
</span><span class="cx">
</span><span class="cx"> // ---------
</span><span class="cx">
</span><del>-static unsigned startWordBoundary(const UChar* characters, unsigned length, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreContext)
</del><ins>+static unsigned startWordBoundary(StringView text, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreContext)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(offset);
</span><del>- if (mayHaveMoreContext && !startOfLastWordBoundaryContext(characters, offset)) {
</del><ins>+ if (mayHaveMoreContext && !startOfLastWordBoundaryContext(text.substring(0, offset))) {
</ins><span class="cx"> needMoreContext = true;
</span><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx"> needMoreContext = false;
</span><span class="cx"> int start, end;
</span><del>- U16_BACK_1(characters, 0, offset);
- findWordBoundary(characters, length, offset, &start, &end);
</del><ins>+ U16_BACK_1(text, 0, offset);
+ findWordBoundary(text, offset, &start, &end);
</ins><span class="cx"> return start;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-VisiblePosition startOfWord(const VisiblePosition &c, EWordSide side)
</del><ins>+VisiblePosition startOfWord(const VisiblePosition& c, EWordSide side)
</ins><span class="cx"> {
</span><span class="cx"> // FIXME: This returns a null VP for c at the start of the document
</span><span class="cx"> // and side == LeftWordIfOnBoundary
</span><span class="lines">@@ -650,26 +676,20 @@
</span><span class="cx"> return previousBoundary(p, startWordBoundary);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static unsigned endWordBoundary(const UChar* characters, unsigned length, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreContext)
</del><ins>+static unsigned endWordBoundary(StringView text, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreContext)
</ins><span class="cx"> {
</span><del>- ASSERT(offset <= length);
- if (mayHaveMoreContext && endOfFirstWordBoundaryContext(characters + offset, length - offset) == static_cast<int>(length - offset)) {
</del><ins>+ ASSERT(offset <= text.length());
+ if (mayHaveMoreContext && endOfFirstWordBoundaryContext(text.substring(offset)) == text.length() - offset) {
</ins><span class="cx"> needMoreContext = true;
</span><del>- return length;
</del><ins>+ return text.length();
</ins><span class="cx"> }
</span><span class="cx"> needMoreContext = false;
</span><del>-#if PLATFORM(IOS)
- // FIXME: Bug 126830: [iOS] Implement WebCore::findEndWordBoundary()
- int start, end;
- findWordBoundary(characters, length, offset, &start, &end);
-#else
</del><span class="cx"> int end;
</span><del>- findEndWordBoundary(characters, length, offset, &end);
-#endif
</del><ins>+ findEndWordBoundary(text, offset, &end);
</ins><span class="cx"> return end;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-VisiblePosition endOfWord(const VisiblePosition &c, EWordSide side)
</del><ins>+VisiblePosition endOfWord(const VisiblePosition& c, EWordSide side)
</ins><span class="cx"> {
</span><span class="cx"> VisiblePosition p = c;
</span><span class="cx"> if (side == LeftWordIfOnBoundary) {
</span><span class="lines">@@ -685,36 +705,34 @@
</span><span class="cx"> return nextBoundary(p, endWordBoundary);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static unsigned previousWordPositionBoundary(const UChar* characters, unsigned length, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreContext)
</del><ins>+static unsigned previousWordPositionBoundary(StringView text, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreContext)
</ins><span class="cx"> {
</span><del>- if (mayHaveMoreContext && !startOfLastWordBoundaryContext(characters, offset)) {
</del><ins>+ if (mayHaveMoreContext && !startOfLastWordBoundaryContext(text.substring(0, offset))) {
</ins><span class="cx"> needMoreContext = true;
</span><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx"> needMoreContext = false;
</span><del>- return findNextWordFromIndex(characters, length, offset, false);
</del><ins>+ return findNextWordFromIndex(text, offset, false);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-VisiblePosition previousWordPosition(const VisiblePosition &c)
</del><ins>+VisiblePosition previousWordPosition(const VisiblePosition& position)
</ins><span class="cx"> {
</span><del>- VisiblePosition prev = previousBoundary(c, previousWordPositionBoundary);
- return c.honorEditingBoundaryAtOrBefore(prev);
</del><ins>+ return position.honorEditingBoundaryAtOrBefore(previousBoundary(position, previousWordPositionBoundary));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static unsigned nextWordPositionBoundary(const UChar* characters, unsigned length, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreContext)
</del><ins>+static unsigned nextWordPositionBoundary(StringView text, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreContext)
</ins><span class="cx"> {
</span><del>- if (mayHaveMoreContext && endOfFirstWordBoundaryContext(characters + offset, length - offset) == static_cast<int>(length - offset)) {
</del><ins>+ if (mayHaveMoreContext && endOfFirstWordBoundaryContext(text.substring(offset)) == text.length() - offset) {
</ins><span class="cx"> needMoreContext = true;
</span><del>- return length;
</del><ins>+ return text.length();
</ins><span class="cx"> }
</span><span class="cx"> needMoreContext = false;
</span><del>- return findNextWordFromIndex(characters, length, offset, true);
</del><ins>+ return findNextWordFromIndex(text, offset, true);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-VisiblePosition nextWordPosition(const VisiblePosition &c)
</del><ins>+VisiblePosition nextWordPosition(const VisiblePosition& position)
</ins><span class="cx"> {
</span><del>- VisiblePosition next = nextBoundary(c, nextWordPositionBoundary);
- return c.honorEditingBoundaryAtOrAfter(next);
</del><ins>+ return position.honorEditingBoundaryAtOrAfter(nextBoundary(position, nextWordPositionBoundary));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool isStartOfWord(const VisiblePosition& p)
</span><span class="lines">@@ -900,36 +918,35 @@
</span><span class="cx"> return endOfLine(currentPosition, UseLogicalOrdering);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool inSameLine(const VisiblePosition &a, const VisiblePosition &b)
</del><ins>+bool inSameLine(const VisiblePosition& a, const VisiblePosition& b)
</ins><span class="cx"> {
</span><span class="cx"> return a.isNotNull() && startOfLine(a) == startOfLine(b);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool isStartOfLine(const VisiblePosition &p)
</del><ins>+bool isStartOfLine(const VisiblePosition& p)
</ins><span class="cx"> {
</span><span class="cx"> return p.isNotNull() && p == startOfLine(p);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool isEndOfLine(const VisiblePosition &p)
</del><ins>+bool isEndOfLine(const VisiblePosition& p)
</ins><span class="cx"> {
</span><span class="cx"> return p.isNotNull() && p == endOfLine(p);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static inline IntPoint absoluteLineDirectionPointToLocalPointInBlock(RootInlineBox* root, int lineDirectionPoint)
</del><ins>+static inline IntPoint absoluteLineDirectionPointToLocalPointInBlock(RootInlineBox& root, int lineDirectionPoint)
</ins><span class="cx"> {
</span><del>- ASSERT(root);
- RenderBlockFlow& containingBlock = root->blockFlow();
</del><ins>+ RenderBlockFlow& containingBlock = root.blockFlow();
</ins><span class="cx"> FloatPoint absoluteBlockPoint = containingBlock.localToAbsolute(FloatPoint());
</span><span class="cx"> if (containingBlock.hasOverflowClip())
</span><span class="cx"> absoluteBlockPoint -= containingBlock.scrolledContentOffset();
</span><span class="cx">
</span><span class="cx"> if (containingBlock.isHorizontalWritingMode())
</span><del>- return IntPoint(lineDirectionPoint - absoluteBlockPoint.x(), root->blockDirectionPointInLine());
</del><ins>+ return IntPoint(lineDirectionPoint - absoluteBlockPoint.x(), root.blockDirectionPointInLine());
</ins><span class="cx">
</span><del>- return IntPoint(root->blockDirectionPointInLine(), lineDirectionPoint - absoluteBlockPoint.y());
</del><ins>+ return IntPoint(root.blockDirectionPointInLine(), lineDirectionPoint - absoluteBlockPoint.y());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, int lineDirectionPoint, EditableType editableType)
</del><ins>+VisiblePosition previousLinePosition(const VisiblePosition& visiblePosition, int lineDirectionPoint, EditableType editableType)
</ins><span class="cx"> {
</span><span class="cx"> Position p = visiblePosition.deepEquivalent();
</span><span class="cx"> Node* node = p.deprecatedNode();
</span><span class="lines">@@ -967,7 +984,7 @@
</span><span class="cx">
</span><span class="cx"> if (root) {
</span><span class="cx"> // FIXME: Can be wrong for multi-column layout and with transforms.
</span><del>- IntPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(root, lineDirectionPoint);
</del><ins>+ IntPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(*root, lineDirectionPoint);
</ins><span class="cx"> RenderObject& renderer = root->closestLeafChildForPoint(pointInLine, isEditablePosition(p))->renderer();
</span><span class="cx"> Node* node = renderer.node();
</span><span class="cx"> if (node && editingIgnoresContent(node))
</span><span class="lines">@@ -984,7 +1001,7 @@
</span><span class="cx"> return VisiblePosition(firstPositionInNode(rootElement), DOWNSTREAM);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, int lineDirectionPoint, EditableType editableType)
</del><ins>+VisiblePosition nextLinePosition(const VisiblePosition& visiblePosition, int lineDirectionPoint, EditableType editableType)
</ins><span class="cx"> {
</span><span class="cx"> Position p = visiblePosition.deepEquivalent();
</span><span class="cx"> Node* node = p.deprecatedNode();
</span><span class="lines">@@ -1025,7 +1042,7 @@
</span><span class="cx">
</span><span class="cx"> if (root) {
</span><span class="cx"> // FIXME: Can be wrong for multi-column layout and with transforms.
</span><del>- IntPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(root, lineDirectionPoint);
</del><ins>+ IntPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(*root, lineDirectionPoint);
</ins><span class="cx"> RenderObject& renderer = root->closestLeafChildForPoint(pointInLine, isEditablePosition(p))->renderer();
</span><span class="cx"> Node* node = renderer.node();
</span><span class="cx"> if (node && editingIgnoresContent(node))
</span><span class="lines">@@ -1044,56 +1061,50 @@
</span><span class="cx">
</span><span class="cx"> // ---------
</span><span class="cx">
</span><del>-static unsigned startSentenceBoundary(const UChar* characters, unsigned length, unsigned, BoundarySearchContextAvailability, bool&)
</del><ins>+static unsigned startSentenceBoundary(StringView text, unsigned, BoundarySearchContextAvailability, bool&)
</ins><span class="cx"> {
</span><del>- TextBreakIterator* iterator = sentenceBreakIterator(StringView(characters, length));
</del><span class="cx"> // FIXME: The following function can return -1; we don't handle that.
</span><del>- return textBreakPreceding(iterator, length);
</del><ins>+ return textBreakPreceding(sentenceBreakIterator(text), text.length());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-VisiblePosition startOfSentence(const VisiblePosition &c)
</del><ins>+VisiblePosition startOfSentence(const VisiblePosition& position)
</ins><span class="cx"> {
</span><del>- return previousBoundary(c, startSentenceBoundary);
</del><ins>+ return previousBoundary(position, startSentenceBoundary);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static unsigned endSentenceBoundary(const UChar* characters, unsigned length, unsigned, BoundarySearchContextAvailability, bool&)
</del><ins>+static unsigned endSentenceBoundary(StringView text, unsigned, BoundarySearchContextAvailability, bool&)
</ins><span class="cx"> {
</span><del>- TextBreakIterator* iterator = sentenceBreakIterator(StringView(characters, length));
- return textBreakNext(iterator);
</del><ins>+ return textBreakNext(sentenceBreakIterator(text));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-// FIXME: This includes the space after the punctuation that marks the end of the sentence.
-VisiblePosition endOfSentence(const VisiblePosition &c)
</del><ins>+VisiblePosition endOfSentence(const VisiblePosition& position)
</ins><span class="cx"> {
</span><del>- return nextBoundary(c, endSentenceBoundary);
</del><ins>+ // FIXME: This includes the space after the punctuation that marks the end of the sentence.
+ return nextBoundary(position, endSentenceBoundary);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static unsigned previousSentencePositionBoundary(const UChar* characters, unsigned length, unsigned, BoundarySearchContextAvailability, bool&)
</del><ins>+static unsigned previousSentencePositionBoundary(StringView text, unsigned, BoundarySearchContextAvailability, bool&)
</ins><span class="cx"> {
</span><span class="cx"> // FIXME: This is identical to startSentenceBoundary. I'm pretty sure that's not right.
</span><del>- TextBreakIterator* iterator = sentenceBreakIterator(StringView(characters, length));
</del><span class="cx"> // FIXME: The following function can return -1; we don't handle that.
</span><del>- return textBreakPreceding(iterator, length);
</del><ins>+ return textBreakPreceding(sentenceBreakIterator(text), text.length());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-VisiblePosition previousSentencePosition(const VisiblePosition &c)
</del><ins>+VisiblePosition previousSentencePosition(const VisiblePosition& position)
</ins><span class="cx"> {
</span><del>- VisiblePosition prev = previousBoundary(c, previousSentencePositionBoundary);
- return c.honorEditingBoundaryAtOrBefore(prev);
</del><ins>+ return position.honorEditingBoundaryAtOrBefore(previousBoundary(position, previousSentencePositionBoundary));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static unsigned nextSentencePositionBoundary(const UChar* characters, unsigned length, unsigned, BoundarySearchContextAvailability, bool&)
</del><ins>+static unsigned nextSentencePositionBoundary(StringView text, unsigned, BoundarySearchContextAvailability, bool&)
</ins><span class="cx"> {
</span><del>- // FIXME: This is identical to endSentenceBoundary. This isn't right, it needs to
- // move to the equivlant position in the following sentence.
- TextBreakIterator* iterator = sentenceBreakIterator(StringView(characters, length));
- return textBreakFollowing(iterator, 0);
</del><ins>+ // FIXME: This is identical to endSentenceBoundary.
+ // That isn't right. This function needs to move to the equivalent position in the following sentence.
+ return textBreakFollowing(sentenceBreakIterator(text), 0);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-VisiblePosition nextSentencePosition(const VisiblePosition &c)
</del><ins>+VisiblePosition nextSentencePosition(const VisiblePosition& position)
</ins><span class="cx"> {
</span><del>- VisiblePosition next = nextBoundary(c, nextSentencePositionBoundary);
- return c.honorEditingBoundaryAtOrAfter(next);
</del><ins>+ return position.honorEditingBoundaryAtOrAfter(nextBoundary(position, nextSentencePositionBoundary));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossingRule boundaryCrossingRule)
</span><span class="lines">@@ -1175,7 +1186,7 @@
</span><span class="cx"> return VisiblePosition(Position(node, type), DOWNSTREAM);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-VisiblePosition endOfParagraph(const VisiblePosition &c, EditingBoundaryCrossingRule boundaryCrossingRule)
</del><ins>+VisiblePosition endOfParagraph(const VisiblePosition& c, EditingBoundaryCrossingRule boundaryCrossingRule)
</ins><span class="cx"> {
</span><span class="cx"> if (c.isNull())
</span><span class="cx"> return VisiblePosition();
</span><span class="lines">@@ -1265,17 +1276,17 @@
</span><span class="cx"> return afterParagraphEnd;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool inSameParagraph(const VisiblePosition &a, const VisiblePosition &b, EditingBoundaryCrossingRule boundaryCrossingRule)
</del><ins>+bool inSameParagraph(const VisiblePosition& a, const VisiblePosition& b, EditingBoundaryCrossingRule boundaryCrossingRule)
</ins><span class="cx"> {
</span><span class="cx"> return a.isNotNull() && startOfParagraph(a, boundaryCrossingRule) == startOfParagraph(b, boundaryCrossingRule);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool isStartOfParagraph(const VisiblePosition &pos, EditingBoundaryCrossingRule boundaryCrossingRule)
</del><ins>+bool isStartOfParagraph(const VisiblePosition& pos, EditingBoundaryCrossingRule boundaryCrossingRule)
</ins><span class="cx"> {
</span><span class="cx"> return pos.isNotNull() && pos == startOfParagraph(pos, boundaryCrossingRule);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool isEndOfParagraph(const VisiblePosition &pos, EditingBoundaryCrossingRule boundaryCrossingRule)
</del><ins>+bool isEndOfParagraph(const VisiblePosition& pos, EditingBoundaryCrossingRule boundaryCrossingRule)
</ins><span class="cx"> {
</span><span class="cx"> return pos.isNotNull() && pos == endOfParagraph(pos, boundaryCrossingRule);
</span><span class="cx"> }
</span><span class="lines">@@ -1324,17 +1335,17 @@
</span><span class="cx"> return lastPositionInNode(endBlock);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool inSameBlock(const VisiblePosition &a, const VisiblePosition &b)
</del><ins>+bool inSameBlock(const VisiblePosition& a, const VisiblePosition& b)
</ins><span class="cx"> {
</span><span class="cx"> return !a.isNull() && enclosingBlock(a.deepEquivalent().containerNode()) == enclosingBlock(b.deepEquivalent().containerNode());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool isStartOfBlock(const VisiblePosition &pos)
</del><ins>+bool isStartOfBlock(const VisiblePosition& pos)
</ins><span class="cx"> {
</span><span class="cx"> return pos.isNotNull() && pos == startOfBlock(pos, CanCrossEditingBoundary);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool isEndOfBlock(const VisiblePosition &pos)
</del><ins>+bool isEndOfBlock(const VisiblePosition& pos)
</ins><span class="cx"> {
</span><span class="cx"> return pos.isNotNull() && pos == endOfBlock(pos, CanCrossEditingBoundary);
</span><span class="cx"> }
</span><span class="lines">@@ -1350,7 +1361,7 @@
</span><span class="cx"> // The canonicalization of the position at (documentElement, 0) can turn the visible
</span><span class="cx"> // position to null, even when there's a valid candidate to be had, because the root HTML element
</span><span class="cx"> // is not content editable. So we construct directly from the valid candidate.
</span><del>- // FIXME: Merge this to Open Source. https://bugs.webkit.org/show_bug.cgi?id=56437
</del><ins>+ // FIXME: Do this for non-iOS platforms too. https://bugs.webkit.org/show_bug.cgi?id=56437
</ins><span class="cx"> Position firstCandidate = nextCandidate(createLegacyEditingPosition(node->document().documentElement(), 0));
</span><span class="cx"> if (firstCandidate.isNull())
</span><span class="cx"> return VisiblePosition();
</span><span class="lines">@@ -1360,7 +1371,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-VisiblePosition startOfDocument(const VisiblePosition &c)
</del><ins>+VisiblePosition startOfDocument(const VisiblePosition& c)
</ins><span class="cx"> {
</span><span class="cx"> return startOfDocument(c.deepEquivalent().deprecatedNode());
</span><span class="cx"> }
</span><span class="lines">@@ -1374,25 +1385,23 @@
</span><span class="cx"> // (As above, in startOfDocument.) The canonicalization can reject valid visible positions
</span><span class="cx"> // when descending from the root element, so we construct the visible position directly from a
</span><span class="cx"> // valid candidate.
</span><del>- // FIXME: Merge this to Open Source. https://bugs.webkit.org/show_bug.cgi?id=56437
-#endif
- Element* doc = node->document().documentElement();
-#if PLATFORM(IOS)
- Position lastPosition = createLegacyEditingPosition(node->document().documentElement(), doc->childNodeCount());
</del><ins>+ // FIXME: Do this for non-iOS platforms too. https://bugs.webkit.org/show_bug.cgi?id=56437
+ Position lastPosition = createLegacyEditingPosition(node->document().documentElement(), node->document().documentElement()->childNodeCount());
</ins><span class="cx"> Position lastCandidate = previousCandidate(lastPosition);
</span><span class="cx"> if (lastCandidate.isNull())
</span><span class="cx"> return VisiblePosition();
</span><span class="cx"> return VisiblePosition(lastCandidate);
</span><ins>+#else
+ return VisiblePosition(lastPositionInNode(node->document().documentElement()), DOWNSTREAM);
</ins><span class="cx"> #endif
</span><del>- return VisiblePosition(lastPositionInNode(doc), DOWNSTREAM);
</del><span class="cx"> }
</span><span class="cx">
</span><del>-VisiblePosition endOfDocument(const VisiblePosition &c)
</del><ins>+VisiblePosition endOfDocument(const VisiblePosition& c)
</ins><span class="cx"> {
</span><span class="cx"> return endOfDocument(c.deepEquivalent().deprecatedNode());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool inSameDocument(const VisiblePosition &a, const VisiblePosition &b)
</del><ins>+bool inSameDocument(const VisiblePosition& a, const VisiblePosition& b)
</ins><span class="cx"> {
</span><span class="cx"> Position ap = a.deepEquivalent();
</span><span class="cx"> Node* an = ap.deprecatedNode();
</span><span class="lines">@@ -1406,12 +1415,12 @@
</span><span class="cx"> return &an->document() == &bn->document();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool isStartOfDocument(const VisiblePosition &p)
</del><ins>+bool isStartOfDocument(const VisiblePosition& p)
</ins><span class="cx"> {
</span><span class="cx"> return p.isNotNull() && p.previous(CanCrossEditingBoundary).isNull();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool isEndOfDocument(const VisiblePosition &p)
</del><ins>+bool isEndOfDocument(const VisiblePosition& p)
</ins><span class="cx"> {
</span><span class="cx"> return p.isNotNull() && p.next(CanCrossEditingBoundary).isNull();
</span><span class="cx"> }
</span><span class="lines">@@ -1436,7 +1445,7 @@
</span><span class="cx"> return lastPositionInNode(highestRoot);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool isEndOfEditableOrNonEditableContent(const VisiblePosition &p)
</del><ins>+bool isEndOfEditableOrNonEditableContent(const VisiblePosition& p)
</ins><span class="cx"> {
</span><span class="cx"> return p.isNotNull() && p.next().isNull();
</span><span class="cx"> }
</span><span class="lines">@@ -1452,6 +1461,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><ins>+
</ins><span class="cx"> static bool directionIsDownstream(SelectionDirection direction)
</span><span class="cx"> {
</span><span class="cx"> if (direction == DirectionBackward)
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmarkupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/markup.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/markup.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/editing/markup.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -53,7 +53,6 @@
</span><span class="cx"> #include "Range.h"
</span><span class="cx"> #include "RenderBlock.h"
</span><span class="cx"> #include "StyleProperties.h"
</span><del>-#include "TextIterator.h"
</del><span class="cx"> #include "VisibleSelection.h"
</span><span class="cx"> #include "VisibleUnits.h"
</span><span class="cx"> #include "htmlediting.h"
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLElement.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLElement.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/html/HTMLElement.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -56,7 +56,6 @@
</span><span class="cx"> #include "StyleProperties.h"
</span><span class="cx"> #include "SubframeLoader.h"
</span><span class="cx"> #include "Text.h"
</span><del>-#include "TextIterator.h"
</del><span class="cx"> #include "XMLNames.h"
</span><span class="cx"> #include "markup.h"
</span><span class="cx"> #include <wtf/NeverDestroyed.h>
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLTextAreaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -47,7 +47,6 @@
</span><span class="cx"> #include "Text.h"
</span><span class="cx"> #include "TextBreakIterator.h"
</span><span class="cx"> #include "TextControlInnerElements.h"
</span><del>-#include "TextIterator.h"
</del><span class="cx"> #include "TextNodeTraversal.h"
</span><span class="cx"> #include <wtf/Ref.h>
</span><span class="cx"> #include <wtf/StdLibExtras.h>
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderEmptyClientsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/EmptyClients.h (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/EmptyClients.h        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/loader/EmptyClients.h        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -403,9 +403,9 @@
</span><span class="cx"> virtual bool shouldEraseMarkersAfterChangeSelection(TextCheckingType) const override { return true; }
</span><span class="cx"> virtual void ignoreWordInSpellDocument(const String&) override { }
</span><span class="cx"> virtual void learnWord(const String&) override { }
</span><del>- virtual void checkSpellingOfString(const UChar*, int, int*, int*) override { }
</del><ins>+ virtual void checkSpellingOfString(StringView, int*, int*) override { }
</ins><span class="cx"> virtual String getAutoCorrectSuggestionForMisspelledWord(const String&) override { return String(); }
</span><del>- virtual void checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*) override { }
</del><ins>+ virtual void checkGrammarOfString(StringView, Vector<GrammarDetail>&, int*, int*) override { }
</ins><span class="cx">
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><span class="cx"> virtual Vector<TextCheckingResult> checkTextOfParagraph(StringView, TextCheckingTypeMask) override { return Vector<TextCheckingResult>(); }
</span></span></pre></div>
<a id="trunkSourceWebCorepageFramecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Frame.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Frame.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/page/Frame.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -91,7 +91,6 @@
</span><span class="cx"> #include "ScrollingCoordinator.h"
</span><span class="cx"> #include "Settings.h"
</span><span class="cx"> #include "StyleProperties.h"
</span><del>-#include "TextIterator.h"
</del><span class="cx"> #include "TextNodeTraversal.h"
</span><span class="cx"> #include "TextResourceDecoder.h"
</span><span class="cx"> #include "UserContentController.h"
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacHTMLConvertermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/HTMLConverter.mm (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/HTMLConverter.mm        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/platform/mac/HTMLConverter.mm        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -2472,6 +2472,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if !PLATFORM(IOS)
</span><ins>+
</ins><span class="cx"> // This function uses TextIterator, which makes offsets in its result compatible with HTML editing.
</span><span class="cx"> + (NSAttributedString *)editingAttributedStringFromRange:(Range*)range
</span><span class="cx"> {
</span><span class="lines">@@ -2523,18 +2524,20 @@
</span><span class="cx"> else
</span><span class="cx"> [attrs.get() removeObjectForKey:NSBackgroundColorAttributeName];
</span><span class="cx">
</span><del>- RetainPtr<NSString> substring = adoptNS([[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(it.characters()) length:currentTextLength freeWhenDone:NO]);
- [string replaceCharactersInRange:NSMakeRange(stringLength, 0) withString:substring.get()];
</del><ins>+ [string replaceCharactersInRange:NSMakeRange(stringLength, 0) withString:it.text().createNSStringWithoutCopying().get()];
</ins><span class="cx"> [string setAttributes:attrs.get() range:NSMakeRange(stringLength, currentTextLength)];
</span><span class="cx"> stringLength += currentTextLength;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return [string autorelease];
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #endif
</span><ins>+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #if !PLATFORM(IOS)
</span><ins>+
</ins><span class="cx"> static NSFileWrapper *fileWrapperForURL(DocumentLoader *dataSource, NSURL *URL)
</span><span class="cx"> {
</span><span class="cx"> if ([URL isFileURL])
</span><span class="lines">@@ -2585,4 +2588,5 @@
</span><span class="cx">
</span><span class="cx"> return wrapper;
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextTextBoundariescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/TextBoundaries.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/TextBoundaries.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/platform/text/TextBoundaries.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -32,24 +32,26 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-int endOfFirstWordBoundaryContext(const UChar* characters, int length)
</del><ins>+unsigned endOfFirstWordBoundaryContext(StringView text)
</ins><span class="cx"> {
</span><del>- for (int i = 0; i < length; ) {
- int first = i;
</del><ins>+ unsigned length = text.length();
+ for (unsigned i = 0; i < length; ) {
+ unsigned first = i;
</ins><span class="cx"> UChar32 ch;
</span><del>- U16_NEXT(characters, i, length, ch);
</del><ins>+ U16_NEXT(text, i, length, ch);
</ins><span class="cx"> if (!requiresContextForWordBoundary(ch))
</span><span class="cx"> return first;
</span><span class="cx"> }
</span><span class="cx"> return length;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-int startOfLastWordBoundaryContext(const UChar* characters, int length)
</del><ins>+unsigned startOfLastWordBoundaryContext(StringView text)
</ins><span class="cx"> {
</span><del>- for (int i = length; i > 0; ) {
- int last = i;
</del><ins>+ unsigned length = text.length();
+ for (unsigned i = length; i > 0; ) {
+ unsigned last = i;
</ins><span class="cx"> UChar32 ch;
</span><del>- U16_PREV(characters, 0, i, ch);
</del><ins>+ U16_PREV(text, 0, i, ch);
</ins><span class="cx"> if (!requiresContextForWordBoundary(ch))
</span><span class="cx"> return last;
</span><span class="cx"> }
</span><span class="lines">@@ -58,26 +60,26 @@
</span><span class="cx">
</span><span class="cx"> #if !PLATFORM(COCOA)
</span><span class="cx">
</span><del>-int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward)
</del><ins>+int findNextWordFromIndex(StringView text, int position, bool forward)
</ins><span class="cx"> {
</span><del>- TextBreakIterator* it = wordBreakIterator(StringView(chars, len));
</del><ins>+ TextBreakIterator* it = wordBreakIterator(text);
</ins><span class="cx">
</span><span class="cx"> if (forward) {
</span><span class="cx"> position = textBreakFollowing(it, position);
</span><span class="cx"> while (position != TextBreakDone) {
</span><span class="cx"> // We stop searching when the character preceeding the break is alphanumeric.
</span><del>- if (position < len && u_isalnum(chars[position - 1]))
</del><ins>+ if (static_cast<unsigned>(position) < text.length() && u_isalnum(text[position - 1]))
</ins><span class="cx"> return position;
</span><span class="cx">
</span><span class="cx"> position = textBreakFollowing(it, position);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- return len;
</del><ins>+ return text.length();
</ins><span class="cx"> } else {
</span><span class="cx"> position = textBreakPreceding(it, position);
</span><span class="cx"> while (position != TextBreakDone) {
</span><span class="cx"> // We stop searching when the character following the break is alphanumeric.
</span><del>- if (position > 0 && u_isalnum(chars[position]))
</del><ins>+ if (position && u_isalnum(text[position]))
</ins><span class="cx"> return position;
</span><span class="cx">
</span><span class="cx"> position = textBreakPreceding(it, position);
</span><span class="lines">@@ -87,18 +89,18 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void findWordBoundary(const UChar* chars, int len, int position, int* start, int* end)
</del><ins>+void findWordBoundary(StringView text, int position, int* start, int* end)
</ins><span class="cx"> {
</span><del>- TextBreakIterator* it = wordBreakIterator(StringView(chars, len));
</del><ins>+ TextBreakIterator* it = wordBreakIterator(text);
</ins><span class="cx"> *end = textBreakFollowing(it, position);
</span><span class="cx"> if (*end < 0)
</span><span class="cx"> *end = textBreakLast(it);
</span><span class="cx"> *start = textBreakPrevious(it);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void findEndWordBoundary(const UChar* chars, int len, int position, int* end)
</del><ins>+void findEndWordBoundary(StringView text, int position, int* end)
</ins><span class="cx"> {
</span><del>- TextBreakIterator* it = wordBreakIterator(StringView(chars, len));
</del><ins>+ TextBreakIterator* it = wordBreakIterator(text);
</ins><span class="cx"> *end = textBreakFollowing(it, position);
</span><span class="cx"> if (*end < 0)
</span><span class="cx"> *end = textBreakLast(it);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextTextBoundariesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/TextBoundaries.h (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/TextBoundaries.h        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/platform/text/TextBoundaries.h        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #define TextBoundaries_h
</span><span class="cx">
</span><span class="cx"> #include <unicode/uchar.h>
</span><ins>+#include <wtf/Forward.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -41,12 +42,12 @@
</span><span class="cx"> return lineBreak == U_LB_COMPLEX_CONTEXT || lineBreak == WK_U_LB_CONDITIONAL_JAPANESE_STARTER || lineBreak == U_LB_IDEOGRAPHIC;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- int endOfFirstWordBoundaryContext(const UChar* characters, int length);
- int startOfLastWordBoundaryContext(const UChar* characters, int length);
</del><ins>+ unsigned endOfFirstWordBoundaryContext(StringView);
+ unsigned startOfLastWordBoundaryContext(StringView);
</ins><span class="cx">
</span><del>- void findWordBoundary(const UChar*, int len, int position, int* start, int* end);
- void findEndWordBoundary(const UChar*, int len, int position, int* end);
- int findNextWordFromIndex(const UChar*, int len, int position, bool forward);
</del><ins>+ void findWordBoundary(StringView, int position, int* start, int* end);
+ void findEndWordBoundary(StringView, int position, int* end);
+ int findNextWordFromIndex(StringView, int position, bool forward);
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextTextCheckerClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/TextCheckerClient.h (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/TextCheckerClient.h        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/platform/text/TextCheckerClient.h        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -44,9 +44,9 @@
</span><span class="cx"> virtual bool shouldEraseMarkersAfterChangeSelection(TextCheckingType) const = 0;
</span><span class="cx"> virtual void ignoreWordInSpellDocument(const String&) = 0;
</span><span class="cx"> virtual void learnWord(const String&) = 0;
</span><del>- virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength) = 0;
</del><ins>+ virtual void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) = 0;
</ins><span class="cx"> virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord) = 0;
</span><del>- virtual void checkGrammarOfString(const UChar*, int length, Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) = 0;
</del><ins>+ virtual void checkGrammarOfString(StringView, Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) = 0;
</ins><span class="cx">
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><span class="cx"> virtual Vector<TextCheckingResult> checkTextOfParagraph(StringView, TextCheckingTypeMask checkingTypes) = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextmacTextBoundariesmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/mac/TextBoundaries.mm (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/mac/TextBoundaries.mm        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/platform/text/mac/TextBoundaries.mm        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2004, 2006, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -26,7 +26,7 @@
</span><span class="cx"> #import "config.h"
</span><span class="cx"> #import "TextBoundaries.h"
</span><span class="cx">
</span><del>-#if PLATFORM(IOS)
</del><ins>+#import "TextBreakIterator.h"
</ins><span class="cx"> #import "TextBreakIteratorInternalICU.h"
</span><span class="cx"> #import <CoreFoundation/CFStringTokenizer.h>
</span><span class="cx"> #import <Foundation/Foundation.h>
</span><span class="lines">@@ -34,45 +34,33 @@
</span><span class="cx"> #import <unicode/uchar.h>
</span><span class="cx"> #import <unicode/ustring.h>
</span><span class="cx"> #import <unicode/utypes.h>
</span><del>-#import <wtf/unicode/CharacterNames.h>
</del><span class="cx"> #import <wtf/RetainPtr.h>
</span><del>-#endif
</del><ins>+#import <wtf/text/StringView.h>
+#import <wtf/unicode/CharacterNames.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-#if PLATFORM(IOS)
</del><ins>+#if !USE(APPKIT)
</ins><span class="cx">
</span><span class="cx"> static bool isSkipCharacter(UChar32 c)
</span><span class="cx"> {
</span><del>- return c == 0xA0 ||
- c == '\n' ||
- c == '.' ||
- c == ',' ||
- c == '!' ||
- c == '?' ||
- c == ';' ||
- c == ':' ||
- u_isspace(c);
</del><ins>+ return c == 0xA0 || c == '\n' || c == '.' || c == ',' || c == '!' || c == '?' || c == ';' || c == ':' || u_isspace(c);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static bool isWhitespaceCharacter(UChar32 c)
</span><span class="cx"> {
</span><del>- return c == 0xA0 ||
- c == '\n' ||
- u_isspace(c);
</del><ins>+ return c == 0xA0 || c == '\n' || u_isspace(c);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static bool isWordDelimitingCharacter(UChar32 c)
</span><span class="cx"> {
</span><del>- CFCharacterSetRef set = CFCharacterSetGetPredefined(kCFCharacterSetAlphaNumeric);
</del><span class="cx"> // Ampersand is an exception added to treat AT&T as a single word (see <rdar://problem/5022264>).
</span><del>- return !CFCharacterSetIsLongCharacterMember(set, c) && c != '&';
</del><ins>+ return !CFCharacterSetIsLongCharacterMember(CFCharacterSetGetPredefined(kCFCharacterSetAlphaNumeric), c) && c != '&';
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static bool isSymbolCharacter(UChar32 c)
</span><span class="cx"> {
</span><del>- CFCharacterSetRef set = CFCharacterSetGetPredefined(kCFCharacterSetSymbol);
- return CFCharacterSetIsLongCharacterMember(set, c);
</del><ins>+ return CFCharacterSetIsLongCharacterMember(CFCharacterSetGetPredefined(kCFCharacterSetSymbol), c);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static bool isAmbiguousBoundaryCharacter(UChar32 character)
</span><span class="lines">@@ -83,39 +71,36 @@
</span><span class="cx">
</span><span class="cx"> static CFStringTokenizerRef tokenizerForString(CFStringRef str)
</span><span class="cx"> {
</span><del>- static CFStringTokenizerRef tokenizer = nullptr;
</del><span class="cx"> static CFLocaleRef locale = nullptr;
</span><del>-
</del><span class="cx"> if (!locale) {
</span><span class="cx"> const char* temp = currentTextBreakLocaleID();
</span><del>- RetainPtr<CFStringRef> currentLocaleID = adoptCF(CFStringCreateWithBytesNoCopy(nullptr, reinterpret_cast<const UInt8*>(temp), strlen(temp), kCFStringEncodingASCII, false, kCFAllocatorNull));
- locale = CFLocaleCreate(nullptr, currentLocaleID.get());
</del><ins>+ RetainPtr<CFStringRef> currentLocaleID = adoptCF(CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(temp), strlen(temp), kCFStringEncodingASCII, false, kCFAllocatorNull));
+ locale = CFLocaleCreate(kCFAllocatorDefault, currentLocaleID.get());
</ins><span class="cx"> if (!locale)
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> CFRange entireRange = CFRangeMake(0, CFStringGetLength(str));
</span><span class="cx">
</span><ins>+ static CFStringTokenizerRef tokenizer = nullptr;
</ins><span class="cx"> if (!tokenizer)
</span><del>- tokenizer = CFStringTokenizerCreate(nullptr, str, entireRange, kCFStringTokenizerUnitWordBoundary, locale);
</del><ins>+ tokenizer = CFStringTokenizerCreate(kCFAllocatorDefault, str, entireRange, kCFStringTokenizerUnitWordBoundary, locale);
</ins><span class="cx"> else
</span><span class="cx"> CFStringTokenizerSetString(tokenizer, str, entireRange);
</span><span class="cx"> return tokenizer;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-
-// Simple case: a word is a stream of characters
-// delimited by a special set of word-delimiting characters.
-static void findSimpleWordBoundary(const UChar* chars, int len, int position, int* start, int* end)
</del><ins>+// Simple case: A word is a stream of characters delimited by a special set of word-delimiting characters.
+static void findSimpleWordBoundary(StringView text, int position, int* start, int* end)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(position >= 0);
</span><del>- ASSERT(position < len);
</del><ins>+ ASSERT(static_cast<unsigned>(position) < text.length());
</ins><span class="cx">
</span><del>- int startPos = position;
</del><ins>+ unsigned startPos = position;
</ins><span class="cx"> while (startPos > 0) {
</span><span class="cx"> int i = startPos;
</span><span class="cx"> UChar32 characterBeforeStartPos;
</span><del>- U16_PREV(chars, 0, i, characterBeforeStartPos);
</del><ins>+ U16_PREV(text, 0, i, characterBeforeStartPos);
</ins><span class="cx"> if (isWordDelimitingCharacter(characterBeforeStartPos)) {
</span><span class="cx"> ASSERT(i >= 0);
</span><span class="cx"> if (!i)
</span><span class="lines">@@ -125,40 +110,40 @@
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="cx"> UChar32 characterBeforeBeforeStartPos;
</span><del>- U16_PREV(chars, 0, i, characterBeforeBeforeStartPos);
</del><ins>+ U16_PREV(text, 0, i, characterBeforeBeforeStartPos);
</ins><span class="cx"> if (isWordDelimitingCharacter(characterBeforeBeforeStartPos))
</span><span class="cx"> break;
</span><span class="cx"> }
</span><del>- U16_BACK_1(chars, 0, startPos);
</del><ins>+ U16_BACK_1(text, 0, startPos);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- int endPos = position;
- while (endPos < len) {
</del><ins>+ unsigned endPos = position;
+ while (endPos < text.length()) {
</ins><span class="cx"> UChar32 character;
</span><del>- U16_GET(chars, 0, endPos, len, character);
</del><ins>+ U16_GET(text, 0, endPos, text.length(), character);
</ins><span class="cx"> if (isWordDelimitingCharacter(character)) {
</span><del>- int i = endPos;
- U16_FWD_1(chars, i, len);
- ASSERT(i <= len);
- if (i == len)
</del><ins>+ unsigned i = endPos;
+ U16_FWD_1(text, i, text.length());
+ ASSERT(i <= text.length());
+ if (i == text.length())
</ins><span class="cx"> break;
</span><span class="cx"> UChar32 characterAfterEndPos;
</span><del>- U16_NEXT(chars, i, len, characterAfterEndPos);
</del><ins>+ U16_NEXT(text, i, text.length(), characterAfterEndPos);
</ins><span class="cx"> if (!isAmbiguousBoundaryCharacter(character))
</span><span class="cx"> break;
</span><span class="cx"> if (isWordDelimitingCharacter(characterAfterEndPos))
</span><span class="cx"> break;
</span><span class="cx"> }
</span><del>- U16_FWD_1(chars, endPos, len);
</del><ins>+ U16_FWD_1(text, endPos, text.length());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // The text may consist of all delimiter characters (e.g. "++++++++" or a series of emoji), and returning an empty range
</span><span class="cx"> // makes no sense (and doesn't match findComplexWordBoundary() behavior).
</span><del>- if (startPos == endPos && endPos < len) {
</del><ins>+ if (startPos == endPos && endPos < text.length()) {
</ins><span class="cx"> UChar32 character;
</span><del>- U16_GET(chars, 0, endPos, len, character);
</del><ins>+ U16_GET(text, 0, endPos, text.length(), character);
</ins><span class="cx"> if (isSymbolCharacter(character))
</span><del>- U16_FWD_1(chars, endPos, len);
</del><ins>+ U16_FWD_1(text, endPos, text.length());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> *start = startPos;
</span><span class="lines">@@ -166,143 +151,115 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Complex case: use CFStringTokenizer to find word boundary.
</span><del>-static void findComplexWordBoundary(const UChar* chars, int len, int position, int* start, int* end)
</del><ins>+static void findComplexWordBoundary(StringView text, int position, int* start, int* end)
</ins><span class="cx"> {
</span><del>- CFStringRef charString = CFStringCreateWithCharactersNoCopy(NULL, chars, len, kCFAllocatorNull);
- ASSERT(charString);
-
- CFStringTokenizerRef tokenizer = tokenizerForString(charString);
- if (tokenizer) {
- CFStringTokenizerTokenType token = CFStringTokenizerGoToTokenAtIndex(tokenizer, position);
- CFRange result;
- if (token != kCFStringTokenizerTokenNone) {
- result = CFStringTokenizerGetCurrentTokenRange(tokenizer);
- } else {
- // if no token found: select entire block
- // NB: I never hit this section in all my testing...
- result.location = 0;
- result.length = len;
- }
-
- *start = result.location;
- *end = result.location + result.length;
- } else { // error creating tokenizer
- findSimpleWordBoundary(chars, len, position, start, end);
</del><ins>+ RetainPtr<CFStringRef> charString = text.createCFStringWithoutCopying();
+
+ CFStringTokenizerRef tokenizer = tokenizerForString(charString.get());
+ if (!tokenizer) {
+ // Error creating tokenizer, so just use simple function.
+ findSimpleWordBoundary(text, position, start, end);
+ return;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- CFRelease(charString);
</del><ins>+ CFStringTokenizerTokenType token = CFStringTokenizerGoToTokenAtIndex(tokenizer, position);
+ if (token == kCFStringTokenizerTokenNone) {
+ // No token found: select entire block.
+ // NB: I never hit this section in all my testing.
+ *start = 0;
+ *end = text.length();
+ return;
+ }
+
+ CFRange result = CFStringTokenizerGetCurrentTokenRange(tokenizer);
+ *start = result.location;
+ *end = result.location + result.length;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>-void findWordBoundary(const UChar* chars, int len, int position, int* start, int* end)
</del><ins>+void findWordBoundary(StringView text, int position, int* start, int* end)
</ins><span class="cx"> {
</span><del>-#if !PLATFORM(IOS)
- NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(chars)
- length:len freeWhenDone:NO];
- NSAttributedString* attr = [[NSAttributedString alloc] initWithString:string];
- NSRange range = [attr doubleClickAtIndex:(position >= len) ? len - 1 : position];
- [attr release];
- [string release];
</del><ins>+#if USE(APPKIT)
+ NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:text.createNSStringWithoutCopying().get()];
+ NSRange range = [attributedString doubleClickAtIndex:std::min<unsigned>(position, text.length() - 1)];
+ [attributedString release];
</ins><span class="cx"> *start = range.location;
</span><span class="cx"> *end = range.location + range.length;
</span><span class="cx"> #else
</span><del>- int pos = position;
- if ( position == len && position != 0)
- pos--;
-
</del><ins>+ unsigned pos = position;
+ if (pos == text.length() && pos)
+ --pos;
+
</ins><span class="cx"> // For complex text (Thai, Japanese, Chinese), visible_units will pass the text in as a
</span><span class="cx"> // single contiguous run of characters, providing as much context as is possible.
</span><span class="cx"> // We only need one character to determine if the text is complex.
</span><span class="cx"> UChar32 ch;
</span><del>- int i = pos;
- U16_NEXT(chars,i,len,ch);
</del><ins>+ unsigned i = pos;
+ U16_NEXT(text, i, text.length(), ch);
</ins><span class="cx"> bool isComplex = requiresContextForWordBoundary(ch);
</span><del>-
</del><ins>+
</ins><span class="cx"> // FIXME: This check improves our word boundary behavior, but doesn't actually go far enough.
</span><span class="cx"> // See <rdar://problem/8853951> Take complex word boundary finding path when necessary
</span><span class="cx"> if (!isComplex) {
</span><span class="cx"> // Check again for complex text, at the start of the run.
</span><span class="cx"> i = 0;
</span><del>- U16_NEXT(chars, i, len, ch);
</del><ins>+ U16_NEXT(text, i, text.length(), ch);
</ins><span class="cx"> isComplex = requiresContextForWordBoundary(ch);
</span><span class="cx"> }
</span><del>-
- if (isComplex) {
- findComplexWordBoundary(chars,len, position, start, end);
- } else {
- findSimpleWordBoundary(chars,len, position, start, end);
- }
</del><span class="cx">
</span><ins>+ if (isComplex)
+ findComplexWordBoundary(text, position, start, end);
+ else
+ findSimpleWordBoundary(text, position, start, end);
+
</ins><span class="cx"> #define LOG_WORD_BREAK 0
</span><span class="cx"> #if LOG_WORD_BREAK
</span><del>- CFStringRef uniString = CFStringCreateWithCharacters(NULL, chars, len);
- CFStringRef foundWord = CFStringCreateWithCharacters(NULL, (const UniChar *) chars + *start, *end - *start);
- NSLog(@"%s_BREAK '%@' (%d,%d) in '%@' (%p) at %d, length=%d", isComplex ? "COMPLEX" : "SIMPLE", foundWord, *start, *end, uniString, uniString, position, len);
- CFRelease(foundWord);
- CFRelease(uniString);
</del><ins>+ auto uniString = text.createCFStringWithoutCopying();
+ auto foundWord = text.substring(*start, *end - *start).createCFStringWithoutCopying();
+ NSLog(@"%s_BREAK '%@' (%d,%d) in '%@' (%p) at %d, length=%d", isComplex ? "COMPLEX" : "SIMPLE", foundWord.get(), *start, *end, uniString.get(), uniString.get(), position, text.length());
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void findEndWordBoundary(const UChar* chars, int len, int position, int* end)
</del><ins>+void findEndWordBoundary(StringView text, int position, int* end)
</ins><span class="cx"> {
</span><del>-#if !PLATFORM(IOS)
- NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(chars)
- length:len freeWhenDone:NO];
- NSAttributedString* attr = [[NSAttributedString alloc] initWithString:string];
- NSRange range = [attr doubleClickAtIndex:(position >= len) ? len - 1 : position];
- [attr release];
- [string release];
- *end = range.location + range.length;
-#else
- // FIXME: Bug 126830: [iOS] Implement WebCore::findEndWordBoundary()
- UNUSED_PARAM(chars);
- UNUSED_PARAM(len);
- UNUSED_PARAM(position);
- UNUSED_PARAM(end);
-#endif
</del><ins>+ int start;
+ findWordBoundary(text, position, &start, end);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward)
</del><ins>+int findNextWordFromIndex(StringView text, int position, bool forward)
</ins><span class="cx"> {
</span><del>-#if !PLATFORM(IOS)
- NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(chars)
- length:len freeWhenDone:NO];
- NSAttributedString* attr = [[NSAttributedString alloc] initWithString:string];
- int result = [attr nextWordFromIndex:position forward:forward];
- [attr release];
- [string release];
</del><ins>+#if USE(APPKIT)
+ NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:text.createNSStringWithoutCopying().get()];
+ int result = [attributedString nextWordFromIndex:position forward:forward];
+ [attributedString release];
</ins><span class="cx"> return result;
</span><span class="cx"> #else
</span><span class="cx"> // This very likely won't behave exactly like the non-iPhone version, but it works
</span><span class="cx"> // for the contexts in which it is used on iPhone, and in the future will be
</span><span class="cx"> // tuned to improve the iPhone-specific behavior for the keyboard and text editing.
</span><span class="cx"> int pos = position;
</span><del>- UErrorCode status = U_ZERO_ERROR;
- UBreakIterator *boundary = ubrk_open(UBRK_WORD, currentTextBreakLocaleID(), const_cast<unichar *>(reinterpret_cast<const unichar *>(chars)), len, &status);
-
- if (boundary && U_SUCCESS(status)) {
</del><ins>+ TextBreakIterator* boundary = wordBreakIterator(text);
+ if (boundary) {
</ins><span class="cx"> if (forward) {
</span><span class="cx"> do {
</span><del>- pos = ubrk_following(boundary, pos);
- if (pos == UBRK_DONE) {
- pos = len;
- }
- } while (pos < len && (pos == 0 || !isSkipCharacter(chars[pos-1])) && isSkipCharacter(chars[pos]));
</del><ins>+ pos = textBreakFollowing(boundary, pos);
+ if (pos == UBRK_DONE)
+ pos = text.length();
+ } while (static_cast<unsigned>(pos) < text.length() && (pos == 0 || !isSkipCharacter(text[pos - 1])) && isSkipCharacter(text[pos]));
</ins><span class="cx"> }
</span><span class="cx"> else {
</span><span class="cx"> do {
</span><del>- pos = ubrk_preceding(boundary, pos);
- if (pos == UBRK_DONE) {
</del><ins>+ pos = textBreakPreceding(boundary, pos);
+ if (pos == UBRK_DONE)
</ins><span class="cx"> pos = 0;
</span><del>- }
- } while (pos > 0 && isSkipCharacter(chars[pos]) && !isWhitespaceCharacter(chars[pos-1]));
</del><ins>+ } while (pos > 0 && isSkipCharacter(text[pos]) && !isWhitespaceCharacter(text[pos - 1]));
</ins><span class="cx"> }
</span><del>- ubrk_close(boundary);
</del><span class="cx"> }
</span><span class="cx"> return pos;
</span><del>-#endif // !PLATFORM(IOS)
</del><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTextControlcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTextControl.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> #include "ScrollbarTheme.h"
</span><span class="cx"> #include "StyleInheritedData.h"
</span><span class="cx"> #include "TextControlInnerElements.h"
</span><del>-#include "TextIterator.h"
</del><span class="cx"> #include "VisiblePosition.h"
</span><span class="cx"> #include <wtf/unicode/CharacterNames.h>
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKiteflChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/efl/ChangeLog (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/efl/ChangeLog        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/efl/ChangeLog        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-02-08 Darin Adler <darin@apple.com>
+
+ Change TextIterator to use StringView, preparing to wean it from deprecatedCharacters
+ https://bugs.webkit.org/show_bug.cgi?id=128233
+
+ Reviewed by Anders Carlsson.
+
+ * WebCoreSupport/EditorClientEfl.cpp:
+ (WebCore::EditorClientEfl::checkSpellingOfString): Use StringView.
+ (WebCore::EditorClientEfl::checkGrammarOfString): Ditto.
+ * WebCoreSupport/EditorClientEfl.h: Ditto.
+
</ins><span class="cx"> 2014-02-07 Gavin Barraclough <barraclough@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove isInitialState flag from Page::setViewState
</span></span></pre></div>
<a id="trunkSourceWebKiteflWebCoreSupportEditorClientEflcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/efl/WebCoreSupport/EditorClientEfl.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/efl/WebCoreSupport/EditorClientEfl.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/efl/WebCoreSupport/EditorClientEfl.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -409,7 +409,7 @@
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void EditorClientEfl::checkSpellingOfString(const UChar*, int, int*, int*)
</del><ins>+void EditorClientEfl::checkSpellingOfString(StringView, int*, int*)
</ins><span class="cx"> {
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="lines">@@ -420,7 +420,7 @@
</span><span class="cx"> return String();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void EditorClientEfl::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*)
</del><ins>+void EditorClientEfl::checkGrammarOfString(StringView, Vector<GrammarDetail>&, int*, int*)
</ins><span class="cx"> {
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKiteflWebCoreSupportEditorClientEflh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/efl/WebCoreSupport/EditorClientEfl.h (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/efl/WebCoreSupport/EditorClientEfl.h        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/efl/WebCoreSupport/EditorClientEfl.h        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -136,9 +136,9 @@
</span><span class="cx"> virtual bool shouldEraseMarkersAfterChangeSelection(TextCheckingType) const;
</span><span class="cx"> virtual void ignoreWordInSpellDocument(const String&);
</span><span class="cx"> virtual void learnWord(const String&);
</span><del>- virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength);
</del><ins>+ virtual void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength);
</ins><span class="cx"> virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord);
</span><del>- virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength);
</del><ins>+ virtual void checkGrammarOfString(StringView, WTF::Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength);
</ins><span class="cx"> virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&);
</span><span class="cx"> virtual void updateSpellingUIWithMisspelledWord(const String&);
</span><span class="cx"> virtual void showSpellingUI(bool show);
</span></span></pre></div>
<a id="trunkSourceWebKitgtkChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/gtk/ChangeLog (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/gtk/ChangeLog        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/gtk/ChangeLog        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-02-08 Darin Adler <darin@apple.com>
+
+ Change TextIterator to use StringView, preparing to wean it from deprecatedCharacters
+ https://bugs.webkit.org/show_bug.cgi?id=128233
+
+ Reviewed by Anders Carlsson.
+
+ * WebCoreSupport/TextCheckerClientGtk.cpp:
+ (WebKit::TextCheckerClientGtk::checkSpellingOfString): Use StringView.
+ (WebKit::TextCheckerClientGtk::checkGrammarOfString): Ditto.
+ * WebCoreSupport/TextCheckerClientGtk.h: Ditto.
+
</ins><span class="cx"> 2014-02-07 Gavin Barraclough <barraclough@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove isInitialState flag from Page::setViewState
</span></span></pre></div>
<a id="trunkSourceWebKitgtkWebCoreSupportTextCheckerClientGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/gtk/WebCoreSupport/TextCheckerClientGtk.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/gtk/WebCoreSupport/TextCheckerClientGtk.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/TextCheckerClientGtk.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include <glib.h>
</span><span class="cx"> #include <wtf/gobject/GOwnPtr.h>
</span><span class="cx"> #include <wtf/text/CString.h>
</span><ins>+#include <wtf/text/StringView.h>
</ins><span class="cx">
</span><span class="cx"> using namespace WebCore;
</span><span class="cx">
</span><span class="lines">@@ -59,10 +60,9 @@
</span><span class="cx"> webkit_spell_checker_learn_word(m_spellChecker.get(), text.utf8().data());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void TextCheckerClientGtk::checkSpellingOfString(const UChar* text, int length, int* misspellingLocation, int* misspellingLength)
</del><ins>+void TextCheckerClientGtk::checkSpellingOfString(StringView text, int* misspellingLocation, int* misspellingLength)
</ins><span class="cx"> {
</span><del>- String textAsString(text, length);
- webkit_spell_checker_check_spelling_of_string(m_spellChecker.get(), textAsString.utf8().data(), misspellingLocation, misspellingLength);
</del><ins>+ webkit_spell_checker_check_spelling_of_string(m_spellChecker.get(), text.toStringWithoutCopying().utf8().data(), misspellingLocation, misspellingLength);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> String TextCheckerClientGtk::getAutoCorrectSuggestionForMisspelledWord(const String& inputWord)
</span><span class="lines">@@ -70,7 +70,7 @@
</span><span class="cx"> return webkit_spell_checker_get_autocorrect_suggestions_for_misspelled_word(m_spellChecker.get(), inputWord.utf8().data());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void TextCheckerClientGtk::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*)
</del><ins>+void TextCheckerClientGtk::checkGrammarOfString(StringView, Vector<GrammarDetail>&, int*, int*)
</ins><span class="cx"> {
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitgtkWebCoreSupportTextCheckerClientGtkh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/gtk/WebCoreSupport/TextCheckerClientGtk.h (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/gtk/WebCoreSupport/TextCheckerClientGtk.h        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/TextCheckerClientGtk.h        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -42,14 +42,14 @@
</span><span class="cx"> public:
</span><span class="cx"> TextCheckerClientGtk(WebKitSpellChecker*);
</span><span class="cx"> ~TextCheckerClientGtk();
</span><del>- virtual bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const;
- virtual void ignoreWordInSpellDocument(const WTF::String&);
- virtual void learnWord(const WTF::String&);
- virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength);
- virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&);
- virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength);
- virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses);
- virtual void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>) { }
</del><ins>+ virtual bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const override;
+ virtual void ignoreWordInSpellDocument(const WTF::String&) override;
+ virtual void learnWord(const WTF::String&) override;
+ virtual void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) override;
+ virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&) override;
+ virtual void checkGrammarOfString(StringView, WTF::Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) override;
+ virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses) override;
+ virtual void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>) override { }
</ins><span class="cx">
</span><span class="cx"> void updateSpellCheckingLanguage(const char*);
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/mac/ChangeLog        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2014-02-08 Darin Adler <darin@apple.com>
+
+ Change TextIterator to use StringView, preparing to wean it from deprecatedCharacters
+ https://bugs.webkit.org/show_bug.cgi?id=128233
+
+ Reviewed by Anders Carlsson.
+
+ * WebCoreSupport/WebEditorClient.h: Made most data members private. Moved inlines
+ for iOS out of the class definition. Fixed formatting. Added missing virtual keyword.
+ Changed interfaces to use StringView.
+
+ * WebCoreSupport/WebEditorClient.mm:
+ (WebEditorClient::checkTextOfParagraph): Use the new StringView::createNSStringWithoutCopying
+ function instead of a similar function that was local in this file.
+ (WebEditorClient::ignoreWordInSpellDocument): Tweaked formatting.
+ (WebEditorClient::checkSpellingOfString): Changed to take a StringView.
+ (WebEditorClient::checkGrammarOfString): Ditto.
+
+ * WebView/WebTextIterator.mm:
+ (-[WebTextIterator currentTextPointer]): Call TextIterator::deprecatedTextIteratorCharacters.
+ (-[WebTextIterator currentText]): Convert a the text to an NSString with TextIterator::text
+ instead of with TextIterator::characters/length.
+
</ins><span class="cx"> 2014-02-07 Gavin Barraclough <barraclough@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove isInitialState flag from Page::setViewState
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
</span><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -40,22 +40,17 @@
</span><span class="cx"> public:
</span><span class="cx"> WebEditorClient(WebView *);
</span><span class="cx"> virtual ~WebEditorClient();
</span><ins>+
+ void didCheckSucceed(int sequence, NSArray *results);
+
+private:
</ins><span class="cx"> virtual void pageDestroyed() override;
</span><span class="cx">
</span><del>-#if !PLATFORM(IOS)
</del><span class="cx"> virtual bool isGrammarCheckingEnabled() override;
</span><span class="cx"> virtual void toggleGrammarChecking() override;
</span><span class="cx"> virtual bool isContinuousSpellCheckingEnabled() override;
</span><span class="cx"> virtual void toggleContinuousSpellChecking() override;
</span><span class="cx"> virtual int spellCheckerDocumentTag() override;
</span><del>-#else
- virtual bool isGrammarCheckingEnabled() override { return false; }
- virtual void toggleGrammarChecking() override { }
- // Note: isContinuousSpellCheckingEnabled() is implemented.
- virtual bool isContinuousSpellCheckingEnabled() override;
- virtual void toggleContinuousSpellChecking() override { }
- virtual int spellCheckerDocumentTag() override { return 0; }
-#endif
</del><span class="cx">
</span><span class="cx"> virtual bool smartInsertDeleteEnabled() override;
</span><span class="cx"> virtual bool isSelectTrailingWhitespaceEnabled() override;
</span><span class="lines">@@ -65,7 +60,7 @@
</span><span class="cx"> virtual bool shouldBeginEditing(WebCore::Range*) override;
</span><span class="cx"> virtual bool shouldEndEditing(WebCore::Range*) override;
</span><span class="cx"> virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction) override;
</span><del>- virtual bool shouldInsertText(const WTF::String&, WebCore::Range*, WebCore::EditorInsertAction) override;
</del><ins>+ virtual bool shouldInsertText(const String&, WebCore::Range*, WebCore::EditorInsertAction) override;
</ins><span class="cx"> virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting) override;
</span><span class="cx">
</span><span class="cx"> virtual bool shouldApplyStyle(WebCore::StyleProperties*, WebCore::Range*) override;
</span><span class="lines">@@ -78,11 +73,11 @@
</span><span class="cx"> virtual void didWriteSelectionToPasteboard() override;
</span><span class="cx"> virtual void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) override;
</span><span class="cx">
</span><del>- virtual NSString* userVisibleString(NSURL *) override;
</del><ins>+ virtual NSString *userVisibleString(NSURL *) override;
</ins><span class="cx"> virtual WebCore::DocumentFragment* documentFragmentFromAttributedString(NSAttributedString *, Vector< RefPtr<WebCore::ArchiveResource>>&) override;
</span><span class="cx"> virtual void setInsertionPasteboard(const String&) override;
</span><del>- virtual NSURL* canonicalizeURL(NSURL*) override;
- virtual NSURL* canonicalizeURLString(NSString*) override;
</del><ins>+ virtual NSURL *canonicalizeURL(NSURL *) override;
+ virtual NSURL *canonicalizeURLString(NSString *) override;
</ins><span class="cx">
</span><span class="cx"> #if USE(APPKIT)
</span><span class="cx"> virtual void uppercaseWord() override;
</span><span class="lines">@@ -110,7 +105,7 @@
</span><span class="cx"> virtual bool shouldShowDeleteInterface(WebCore::HTMLElement*) override;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- TextCheckerClient* textChecker() override { return this; }
</del><ins>+ virtual TextCheckerClient* textChecker() override { return this; }
</ins><span class="cx">
</span><span class="cx"> virtual void respondToChangedContents() override;
</span><span class="cx"> virtual void respondToChangedSelection(WebCore::Frame*) override;
</span><span class="lines">@@ -152,42 +147,24 @@
</span><span class="cx"> virtual int pasteboardChangeCount() override;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if !PLATFORM(IOS)
</del><span class="cx"> virtual bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const override;
</span><del>- virtual void ignoreWordInSpellDocument(const WTF::String&) override;
- virtual void learnWord(const WTF::String&) override;
- virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength) override;
- virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&) override;
- virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) override;
</del><ins>+ virtual void ignoreWordInSpellDocument(const String&) override;
+ virtual void learnWord(const String&) override;
+ virtual void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) override;
+ virtual String getAutoCorrectSuggestionForMisspelledWord(const String&) override;
+ virtual void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) override;
</ins><span class="cx"> virtual Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes) override;
</span><del>- virtual void updateSpellingUIWithGrammarString(const WTF::String&, const WebCore::GrammarDetail&) override;
- virtual void updateSpellingUIWithMisspelledWord(const WTF::String&) override;
</del><ins>+ virtual void updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&) override;
+ virtual void updateSpellingUIWithMisspelledWord(const String&) override;
</ins><span class="cx"> virtual void showSpellingUI(bool show) override;
</span><span class="cx"> virtual bool spellingUIIsShowing() override;
</span><del>- virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses) override;
-#else
- virtual bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const override { return true; }
- virtual void ignoreWordInSpellDocument(const WTF::String&) override { }
- virtual void learnWord(const WTF::String&) override { }
- virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength) override { }
- virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&) override { return ""; }
- virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) override { }
- virtual Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes) override;
- virtual void updateSpellingUIWithGrammarString(const WTF::String&, const WebCore::GrammarDetail&) override { }
- virtual void updateSpellingUIWithMisspelledWord(const WTF::String&) override { }
- virtual void showSpellingUI(bool show) override { }
- virtual bool spellingUIIsShowing() override { return false; }
- virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses) override { }
-#endif // PLATFORM(IOS)
</del><ins>+ virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses) override;
+
</ins><span class="cx"> virtual void willSetInputMethodState() override;
</span><span class="cx"> virtual void setInputMethodState(bool enabled) override;
</span><span class="cx"> virtual void requestCheckingOfString(PassRefPtr<WebCore::TextCheckingRequest>) override;
</span><span class="cx">
</span><del>- void didCheckSucceed(int sequence, NSArray* results);
-
-private:
</del><span class="cx"> void registerUndoOrRedoStep(PassRefPtr<WebCore::UndoStep>, bool isRedo);
</span><del>- WebEditorClient();
</del><span class="cx">
</span><span class="cx"> WebView *m_webView;
</span><span class="cx"> RetainPtr<WebEditorUndoTarget> m_undoTarget;
</span><span class="lines">@@ -199,3 +176,72 @@
</span><span class="cx"> bool m_hasDelayedContentChangeNotification;
</span><span class="cx"> #endif
</span><span class="cx"> };
</span><ins>+
+#if PLATFORM(IOS)
+
+inline bool WebEditorClient::isGrammarCheckingEnabled()
+{
+ return false;
+}
+
+inline void WebEditorClient::toggleGrammarChecking()
+{
+}
+
+inline void WebEditorClient::toggleContinuousSpellChecking()
+{
+}
+
+inline int WebEditorClient::spellCheckerDocumentTag()
+{
+ return 0;
+}
+
+inline bool WebEditorClient::shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const
+{
+ return true;
+}
+
+inline void WebEditorClient::ignoreWordInSpellDocument(const String&)
+{
+}
+
+inline void WebEditorClient::learnWord(const String&)
+{
+}
+
+inline void WebEditorClient::checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength)
+{
+}
+
+inline String WebEditorClient::getAutoCorrectSuggestionForMisspelledWord(const String&)
+{
+ return "";
+}
+
+inline void WebEditorClient::checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength)
+{
+}
+
+inline void WebEditorClient::updateSpellingUIWithGrammarString(const String&, const WebCore::GrammarDetail&)
+{
+}
+
+inline void WebEditorClient::updateSpellingUIWithMisspelledWord(const String&)
+{
+}
+
+inline void WebEditorClient::showSpellingUI(bool show)
+{
+}
+
+inline bool WebEditorClient::spellingUIIsShowing()
+{
+ return false;
+}
+
+inline void WebEditorClient::getGuessesForWord(const String&, const String&, Vector<String>&)
+{
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebEditorClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -797,15 +797,8 @@
</span><span class="cx"> CallFormDelegate(m_webView, @selector(textDidChangeInTextArea:inFrame:), textAreaElement, kit(element->document().frame()));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static RetainPtr<NSString> nsStringWithoutCopying(StringView stringView)
-{
- if (stringView.is8Bit())
- return adoptNS([[NSString alloc] initWithBytesNoCopy:const_cast<LChar*>(stringView.characters8()) length:stringView.length() encoding:NSISOLatin1StringEncoding freeWhenDone:NO]);
-
- return adoptNS([[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(stringView.characters16()) length:stringView.length() freeWhenDone:NO]);
-}
-
</del><span class="cx"> #if PLATFORM(IOS)
</span><ins>+
</ins><span class="cx"> void WebEditorClient::suppressSelectionNotifications()
</span><span class="cx"> {
</span><span class="cx"> m_selectionNotificationSuppressions++;
</span><span class="lines">@@ -889,8 +882,7 @@
</span><span class="cx">
</span><span class="cx"> Vector<TextCheckingResult> results;
</span><span class="cx">
</span><del>- auto textString = nsStringWithoutCopying(string);
- NSArray *incomingResults = [[m_webView _UIKitDelegateForwarder] checkSpellingOfString:textString.get()];
</del><ins>+ NSArray *incomingResults = [[m_webView _UIKitDelegateForwarder] checkSpellingOfString:string.createNSStringWithoutCopying().get()];
</ins><span class="cx"> for (NSValue *incomingResult in incomingResults) {
</span><span class="cx"> NSRange resultRange = [incomingResult rangeValue];
</span><span class="cx"> ASSERT(resultRange.location != NSNotFound && resultRange.length > 0);
</span><span class="lines">@@ -903,9 +895,11 @@
</span><span class="cx">
</span><span class="cx"> return results;
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx">
</span><span class="cx"> #if !PLATFORM(IOS)
</span><ins>+
</ins><span class="cx"> bool WebEditorClient::shouldEraseMarkersAfterChangeSelection(TextCheckingType type) const
</span><span class="cx"> {
</span><span class="cx"> // This prevents erasing spelling markers on OS X Lion or later to match AppKit on these Mac OS X versions.
</span><span class="lines">@@ -914,8 +908,7 @@
</span><span class="cx">
</span><span class="cx"> void WebEditorClient::ignoreWordInSpellDocument(const String& text)
</span><span class="cx"> {
</span><del>- [[NSSpellChecker sharedSpellChecker] ignoreWord:text
- inSpellDocumentWithTag:spellCheckerDocumentTag()];
</del><ins>+ [[NSSpellChecker sharedSpellChecker] ignoreWord:text inSpellDocumentWithTag:spellCheckerDocumentTag()];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebEditorClient::learnWord(const String& text)
</span><span class="lines">@@ -923,11 +916,10 @@
</span><span class="cx"> [[NSSpellChecker sharedSpellChecker] learnWord:text];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebEditorClient::checkSpellingOfString(const UChar* text, int length, int* misspellingLocation, int* misspellingLength)
</del><ins>+void WebEditorClient::checkSpellingOfString(StringView text, int* misspellingLocation, int* misspellingLength)
</ins><span class="cx"> {
</span><del>- NSString* textString = [[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(text) length:length freeWhenDone:NO];
- NSRange range = [[NSSpellChecker sharedSpellChecker] checkSpellingOfString:textString startingAt:0 language:nil wrap:NO inSpellDocumentWithTag:spellCheckerDocumentTag() wordCount:NULL];
- [textString release];
</del><ins>+ NSRange range = [[NSSpellChecker sharedSpellChecker] checkSpellingOfString:text.createNSStringWithoutCopying().get() startingAt:0 language:nil wrap:NO inSpellDocumentWithTag:spellCheckerDocumentTag() wordCount:NULL];
+
</ins><span class="cx"> if (misspellingLocation) {
</span><span class="cx"> // WebCore expects -1 to represent "not found"
</span><span class="cx"> if (range.location == NSNotFound)
</span><span class="lines">@@ -947,12 +939,10 @@
</span><span class="cx"> return String();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebEditorClient::checkGrammarOfString(const UChar* text, int length, Vector<GrammarDetail>& details, int* badGrammarLocation, int* badGrammarLength)
</del><ins>+void WebEditorClient::checkGrammarOfString(StringView text, Vector<GrammarDetail>& details, int* badGrammarLocation, int* badGrammarLength)
</ins><span class="cx"> {
</span><span class="cx"> NSArray *grammarDetails;
</span><del>- NSString* textString = [[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(text) length:length freeWhenDone:NO];
- NSRange range = [[NSSpellChecker sharedSpellChecker] checkGrammarOfString:textString startingAt:0 language:nil wrap:NO inSpellDocumentWithTag:spellCheckerDocumentTag() details:&grammarDetails];
- [textString release];
</del><ins>+ NSRange range = [[NSSpellChecker sharedSpellChecker] checkGrammarOfString:text.createNSStringWithoutCopying().get() startingAt:0 language:nil wrap:NO inSpellDocumentWithTag:spellCheckerDocumentTag() details:&grammarDetails];
</ins><span class="cx"> if (badGrammarLocation)
</span><span class="cx"> // WebCore expects -1 to represent "not found"
</span><span class="cx"> *badGrammarLocation = (range.location == NSNotFound) ? -1 : static_cast<int>(range.location);
</span><span class="lines">@@ -1057,11 +1047,7 @@
</span><span class="cx">
</span><span class="cx"> Vector<TextCheckingResult> WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes)
</span><span class="cx"> {
</span><del>- auto textString = nsStringWithoutCopying(string);
-
- NSArray *incomingResults = [[NSSpellChecker sharedSpellChecker] checkString:textString.get() range:NSMakeRange(0, [textString length]) types:(checkingTypes|NSTextCheckingTypeOrthography) options:nil inSpellDocumentWithTag:spellCheckerDocumentTag() orthography:NULL wordCount:NULL];
-
- return core(incomingResults, checkingTypes);
</del><ins>+ return core([[NSSpellChecker sharedSpellChecker] checkString:string.createNSStringWithoutCopying().get() range:NSMakeRange(0, string.length()) types:(checkingTypes | NSTextCheckingTypeOrthography) options:nil inSpellDocumentWithTag:spellCheckerDocumentTag() orthography:NULL wordCount:NULL], checkingTypes);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebEditorClient::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
</span><span class="lines">@@ -1116,6 +1102,7 @@
</span><span class="cx"> guesses.append(string);
</span><span class="cx"> }
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #endif // !PLATFORM(IOS)
</span><span class="cx">
</span><span class="cx"> void WebEditorClient::willSetInputMethodState()
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebTextIteratormm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebTextIterator.mm (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebTextIterator.mm        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/mac/WebView/WebTextIterator.mm        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -94,7 +94,7 @@
</span><span class="cx">
</span><span class="cx"> - (const unichar *)currentTextPointer
</span><span class="cx"> {
</span><del>- return _private->_textIterator->characters();
</del><ins>+ return _private->_textIterator->deprecatedTextIteratorCharacters();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (NSUInteger)currentTextLength
</span><span class="lines">@@ -113,7 +113,7 @@
</span><span class="cx">
</span><span class="cx"> - (NSString *)currentText
</span><span class="cx"> {
</span><del>- return [NSString stringWithCharacters:_private->_textIterator->characters() length:_private->_textIterator->length()];
</del><ins>+ return [[_private->_textIterator->text().createNSString().get() retain] autorelease];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKitwinChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/ChangeLog (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/ChangeLog        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/win/ChangeLog        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-02-08 Darin Adler <darin@apple.com>
+
+ Change TextIterator to use StringView, preparing to wean it from deprecatedCharacters
+ https://bugs.webkit.org/show_bug.cgi?id=128233
+
+ Reviewed by Anders Carlsson.
+
+ * WebCoreSupport/WebEditorClient.cpp:
+ (WebEditorClient::checkSpellingOfString): Use StringView.
+ (WebEditorClient::checkGrammarOfString): Ditto.
+ * WebCoreSupport/WebEditorClient.h: Ditto.
+
</ins><span class="cx"> 2014-02-06 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><span class="cx"> Web Inspector: Add Console support to JSContext Inspection
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebCoreSupportWebEditorClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -657,7 +657,7 @@
</span><span class="cx"> ed->learnWord(BString(word));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebEditorClient::checkSpellingOfString(const UChar* text, int length, int* misspellingLocation, int* misspellingLength)
</del><ins>+void WebEditorClient::checkSpellingOfString(StringView text, int* misspellingLocation, int* misspellingLength)
</ins><span class="cx"> {
</span><span class="cx"> *misspellingLocation = -1;
</span><span class="cx"> *misspellingLength = 0;
</span><span class="lines">@@ -667,7 +667,7 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> initViewSpecificSpelling(m_webView);
</span><del>- ed->checkSpellingOfString(m_webView, text, length, misspellingLocation, misspellingLength);
</del><ins>+ ed->checkSpellingOfString(m_webView, text.toStringWithoutCopying().deprecatedCharacters(), text.length(), misspellingLocation, misspellingLength);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> String WebEditorClient::getAutoCorrectSuggestionForMisspelledWord(const String& inputWord)
</span><span class="lines">@@ -677,7 +677,7 @@
</span><span class="cx"> return String();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebEditorClient::checkGrammarOfString(const UChar* text, int length, Vector<GrammarDetail>& details, int* badGrammarLocation, int* badGrammarLength)
</del><ins>+void WebEditorClient::checkGrammarOfString(StringView text, Vector<GrammarDetail>& details, int* badGrammarLocation, int* badGrammarLength)
</ins><span class="cx"> {
</span><span class="cx"> details.clear();
</span><span class="cx"> *badGrammarLocation = -1;
</span><span class="lines">@@ -689,7 +689,7 @@
</span><span class="cx">
</span><span class="cx"> initViewSpecificSpelling(m_webView);
</span><span class="cx"> COMPtr<IEnumWebGrammarDetails> enumDetailsObj;
</span><del>- if (FAILED(ed->checkGrammarOfString(m_webView, text, length, &enumDetailsObj, badGrammarLocation, badGrammarLength)))
</del><ins>+ if (FAILED(ed->checkGrammarOfString(m_webView, text.toStringWithoutCopying().deprecatedCharacters(), text.length(), &enumDetailsObj, badGrammarLocation, badGrammarLength)))
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> while (true) {
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.h (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.h        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.h        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -86,34 +86,34 @@
</span><span class="cx"> void undo();
</span><span class="cx"> void redo();
</span><span class="cx">
</span><del>- virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting);
- virtual void textFieldDidBeginEditing(WebCore::Element*);
- virtual void textFieldDidEndEditing(WebCore::Element*);
- virtual void textDidChangeInTextField(WebCore::Element*);
- virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*);
- virtual void textWillBeDeletedInTextField(WebCore::Element* input);
- virtual void textDidChangeInTextArea(WebCore::Element*);
</del><ins>+ virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting) override;
+ virtual void textFieldDidBeginEditing(WebCore::Element*) override;
+ virtual void textFieldDidEndEditing(WebCore::Element*) override;
+ virtual void textDidChangeInTextField(WebCore::Element*) override;
+ virtual bool doTextFieldCommandFromEvent(WebCore::Element*, WebCore::KeyboardEvent*) override;
+ virtual void textWillBeDeletedInTextField(WebCore::Element* input) override;
+ virtual void textDidChangeInTextArea(WebCore::Element*) override;
</ins><span class="cx">
</span><span class="cx"> void handleKeyboardEvent(WebCore::KeyboardEvent*);
</span><span class="cx"> void handleInputMethodKeydown(WebCore::KeyboardEvent*);
</span><span class="cx">
</span><del>- virtual bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const;
- virtual void ignoreWordInSpellDocument(const WTF::String&);
- virtual void learnWord(const WTF::String&);
- virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength);
- virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&);
- virtual void checkGrammarOfString(const UChar*, int length, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength);
- virtual void updateSpellingUIWithGrammarString(const WTF::String&, const WebCore::GrammarDetail& detail);
- virtual void updateSpellingUIWithMisspelledWord(const WTF::String&);
- virtual void showSpellingUI(bool show);
- virtual bool spellingUIIsShowing();
- virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses);
</del><ins>+ virtual bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const override;
+ virtual void ignoreWordInSpellDocument(const WTF::String&) override;
+ virtual void learnWord(const WTF::String&) override;
+ virtual void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) override;
+ virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&) override;
+ virtual void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) override;
+ virtual void updateSpellingUIWithGrammarString(const WTF::String&, const WebCore::GrammarDetail&) override;
+ virtual void updateSpellingUIWithMisspelledWord(const WTF::String&) override;
+ virtual void showSpellingUI(bool show) override;
+ virtual bool spellingUIIsShowing() override;
+ virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses) override;
</ins><span class="cx">
</span><del>- virtual void willSetInputMethodState();
- virtual void setInputMethodState(bool);
- virtual void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>) { }
</del><ins>+ virtual void willSetInputMethodState() override;
+ virtual void setInputMethodState(bool) override;
+ virtual void requestCheckingOfString(WTF::PassRefPtr<WebCore::TextCheckingRequest>) override { }
</ins><span class="cx">
</span><del>- virtual WebCore::TextCheckerClient* textChecker() { return this; }
</del><ins>+ virtual WebCore::TextCheckerClient* textChecker() override { return this; }
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> WebView* m_webView;
</span></span></pre></div>
<a id="trunkSourceWebKitwinceChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/wince/ChangeLog (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/wince/ChangeLog        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/wince/ChangeLog        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-02-08 Darin Adler <darin@apple.com>
+
+ Change TextIterator to use StringView, preparing to wean it from deprecatedCharacters
+ https://bugs.webkit.org/show_bug.cgi?id=128233
+
+ Reviewed by Anders Carlsson.
+
+ * WebCoreSupport/EditorClientWinCE.cpp:
+ (WebKit::EditorClientWinCE::checkSpellingOfString): Use StringView.
+ (WebKit::EditorClientWinCE::checkGrammarOfString): Ditto.
+ * WebCoreSupport/EditorClientWinCE.h: Ditto.
+
</ins><span class="cx"> 2014-02-06 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><span class="cx"> Web Inspector: Add Console support to JSContext Inspection
</span></span></pre></div>
<a id="trunkSourceWebKitwinceWebCoreSupportEditorClientWinCEcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/wince/WebCoreSupport/EditorClientWinCE.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/wince/WebCoreSupport/EditorClientWinCE.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/wince/WebCoreSupport/EditorClientWinCE.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -466,7 +466,7 @@
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void EditorClientWinCE::checkSpellingOfString(const UChar* text, int length, int* misspellingLocation, int* misspellingLength)
</del><ins>+void EditorClientWinCE::checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength)
</ins><span class="cx"> {
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="lines">@@ -478,7 +478,7 @@
</span><span class="cx"> return String();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void EditorClientWinCE::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*)
</del><ins>+void EditorClientWinCE::checkGrammarOfString(StringVIew, Vector<GrammarDetail>&, int*, int*)
</ins><span class="cx"> {
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitwinceWebCoreSupportEditorClientWinCEh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/wince/WebCoreSupport/EditorClientWinCE.h (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/wince/WebCoreSupport/EditorClientWinCE.h        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit/wince/WebCoreSupport/EditorClientWinCE.h        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -90,9 +90,9 @@
</span><span class="cx"> virtual bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const override;
</span><span class="cx"> virtual void ignoreWordInSpellDocument(const WTF::String&) override;
</span><span class="cx"> virtual void learnWord(const WTF::String&) override;
</span><del>- virtual void checkSpellingOfString(const UChar*, int, int*, int*) override;
</del><ins>+ virtual void checkSpellingOfString(StringView, int*, int*) override;
</ins><span class="cx"> virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&) override;
</span><del>- virtual void checkGrammarOfString(const UChar*, int, WTF::Vector<WebCore::GrammarDetail>&, int*, int*) override;
</del><ins>+ virtual void checkGrammarOfString(StringView, WTF::Vector<WebCore::GrammarDetail>&, int*, int*) override;
</ins><span class="cx"> virtual void updateSpellingUIWithGrammarString(const WTF::String&, const WebCore::GrammarDetail&) override;
</span><span class="cx"> virtual void updateSpellingUIWithMisspelledWord(const WTF::String&) override;
</span><span class="cx"> virtual void showSpellingUI(bool) override;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit2/ChangeLog        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-02-08 Darin Adler <darin@apple.com>
+
+ Change TextIterator to use StringView, preparing to wean it from deprecatedCharacters
+ https://bugs.webkit.org/show_bug.cgi?id=128233
+
+ Reviewed by Anders Carlsson.
+
+ * WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm:
+ (-[WKDOMTextIterator currentTextPointer]): Call TextIterator::deprecatedTextIteratorCharacters.
+
+ * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+ (WebKit::WebEditorClient::checkSpellingOfString): Use StringView.
+ (WebKit::WebEditorClient::checkGrammarOfString): Ditto.
+ * WebProcess/WebCoreSupport/WebEditorClient.h: Ditto.
+
</ins><span class="cx"> 2014-02-08 Piotr Grad <p.grad@samsung.com>
</span><span class="cx">
</span><span class="cx"> [GTK] Build break in WebKitWebViewBase.cpp::webkitWebViewBaseCreateWebPage
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPImacWKDOMTextIteratormm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx">
</span><span class="cx"> - (const unichar *)currentTextPointer
</span><span class="cx"> {
</span><del>- return _textIterator->characters();
</del><ins>+ return _textIterator->deprecatedTextIteratorCharacters();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (NSUInteger)currentTextLength
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -414,12 +414,11 @@
</span><span class="cx"> m_page->send(Messages::WebPageProxy::LearnWord(word));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebEditorClient::checkSpellingOfString(const UChar* text, int length, int* misspellingLocation, int* misspellingLength)
</del><ins>+void WebEditorClient::checkSpellingOfString(StringView text, int* misspellingLocation, int* misspellingLength)
</ins><span class="cx"> {
</span><span class="cx"> int32_t resultLocation = -1;
</span><span class="cx"> int32_t resultLength = 0;
</span><del>- // FIXME: It would be nice if we wouldn't have to copy the text here.
- m_page->sendSync(Messages::WebPageProxy::CheckSpellingOfString(String(text, length)),
</del><ins>+ m_page->sendSync(Messages::WebPageProxy::CheckSpellingOfString(text.toStringWithoutCopying()),
</ins><span class="cx"> Messages::WebPageProxy::CheckSpellingOfString::Reply(resultLocation, resultLength));
</span><span class="cx"> *misspellingLocation = resultLocation;
</span><span class="cx"> *misspellingLength = resultLength;
</span><span class="lines">@@ -431,12 +430,11 @@
</span><span class="cx"> return String();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebEditorClient::checkGrammarOfString(const UChar* text, int length, Vector<WebCore::GrammarDetail>& grammarDetails, int* badGrammarLocation, int* badGrammarLength)
</del><ins>+void WebEditorClient::checkGrammarOfString(StringView text, Vector<WebCore::GrammarDetail>& grammarDetails, int* badGrammarLocation, int* badGrammarLength)
</ins><span class="cx"> {
</span><span class="cx"> int32_t resultLocation = -1;
</span><span class="cx"> int32_t resultLength = 0;
</span><del>- // FIXME: It would be nice if we wouldn't have to copy the text here.
- m_page->sendSync(Messages::WebPageProxy::CheckGrammarOfString(String(text, length)),
</del><ins>+ m_page->sendSync(Messages::WebPageProxy::CheckGrammarOfString(text.toStringWithoutCopying()),
</ins><span class="cx"> Messages::WebPageProxy::CheckGrammarOfString::Reply(grammarDetails, resultLocation, resultLength));
</span><span class="cx"> *badGrammarLocation = resultLocation;
</span><span class="cx"> *badGrammarLength = resultLength;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h (163711 => 163712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2014-02-08 16:14:53 UTC (rev 163711)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2014-02-08 16:32:05 UTC (rev 163712)
</span><span class="lines">@@ -135,9 +135,9 @@
</span><span class="cx"> virtual bool shouldEraseMarkersAfterChangeSelection(WebCore::TextCheckingType) const override;
</span><span class="cx"> virtual void ignoreWordInSpellDocument(const String&) override;
</span><span class="cx"> virtual void learnWord(const String&) override;
</span><del>- virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength) override;
</del><ins>+ virtual void checkSpellingOfString(StringView, int* misspellingLocation, int* misspellingLength) override;
</ins><span class="cx"> virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord) override;
</span><del>- virtual void checkGrammarOfString(const UChar*, int length, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) override;
</del><ins>+ virtual void checkGrammarOfString(StringView, Vector<WebCore::GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) override;
</ins><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><span class="cx"> virtual Vector<WebCore::TextCheckingResult> checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes) override;
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>
</body>
</html>