<!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>[166046] 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/166046">166046</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2014-03-21 00:12:07 -0700 (Fri, 21 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add a combined decodeAndFlush to TextResourceDecoder
https://bugs.webkit.org/show_bug.cgi?id=130560

Reviewed by Andreas Kling.

Source/WebCore:

* WebCore.exp.in: Added new symbol for decodeAndFlush. Also re-did
the geometry types #if so it would sort more logically.

* fileapi/FileReaderLoader.cpp:
(WebCore::FileReaderLoader::convertToText): Use decodeAndFlush.
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::cachedResourceContent): Ditto.
* inspector/NetworkResourcesData.cpp:
(WebCore::NetworkResourcesData::ResourceData::decodeDataToContent): Ditto.

* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::decodeAndFlush): Added.
* loader/TextResourceDecoder.h: Ditto.

* loader/appcache/ManifestParser.cpp:
(WebCore::parseManifest): Use decodeAndFlush.
* loader/cache/CachedCSSStyleSheet.cpp:
(WebCore::CachedCSSStyleSheet::sheetText): Ditto.
(WebCore::CachedCSSStyleSheet::finishLoading): Ditto.

* loader/cache/CachedFont.cpp:
(WebCore::CachedFont::ensureSVGFontData): Use decodeAndFlush. Also use nullptr.
(WebCore::CachedFont::getSVGFontById): Use descendantsOfType&lt;SVGFontElement&gt;
instead of using a NodeList. Much more efficient!

* loader/cache/CachedSVGDocument.cpp:
(WebCore::CachedSVGDocument::finishLoading): Use decodeAndFlush.
* loader/cache/CachedScript.cpp:
(WebCore::CachedScript::script): Ditto.
* loader/cache/CachedXSLStyleSheet.cpp:
(WebCore::CachedXSLStyleSheet::finishLoading): Ditto.
* page/Page.cpp:
(WebCore::Page::userStyleSheet): Ditto.

Source/WebKit/mac:

* WebView/WebView.mm:
(+[WebView _decodeData:]): Use decodeAndFlush.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCorefileapiFileReaderLoadercpp">trunk/Source/WebCore/fileapi/FileReaderLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorPageAgentcpp">trunk/Source/WebCore/inspector/InspectorPageAgent.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorNetworkResourcesDatacpp">trunk/Source/WebCore/inspector/NetworkResourcesData.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderTextResourceDecodercpp">trunk/Source/WebCore/loader/TextResourceDecoder.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderTextResourceDecoderh">trunk/Source/WebCore/loader/TextResourceDecoder.h</a></li>
<li><a href="#trunkSourceWebCoreloaderappcacheManifestParsercpp">trunk/Source/WebCore/loader/appcache/ManifestParser.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedCSSStyleSheetcpp">trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedFontcpp">trunk/Source/WebCore/loader/cache/CachedFont.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedSVGDocumentcpp">trunk/Source/WebCore/loader/cache/CachedSVGDocument.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedScriptcpp">trunk/Source/WebCore/loader/cache/CachedScript.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedXSLStyleSheetcpp">trunk/Source/WebCore/loader/cache/CachedXSLStyleSheet.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/ChangeLog        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2014-03-21  Darin Adler  &lt;darin@apple.com&gt;
+
+        Add a combined decodeAndFlush to TextResourceDecoder
+        https://bugs.webkit.org/show_bug.cgi?id=130560
+
+        Reviewed by Andreas Kling.
+
+        * WebCore.exp.in: Added new symbol for decodeAndFlush. Also re-did
+        the geometry types #if so it would sort more logically.
+
+        * fileapi/FileReaderLoader.cpp:
+        (WebCore::FileReaderLoader::convertToText): Use decodeAndFlush.
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::cachedResourceContent): Ditto.
+        * inspector/NetworkResourcesData.cpp:
+        (WebCore::NetworkResourcesData::ResourceData::decodeDataToContent): Ditto.
+
+        * loader/TextResourceDecoder.cpp:
+        (WebCore::TextResourceDecoder::decodeAndFlush): Added.
+        * loader/TextResourceDecoder.h: Ditto.
+
+        * loader/appcache/ManifestParser.cpp:
+        (WebCore::parseManifest): Use decodeAndFlush.
+        * loader/cache/CachedCSSStyleSheet.cpp:
+        (WebCore::CachedCSSStyleSheet::sheetText): Ditto.
+        (WebCore::CachedCSSStyleSheet::finishLoading): Ditto.
+
+        * loader/cache/CachedFont.cpp:
+        (WebCore::CachedFont::ensureSVGFontData): Use decodeAndFlush. Also use nullptr.
+        (WebCore::CachedFont::getSVGFontById): Use descendantsOfType&lt;SVGFontElement&gt;
+        instead of using a NodeList. Much more efficient!
+
+        * loader/cache/CachedSVGDocument.cpp:
+        (WebCore::CachedSVGDocument::finishLoading): Use decodeAndFlush.
+        * loader/cache/CachedScript.cpp:
+        (WebCore::CachedScript::script): Ditto.
+        * loader/cache/CachedXSLStyleSheet.cpp:
+        (WebCore::CachedXSLStyleSheet::finishLoading): Ditto.
+        * page/Page.cpp:
+        (WebCore::Page::userStyleSheet): Ditto.
+
</ins><span class="cx"> 2014-03-20  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove a couple of unused functions from CSSOMUtils
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -2017,11 +2017,6 @@
</span><span class="cx"> _wkSignalCFReadStreamError
</span><span class="cx"> _wkSignalCFReadStreamHasBytes
</span><span class="cx"> 
</span><del>-#if !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES) &amp;&amp; PLATFORM(MAC)
-__ZN7WebCore7IntSizeC1ERK7_NSSize
-__ZNK7WebCore7IntSizecv7_NSSizeEv
-#endif
-
</del><span class="cx"> #if !defined(NDEBUG)
</span><span class="cx"> __ZN7WebCore14SQLiteDatabase22disableThreadingChecksEv
</span><span class="cx"> __ZN7WebCore24NoEventDispatchAssertion7s_countE
</span><span class="lines">@@ -2146,6 +2141,7 @@
</span><span class="cx"> __ZN7WebCore17ScrollbarThemeMac24removeOverhangAreaShadowEP7CALayer
</span><span class="cx"> __ZN7WebCore17ScrollbarThemeMac27setUpOverhangAreaBackgroundEP7CALayerRKNS_5ColorE
</span><span class="cx"> __ZN7WebCore17ScrollbarThemeMac28removeOverhangAreaBackgroundEP7CALayer
</span><ins>+__ZN7WebCore19TextResourceDecoder14decodeAndFlushEPKcm
</ins><span class="cx"> __ZN7WebCore19applicationIsSafariEv
</span><span class="cx"> __ZN7WebCore20PlatformEventFactory24createPlatformMouseEventEP7NSEventP6NSView
</span><span class="cx"> __ZN7WebCore20PlatformEventFactory27createPlatformKeyboardEventEP7NSEvent
</span><span class="lines">@@ -2315,6 +2311,11 @@
</span><span class="cx"> _wkWindowSetScaledFrame
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC) &amp;&amp; !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
+__ZN7WebCore7IntSizeC1ERK7_NSSize
+__ZNK7WebCore7IntSizecv7_NSSizeEv
+#endif
+
</ins><span class="cx"> #if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 1080
</span><span class="cx"> __ZN7WebCore24TextAlternativeWithRangeC1EP18NSTextAlternatives8_NSRange
</span><span class="cx"> __ZN7WebCore27AlternativeTextUIController15addAlternativesERKN3WTF9RetainPtrI18NSTextAlternativesEE
</span></span></pre></div>
<a id="trunkSourceWebCorefileapiFileReaderLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/fileapi/FileReaderLoader.cpp (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/fileapi/FileReaderLoader.cpp        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/fileapi/FileReaderLoader.cpp        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -316,15 +316,12 @@
</span><span class="cx">     // requirement in order to be consistent with how WebKit decodes the web content: always has the BOM override the
</span><span class="cx">     // provided encoding.     
</span><span class="cx">     // FIXME: consider supporting incremental decoding to improve the perf.
</span><del>-    StringBuilder builder;
</del><span class="cx">     if (!m_decoder)
</span><span class="cx">         m_decoder = TextResourceDecoder::create(&quot;text/plain&quot;, m_encoding.isValid() ? m_encoding : UTF8Encoding());
</span><del>-    builder.append(m_decoder-&gt;decode(static_cast&lt;const char*&gt;(m_rawData-&gt;data()), m_bytesLoaded));
-
</del><span class="cx">     if (isCompleted())
</span><del>-        builder.append(m_decoder-&gt;flush());
-
-    m_stringResult = builder.toString();
</del><ins>+        m_stringResult = m_decoder-&gt;decodeAndFlush(static_cast&lt;const char*&gt;(m_rawData-&gt;data()), m_bytesLoaded);
+    else
+        m_stringResult = m_decoder-&gt;decode(static_cast&lt;const char*&gt;(m_rawData-&gt;data()), m_bytesLoaded);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FileReaderLoader::convertToDataURL()
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorPageAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -186,8 +186,7 @@
</span><span class="cx">             // We show content for raw resources only for certain mime types (text, html and xml). Otherwise decoder will be null.
</span><span class="cx">             if (!decoder)
</span><span class="cx">                 return false;
</span><del>-            String content = decoder-&gt;decode(buffer-&gt;data(), buffer-&gt;size());
-            *result = content + decoder-&gt;flush();
</del><ins>+            *result = decoder-&gt;decodeAndFlush(buffer-&gt;data(), buffer-&gt;size());
</ins><span class="cx">             return true;
</span><span class="cx">         }
</span><span class="cx">         default:
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorNetworkResourcesDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/NetworkResourcesData.cpp (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/NetworkResourcesData.cpp        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/inspector/NetworkResourcesData.cpp        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -135,8 +135,7 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!hasContent());
</span><span class="cx">     size_t dataLength = m_dataBuffer-&gt;size();
</span><del>-    m_content = m_decoder-&gt;decode(m_dataBuffer-&gt;data(), m_dataBuffer-&gt;size());
-    m_content.append(m_decoder-&gt;flush());
</del><ins>+    m_content = m_decoder-&gt;decodeAndFlush(m_dataBuffer-&gt;data(), m_dataBuffer-&gt;size());
</ins><span class="cx">     m_dataBuffer = nullptr;
</span><span class="cx">     return contentSizeInBytes(m_content) - dataLength;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderTextResourceDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/TextResourceDecoder.cpp (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/TextResourceDecoder.cpp        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/loader/TextResourceDecoder.cpp        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -663,4 +663,10 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String TextResourceDecoder::decodeAndFlush(const char* data, size_t length)
+{
+    String decoded = decode(data, length);
+    return decoded + flush();
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreloaderTextResourceDecoderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/TextResourceDecoder.h (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/TextResourceDecoder.h        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/loader/TextResourceDecoder.h        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -55,6 +55,8 @@
</span><span class="cx">     String decode(const char* data, size_t length);
</span><span class="cx">     String flush();
</span><span class="cx"> 
</span><ins>+    String decodeAndFlush(const char* data, size_t length);
+
</ins><span class="cx">     void setHintEncoding(const TextResourceDecoder* hintDecoder)
</span><span class="cx">     {
</span><span class="cx">         // hintEncoding is for use with autodetection, which should be 
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderappcacheManifestParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/appcache/ManifestParser.cpp (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/appcache/ManifestParser.cpp        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/loader/appcache/ManifestParser.cpp        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -43,9 +43,7 @@
</span><span class="cx"> 
</span><span class="cx">     Mode mode = Explicit;
</span><span class="cx"> 
</span><del>-    RefPtr&lt;TextResourceDecoder&gt; decoder = TextResourceDecoder::create(&quot;text/cache-manifest&quot;, &quot;UTF-8&quot;);
-    String s = decoder-&gt;decode(data, length);
-    s.append(decoder-&gt;flush());
</del><ins>+    String s = TextResourceDecoder::create(&quot;text/cache-manifest&quot;, &quot;UTF-8&quot;)-&gt;decodeAndFlush(data, length);
</ins><span class="cx">     
</span><span class="cx">     // Look for the magic signature: &quot;^\xFEFF?CACHE MANIFEST[ \t]?&quot; (the BOM is removed by TextResourceDecoder).
</span><span class="cx">     // Example: &quot;CACHE MANIFEST #comment&quot; is a valid signature.
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedCSSStyleSheetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -88,9 +88,7 @@
</span><span class="cx">         return m_decodedSheetText;
</span><span class="cx">     
</span><span class="cx">     // Don't cache the decoded text, regenerating is cheap and it can use quite a bit of memory
</span><del>-    String sheetText = m_decoder-&gt;decode(m_data-&gt;data(), m_data-&gt;size());
-    sheetText.append(m_decoder-&gt;flush());
-    return sheetText;
</del><ins>+    return m_decoder-&gt;decodeAndFlush(m_data-&gt;data(), m_data-&gt;size());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CachedCSSStyleSheet::finishLoading(ResourceBuffer* data)
</span><span class="lines">@@ -98,10 +96,8 @@
</span><span class="cx">     m_data = data;
</span><span class="cx">     setEncodedSize(m_data.get() ? m_data-&gt;size() : 0);
</span><span class="cx">     // Decode the data to find out the encoding and keep the sheet text around during checkNotify()
</span><del>-    if (m_data) {
-        m_decodedSheetText = m_decoder-&gt;decode(m_data-&gt;data(), m_data-&gt;size());
-        m_decodedSheetText.append(m_decoder-&gt;flush());
-    }
</del><ins>+    if (m_data)
+        m_decodedSheetText = m_decoder-&gt;decodeAndFlush(m_data-&gt;data(), m_data-&gt;size());
</ins><span class="cx">     setLoading(false);
</span><span class="cx">     checkNotify();
</span><span class="cx">     // Clear the decoded text as it is unlikely to be needed immediately again and is cheap to regenerate.
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedFontcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedFont.cpp (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedFont.cpp        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/loader/cache/CachedFont.cpp        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include &quot;ResourceBuffer.h&quot;
</span><span class="cx"> #include &quot;SharedBuffer.h&quot;
</span><span class="cx"> #include &quot;TextResourceDecoder.h&quot;
</span><ins>+#include &quot;TypedElementDescendantIterator.h&quot;
</ins><span class="cx"> #include &quot;WOFFFileFormat.h&quot;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -129,52 +130,33 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SVG_FONTS)
</span><ins>+
</ins><span class="cx"> bool CachedFont::ensureSVGFontData()
</span><span class="cx"> {
</span><span class="cx">     if (!m_externalSVGDocument &amp;&amp; !errorOccurred() &amp;&amp; !isLoading() &amp;&amp; m_data) {
</span><del>-        m_externalSVGDocument = SVGDocument::create(0, URL());
-
</del><ins>+        m_externalSVGDocument = SVGDocument::create(nullptr, URL());
</ins><span class="cx">         RefPtr&lt;TextResourceDecoder&gt; decoder = TextResourceDecoder::create(&quot;application/xml&quot;);
</span><del>-        String svgSource = decoder-&gt;decode(m_data-&gt;data(), m_data-&gt;size());
-        svgSource.append(decoder-&gt;flush());
-        
-        m_externalSVGDocument-&gt;setContent(svgSource);
-        
</del><ins>+        m_externalSVGDocument-&gt;setContent(decoder-&gt;decodeAndFlush(m_data-&gt;data(), m_data-&gt;size()));
</ins><span class="cx">         if (decoder-&gt;sawError())
</span><del>-            m_externalSVGDocument = 0;
</del><ins>+            m_externalSVGDocument = nullptr;
</ins><span class="cx">     }
</span><del>-
</del><span class="cx">     return m_externalSVGDocument;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> SVGFontElement* CachedFont::getSVGFontById(const String&amp; fontName) const
</span><span class="cx"> {
</span><del>-    RefPtr&lt;NodeList&gt; list = m_externalSVGDocument-&gt;getElementsByTagNameNS(SVGNames::fontTag.namespaceURI(), SVGNames::fontTag.localName());
-    if (!list)
-        return 0;
</del><ins>+    auto elements = descendantsOfType&lt;SVGFontElement&gt;(*m_externalSVGDocument);
</ins><span class="cx"> 
</span><del>-    unsigned listLength = list-&gt;length();
-    if (!listLength)
-        return 0;
-
-#ifndef NDEBUG
-    for (unsigned i = 0; i &lt; listLength; ++i) {
-        ASSERT(list-&gt;item(i));
-        ASSERT(isSVGFontElement(list-&gt;item(i)));
-    }
-#endif
-
</del><span class="cx">     if (fontName.isEmpty())
</span><del>-        return toSVGFontElement(list-&gt;item(0));
</del><ins>+        return elements.first();
</ins><span class="cx"> 
</span><del>-    for (unsigned i = 0; i &lt; listLength; ++i) {
-        SVGFontElement* element = toSVGFontElement(list-&gt;item(i));
-        if (element-&gt;getIdAttribute() == fontName)
-            return element;
</del><ins>+    for (auto&amp; element : elements) {
+        if (element.getIdAttribute() == fontName)
+            return &amp;element;
</ins><span class="cx">     }
</span><del>-
-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> void CachedFont::allClientsRemoved()
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedSVGDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedSVGDocument.cpp (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedSVGDocument.cpp        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/loader/cache/CachedSVGDocument.cpp        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -54,12 +54,9 @@
</span><span class="cx"> void CachedSVGDocument::finishLoading(ResourceBuffer* data)
</span><span class="cx"> {
</span><span class="cx">     if (data) {
</span><del>-        StringBuilder decodedText;
-        decodedText.append(m_decoder-&gt;decode(data-&gt;data(), data-&gt;size()));
-        decodedText.append(m_decoder-&gt;flush());
</del><span class="cx">         // We don't need to create a new frame because the new document belongs to the parent UseElement.
</span><del>-        m_document = SVGDocument::create(0, response().url());
-        m_document-&gt;setContent(decodedText.toString());
</del><ins>+        m_document = SVGDocument::create(nullptr, response().url());
+        m_document-&gt;setContent(m_decoder-&gt;decodeAndFlush(data-&gt;data(), data-&gt;size()));
</ins><span class="cx">     }
</span><span class="cx">     CachedResource::finishLoading(data);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedScriptcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedScript.cpp (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedScript.cpp        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/loader/cache/CachedScript.cpp        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -73,8 +73,7 @@
</span><span class="cx">     ASSERT(!isPurgeable());
</span><span class="cx"> 
</span><span class="cx">     if (!m_script &amp;&amp; m_data) {
</span><del>-        m_script = m_decoder-&gt;decode(m_data-&gt;data(), encodedSize());
-        m_script.append(m_decoder-&gt;flush());
</del><ins>+        m_script = m_decoder-&gt;decodeAndFlush(m_data-&gt;data(), encodedSize());
</ins><span class="cx">         setDecodedSize(m_script.sizeInBytes());
</span><span class="cx">     }
</span><span class="cx">     m_decodedDataDeletionTimer.restart();
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedXSLStyleSheetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedXSLStyleSheet.cpp (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedXSLStyleSheet.cpp        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/loader/cache/CachedXSLStyleSheet.cpp        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -67,10 +67,8 @@
</span><span class="cx"> {
</span><span class="cx">     m_data = data;
</span><span class="cx">     setEncodedSize(m_data.get() ? m_data-&gt;size() : 0);
</span><del>-    if (m_data.get()) {
-        m_sheet = m_decoder-&gt;decode(m_data-&gt;data(), encodedSize());
-        m_sheet.append(m_decoder-&gt;flush());
-    }
</del><ins>+    if (m_data.get())
+        m_sheet = m_decoder-&gt;decodeAndFlush(m_data-&gt;data(), encodedSize());
</ins><span class="cx">     setLoading(false);
</span><span class="cx">     checkNotify();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebCore/page/Page.cpp        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -924,9 +924,7 @@
</span><span class="cx">     if (!data)
</span><span class="cx">         return m_userStyleSheet;
</span><span class="cx"> 
</span><del>-    RefPtr&lt;TextResourceDecoder&gt; decoder = TextResourceDecoder::create(&quot;text/css&quot;);
-    m_userStyleSheet = decoder-&gt;decode(data-&gt;data(), data-&gt;size());
-    m_userStyleSheet.append(decoder-&gt;flush());
</del><ins>+    m_userStyleSheet = TextResourceDecoder::create(&quot;text/css&quot;)-&gt;decodeAndFlush(data-&gt;data(), data-&gt;size());
</ins><span class="cx"> 
</span><span class="cx">     return m_userStyleSheet;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebKit/mac/ChangeLog        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-03-21  Darin Adler  &lt;darin@apple.com&gt;
+
+        Add a combined decodeAndFlush to TextResourceDecoder
+        https://bugs.webkit.org/show_bug.cgi?id=130560
+
+        Reviewed by Andreas Kling.
+
+        * WebView/WebView.mm:
+        (+[WebView _decodeData:]): Use decodeAndFlush.
+
</ins><span class="cx"> 2014-03-20  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix build.
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (166045 => 166046)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2014-03-21 06:51:18 UTC (rev 166045)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2014-03-21 07:12:07 UTC (rev 166046)
</span><span class="lines">@@ -2759,10 +2759,7 @@
</span><span class="cx"> + (NSString *)_decodeData:(NSData *)data
</span><span class="cx"> {
</span><span class="cx">     HTMLNames::init(); // this method is used for importing bookmarks at startup, so HTMLNames are likely to be uninitialized yet
</span><del>-    RefPtr&lt;TextResourceDecoder&gt; decoder = TextResourceDecoder::create(&quot;text/html&quot;); // bookmark files are HTML
-    String result = decoder-&gt;decode(static_cast&lt;const char*&gt;([data bytes]), [data length]);
-    result.append(decoder-&gt;flush());
-    return result;
</del><ins>+    return TextResourceDecoder::create(&quot;text/html&quot;)-&gt;decodeAndFlush(static_cast&lt;const char*&gt;([data bytes]), [data length]); // bookmark files are HTML
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_pushPerformingProgrammaticFocus
</span></span></pre>
</div>
</div>

</body>
</html>