<!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>[161518] 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/161518">161518</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2014-01-08 13:19:21 -0800 (Wed, 08 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add WTF::StringView and use it for grammar checking
https://bugs.webkit.org/show_bug.cgi?id=126644

Reviewed by Antti Koivisto.

Source/WebCore:

Use a StringView in TextCheckerClient::checkTextOfParagraph to avoid upconverting strings unnecessarily.

* editing/TextCheckingHelper.cpp:
(WebCore::checkTextOfParagraph):
Pass a StringView to TextCheckerClient::checkTextOfParagraph.

* loader/EmptyClients.h:
Update for TextCheckerClient changes.

* platform/text/TextCheckerClient.h:
Change TextCheckerClient::checkTextOfParagraph to take a StringView.

Source/WebKit/efl:

Update to match WebCore changes.

* WebCoreSupport/EditorClientEfl.h:
(WebCore::EditorClientEfl::checkTextOfParagraph):

Source/WebKit/mac:

* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::checkTextOfParagraph):
Update to match the new signature.

(nsStringWithoutCopying):
New function that creates an NSString that references StringView data
without copying the data. (If this function proves to be useful elsewhere, it could
potentially be added to StringView).

Source/WebKit2:

Use a StringView and remove a FIXME.

* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::checkTextOfParagraph):
* WebProcess/WebCoreSupport/WebEditorClient.h:

Source/WTF:

Add a new StringView class which is an immutable reference to either an 8-bit or a 16-bit string.

This makes it easier to pass substrings around without having to either copy string data
or upconvert and use UChar pointers.

The StringView class is very loosely based on the std::string_view class which is proposed for a future version of C++,
see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3609.html for more details.

* GNUmakefile.list.am:
* WTF.vcxproj/WTF.vcxproj:
* WTF.vcxproj/WTF.vcxproj.filters:
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/Forward.h:
* wtf/text/StringView.h: Added.
(WTF::StringView::StringView):
(WTF::StringView::empty):
(WTF::StringView::characters8):
(WTF::StringView::characters16):
(WTF::StringView::isEmpty):
(WTF::StringView::length):
(WTF::StringView::is8Bit):
(WTF::StringView::substring):
(WTF::StringView::toString):
(WTF::StringView::toStringWithoutCopying):
(WTF::StringView::encodedCharacters):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFGNUmakefilelistam">trunk/Source/WTF/GNUmakefile.list.am</a></li>
<li><a href="#trunkSourceWTFWTFvcxprojWTFvcxproj">trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj</a></li>
<li><a href="#trunkSourceWTFWTFvcxprojWTFvcxprojfilters">trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWTFwtfCMakeListstxt">trunk/Source/WTF/wtf/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWTFwtfForwardh">trunk/Source/WTF/wtf/Forward.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingTextCheckingHelpercpp">trunk/Source/WebCore/editing/TextCheckingHelper.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderEmptyClientsh">trunk/Source/WebCore/loader/EmptyClients.h</a></li>
<li><a href="#trunkSourceWebCoreplatformtextTextCheckerClienth">trunk/Source/WebCore/platform/text/TextCheckerClient.h</a></li>
<li><a href="#trunkSourceWebKiteflChangeLog">trunk/Source/WebKit/efl/ChangeLog</a></li>
<li><a href="#trunkSourceWebKiteflWebCoreSupportEditorClientEflh">trunk/Source/WebKit/efl/WebCoreSupport/EditorClientEfl.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="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</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="#trunkSourceWTFwtftextStringViewh">trunk/Source/WTF/wtf/text/StringView.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WTF/ChangeLog        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2014-01-08  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Add WTF::StringView and use it for grammar checking
+        https://bugs.webkit.org/show_bug.cgi?id=126644
+
+        Reviewed by Antti Koivisto.
+
+        Add a new StringView class which is an immutable reference to either an 8-bit or a 16-bit string.
+
+        This makes it easier to pass substrings around without having to either copy string data
+        or upconvert and use UChar pointers.
+
+        The StringView class is very loosely based on the std::string_view class which is proposed for a future version of C++,
+        see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3609.html for more details.
+
+        * GNUmakefile.list.am:
+        * WTF.vcxproj/WTF.vcxproj:
+        * WTF.vcxproj/WTF.vcxproj.filters:
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/Forward.h:
+        * wtf/text/StringView.h: Added.
+        (WTF::StringView::StringView):
+        (WTF::StringView::empty):
+        (WTF::StringView::characters8):
+        (WTF::StringView::characters16):
+        (WTF::StringView::isEmpty):
+        (WTF::StringView::length):
+        (WTF::StringView::is8Bit):
+        (WTF::StringView::substring):
+        (WTF::StringView::toString):
+        (WTF::StringView::toStringWithoutCopying):
+        (WTF::StringView::encodedCharacters):
+
</ins><span class="cx"> 2014-01-07  David Farler  &lt;dfarler@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [ASAN] Building with trunk clang corrupts sandbox profile with comment from Compiler.h
</span></span></pre></div>
<a id="trunkSourceWTFGNUmakefilelistam"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/GNUmakefile.list.am (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/GNUmakefile.list.am        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WTF/GNUmakefile.list.am        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -157,9 +157,9 @@
</span><span class="cx">     Source/WTF/wtf/StreamBuffer.h \
</span><span class="cx">     Source/WTF/wtf/StringExtras.h \
</span><span class="cx">     Source/WTF/wtf/StringHashDumpContext.h \
</span><ins>+    Source/WTF/wtf/StringHasher.h \
</ins><span class="cx">     Source/WTF/wtf/StringPrintStream.cpp \
</span><span class="cx">     Source/WTF/wtf/StringPrintStream.h \
</span><del>-    Source/WTF/wtf/StringHasher.h \
</del><span class="cx">     Source/WTF/wtf/TCPackedCache.h \
</span><span class="cx">     Source/WTF/wtf/TCPageMap.h \
</span><span class="cx">     Source/WTF/wtf/TCSpinLock.h \
</span><span class="lines">@@ -241,6 +241,7 @@
</span><span class="cx">     Source/WTF/wtf/text/StringImpl.h \
</span><span class="cx">     Source/WTF/wtf/text/StringOperators.h \
</span><span class="cx">     Source/WTF/wtf/text/StringStatics.cpp \
</span><ins>+    Source/WTF/wtf/text/StringView.h \
</ins><span class="cx">     Source/WTF/wtf/text/TextPosition.h \
</span><span class="cx">     Source/WTF/wtf/text/WTFString.cpp \
</span><span class="cx">     Source/WTF/wtf/text/WTFString.h \
</span></span></pre></div>
<a id="trunkSourceWTFWTFvcxprojWTFvcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -291,6 +291,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\text\StringHash.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\text\StringImpl.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\text\StringOperators.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\wtf\text\StringView.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\text\WTFString.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\Threading.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\ThreadingPrimitives.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWTFWTFvcxprojWTFvcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -318,6 +318,9 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\text\StringOperators.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;text&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\wtf\text\StringView.h&quot;&gt;
+      &lt;Filter&gt;wtf&lt;/Filter&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\text\WTFString.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;text&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx">                 1A1D8B9E1731879800141DA4 /* FunctionDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1D8B9D1731879800141DA4 /* FunctionDispatcher.cpp */; };
</span><span class="cx">                 1A233C7D17DAA6E300A93ACF /* MallocPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A233C7C17DAA6E300A93ACF /* MallocPtr.h */; };
</span><span class="cx">                 1A6BB769162F300500DD16DB /* StreamBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6BB768162F300500DD16DB /* StreamBuffer.h */; };
</span><ins>+                1A6EB1E0187D0BD30030126F /* StringView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6EB1DF187D0BD30030126F /* StringView.h */; };
</ins><span class="cx">                 1FA47C8A152502DA00568D1B /* WebCoreThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1FA47C88152502DA00568D1B /* WebCoreThread.cpp */; };
</span><span class="cx">                 1FA47C8B152502DA00568D1B /* WebCoreThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FA47C89152502DA00568D1B /* WebCoreThread.h */; };
</span><span class="cx">                 26147B0A15DDCCDC00DDB907 /* IntegerToStringConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 26147B0815DDCCDC00DDB907 /* IntegerToStringConversion.h */; };
</span><span class="lines">@@ -322,6 +323,7 @@
</span><span class="cx">                 1A233C7C17DAA6E300A93ACF /* MallocPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MallocPtr.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1A3F6BE6174ADA2100B2EEA7 /* NeverDestroyed.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NeverDestroyed.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1A6BB768162F300500DD16DB /* StreamBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamBuffer.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                1A6EB1DF187D0BD30030126F /* StringView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringView.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 1FA47C88152502DA00568D1B /* WebCoreThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreThread.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1FA47C89152502DA00568D1B /* WebCoreThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreThread.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 26147B0815DDCCDC00DDB907 /* IntegerToStringConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntegerToStringConversion.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -905,6 +907,7 @@
</span><span class="cx">                                 A8A4732C151A825B004123FF /* TextPosition.h */,
</span><span class="cx">                                 A8A4732D151A825B004123FF /* WTFString.cpp */,
</span><span class="cx">                                 A8A4732E151A825B004123FF /* WTFString.h */,
</span><ins>+                                1A6EB1DF187D0BD30030126F /* StringView.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = text;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -1104,6 +1107,7 @@
</span><span class="cx">                                 A8A4742F151A825B004123FF /* TCPageMap.h in Headers */,
</span><span class="cx">                                 A8A47430151A825B004123FF /* TCSpinLock.h in Headers */,
</span><span class="cx">                                 A8A47432151A825B004123FF /* TCSystemAlloc.h in Headers */,
</span><ins>+                                1A6EB1E0187D0BD30030126F /* StringView.h in Headers */,
</ins><span class="cx">                                 A8A47433151A825B004123FF /* TemporaryChange.h in Headers */,
</span><span class="cx">                                 A8A47444151A825B004123FF /* TextPosition.h in Headers */,
</span><span class="cx">                                 A8A47447151A825B004123FF /* ThreadFunctionInvocation.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWTFwtfCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/CMakeLists.txt (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/CMakeLists.txt        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WTF/wtf/CMakeLists.txt        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -134,6 +134,7 @@
</span><span class="cx">     text/StringBuffer.h
</span><span class="cx">     text/StringHash.h
</span><span class="cx">     text/StringImpl.h
</span><ins>+    text/StringView.h
</ins><span class="cx">     text/WTFString.h
</span><span class="cx"> 
</span><span class="cx">     threads/BinarySemaphore.h
</span></span></pre></div>
<a id="trunkSourceWTFwtfForwardh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Forward.h (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Forward.h        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WTF/wtf/Forward.h        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -47,6 +47,7 @@
</span><span class="cx"> class String;
</span><span class="cx"> class StringBuilder;
</span><span class="cx"> class StringImpl;
</span><ins>+class StringView;
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -69,6 +70,7 @@
</span><span class="cx"> using WTF::StringBuffer;
</span><span class="cx"> using WTF::StringBuilder;
</span><span class="cx"> using WTF::StringImpl;
</span><ins>+using WTF::StringView;
</ins><span class="cx"> using WTF::Vector;
</span><span class="cx"> 
</span><span class="cx"> #endif // WTF_Forward_h
</span></span></pre></div>
<a id="trunkSourceWTFwtftextStringViewh"></a>
<div class="addfile"><h4>Added: trunk/Source/WTF/wtf/text/StringView.h (0 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/StringView.h                                (rev 0)
+++ trunk/Source/WTF/wtf/text/StringView.h        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -0,0 +1,148 @@
</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.
+ */
+
+#ifndef StringView_h
+#define StringView_h
+
+#include &lt;wtf/text/WTFString.h&gt;
+
+namespace WTF {
+
+// StringView is a non-owning reference to a string, similar to the proposed std::string_view.
+// Whether the string is 8-bit or 16-bit is encoded in the upper bit of the length member.
+// This means that strings longer than 2 Gigabytes can not be represented. If that turns out to be
+// a problem we can investigate alternative solutions.
+
+class StringView {
+public:
+    StringView(const LChar *characters, unsigned length)
+    {
+        initialize(characters, length);
+    }
+
+    StringView(const UChar *characters, unsigned length)
+    {
+        initialize(characters, length);
+    }
+
+    StringView(const String&amp; string)
+        : m_characters(nullptr)
+        , m_length(0)
+    {
+        if (!string.impl())
+            return;
+        
+        if (string.is8Bit())
+            initialize(string.characters8(), string.length());
+        else
+            initialize(string.characters16(), string.length());
+    }
+
+    static StringView empty()
+    {
+        return StringView(reinterpret_cast&lt;const LChar*&gt;(&quot;&quot;), 0);
+    }
+
+    const LChar* characters8() const
+    {
+        ASSERT(is8Bit());
+
+        return static_cast&lt;const LChar*&gt;(m_characters);
+    }
+
+    const UChar* characters16() const
+    {
+        ASSERT(!is8Bit());
+
+        return static_cast&lt;const UChar*&gt;(m_characters);
+    }
+
+    bool isEmpty() const { return !length(); }
+    unsigned length() const { return m_length &amp; ~is16BitStringFlag; }
+
+    bool is8Bit() const { return !(m_length &amp; is16BitStringFlag); }
+
+    StringView substring(unsigned start, unsigned length = std::numeric_limits&lt;unsigned&gt;::max()) const
+    {
+        if (start &gt;= this-&gt;length())
+            return empty();
+        unsigned maxLength = this-&gt;length() - start;
+
+        if (length &gt;= maxLength) {
+            if (!start)
+                return *this;
+            length = maxLength;
+        }
+
+        if (is8Bit())
+            return StringView(characters8() + start, length);
+
+        return StringView(characters16() + start, length);
+    }
+
+    String toString() const
+    {
+        if (is8Bit())
+            return String(characters8(), length());
+
+        return String(characters16(), length());
+    }
+
+    String toStringWithoutCopying() const
+    {
+        if (is8Bit())
+            return StringImpl::createWithoutCopying(characters8(), length());
+
+        return StringImpl::createWithoutCopying(characters16(), length());
+    }
+
+private:
+    void initialize(const LChar *characters, unsigned length)
+    {
+        ASSERT(!(length &amp; is16BitStringFlag));
+        
+        m_characters = characters;
+        m_length = length;
+    }
+
+    void initialize(const UChar *characters, unsigned length)
+    {
+        ASSERT(!(length &amp; is16BitStringFlag));
+        
+        m_characters = characters;
+        m_length = is16BitStringFlag | length;
+    }
+
+    static const unsigned is16BitStringFlag = 1u &lt;&lt; 31;
+
+    const void* m_characters;
+    unsigned m_length;
+};
+
+} // namespace WTF
+
+using WTF::StringView;
+
+#endif // StringView_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WebCore/ChangeLog        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2014-01-08  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Add WTF::StringView and use it for grammar checking
+        https://bugs.webkit.org/show_bug.cgi?id=126644
+
+        Reviewed by Antti Koivisto.
+
+        Use a StringView in TextCheckerClient::checkTextOfParagraph to avoid upconverting strings unnecessarily.
+
+        * editing/TextCheckingHelper.cpp:
+        (WebCore::checkTextOfParagraph):
+        Pass a StringView to TextCheckerClient::checkTextOfParagraph.
+        
+        * loader/EmptyClients.h:
+        Update for TextCheckerClient changes.
+
+        * platform/text/TextCheckerClient.h:
+        Change TextCheckerClient::checkTextOfParagraph to take a StringView.
+        
</ins><span class="cx"> 2014-01-08  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed Windows build fix attempt after r161481.
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTextCheckingHelpercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TextCheckingHelper.cpp (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TextCheckingHelper.cpp        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WebCore/editing/TextCheckingHelper.cpp        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include &quot;TextIterator.h&quot;
</span><span class="cx"> #include &quot;VisiblePosition.h&quot;
</span><span class="cx"> #include &quot;VisibleUnits.h&quot;
</span><ins>+#include &lt;wtf/text/StringView.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -639,7 +640,7 @@
</span><span class="cx">                           TextCheckingTypeMask checkingTypes, Vector&lt;TextCheckingResult&gt;&amp; results)
</span><span class="cx"> {
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-    client-&gt;checkTextOfParagraph(text, length, checkingTypes, results);
</del><ins>+    results = client-&gt;checkTextOfParagraph(StringView(text, length), checkingTypes);
</ins><span class="cx"> #else
</span><span class="cx">     Vector&lt;TextCheckingResult&gt; spellingResult;
</span><span class="cx">     if (checkingTypes &amp; TextCheckingTypeSpelling)
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderEmptyClientsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/EmptyClients.h (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/EmptyClients.h        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WebCore/loader/EmptyClients.h        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx"> #include &quot;InspectorClient.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;ResourceError.h&quot;
</span><ins>+#include &lt;wtf/text/StringView.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> /*
</span><span class="cx">  This file holds empty Client stubs for use by WebCore.
</span><span class="lines">@@ -425,7 +426,7 @@
</span><span class="cx">     virtual void checkGrammarOfString(const UChar*, int, Vector&lt;GrammarDetail&gt;&amp;, int*, int*) OVERRIDE { }
</span><span class="cx"> 
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-    virtual void checkTextOfParagraph(const UChar*, int, TextCheckingTypeMask, Vector&lt;TextCheckingResult&gt;&amp;) OVERRIDE { };
</del><ins>+    virtual Vector&lt;TextCheckingResult&gt; checkTextOfParagraph(StringView, TextCheckingTypeMask) OVERRIDE { return Vector&lt;TextCheckingResult&gt;(); }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     virtual void getGuessesForWord(const String&amp;, const String&amp;, Vector&lt;String&gt;&amp;) OVERRIDE { }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextTextCheckerClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/TextCheckerClient.h (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/TextCheckerClient.h        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WebCore/platform/text/TextCheckerClient.h        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx">     virtual void checkGrammarOfString(const UChar*, int length, Vector&lt;GrammarDetail&gt;&amp;, int* badGrammarLocation, int* badGrammarLength) = 0;
</span><span class="cx"> 
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-    virtual void checkTextOfParagraph(const UChar* text, int length, TextCheckingTypeMask checkingTypes, Vector&lt;TextCheckingResult&gt;&amp; results) = 0;
</del><ins>+    virtual Vector&lt;TextCheckingResult&gt; checkTextOfParagraph(StringView, TextCheckingTypeMask checkingTypes) = 0;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     // For spellcheckers that support multiple languages, it's often important to be able to identify the language in order to
</span></span></pre></div>
<a id="trunkSourceWebKiteflChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/efl/ChangeLog (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/efl/ChangeLog        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WebKit/efl/ChangeLog        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-01-08  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Add WTF::StringView and use it for grammar checking
+        https://bugs.webkit.org/show_bug.cgi?id=126644
+
+        Reviewed by Antti Koivisto.
+
+        Update to match WebCore changes.
+
+        * WebCoreSupport/EditorClientEfl.h:
+        (WebCore::EditorClientEfl::checkTextOfParagraph):
+
</ins><span class="cx"> 2014-01-05  Jinwoo Song  &lt;jinwoo7.song@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [EFL] Fix failing WebKit1 API test of ewk_view_setting_tiled_backing_store
</span></span></pre></div>
<a id="trunkSourceWebKiteflWebCoreSupportEditorClientEflh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/efl/WebCoreSupport/EditorClientEfl.h (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/efl/WebCoreSupport/EditorClientEfl.h        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WebKit/efl/WebCoreSupport/EditorClientEfl.h        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> #include &quot;TextCheckerClient.h&quot;
</span><span class="cx"> #include &lt;wtf/Deque.h&gt;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><ins>+#include &lt;wtf/text/StringView.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> struct Ewk_Should_Insert_Node_Event {
</span><span class="cx">     WebCore::Node* node;
</span><span class="lines">@@ -147,7 +148,7 @@
</span><span class="cx">     virtual void setInputMethodState(bool enabled);
</span><span class="cx">     virtual void requestCheckingOfString(WTF::PassRefPtr&lt;WebCore::TextCheckingRequest&gt;) { }
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-    virtual void checkTextOfParagraph(const UChar*, int, TextCheckingTypeMask, Vector&lt;TextCheckingResult&gt;&amp;) { }
</del><ins>+    virtual Vector&lt;TextCheckingResult&gt; checkTextOfParagraph(StringView, TextCheckingTypeMask checkingTypes) { return Vector&lt;TextCheckingResult&gt;(); }
</ins><span class="cx"> #endif
</span><span class="cx">     virtual TextCheckerClient* textChecker() { return this; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WebKit/mac/ChangeLog        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2014-01-08  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Add WTF::StringView and use it for grammar checking
+        https://bugs.webkit.org/show_bug.cgi?id=126644
+
+        Reviewed by Antti Koivisto.
+
+        * WebCoreSupport/WebEditorClient.h:
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::checkTextOfParagraph):
+        Update to match the new signature.
+
+        (nsStringWithoutCopying):
+        New function that creates an NSString that references StringView data
+        without copying the data. (If this function proves to be useful elsewhere, it could
+        potentially be added to StringView).
+
</ins><span class="cx"> 2014-01-02  Andy Estes  &lt;aestes@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS] Clean up some exported headers
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -159,7 +159,7 @@
</span><span class="cx">     virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength) OVERRIDE;
</span><span class="cx">     virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&amp;) OVERRIDE;
</span><span class="cx">     virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector&lt;WebCore::GrammarDetail&gt;&amp;, int* badGrammarLocation, int* badGrammarLength) OVERRIDE;
</span><del>-    virtual void checkTextOfParagraph(const UChar* text, int length, WebCore::TextCheckingTypeMask checkingTypes, WTF::Vector&lt;WebCore::TextCheckingResult&gt;&amp; results) OVERRIDE;
</del><ins>+    virtual Vector&lt;WebCore::TextCheckingResult&gt; checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes) OVERRIDE;
</ins><span class="cx">     virtual void updateSpellingUIWithGrammarString(const WTF::String&amp;, const WebCore::GrammarDetail&amp;) OVERRIDE;
</span><span class="cx">     virtual void updateSpellingUIWithMisspelledWord(const WTF::String&amp;) OVERRIDE;
</span><span class="cx">     virtual void showSpellingUI(bool show) OVERRIDE;
</span><span class="lines">@@ -173,7 +173,7 @@
</span><span class="cx">     virtual WTF::String getAutoCorrectSuggestionForMisspelledWord(const WTF::String&amp;) OVERRIDE { return &quot;&quot;; }
</span><span class="cx">     virtual void checkGrammarOfString(const UChar*, int length, WTF::Vector&lt;WebCore::GrammarDetail&gt;&amp;, int* badGrammarLocation, int* badGrammarLength) OVERRIDE { }
</span><span class="cx">     // Note: checkTextOfParagraph() is implemented. 
</span><del>-    virtual void checkTextOfParagraph(const UChar* text, int length, WebCore::TextCheckingTypeMask checkingTypes, WTF::Vector&lt;WebCore::TextCheckingResult&gt;&amp; results) OVERRIDE;
</del><ins>+    virtual Vector&lt;WebCore::TextCheckingResult&gt; checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes) OVERRIDE;
</ins><span class="cx">     virtual void updateSpellingUIWithGrammarString(const WTF::String&amp;, const WebCore::GrammarDetail&amp;) OVERRIDE { }
</span><span class="cx">     virtual void updateSpellingUIWithMisspelledWord(const WTF::String&amp;) OVERRIDE { }
</span><span class="cx">     virtual void showSpellingUI(bool show) OVERRIDE { }
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebEditorClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -71,6 +71,7 @@
</span><span class="cx"> #import &lt;wtf/MainThread.h&gt;
</span><span class="cx"> #import &lt;wtf/PassRefPtr.h&gt;
</span><span class="cx"> #import &lt;wtf/RunLoop.h&gt;
</span><ins>+#import &lt;wtf/text/StringView.h&gt;
</ins><span class="cx"> #import &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -874,12 +875,14 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, TextCheckingTypeMask checkingTypes, Vector&lt;TextCheckingResult&gt;&amp; results)
</del><ins>+void WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(checkingTypes &amp; NSTextCheckingTypeSpelling);
</span><del>-    NSString *textString = [[NSString alloc] initWithCharactersNoCopy:const_cast&lt;UChar*&gt;(text) length:length freeWhenDone:NO];
-    NSArray *incomingResults = [[m_webView _UIKitDelegateForwarder] checkSpellingOfString:textString];
-    [textString release];
</del><ins>+
+    NSArray *incomingResults = [[m_webView _UIKitDelegateForwarder] checkSpellingOfString:nsStringWithoutCopying(string).get()];
+
+    Vector&lt;TextCheckingResult&gt; results;
+
</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 &amp;&amp; resultRange.length &gt; 0);
</span><span class="lines">@@ -889,9 +892,19 @@
</span><span class="cx">         result.length = resultRange.length;
</span><span class="cx">         results.append(result);
</span><span class="cx">     }
</span><ins>+
+    return results;
</ins><span class="cx"> }
</span><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx"> 
</span><ins>+static RetainPtr&lt;NSString&gt; nsStringWithoutCopying(StringView stringView)
+{
+    if (stringView.is8Bit())
+        return adoptNS([[NSString alloc] initWithBytesNoCopy:const_cast&lt;LChar*&gt;(stringView.characters8()) length:stringView.length() encoding:NSISOLatin1StringEncoding freeWhenDone:NO]);
+
+    return adoptNS([[NSString alloc] initWithCharactersNoCopy:const_cast&lt;unichar*&gt;(stringView.characters16()) length:stringView.length() freeWhenDone:NO]);
+}
+
</ins><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> bool WebEditorClient::shouldEraseMarkersAfterChangeSelection(TextCheckingType type) const
</span><span class="cx"> {
</span><span class="lines">@@ -1042,12 +1055,13 @@
</span><span class="cx">     return results;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, TextCheckingTypeMask checkingTypes, Vector&lt;TextCheckingResult&gt;&amp; results)
</del><ins>+Vector&lt;TextCheckingResult&gt; WebEditorClient::checkTextOfParagraph(StringView string, TextCheckingTypeMask checkingTypes)
</ins><span class="cx"> {
</span><del>-    NSString *textString = [[NSString alloc] initWithCharactersNoCopy:const_cast&lt;UChar*&gt;(text) length:length freeWhenDone:NO];
-    NSArray *incomingResults = [[NSSpellChecker sharedSpellChecker] checkString:textString range:NSMakeRange(0, [textString length]) types:(checkingTypes|NSTextCheckingTypeOrthography) options:nil inSpellDocumentWithTag:spellCheckerDocumentTag() orthography:NULL wordCount:NULL];
-    [textString release];
-    results = core(incomingResults, checkingTypes);
</del><ins>+    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);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebEditorClient::updateSpellingUIWithGrammarString(const String&amp; badGrammarPhrase, const GrammarDetail&amp; grammarDetail)
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WebKit2/ChangeLog        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2014-01-08  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Add WTF::StringView and use it for grammar checking
+        https://bugs.webkit.org/show_bug.cgi?id=126644
+
+        Reviewed by Antti Koivisto.
+
+        Use a StringView and remove a FIXME.
+
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::checkTextOfParagraph):
+        * WebProcess/WebCoreSupport/WebEditorClient.h:
+
</ins><span class="cx"> 2014-01-08  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Automake] Scripts for generated build targets do not necessarily produce their output
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx"> #include &lt;WebCore/UndoStep.h&gt;
</span><span class="cx"> #include &lt;WebCore/UserTypingGestureIndicator.h&gt;
</span><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><ins>+#include &lt;wtf/text/StringView.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> using namespace HTMLNames;
</span><span class="lines">@@ -442,10 +443,13 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, WebCore::TextCheckingTypeMask checkingTypes, Vector&lt;TextCheckingResult&gt;&amp; results)
</del><ins>+Vector&lt;TextCheckingResult&gt; WebEditorClient::checkTextOfParagraph(StringView stringView, WebCore::TextCheckingTypeMask checkingTypes)
</ins><span class="cx"> {
</span><del>-    // FIXME: It would be nice if we wouldn't have to copy the text here.
-    m_page-&gt;sendSync(Messages::WebPageProxy::CheckTextOfParagraph(String(text, length), checkingTypes), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results));
</del><ins>+    Vector&lt;TextCheckingResult&gt; results;
+
+    m_page-&gt;sendSync(Messages::WebPageProxy::CheckTextOfParagraph(stringView.toStringWithoutCopying(), checkingTypes), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results));
+
+    return results;
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h (161517 => 161518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2014-01-08 21:03:43 UTC (rev 161517)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2014-01-08 21:19:21 UTC (rev 161518)
</span><span class="lines">@@ -139,7 +139,7 @@
</span><span class="cx">     virtual String getAutoCorrectSuggestionForMisspelledWord(const String&amp; misspelledWord) OVERRIDE;
</span><span class="cx">     virtual void checkGrammarOfString(const UChar*, int length, Vector&lt;WebCore::GrammarDetail&gt;&amp;, int* badGrammarLocation, int* badGrammarLength) OVERRIDE;
</span><span class="cx"> #if USE(UNIFIED_TEXT_CHECKING)
</span><del>-    virtual void checkTextOfParagraph(const UChar* text, int length, WebCore::TextCheckingTypeMask checkingTypes, Vector&lt;WebCore::TextCheckingResult&gt;&amp; results) OVERRIDE;
</del><ins>+    virtual Vector&lt;WebCore::TextCheckingResult&gt; checkTextOfParagraph(StringView, WebCore::TextCheckingTypeMask checkingTypes) OVERRIDE;
</ins><span class="cx"> #endif
</span><span class="cx">     virtual void updateSpellingUIWithGrammarString(const String&amp;, const WebCore::GrammarDetail&amp;) OVERRIDE;
</span><span class="cx">     virtual void updateSpellingUIWithMisspelledWord(const String&amp;) OVERRIDE;
</span></span></pre>
</div>
</div>

</body>
</html>