<!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>[188820] 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/188820">188820</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2015-08-22 02:57:23 -0700 (Sat, 22 Aug 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Decode data URLs in web process
https://bugs.webkit.org/show_bug.cgi?id=148128

Reviewed by Darin Adler.

Source/WebCore:

We currenly send data URLs to networking layer for decoding. This involves a long and slow roundtrip through IPC and API layers.

* WebCore.xcodeproj/project.pbxproj:
* loader/ResourceLoadScheduler.cpp:
(WebCore::ResourceLoadScheduler::maybeLoadQuickLookResource): Deleted.

    Remove this awkward interface for WebKit2.

* loader/ResourceLoadScheduler.h:
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::start):
(WebCore::ResourceLoader::loadDataURL):

    Load using DataURLDecoder.

* loader/ResourceLoader.h:

    Make start() public and export it so it can be called directly from WebKit2.

* platform/network/DataURLDecoder.cpp: Added.
(WebCore::DataURLDecoder::decodeQueue):
(WebCore::DataURLDecoder::DecodeTask::DecodeTask):
(WebCore::DataURLDecoder::createDecodeTask):

    Parse data URL metadata and initialize the decode task.

(WebCore::DataURLDecoder::decodeBase64):
(WebCore::DataURLDecoder::decodeEscaped):
(WebCore::DataURLDecoder::decode):

    Asynchronously decode in a concurrent distpatch queue.

* platform/network/DataURLDecoder.h: Added.
* platform/network/ios/QuickLook.h:
* platform/text/DecodeEscapeSequences.h:
(WebCore::URLEscapeSequence::findEndOfRun):
(WebCore::URLEscapeSequence::decodeRun):

    Factor buffer generation to a function.

(WebCore::decodeEscapeSequences):
(WebCore::decodeURLEscapeSequencesAsData):

    Add decode function that produces bytes instead of a String.

Source/WebKit2:

* WebProcess/Network/WebResourceLoadScheduler.cpp:
(WebKit::WebResourceLoadScheduler::scheduleLoad):

    Don't send data: loads to the network process, handle them locally.

(WebKit::WebResourceLoadScheduler::startLocalLoad):

    Call ResourceLoder::start() directly.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadSchedulercpp">trunk/Source/WebCore/loader/ResourceLoadScheduler.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadSchedulerh">trunk/Source/WebCore/loader/ResourceLoadScheduler.h</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadercpp">trunk/Source/WebCore/loader/ResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoaderh">trunk/Source/WebCore/loader/ResourceLoader.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkiosQuickLookh">trunk/Source/WebCore/platform/network/ios/QuickLook.h</a></li>
<li><a href="#trunkSourceWebCoreplatformtextDecodeEscapeSequencesh">trunk/Source/WebCore/platform/text/DecodeEscapeSequences.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebResourceLoadSchedulercpp">trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebResourceLoadSchedulerh">trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformnetworkDataURLDecodercpp">trunk/Source/WebCore/platform/network/DataURLDecoder.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkDataURLDecoderh">trunk/Source/WebCore/platform/network/DataURLDecoder.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (188819 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2015-08-22 07:20:33 UTC (rev 188819)
+++ trunk/Source/WebCore/CMakeLists.txt        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -2253,6 +2253,7 @@
</span><span class="cx">     platform/network/CredentialStorage.cpp
</span><span class="cx">     platform/network/DNSResolveQueue.cpp
</span><span class="cx">     platform/network/DataURL.cpp
</span><ins>+    platform/network/DataURLDecoder.cpp
</ins><span class="cx">     platform/network/FormData.cpp
</span><span class="cx">     platform/network/FormDataBuilder.cpp
</span><span class="cx">     platform/network/HTTPHeaderMap.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (188819 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-08-22 07:20:33 UTC (rev 188819)
+++ trunk/Source/WebCore/ChangeLog        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -1,3 +1,55 @@
</span><ins>+2015-08-22  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Decode data URLs in web process
+        https://bugs.webkit.org/show_bug.cgi?id=148128
+
+        Reviewed by Darin Adler.
+
+        We currenly send data URLs to networking layer for decoding. This involves a long and slow roundtrip through IPC and API layers.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/ResourceLoadScheduler.cpp:
+        (WebCore::ResourceLoadScheduler::maybeLoadQuickLookResource): Deleted.
+
+            Remove this awkward interface for WebKit2.
+
+        * loader/ResourceLoadScheduler.h:
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::start):
+        (WebCore::ResourceLoader::loadDataURL):
+
+            Load using DataURLDecoder.
+
+        * loader/ResourceLoader.h:
+
+            Make start() public and export it so it can be called directly from WebKit2.
+
+        * platform/network/DataURLDecoder.cpp: Added.
+        (WebCore::DataURLDecoder::decodeQueue):
+        (WebCore::DataURLDecoder::DecodeTask::DecodeTask):
+        (WebCore::DataURLDecoder::createDecodeTask):
+
+            Parse data URL metadata and initialize the decode task.
+
+        (WebCore::DataURLDecoder::decodeBase64):
+        (WebCore::DataURLDecoder::decodeEscaped):
+        (WebCore::DataURLDecoder::decode):
+
+            Asynchronously decode in a concurrent distpatch queue.
+
+        * platform/network/DataURLDecoder.h: Added.
+        * platform/network/ios/QuickLook.h:
+        * platform/text/DecodeEscapeSequences.h:
+        (WebCore::URLEscapeSequence::findEndOfRun):
+        (WebCore::URLEscapeSequence::decodeRun):
+
+            Factor buffer generation to a function.
+
+        (WebCore::decodeEscapeSequences):
+        (WebCore::decodeURLEscapeSequencesAsData):
+
+            Add decode function that produces bytes instead of a String.
+
</ins><span class="cx"> 2015-08-21  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r188792 and r188803.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (188819 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-08-22 07:20:33 UTC (rev 188819)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -8820,6 +8820,7 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\network\CredentialBase.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\network\CredentialStorage.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\network\DataURL.cpp&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\platform\network\DataURLDecoder.cpp&quot; /&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\platform\network\DNSResolveQueue.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\network\FormData.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\network\FormDataBuilder.cpp&quot; /&gt;
</span><span class="lines">@@ -21331,6 +21332,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\network\CredentialBase.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\network\CredentialStorage.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\network\DataURL.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\platform\network\DataURLDecoder.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\platform\network\DNSResolveQueue.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\network\FormData.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\network\FormDataBuilder.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (188819 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-08-22 07:20:33 UTC (rev 188819)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -6372,6 +6372,8 @@
</span><span class="cx">                 E4946EAF156E64DD00D3297F /* StyleRuleImport.h in Headers */ = {isa = PBXBuildFile; fileRef = E4946EAD156E64DD00D3297F /* StyleRuleImport.h */; };
</span><span class="cx">                 E49BD9FA131FD2ED003C56F0 /* CSSValuePool.h in Headers */ = {isa = PBXBuildFile; fileRef = E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */; };
</span><span class="cx">                 E49BDA0B131FD3E5003C56F0 /* CSSValuePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E49BDA0A131FD3E5003C56F0 /* CSSValuePool.cpp */; };
</span><ins>+                E4A007831B820EC8002C5A6E /* DataURLDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A007821B820EC8002C5A6E /* DataURLDecoder.h */; };
+                E4A007851B820ED3002C5A6E /* DataURLDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A007841B820ED3002C5A6E /* DataURLDecoder.cpp */; };
</ins><span class="cx">                 E4AE7C1617D1BB950009FB31 /* ElementIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AE7C1517D1BB950009FB31 /* ElementIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E4AE7C1A17D232350009FB31 /* ElementAncestorIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AE7C1917D232350009FB31 /* ElementAncestorIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E4AFCFA50DAF29A300F5F55C /* UnitBezier.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */; };
</span><span class="lines">@@ -14081,6 +14083,8 @@
</span><span class="cx">                 E4946EAD156E64DD00D3297F /* StyleRuleImport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleRuleImport.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSValuePool.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E49BDA0A131FD3E5003C56F0 /* CSSValuePool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSValuePool.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                E4A007821B820EC8002C5A6E /* DataURLDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataURLDecoder.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                E4A007841B820ED3002C5A6E /* DataURLDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataURLDecoder.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 E4AE7C1517D1BB950009FB31 /* ElementIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementIterator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E4AE7C1917D232350009FB31 /* ElementAncestorIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementAncestorIterator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnitBezier.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -16879,6 +16883,8 @@
</span><span class="cx">                                 379291781985EF3900F4B661 /* CredentialBase.h */,
</span><span class="cx">                                 51A052321058774F00CC9E95 /* CredentialStorage.cpp */,
</span><span class="cx">                                 51A052311058774F00CC9E95 /* CredentialStorage.h */,
</span><ins>+                                E4A007841B820ED3002C5A6E /* DataURLDecoder.cpp */,
+                                E4A007821B820EC8002C5A6E /* DataURLDecoder.h */,
</ins><span class="cx">                                 B2F34FE50E82F81400F627CD /* DNS.h */,
</span><span class="cx">                                 7C60128060078BB70E367A95 /* DNSResolveQueue.cpp */,
</span><span class="cx">                                 FA6E466FCD0418A9966A5B60 /* DNSResolveQueue.h */,
</span><span class="lines">@@ -26074,6 +26080,7 @@
</span><span class="cx">                                 C9D851F01B39DC780085062E /* MediaSessionMetadata.h in Headers */,
</span><span class="cx">                                 CD3A495F17A9D01B00274E42 /* MediaSource.h in Headers */,
</span><span class="cx">                                 CD641EB31818F5ED00EE4C41 /* MediaSourcePrivate.h in Headers */,
</span><ins>+                                E4A007831B820EC8002C5A6E /* DataURLDecoder.h in Headers */,
</ins><span class="cx">                                 CDC8B5A7180474F70016E685 /* MediaSourcePrivateAVFObjC.h in Headers */,
</span><span class="cx">                                 CDDC1E7A18A952F30027A9D4 /* MediaSourcePrivateClient.h in Headers */,
</span><span class="cx">                                 CD61FE681794AADB004101EB /* MediaSourceRegistry.h in Headers */,
</span><span class="lines">@@ -28408,6 +28415,7 @@
</span><span class="cx">                                 15C770A5100D41CD005BA267 /* DOMValidityState.mm in Sources */,
</span><span class="cx">                                 31C0FF4A0E4CEFDD007D6FE5 /* DOMWebKitAnimationEvent.mm in Sources */,
</span><span class="cx">                                 3106037A143281CD00ABF4BA /* DOMWebKitCSSFilterValue.mm in Sources */,
</span><ins>+                                E4A007851B820ED3002C5A6E /* DataURLDecoder.cpp in Sources */,
</ins><span class="cx">                                 498391510F1E76B400C23782 /* DOMWebKitCSSMatrix.mm in Sources */,
</span><span class="cx">                                 8AD0A59714C88358000D83C5 /* DOMWebKitCSSRegionRule.mm in Sources */,
</span><span class="cx">                                 31611E620E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadSchedulercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoadScheduler.cpp (188819 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoadScheduler.cpp        2015-08-22 07:20:33 UTC (rev 188819)
+++ trunk/Source/WebCore/loader/ResourceLoadScheduler.cpp        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -195,17 +195,6 @@
</span><span class="cx">     scheduleServePendingRequests();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if USE(QUICK_LOOK)
-bool ResourceLoadScheduler::maybeLoadQuickLookResource(ResourceLoader&amp; loader)
-{
-    if (!loader.request().url().protocolIs(QLPreviewProtocol()))
-        return false;
-
-    loader.start();
-    return true;
-}
-#endif
-
</del><span class="cx"> void ResourceLoadScheduler::remove(ResourceLoader* resourceLoader)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(resourceLoader);
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadSchedulerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoadScheduler.h (188819 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoadScheduler.h        2015-08-22 07:20:33 UTC (rev 188819)
+++ trunk/Source/WebCore/loader/ResourceLoadScheduler.h        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -76,10 +76,6 @@
</span><span class="cx">     WEBCORE_EXPORT ResourceLoadScheduler();
</span><span class="cx">     WEBCORE_EXPORT virtual ~ResourceLoadScheduler();
</span><span class="cx"> 
</span><del>-#if USE(QUICK_LOOK)
-    WEBCORE_EXPORT bool maybeLoadQuickLookResource(ResourceLoader&amp;);
-#endif
-
</del><span class="cx"> private:
</span><span class="cx">     void scheduleLoad(ResourceLoader*);
</span><span class="cx">     void scheduleServePendingRequests();
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (188819 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoader.cpp        2015-08-22 07:20:33 UTC (rev 188819)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ApplicationCacheHost.h&quot;
</span><span class="cx"> #include &quot;AuthenticationChallenge.h&quot;
</span><ins>+#include &quot;DataURLDecoder.h&quot;
</ins><span class="cx"> #include &quot;DiagnosticLoggingClient.h&quot;
</span><span class="cx"> #include &quot;DiagnosticLoggingKeys.h&quot;
</span><span class="cx"> #include &quot;DocumentLoader.h&quot;
</span><span class="lines">@@ -202,10 +203,15 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!m_reachedTerminalState) {
-        FrameLoader&amp; loader = m_request.url().protocolIsData() ? dataProtocolFrameLoader() : *frameLoader();
-        m_handle = ResourceHandle::create(loader.networkingContext(), m_request, this, m_defersLoading, m_options.sniffContent() == SniffContent);
</del><ins>+    if (m_reachedTerminalState)
+        return;
+
+    if (m_request.url().protocolIsData()) {
+        loadDataURL();
+        return;
</ins><span class="cx">     }
</span><ins>+
+    m_handle = ResourceHandle::create(frameLoader()-&gt;networkingContext(), m_request, this, m_defersLoading, m_options.sniffContent() == SniffContent);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ResourceLoader::setDefersLoading(bool defers)
</span><span class="lines">@@ -229,6 +235,33 @@
</span><span class="cx">     return &amp;m_frame-&gt;loader();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ResourceLoader::loadDataURL()
+{
+    auto url = m_request.url();
+    ASSERT(url.protocolIsData());
+
+    RefPtr&lt;ResourceLoader&gt; loader(this);
+    DataURLDecoder::decode(url, [loader, url] (Optional&lt;DataURLDecoder::Result&gt; decodeResult) {
+        if (loader-&gt;reachedTerminalState())
+            return;
+        if (!decodeResult) {
+            loader-&gt;didFail(ResourceError(errorDomainWebKitInternal, 0, url.string(), &quot;Data URL decoding failed&quot;));
+            return;
+        }
+        auto&amp; result = decodeResult.value();
+        auto dataSize = result.data-&gt;size();
+
+        ResourceResponse dataResponse { url, result.mimeType, dataSize, result.charset };
+        loader-&gt;didReceiveResponse(dataResponse);
+
+        if (!loader-&gt;reachedTerminalState() &amp;&amp; dataSize)
+            loader-&gt;didReceiveBuffer(result.data.get(), dataSize, DataPayloadWholeResource);
+
+        if (!loader-&gt;reachedTerminalState())
+            loader-&gt;didFinishLoading(currentTime());
+    });
+}
+
</ins><span class="cx"> // This function should only be called when frameLoader() is non-null.
</span><span class="cx"> FrameLoader&amp; ResourceLoader::dataProtocolFrameLoader() const
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoader.h (188819 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoader.h        2015-08-22 07:20:33 UTC (rev 188819)
+++ trunk/Source/WebCore/loader/ResourceLoader.h        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -80,7 +80,8 @@
</span><span class="cx">     FrameLoader&amp; dataProtocolFrameLoader() const;
</span><span class="cx">     DocumentLoader* documentLoader() const { return m_documentLoader.get(); }
</span><span class="cx">     const ResourceRequest&amp; originalRequest() const { return m_originalRequest; }
</span><del>-    
</del><ins>+
+    WEBCORE_EXPORT void start();
</ins><span class="cx">     WEBCORE_EXPORT void cancel(const ResourceError&amp;);
</span><span class="cx">     WEBCORE_EXPORT ResourceError cancelledError();
</span><span class="cx">     ResourceError blockedError();
</span><span class="lines">@@ -148,11 +149,6 @@
</span><span class="cx"> protected:
</span><span class="cx">     ResourceLoader(Frame*, ResourceLoaderOptions);
</span><span class="cx"> 
</span><del>-    friend class ResourceLoadScheduler; // for access to start()
-    // start() actually sends the load to the network (unless the load is being
-    // deferred) and should only be called by ResourceLoadScheduler or setDefersLoading().
-    void start();
-
</del><span class="cx">     void didFinishLoadingOnePart(double finishTime);
</span><span class="cx">     void cleanupForError(const ResourceError&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -181,6 +177,7 @@
</span><span class="cx">     virtual void didCancel(const ResourceError&amp;) = 0;
</span><span class="cx"> 
</span><span class="cx">     void addDataOrBuffer(const char*, unsigned, SharedBuffer*, DataPayloadType);
</span><ins>+    void loadDataURL();
</ins><span class="cx"> 
</span><span class="cx">     // ResourceHandleClient
</span><span class="cx">     virtual void willSendRequest(ResourceHandle*, ResourceRequest&amp;, const ResourceResponse&amp; redirectResponse) override;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkDataURLDecodercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/network/DataURLDecoder.cpp (0 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/DataURLDecoder.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/network/DataURLDecoder.cpp        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -0,0 +1,148 @@
</span><ins>+/*
+ * Copyright (C) 2015 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.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;DataURLDecoder.h&quot;
+
+#include &quot;DecodeEscapeSequences.h&quot;
+#include &quot;HTTPParsers.h&quot;
+#include &quot;SharedBuffer.h&quot;
+#include &quot;URL.h&quot;
+#include &lt;wtf/MainThread.h&gt;
+#include &lt;wtf/RunLoop.h&gt;
+#include &lt;wtf/WorkQueue.h&gt;
+#include &lt;wtf/text/Base64.h&gt;
+
+namespace WebCore {
+namespace DataURLDecoder {
+
+static WorkQueue&amp; decodeQueue()
+{
+    static auto&amp; queue = WorkQueue::create(&quot;org.webkit.DataURLDecoder&quot;).leakRef();
+    return queue;
+}
+
+struct DecodeTask {
+    const String urlString;
+    const StringView encodedData;
+    const bool isBase64;
+    const DecodeCompletionHandler completionHandler;
+
+    Result result;
+};
+
+static Result parseMediaType(const String&amp; mediaType)
+{
+    auto mimeType = extractMIMETypeFromMediaType(mediaType);
+    auto charset = extractCharsetFromMediaType(mediaType);
+
+    // https://tools.ietf.org/html/rfc2397
+    // If &lt;mediatype&gt; is omitted, it defaults to text/plain;charset=US-ASCII. As a shorthand,
+    // &quot;text/plain&quot; can be omitted but the charset parameter supplied.
+    if (mimeType.isEmpty()) {
+        mimeType = ASCIILiteral(&quot;text/plain&quot;);
+        if (charset.isEmpty())
+            charset = ASCIILiteral(&quot;US-ASCII&quot;);
+    }
+    return { mimeType, charset, nullptr };
+}
+
+static std::unique_ptr&lt;DecodeTask&gt; createDecodeTask(const URL&amp; url, DecodeCompletionHandler completionHandler)
+{
+    const char dataString[] = &quot;data:&quot;;
+    const char base64String[] = &quot;;base64&quot;;
+
+    auto urlString = url.string();
+    ASSERT(urlString.startsWith(dataString));
+
+    size_t headerEnd = urlString.find(',', strlen(dataString));
+    size_t encodedDataStart = headerEnd == notFound ? headerEnd : headerEnd + 1;
+
+    auto encodedData = StringView(urlString).substring(encodedDataStart);
+    auto header = StringView(urlString).substring(strlen(dataString), headerEnd - strlen(dataString));
+    bool isBase64 = header.endsWithIgnoringASCIICase(StringView(base64String));
+    auto mediaType = (isBase64 ? header.substring(0, header.length() - strlen(base64String)) : header).toString();
+
+    return std::make_unique&lt;DecodeTask&gt;(DecodeTask {
+        WTF::move(urlString),
+        WTF::move(encodedData),
+        isBase64,
+        WTF::move(completionHandler),
+        parseMediaType(mediaType)
+    });
+}
+
+static void decodeBase64(DecodeTask&amp; task)
+{
+    Vector&lt;char&gt; buffer;
+    // First try base64url.
+    if (!base64URLDecode(task.encodedData.toStringWithoutCopying(), buffer)) {
+        // Didn't work, try unescaping and decoding as base64.
+        auto unescapedString = decodeURLEscapeSequences(task.encodedData.toStringWithoutCopying());
+        if (!base64Decode(unescapedString, buffer, Base64IgnoreWhitespace))
+            return;
+    }
+    buffer.shrinkToFit();
+    task.result.data = SharedBuffer::adoptVector(buffer);
+}
+
+static void decodeEscaped(DecodeTask&amp; task)
+{
+    TextEncoding encodingFromCharset(task.result.charset);
+    auto&amp; encoding = encodingFromCharset.isValid() ? encodingFromCharset : UTF8Encoding();
+    auto buffer = decodeURLEscapeSequencesAsData(task.encodedData, encoding);
+
+    buffer.shrinkToFit();
+    task.result.data = SharedBuffer::adoptVector(buffer);
+}
+
+void decode(const URL&amp; url, DecodeCompletionHandler completionHandler)
+{
+    ASSERT(url.protocolIsData());
+
+    auto decodeTask = createDecodeTask(url, WTF::move(completionHandler));
+
+    auto* decodeTaskPtr = decodeTask.release();
+    decodeQueue().dispatch([decodeTaskPtr] {
+        auto&amp; decodeTask = *decodeTaskPtr;
+
+        if (decodeTask.isBase64)
+            decodeBase64(decodeTask);
+        else
+            decodeEscaped(decodeTask);
+
+        callOnMainThread([decodeTaskPtr] {
+            std::unique_ptr&lt;DecodeTask&gt; decodeTask(decodeTaskPtr);
+            if (!decodeTask-&gt;result.data) {
+                decodeTask-&gt;completionHandler({ });
+                return;
+            }
+            decodeTask-&gt;completionHandler(WTF::move(decodeTask-&gt;result));
+        });
+    });
+}
+
+}
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkDataURLDecoderh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/network/DataURLDecoder.h (0 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/DataURLDecoder.h                                (rev 0)
+++ trunk/Source/WebCore/platform/network/DataURLDecoder.h        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -0,0 +1,55 @@
</span><ins>+/*
+ * Copyright (C) 2015 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 DataURLDecoder_h
+#define DataURLDecoder_h
+
+
+#include &lt;functional&gt;
+#include &lt;wtf/Optional.h&gt;
+#include &lt;wtf/text/WTFString.h&gt;
+
+namespace WebCore {
+
+class SharedBuffer;
+class URL;
+
+namespace DataURLDecoder {
+
+struct Result {
+    String mimeType;
+    String charset;
+    RefPtr&lt;SharedBuffer&gt; data;
+};
+
+using DecodeCompletionHandler = std::function&lt;void (Optional&lt;Result&gt;)&gt;;
+
+void decode(const URL&amp;, DecodeCompletionHandler);
+
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkiosQuickLookh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ios/QuickLook.h (188819 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/ios/QuickLook.h        2015-08-22 07:20:33 UTC (rev 188819)
+++ trunk/Source/WebCore/platform/network/ios/QuickLook.h        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx"> 
</span><span class="cx"> const URL safeQLURLForDocumentURLAndResourceURL(const URL&amp; documentURL, const String&amp; resourceURL);
</span><span class="cx"> 
</span><del>-const char* QLPreviewProtocol();
</del><ins>+WEBCORE_EXPORT const char* QLPreviewProtocol();
</ins><span class="cx"> 
</span><span class="cx"> WEBCORE_EXPORT NSString *createTemporaryFileForQuickLook(NSString *fileName);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextDecodeEscapeSequencesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/DecodeEscapeSequences.h (188819 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/DecodeEscapeSequences.h        2015-08-22 07:20:33 UTC (rev 188819)
+++ trunk/Source/WebCore/platform/text/DecodeEscapeSequences.h        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -40,8 +40,8 @@
</span><span class="cx"> // See &lt;http://en.wikipedia.org/wiki/Percent-encoding#Non-standard_implementations&gt;.
</span><span class="cx"> struct Unicode16BitEscapeSequence {
</span><span class="cx">     enum { sequenceSize = 6 }; // e.g. %u26C4
</span><del>-    static size_t findInString(const String&amp; string, size_t startPosition) { return string.find(&quot;%u&quot;, startPosition); }
-    static size_t findEndOfRun(const String&amp; string, size_t startPosition, size_t endPosition)
</del><ins>+    static size_t findInString(StringView string, size_t startPosition) { return string.find(StringView(&quot;%u&quot;), startPosition); }
+    static size_t findEndOfRun(StringView string, size_t startPosition, size_t endPosition)
</ins><span class="cx">     {
</span><span class="cx">         size_t runEnd = startPosition;
</span><span class="cx">         while (endPosition - runEnd &gt;= sequenceSize &amp;&amp; string[runEnd] == '%' &amp;&amp; string[runEnd + 1] == 'u'
</span><span class="lines">@@ -71,8 +71,8 @@
</span><span class="cx"> 
</span><span class="cx"> struct URLEscapeSequence {
</span><span class="cx">     enum { sequenceSize = 3 }; // e.g. %41
</span><del>-    static size_t findInString(const String&amp; string, size_t startPosition) { return string.find('%', startPosition); }
-    static size_t findEndOfRun(const String&amp; string, size_t startPosition, size_t endPosition)
</del><ins>+    static size_t findInString(StringView string, size_t startPosition) { return string.find('%', startPosition); }
+    static size_t findEndOfRun(StringView string, size_t startPosition, size_t endPosition)
</ins><span class="cx">     {
</span><span class="cx">         // Make the simplifying assumption that supported encodings may have up to two unescaped characters
</span><span class="cx">         // in the range 0x40 - 0x7F as the trailing bytes of their sequences which need to be passed into the
</span><span class="lines">@@ -96,7 +96,8 @@
</span><span class="cx">         }
</span><span class="cx">         return runEnd;
</span><span class="cx">     }
</span><del>-    static String decodeRun(StringView run, const TextEncoding&amp; encoding)
</del><ins>+
+    static Vector&lt;char, 512&gt; decodeRun(StringView run)
</ins><span class="cx">     {
</span><span class="cx">         // For URL escape sequences, we know that findEndOfRun() has given us a run where every %-sign introduces
</span><span class="cx">         // a valid escape sequence, but there may be characters between the sequences.
</span><span class="lines">@@ -113,12 +114,21 @@
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">         ASSERT(buffer.size() &gt;= static_cast&lt;size_t&gt;(p - buffer.data())); // Prove buffer not overrun.
</span><del>-        return (encoding.isValid() ? encoding : UTF8Encoding()).decode(buffer.data(), p - buffer.data());
</del><ins>+        buffer.shrink(p - buffer.data());
+        return buffer;
</ins><span class="cx">     }
</span><ins>+
+    static String decodeRun(StringView run, const TextEncoding&amp; encoding)
+    {
+        auto buffer = decodeRun(run);
+        if (!encoding.isValid())
+            return UTF8Encoding().decode(buffer.data(), buffer.size());
+        return encoding.decode(buffer.data(), buffer.size());
+    }
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename EscapeSequence&gt;
</span><del>-String decodeEscapeSequences(const String&amp; string, const TextEncoding&amp; encoding)
</del><ins>+String decodeEscapeSequences(StringView string, const TextEncoding&amp; encoding)
</ins><span class="cx"> {
</span><span class="cx">     StringBuilder result;
</span><span class="cx">     size_t length = string.length();
</span><span class="lines">@@ -133,18 +143,53 @@
</span><span class="cx">             continue;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        String decoded = EscapeSequence::decodeRun(StringView(string).substring(encodedRunPosition, encodedRunEnd - encodedRunPosition), encoding);
</del><ins>+        String decoded = EscapeSequence::decodeRun(string.substring(encodedRunPosition, encodedRunEnd - encodedRunPosition), encoding);
</ins><span class="cx">         if (decoded.isEmpty())
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        result.append(string, decodedPosition, encodedRunPosition - decodedPosition);
</del><ins>+        result.append(string.substring(decodedPosition, encodedRunPosition - decodedPosition));
</ins><span class="cx">         result.append(decoded);
</span><span class="cx">         decodedPosition = encodedRunEnd;
</span><span class="cx">     }
</span><del>-    result.append(string, decodedPosition, length - decodedPosition);
</del><ins>+    result.append(string.substring(decodedPosition, length - decodedPosition));
</ins><span class="cx">     return result.toString();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline Vector&lt;char&gt; decodeURLEscapeSequencesAsData(StringView string, const TextEncoding&amp; encoding)
+{
+    ASSERT(encoding.isValid());
+
+    Vector&lt;char&gt; result;
+    size_t decodedPosition = 0;
+    size_t searchPosition = 0;
+    while (true) {
+        size_t encodedRunPosition = URLEscapeSequence::findInString(string, searchPosition);
+        size_t encodedRunEnd = 0;
+        if (encodedRunPosition != notFound) {
+            encodedRunEnd = URLEscapeSequence::findEndOfRun(string, encodedRunPosition, string.length());
+            searchPosition = encodedRunEnd;
+            if (encodedRunEnd == encodedRunPosition) {
+                ++searchPosition;
+                continue;
+            }
+        }
+        // Strings are encoded as requested.
+        auto stringFragment = string.substring(decodedPosition, encodedRunPosition - decodedPosition);
+        auto encodedStringFragment = encoding.encode(stringFragment, URLEncodedEntitiesForUnencodables);
+        result.append(encodedStringFragment.data(), encodedStringFragment.length());
+
+        if (encodedRunPosition == notFound)
+            return result;
+        
+        // Bytes go through as-is.
+        auto decodedEscapeSequence = URLEscapeSequence::decodeRun(string.substring(encodedRunPosition, encodedRunEnd - encodedRunPosition));
+        ASSERT(!decodedEscapeSequence.isEmpty());
+        result.appendVector(decodedEscapeSequence);
+
+        decodedPosition = encodedRunEnd;
+    }
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // DecodeEscapeSequences_h
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (188819 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-08-22 07:20:33 UTC (rev 188819)
+++ trunk/Source/WebKit2/ChangeLog        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2015-08-22  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Decode data URLs in web process
+        https://bugs.webkit.org/show_bug.cgi?id=148128
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/Network/WebResourceLoadScheduler.cpp:
+        (WebKit::WebResourceLoadScheduler::scheduleLoad):
+
+            Don't send data: loads to the network process, handle them locally.
+
+        (WebKit::WebResourceLoadScheduler::startLocalLoad):
+
+            Call ResourceLoder::start() directly.
+
</ins><span class="cx"> 2015-08-21  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r188807, r188813, and r188815.
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebResourceLoadSchedulercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp (188819 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp        2015-08-22 07:20:33 UTC (rev 188819)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -141,10 +141,16 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (resourceLoader-&gt;request().url().protocolIsData()) {
+        LOG(NetworkScheduling, &quot;(WebProcess) WebResourceLoadScheduler::scheduleLoad, url '%s' will be loaded as data.&quot;, resourceLoader-&gt;url().string().utf8().data());
+        startLocalLoad(*resourceLoader);
+        return;
+    }
+
</ins><span class="cx"> #if USE(QUICK_LOOK)
</span><del>-    if (maybeLoadQuickLookResource(*resourceLoader)) {
</del><ins>+    if (resourceLoader-&gt;request().url().protocolIs(QLPreviewProtocol())) {
</ins><span class="cx">         LOG(NetworkScheduling, &quot;(WebProcess) WebResourceLoadScheduler::scheduleLoad, url '%s' will be handled as a QuickLook resource.&quot;, resourceLoader-&gt;url().string().utf8().data());
</span><del>-        m_webResourceLoaders.set(identifier, WebResourceLoader::create(resourceLoader));
</del><ins>+        startLocalLoad(*resourceLoader);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="lines">@@ -203,6 +209,12 @@
</span><span class="cx">         internallyFailedResourceLoaders[i]-&gt;didFail(internalError(internallyFailedResourceLoaders[i]-&gt;url()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebResourceLoadScheduler::startLocalLoad(WebCore::ResourceLoader&amp; resourceLoader)
+{
+    resourceLoader.start();
+    m_webResourceLoaders.set(resourceLoader.identifier(), WebResourceLoader::create(&amp;resourceLoader));
+}
+
</ins><span class="cx"> void WebResourceLoadScheduler::remove(ResourceLoader* resourceLoader)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(resourceLoader);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebResourceLoadSchedulerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.h (188819 => 188820)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.h        2015-08-22 07:20:33 UTC (rev 188819)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.h        2015-08-22 09:57:23 UTC (rev 188820)
</span><span class="lines">@@ -67,7 +67,8 @@
</span><span class="cx">     void scheduleLoad(WebCore::ResourceLoader*, WebCore::CachedResource*, bool shouldClearReferrerOnHTTPSToHTTPRedirect);
</span><span class="cx">     void scheduleInternallyFailedLoad(WebCore::ResourceLoader*);
</span><span class="cx">     void internallyFailedLoadTimerFired();
</span><del>-    
</del><ins>+    void startLocalLoad(WebCore::ResourceLoader&amp;);
+
</ins><span class="cx">     HashSet&lt;RefPtr&lt;WebCore::ResourceLoader&gt;&gt; m_internallyFailedResourceLoaders;
</span><span class="cx">     RunLoop::Timer&lt;WebResourceLoadScheduler&gt; m_internallyFailedLoadTimer;
</span><span class="cx">     
</span></span></pre>
</div>
</div>

</body>
</html>