[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

paroga at webkit.org paroga at webkit.org
Wed Dec 22 14:17:04 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 4ad937ae854ee21ea0f40eabad7e8e4eb9feb848
Author: paroga at webkit.org <paroga at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Oct 6 10:59:43 2010 +0000

    2010-10-06  Patrick Gansterer  <paroga at webkit.org>
    
            Reviewed by Darin Adler.
    
            Move parseDataUrl() from CURL into own file
            https://bugs.webkit.org/show_bug.cgi?id=41462
    
            Move the data URL parsing algorithm into a new file to use it in ResourceHandleWin too.
    
            * CMakeLists.txt:
            * WebCore.gypi:
            * WebCore.vcproj/WebCore.vcproj:
            * platform/network/DataURL.cpp: Added.
            (WebCore::handleDataURL):
            * platform/network/DataURL.h: Added.
            * platform/network/curl/ResourceHandleManager.cpp:
            (WebCore::ResourceHandleManager::dispatchSynchronousJob):
            (WebCore::ResourceHandleManager::startJob):
            * platform/network/win/ResourceHandleWin.cpp:
            (WebCore::ResourceHandle::start):
            (WebCore::ResourceHandle::fileLoadTimer):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69183 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 26ce547..5e52e8e 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -1338,6 +1338,7 @@ SET(WebCore_SOURCES
     platform/network/BlobRegistryImpl.cpp
     platform/network/BlobResourceHandle.cpp
     platform/network/Credential.cpp
+    platform/network/DataURL.cpp
     platform/network/FormDataBuilder.cpp
     platform/network/FormData.cpp
     platform/network/HTTPHeaderMap.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 6377ca9..b0e81b6 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-10-06  Patrick Gansterer  <paroga at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Move parseDataUrl() from CURL into own file
+        https://bugs.webkit.org/show_bug.cgi?id=41462
+
+        Move the data URL parsing algorithm into a new file to use it in ResourceHandleWin too.
+
+        * CMakeLists.txt:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * platform/network/DataURL.cpp: Added.
+        (WebCore::handleDataURL):
+        * platform/network/DataURL.h: Added.
+        * platform/network/curl/ResourceHandleManager.cpp:
+        (WebCore::ResourceHandleManager::dispatchSynchronousJob):
+        (WebCore::ResourceHandleManager::startJob):
+        * platform/network/win/ResourceHandleWin.cpp:
+        (WebCore::ResourceHandle::start):
+        (WebCore::ResourceHandle::fileLoadTimer):
+
 2010-10-06  Dirk Schulze  <krit at webkit.org>
 
         Reviewed by Nikolas Zimmermann.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 1f3355b..e8b2cfb 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -3006,6 +3006,8 @@
             'platform/network/Credential.cpp',
             'platform/network/Credential.h',
             'platform/network/DNS.h',
+            'platform/network/DataURL.cpp',
+            'platform/network/DataURL.h',
             'platform/network/FormData.cpp',
             'platform/network/FormData.h',
             'platform/network/FormDataBuilder.cpp',
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 76f6446..74d63da 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -27426,6 +27426,14 @@
 					>
 				</File>
 				<File
+					RelativePath="..\platform\network\DataURL.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\platform\network\DataURL.h"
+					>
+				</File>
+				<File
 					RelativePath="..\platform\network\FormData.cpp"
 					>
 				</File>
diff --git a/WebCore/platform/network/DataURL.cpp b/WebCore/platform/network/DataURL.cpp
new file mode 100644
index 0000000..5de1b34
--- /dev/null
+++ b/WebCore/platform/network/DataURL.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2007 Alp Toker <alp at atoker.com>
+ * Copyright (C) 2010 Patrick Gansterer <paroga at paroga.com>
+ *
+ * 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 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 COMPUTER, INC. OR
+ * 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 "config.h"
+#include "DataURL.h"
+
+#include "Base64.h"
+#include "HTTPParsers.h"
+#include "ResourceHandle.h"
+#include "ResourceHandleClient.h"
+#include "ResourceRequest.h"
+#include "ResourceResponse.h"
+#include "TextEncoding.h"
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+void handleDataURL(ResourceHandle* handle)
+{
+    ASSERT(handle->firstRequest().url().protocolIs("data"));
+    String url = handle->firstRequest().url().string();
+
+    int index = url.find(',');
+    if (index == -1) {
+        handle->client()->cannotShowURL(handle);
+        return;
+    }
+
+    String mediaType = url.substring(5, index - 5);
+    String data = url.substring(index + 1);
+
+    bool base64 = mediaType.endsWith(";base64", false);
+    if (base64)
+        mediaType = mediaType.left(mediaType.length() - 7);
+
+    if (mediaType.isEmpty())
+        mediaType = "text/plain;charset=US-ASCII";
+
+    String mimeType = extractMIMETypeFromMediaType(mediaType);
+    String charset = extractCharsetFromMediaType(mediaType);
+
+    ResourceResponse response;
+    response.setMimeType(mimeType);
+    response.setTextEncodingName(charset);
+    response.setURL(handle->firstRequest().url());
+
+    if (base64) {
+        data = decodeURLEscapeSequences(data);
+        handle->client()->didReceiveResponse(handle, response);
+
+        Vector<char> out;
+        if (base64Decode(data, out, IgnoreWhitespace) && out.size() > 0) {
+            response.setExpectedContentLength(out.size());
+            handle->client()->didReceiveData(handle, out.data(), out.size(), 0);
+        }
+    } else {
+        data = decodeURLEscapeSequences(data, TextEncoding(charset));
+        handle->client()->didReceiveResponse(handle, response);
+
+        CString encodedData = TextEncoding().encode(data.characters(), data.length(), URLEncodedEntitiesForUnencodables);
+        response.setExpectedContentLength(encodedData.length());
+        if (encodedData.length())
+            handle->client()->didReceiveData(handle, encodedData.data(), encodedData.length(), 0);
+    }
+
+    handle->client()->didFinishLoading(handle, 0);
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/network/DataURL.h b/WebCore/platform/network/DataURL.h
new file mode 100644
index 0000000..33076a0
--- /dev/null
+++ b/WebCore/platform/network/DataURL.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2010 Patrick Gansterer <paroga at paroga.com>
+ *
+ * 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 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 COMPUTER, INC. OR
+ * 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 DataURL_h
+#define DataURL_h
+
+namespace WebCore {
+
+class ResourceHandle;
+
+void handleDataURL(ResourceHandle*);
+
+}
+
+#endif // DataURL_h
diff --git a/WebCore/platform/network/curl/ResourceHandleManager.cpp b/WebCore/platform/network/curl/ResourceHandleManager.cpp
index 2cc87ae..f0de23e 100644
--- a/WebCore/platform/network/curl/ResourceHandleManager.cpp
+++ b/WebCore/platform/network/curl/ResourceHandleManager.cpp
@@ -34,14 +34,13 @@
 #include "config.h"
 #include "ResourceHandleManager.h"
 
-#include "Base64.h"
+#include "DataURL.h"
 #include "HTTPParsers.h"
 #include "MIMETypeRegistry.h"
 #include "NotImplemented.h"
 #include "ResourceError.h"
 #include "ResourceHandle.h"
 #include "ResourceHandleInternal.h"
-#include "TextEncoding.h"
 
 #include <errno.h>
 #include <stdio.h>
@@ -573,67 +572,12 @@ bool ResourceHandleManager::startScheduledJobs()
     return started;
 }
 
-static void parseDataUrl(ResourceHandle* handle)
-{
-    ResourceHandleClient* client = handle->client();
-
-    ASSERT(client);
-    if (!client)
-        return;
-
-    String url = handle->firstRequest().url().string();
-    ASSERT(url.startsWith("data:", false));
-
-    int index = url.find(',');
-    if (index == -1) {
-        client->cannotShowURL(handle);
-        return;
-    }
-
-    String mediaType = url.substring(5, index - 5);
-    String data = url.substring(index + 1);
-
-    bool base64 = mediaType.endsWith(";base64", false);
-    if (base64)
-        mediaType = mediaType.left(mediaType.length() - 7);
-
-    if (mediaType.isEmpty())
-        mediaType = "text/plain;charset=US-ASCII";
-
-    String mimeType = extractMIMETypeFromMediaType(mediaType);
-    String charset = extractCharsetFromMediaType(mediaType);
-
-    ResourceResponse response;
-    response.setMimeType(mimeType);
-
-    if (base64) {
-        data = decodeURLEscapeSequences(data);
-        response.setTextEncodingName(charset);
-        client->didReceiveResponse(handle, response);
-
-        // WebCore's decoder fails on Acid3 test 97 (whitespace).
-        Vector<char> out;
-        CString latin1 = data.latin1();
-        if (base64Decode(latin1.data(), latin1.length(), out) && out.size() > 0)
-            client->didReceiveData(handle, out.data(), out.size(), 0);
-    } else {
-        // We have to convert to UTF-16 early due to limitations in KURL
-        data = decodeURLEscapeSequences(data, TextEncoding(charset));
-        response.setTextEncodingName("UTF-16");
-        client->didReceiveResponse(handle, response);
-        if (data.length() > 0)
-            client->didReceiveData(handle, reinterpret_cast<const char*>(data.characters()), data.length() * sizeof(UChar), 0);
-    }
-
-    client->didFinishLoading(handle, 0);
-}
-
 void ResourceHandleManager::dispatchSynchronousJob(ResourceHandle* job)
 {
     KURL kurl = job->firstRequest().url();
 
     if (kurl.protocolIs("data")) {
-        parseDataUrl(job);
+        handleDataURL(job);
         return;
     }
 
@@ -664,7 +608,7 @@ void ResourceHandleManager::startJob(ResourceHandle* job)
     KURL kurl = job->firstRequest().url();
 
     if (kurl.protocolIs("data")) {
-        parseDataUrl(job);
+        handleDataURL(job);
         return;
     }
 
diff --git a/WebCore/platform/network/win/ResourceHandleWin.cpp b/WebCore/platform/network/win/ResourceHandleWin.cpp
index 5de2e1b..511da88 100644
--- a/WebCore/platform/network/win/ResourceHandleWin.cpp
+++ b/WebCore/platform/network/win/ResourceHandleWin.cpp
@@ -27,6 +27,7 @@
 #include "config.h"
 #include "ResourceHandle.h"
 
+#include "DataURL.h"
 #include "HTTPParsers.h"
 #include "MIMETypeRegistry.h"
 #include "MainThread.h"
@@ -259,7 +260,7 @@ bool ResourceHandle::onRequestComplete()
 
 bool ResourceHandle::start(NetworkingContext* context)
 {
-    if (request().url().isLocalFile()) {
+    if (firstRequest().url().isLocalFile() || firstRequest().url().protocolIs("data")) {
         ref(); // balanced by deref in fileLoadTimer
         if (d->m_loadSynchronously)
             fileLoadTimer(0);
@@ -349,6 +350,11 @@ void ResourceHandle::fileLoadTimer(Timer<ResourceHandle>*)
     RefPtr<ResourceHandle> protector(this);
     deref(); // balances ref in start
 
+    if (firstRequest().url().protocolIs("data")) {
+        handleDataURL(this);
+        return;
+    }
+
     String fileName = firstRequest().url().fileSystemPath();
     HANDLE fileHandle = CreateFileW(fileName.charactersWithNullTermination(), GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list