[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 13:17:52 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit fa990e91ebf7232c1794b7a937bcdd7437ae9aeb
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Sep 10 16:19:57 2010 +0000
2010-09-10 Michael Nordman <michaeln at google.com>
Reviewed by Dumitru Daniliuc.
Decouple Blob from ScriptExecutionContext.
https://bugs.webkit.org/show_bug.cgi?id=45410
- Removed ScriptExecutionContext pointers from Blob and File constructors.
- Removed ScriptExecutionContext's collection of Blobs instance in that context.
- Refactored BlobURL to make a distinction between 'public' blob urls and 'internal'
urls that are used solely as identifiers. The former requires a SecurityOrigin to
to manufacture, the latter does not.
- Added a constant and accessor for the blob protocol scheme on the BlobURL class.
No new tests are added since this is a cleanup.
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneDeserializer::readFile):
(WebCore::CloneDeserializer::readTerminal):
* bindings/v8/SerializedScriptValue.cpp:
(WebCore::ZigZag::Reader::readBlob):
(WebCore::ZigZag::Reader::readFile):
(WebCore::ZigZag::Reader::readFileList):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
(WebCore::ScriptExecutionContext::createPublicBlobURL):
(WebCore::ScriptExecutionContext::revokePublicBlobURL):
* dom/ScriptExecutionContext.h:
* fileapi/Blob.cpp:
(WebCore::Blob::Blob):
(WebCore::Blob::~Blob):
(WebCore::Blob::slice):
* fileapi/Blob.h:
(WebCore::Blob::create):
(WebCore::Blob::url):
* fileapi/Blob.idl:
* fileapi/BlobBuilder.cpp:
(WebCore::BlobBuilder::getBlob):
* fileapi/BlobBuilder.h:
* fileapi/BlobBuilder.idl:
* fileapi/BlobURL.cpp:
(WebCore::BlobURL::createPublicURL):
(WebCore::BlobURL::createInternalURL):
(WebCore::BlobURL::getOrigin):
(WebCore::BlobURL::getIdentifier):
(WebCore::BlobURL::createBlobURL):
* fileapi/BlobURL.h:
(WebCore::BlobURL::blobProtocol):
(WebCore::BlobURL::BlobURL):
* fileapi/File.cpp:
(WebCore::File::File):
* fileapi/File.h:
(WebCore::File::create):
* fileapi/FileReader.cpp: Register a public url to perform the read.
(WebCore::FileReader::cleanup):
(WebCore::FileReader::start):
(WebCore::FileReader::didFinishLoading):
(WebCore::FileReader::failed):
* fileapi/FileReader.h: Added m_urlForReading data member.
* fileapi/FileReaderSync.cpp:
(WebCore::FileReaderSync::read): Register a public url to perform the read.
* fileapi/ThreadableBlobRegistry.cpp:
(WebCore::ThreadableBlobRegistry::registerBlobURL):
(WebCore::ThreadableBlobRegistry::unregisterBlobURL):
* fileapi/ThreadableBlobRegistry.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::appendFormData):
(WebCore::HTMLInputElement::setFileListFromRenderer):
* page/SecurityOrigin.cpp: Use BlobURL.blobProtocol().
(WebCore::SecurityOrigin::create):
(WebCore::SecurityOrigin::canRequest):
(WebCore::SecurityOrigin::canDisplay):
* platform/chromium/ClipboardChromium.cpp:
(WebCore::ClipboardChromium::files):
* platform/gtk/ClipboardGtk.cpp:
(WebCore::ClipboardGtk::files):
* platform/mac/ClipboardMac.mm:
(WebCore::ClipboardMac::files):
* platform/win/ClipboardWin.cpp:
(WebCore::ClipboardWin::files):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67208 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7a2c69c..8128fbd 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,84 @@
+2010-09-10 Michael Nordman <michaeln at google.com>
+
+ Reviewed by Dumitru Daniliuc.
+
+ Decouple Blob from ScriptExecutionContext.
+ https://bugs.webkit.org/show_bug.cgi?id=45410
+
+ - Removed ScriptExecutionContext pointers from Blob and File constructors.
+ - Removed ScriptExecutionContext's collection of Blobs instance in that context.
+ - Refactored BlobURL to make a distinction between 'public' blob urls and 'internal'
+ urls that are used solely as identifiers. The former requires a SecurityOrigin to
+ to manufacture, the latter does not.
+ - Added a constant and accessor for the blob protocol scheme on the BlobURL class.
+
+ No new tests are added since this is a cleanup.
+
+ * bindings/js/SerializedScriptValue.cpp:
+ (WebCore::CloneDeserializer::readFile):
+ (WebCore::CloneDeserializer::readTerminal):
+ * bindings/v8/SerializedScriptValue.cpp:
+ (WebCore::ZigZag::Reader::readBlob):
+ (WebCore::ZigZag::Reader::readFile):
+ (WebCore::ZigZag::Reader::readFileList):
+ * dom/ScriptExecutionContext.cpp:
+ (WebCore::ScriptExecutionContext::~ScriptExecutionContext):
+ (WebCore::ScriptExecutionContext::createPublicBlobURL):
+ (WebCore::ScriptExecutionContext::revokePublicBlobURL):
+ * dom/ScriptExecutionContext.h:
+ * fileapi/Blob.cpp:
+ (WebCore::Blob::Blob):
+ (WebCore::Blob::~Blob):
+ (WebCore::Blob::slice):
+ * fileapi/Blob.h:
+ (WebCore::Blob::create):
+ (WebCore::Blob::url):
+ * fileapi/Blob.idl:
+ * fileapi/BlobBuilder.cpp:
+ (WebCore::BlobBuilder::getBlob):
+ * fileapi/BlobBuilder.h:
+ * fileapi/BlobBuilder.idl:
+ * fileapi/BlobURL.cpp:
+ (WebCore::BlobURL::createPublicURL):
+ (WebCore::BlobURL::createInternalURL):
+ (WebCore::BlobURL::getOrigin):
+ (WebCore::BlobURL::getIdentifier):
+ (WebCore::BlobURL::createBlobURL):
+ * fileapi/BlobURL.h:
+ (WebCore::BlobURL::blobProtocol):
+ (WebCore::BlobURL::BlobURL):
+ * fileapi/File.cpp:
+ (WebCore::File::File):
+ * fileapi/File.h:
+ (WebCore::File::create):
+ * fileapi/FileReader.cpp: Register a public url to perform the read.
+ (WebCore::FileReader::cleanup):
+ (WebCore::FileReader::start):
+ (WebCore::FileReader::didFinishLoading):
+ (WebCore::FileReader::failed):
+ * fileapi/FileReader.h: Added m_urlForReading data member.
+ * fileapi/FileReaderSync.cpp:
+ (WebCore::FileReaderSync::read): Register a public url to perform the read.
+ * fileapi/ThreadableBlobRegistry.cpp:
+ (WebCore::ThreadableBlobRegistry::registerBlobURL):
+ (WebCore::ThreadableBlobRegistry::unregisterBlobURL):
+ * fileapi/ThreadableBlobRegistry.h:
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::appendFormData):
+ (WebCore::HTMLInputElement::setFileListFromRenderer):
+ * page/SecurityOrigin.cpp: Use BlobURL.blobProtocol().
+ (WebCore::SecurityOrigin::create):
+ (WebCore::SecurityOrigin::canRequest):
+ (WebCore::SecurityOrigin::canDisplay):
+ * platform/chromium/ClipboardChromium.cpp:
+ (WebCore::ClipboardChromium::files):
+ * platform/gtk/ClipboardGtk.cpp:
+ (WebCore::ClipboardGtk::files):
+ * platform/mac/ClipboardMac.mm:
+ (WebCore::ClipboardMac::files):
+ * platform/win/ClipboardWin.cpp:
+ (WebCore::ClipboardWin::files):
+
2010-09-10 Xan Lopez <xlopez at igalia.com>
Reviewed by Martin Robinson.
diff --git a/WebCore/bindings/js/SerializedScriptValue.cpp b/WebCore/bindings/js/SerializedScriptValue.cpp
index fcd3314..fa8a1ed 100644
--- a/WebCore/bindings/js/SerializedScriptValue.cpp
+++ b/WebCore/bindings/js/SerializedScriptValue.cpp
@@ -974,10 +974,8 @@ private:
Identifier type;
if (!readStringData(type))
return 0;
- if (m_isDOMGlobalObject) {
- ScriptExecutionContext* scriptExecutionContext = static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject())->scriptExecutionContext();
- file = File::create(scriptExecutionContext, String(path.ustring().impl()), KURL(KURL(), String(url.ustring().impl())), String(type.ustring().impl()));
- }
+ if (m_isDOMGlobalObject)
+ file = File::create(String(path.ustring().impl()), KURL(KURL(), String(url.ustring().impl())), String(type.ustring().impl()));
return true;
}
@@ -1074,9 +1072,7 @@ private:
return JSValue();
if (!m_isDOMGlobalObject)
return jsNull();
- ScriptExecutionContext* scriptExecutionContext = static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject())->scriptExecutionContext();
- ASSERT(scriptExecutionContext);
- return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_globalObject), Blob::create(scriptExecutionContext, KURL(KURL(), url.ustring().impl()), String(type.ustring().impl()), size));
+ return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_globalObject), Blob::create(KURL(KURL(), url.ustring().impl()), String(type.ustring().impl()), size));
}
case StringTag: {
Identifier ident;
diff --git a/WebCore/bindings/v8/SerializedScriptValue.cpp b/WebCore/bindings/v8/SerializedScriptValue.cpp
index 0b908b8..4e5354e 100644
--- a/WebCore/bindings/v8/SerializedScriptValue.cpp
+++ b/WebCore/bindings/v8/SerializedScriptValue.cpp
@@ -879,7 +879,7 @@ private:
return false;
if (!doReadUint64(&size))
return false;
- PassRefPtr<Blob> blob = Blob::create(getScriptExecutionContext(), KURL(ParsedURLString, url), type, size);
+ PassRefPtr<Blob> blob = Blob::create(KURL(ParsedURLString, url), type, size);
*value = toV8(blob);
return true;
}
@@ -895,7 +895,7 @@ private:
return false;
if (!readWebCoreString(&type))
return false;
- PassRefPtr<File> file = File::create(getScriptExecutionContext(), path, KURL(ParsedURLString, url), type);
+ PassRefPtr<File> file = File::create(path, KURL(ParsedURLString, url), type);
*value = toV8(file);
return true;
}
@@ -916,7 +916,7 @@ private:
return false;
if (!readWebCoreString(&type))
return false;
- fileList->append(File::create(getScriptExecutionContext(), path, KURL(ParsedURLString, urlString), type));
+ fileList->append(File::create(path, KURL(ParsedURLString, urlString), type));
}
*value = toV8(fileList);
return true;
diff --git a/WebCore/dom/ScriptExecutionContext.cpp b/WebCore/dom/ScriptExecutionContext.cpp
index d014d47..975dece 100644
--- a/WebCore/dom/ScriptExecutionContext.cpp
+++ b/WebCore/dom/ScriptExecutionContext.cpp
@@ -94,13 +94,10 @@ ScriptExecutionContext::~ScriptExecutionContext()
}
#endif
- HashSet<Blob*>::iterator blobsEnd = m_blobs.end();
- for (HashSet<Blob*>::iterator iter = m_blobs.begin(); iter != blobsEnd; ++iter)
- (*iter)->contextDestroyed();
#if ENABLE(BLOB)
HashSet<String>::iterator publicBlobURLsEnd = m_publicBlobURLs.end();
for (HashSet<String>::iterator iter = m_publicBlobURLs.begin(); iter != publicBlobURLsEnd; ++iter)
- ThreadableBlobRegistry::unregisterBlobURL(this, KURL(ParsedURLString, *iter));
+ ThreadableBlobRegistry::unregisterBlobURL(KURL(ParsedURLString, *iter));
#endif
}
@@ -175,18 +172,6 @@ void ScriptExecutionContext::destroyedMessagePort(MessagePort* port)
m_messagePorts.remove(port);
}
-void ScriptExecutionContext::addBlob(Blob* blob)
-{
- ASSERT(blob);
- m_blobs.add(blob);
-}
-
-void ScriptExecutionContext::removeBlob(Blob* blob)
-{
- ASSERT(blob);
- m_blobs.remove(blob);
-}
-
bool ScriptExecutionContext::canSuspendActiveDOMObjects()
{
// No protection against m_activeDOMObjects changing during iteration: canSuspend() shouldn't execute arbitrary JS.
@@ -277,8 +262,8 @@ DOMTimer* ScriptExecutionContext::findTimeout(int timeoutId)
#if ENABLE(BLOB)
KURL ScriptExecutionContext::createPublicBlobURL(Blob* blob)
{
- KURL publicURL = BlobURL::createURL(this);
- ThreadableBlobRegistry::registerBlobURL(this, publicURL, blob->url());
+ KURL publicURL = BlobURL::createPublicURL(securityOrigin());
+ ThreadableBlobRegistry::registerBlobURL(publicURL, blob->url());
m_publicBlobURLs.add(publicURL.string());
return publicURL;
}
@@ -286,7 +271,7 @@ KURL ScriptExecutionContext::createPublicBlobURL(Blob* blob)
void ScriptExecutionContext::revokePublicBlobURL(const KURL& url)
{
if (m_publicBlobURLs.contains(url.string())) {
- ThreadableBlobRegistry::unregisterBlobURL(this, url);
+ ThreadableBlobRegistry::unregisterBlobURL(url);
m_publicBlobURLs.remove(url.string());
}
}
diff --git a/WebCore/dom/ScriptExecutionContext.h b/WebCore/dom/ScriptExecutionContext.h
index 30c12e5..55fa539 100644
--- a/WebCore/dom/ScriptExecutionContext.h
+++ b/WebCore/dom/ScriptExecutionContext.h
@@ -131,8 +131,6 @@ namespace WebCore {
void removeTimeout(int timeoutId);
DOMTimer* findTimeout(int timeoutId);
- void addBlob(Blob*);
- void removeBlob(Blob*);
#if ENABLE(BLOB)
KURL createPublicBlobURL(Blob*);
void revokePublicBlobURL(const KURL&);
@@ -167,7 +165,6 @@ namespace WebCore {
HashMap<int, DOMTimer*> m_timeouts;
- HashSet<Blob*> m_blobs;
#if ENABLE(BLOB)
HashSet<String> m_publicBlobURLs;
#endif
diff --git a/WebCore/fileapi/Blob.cpp b/WebCore/fileapi/Blob.cpp
index 5fed327..d5a5602 100644
--- a/WebCore/fileapi/Blob.cpp
+++ b/WebCore/fileapi/Blob.cpp
@@ -33,57 +33,37 @@
#include "BlobURL.h"
#include "File.h"
-#include "ScriptExecutionContext.h"
#include "ThreadableBlobRegistry.h"
namespace WebCore {
-Blob::Blob(ScriptExecutionContext* scriptExecutionContext, PassOwnPtr<BlobData> blobData, long long size)
- : m_scriptExecutionContext(scriptExecutionContext)
- , m_type(blobData->contentType())
+Blob::Blob(PassOwnPtr<BlobData> blobData, long long size)
+ : m_type(blobData->contentType())
, m_size(size)
{
ASSERT(blobData);
- m_scriptExecutionContext->addBlob(this);
-
// Create a new internal URL and register it with the provided blob data.
- m_url = BlobURL::createURL(scriptExecutionContext);
- ThreadableBlobRegistry::registerBlobURL(scriptExecutionContext, m_url, blobData);
+ m_internalURL = BlobURL::createInternalURL();
+ ThreadableBlobRegistry::registerBlobURL(m_internalURL, blobData);
}
-Blob::Blob(ScriptExecutionContext* scriptExecutionContext, const KURL& srcURL, const String& type, long long size)
- : m_scriptExecutionContext(scriptExecutionContext)
- , m_type(type)
+Blob::Blob(const KURL& srcURL, const String& type, long long size)
+ : m_type(type)
, m_size(size)
{
- m_scriptExecutionContext->addBlob(this);
-
// Create a new internal URL and register it with the same blob data as the source URL.
- m_url = BlobURL::createURL(scriptExecutionContext);
- ThreadableBlobRegistry::registerBlobURL(scriptExecutionContext, m_url, srcURL);
+ m_internalURL = BlobURL::createInternalURL();
+ ThreadableBlobRegistry::registerBlobURL(m_internalURL, srcURL);
}
Blob::~Blob()
{
- // The internal URL is only used to refer to the Blob object. So we need to unregister the URL when the object is GC-ed.
- if (m_scriptExecutionContext) {
- m_scriptExecutionContext->removeBlob(this);
- ThreadableBlobRegistry::unregisterBlobURL(m_scriptExecutionContext, m_url);
- }
-}
-
-void Blob::contextDestroyed()
-{
- ASSERT(m_scriptExecutionContext);
-
- // Unregister the internal URL before the context is gone.
- ThreadableBlobRegistry::unregisterBlobURL(m_scriptExecutionContext, m_url);
- m_scriptExecutionContext = 0;
+ ThreadableBlobRegistry::unregisterBlobURL(m_internalURL);
}
#if ENABLE(BLOB)
-PassRefPtr<Blob> Blob::slice(ScriptExecutionContext* scriptExecutionContext, long long start, long long length, const String& contentType) const
+PassRefPtr<Blob> Blob::slice(long long start, long long length, const String& contentType) const
{
// When we slice a file for the first time, we obtain a snapshot of the file by capturing its current size and modification time.
// The modification time will be used to verify if the file has been changed or not, when the underlying data are accessed.
@@ -114,9 +94,9 @@ PassRefPtr<Blob> Blob::slice(ScriptExecutionContext* scriptExecutionContext, lon
if (isFile())
blobData->appendFile(static_cast<const File*>(this)->path(), start, length, modificationTime);
else
- blobData->appendBlob(m_url, start, length);
+ blobData->appendBlob(m_internalURL, start, length);
- return Blob::create(scriptExecutionContext, blobData.release(), length);
+ return Blob::create(blobData.release(), length);
}
#endif
diff --git a/WebCore/fileapi/Blob.h b/WebCore/fileapi/Blob.h
index 0d5649c..2690ff5 100644
--- a/WebCore/fileapi/Blob.h
+++ b/WebCore/fileapi/Blob.h
@@ -41,46 +41,42 @@
namespace WebCore {
-class ScriptExecutionContext;
-
class Blob : public RefCounted<Blob> {
public:
- static PassRefPtr<Blob> create(ScriptExecutionContext* scriptExecutionContext, PassOwnPtr<BlobData> blobData, long long size)
+ static PassRefPtr<Blob> create(PassOwnPtr<BlobData> blobData, long long size)
{
- return adoptRef(new Blob(scriptExecutionContext, blobData, size));
+ return adoptRef(new Blob(blobData, size));
}
// For deserialization.
- static PassRefPtr<Blob> create(ScriptExecutionContext* scriptExecutionContext, const KURL& srcURL, const String& type, long long size)
+ static PassRefPtr<Blob> create(const KURL& srcURL, const String& type, long long size)
{
- return adoptRef(new Blob(scriptExecutionContext, srcURL, type, size));
+ return adoptRef(new Blob(srcURL, type, size));
}
virtual ~Blob();
- void contextDestroyed();
-
- const KURL& url() const { return m_url; }
+ const KURL& url() const { return m_internalURL; }
const String& type() const { return m_type; }
virtual unsigned long long size() const { return static_cast<unsigned long long>(m_size); }
virtual bool isFile() const { return false; }
#if ENABLE(BLOB)
- PassRefPtr<Blob> slice(ScriptExecutionContext*, long long start, long long length, const String& contentType = String()) const;
+ PassRefPtr<Blob> slice(long long start, long long length, const String& contentType = String()) const;
#endif
protected:
- Blob(ScriptExecutionContext*, PassOwnPtr<BlobData>, long long size);
+ Blob(PassOwnPtr<BlobData>, long long size);
// For deserialization.
- Blob(ScriptExecutionContext*, const KURL& srcURL, const String& type, long long size);
+ Blob(const KURL& srcURL, const String& type, long long size);
- // This is an internal URL referring to the blob data associated with this object.
- // It is only used by FileReader to read the blob data via loading from the blob URL resource.
- KURL m_url;
+ // This is an internal URL referring to the blob data associated with this object. It serves
+ // as an identifier for this blob. The internal URL is never used to source the blob's content
+ // into an HTML or for FileRead'ing, public blob URLs must be used for those purposes.
+ KURL m_internalURL;
- ScriptExecutionContext* m_scriptExecutionContext;
String m_type;
long long m_size;
};
diff --git a/WebCore/fileapi/Blob.idl b/WebCore/fileapi/Blob.idl
index b220233..297d039 100644
--- a/WebCore/fileapi/Blob.idl
+++ b/WebCore/fileapi/Blob.idl
@@ -38,7 +38,7 @@ module html {
#if !defined(LANGUAGE_OBJECTIVE_C)
#if defined(ENABLE_BLOB) && ENABLE_BLOB
- [CallWith=ScriptExecutionContext] Blob slice(in long long start, in long long length, in [Optional, ConvertUndefinedOrNullToNullString] DOMString contentType);
+ Blob slice(in long long start, in long long length, in [Optional, ConvertUndefinedOrNullToNullString] DOMString contentType);
#endif
#endif
};
diff --git a/WebCore/fileapi/BlobBuilder.cpp b/WebCore/fileapi/BlobBuilder.cpp
index e10df6b..34864a5 100644
--- a/WebCore/fileapi/BlobBuilder.cpp
+++ b/WebCore/fileapi/BlobBuilder.cpp
@@ -117,13 +117,13 @@ bool BlobBuilder::append(PassRefPtr<Blob> blob)
return true;
}
-PassRefPtr<Blob> BlobBuilder::getBlob(ScriptExecutionContext* scriptExecutionContext, const String& contentType)
+PassRefPtr<Blob> BlobBuilder::getBlob(const String& contentType)
{
OwnPtr<BlobData> blobData = BlobData::create();
blobData->setContentType(contentType);
blobData->swapItems(m_items);
- RefPtr<Blob> blob = Blob::create(scriptExecutionContext, blobData.release(), m_size);
+ RefPtr<Blob> blob = Blob::create(blobData.release(), m_size);
// After creating a blob from the current blob data, we do not need to keep the data around any more. Instead, we only
// need to keep a reference to the URL of the blob just created.
diff --git a/WebCore/fileapi/BlobBuilder.h b/WebCore/fileapi/BlobBuilder.h
index 20e510a..a981e31 100644
--- a/WebCore/fileapi/BlobBuilder.h
+++ b/WebCore/fileapi/BlobBuilder.h
@@ -41,7 +41,6 @@
namespace WebCore {
class Blob;
-class ScriptExecutionContext;
class TextEncoding;
typedef int ExceptionCode;
@@ -54,7 +53,7 @@ public:
bool append(const String& text, ExceptionCode&);
bool append(const String& text, const String& ending, ExceptionCode&);
- PassRefPtr<Blob> getBlob(ScriptExecutionContext*, const String& contentType = String());
+ PassRefPtr<Blob> getBlob(const String& contentType = String());
private:
BlobBuilder();
diff --git a/WebCore/fileapi/BlobBuilder.idl b/WebCore/fileapi/BlobBuilder.idl
index 53c7add..0da9314 100644
--- a/WebCore/fileapi/BlobBuilder.idl
+++ b/WebCore/fileapi/BlobBuilder.idl
@@ -35,7 +35,7 @@ module html {
NoStaticTables
] BlobBuilder {
#if !defined(LANGUAGE_OBJECTIVE_C)
- [CallWith=ScriptExecutionContext] Blob getBlob(in [Optional, ConvertUndefinedOrNullToNullString] DOMString contentType);
+ Blob getBlob(in [Optional, ConvertUndefinedOrNullToNullString] DOMString contentType);
#endif
void append(in Blob blob);
void append(in DOMString value, in [Optional, ConvertUndefinedOrNullToNullString] DOMString endings) raises (DOMException);
diff --git a/WebCore/fileapi/BlobURL.cpp b/WebCore/fileapi/BlobURL.cpp
index c5571a7..47ebe8d 100644
--- a/WebCore/fileapi/BlobURL.cpp
+++ b/WebCore/fileapi/BlobURL.cpp
@@ -34,28 +34,27 @@
#include "KURL.h"
#include "PlatformString.h"
-#include "ScriptExecutionContext.h"
#include "SecurityOrigin.h"
#include "UUID.h"
namespace WebCore {
-KURL BlobURL::createURL(ScriptExecutionContext* scriptExecutionContext)
+const char BlobURL::kBlobProtocol[] = "blob";
+
+KURL BlobURL::createPublicURL(SecurityOrigin* securityOrigin)
{
- // Create the blob URL in the following format:
- // blob:%escaped_origin%/%UUID%
- // The origin of the host page is encoded in the URL value to allow easy lookup of the origin when the security check needs
- // to be performed.
- String urlString = "blob:";
- urlString += encodeWithURLEscapeSequences(scriptExecutionContext->securityOrigin()->toString());
- urlString += "/";
- urlString += createCanonicalUUIDString();
- return KURL(ParsedURLString, urlString);
+ ASSERT(securityOrigin);
+ return createBlobURL(securityOrigin->toString());
+}
+
+KURL BlobURL::createInternalURL()
+{
+ return createBlobURL("blobinternal://");
}
KURL BlobURL::getOrigin(const KURL& url)
{
- ASSERT(url.protocolIs("blob"));
+ ASSERT(url.protocolIs(kBlobProtocol));
unsigned startIndex = url.pathStart();
unsigned afterEndIndex = url.pathAfterLastSlash();
@@ -65,10 +64,20 @@ KURL BlobURL::getOrigin(const KURL& url)
String BlobURL::getIdentifier(const KURL& url)
{
- ASSERT(url.protocolIs("blob"));
+ ASSERT(url.protocolIs(kBlobProtocol));
unsigned startIndex = url.pathAfterLastSlash();
return url.string().substring(startIndex);
}
+KURL BlobURL::createBlobURL(const String& originString)
+{
+ String urlString = kBlobProtocol;
+ urlString += ":";
+ urlString += encodeWithURLEscapeSequences(originString);
+ urlString += "/";
+ urlString += createCanonicalUUIDString();
+ return KURL(ParsedURLString, urlString);
+}
+
} // namespace WebCore
diff --git a/WebCore/fileapi/BlobURL.h b/WebCore/fileapi/BlobURL.h
index e73b771..4526e63 100644
--- a/WebCore/fileapi/BlobURL.h
+++ b/WebCore/fileapi/BlobURL.h
@@ -35,13 +35,29 @@
namespace WebCore {
-class ScriptExecutionContext;
+class SecurityOrigin;
+// Blob URLs are of the form
+// blob:%escaped_origin%/%UUID%
+// For public urls, the origin of the host page is encoded in the URL value to
+// allow easy lookup of the origin when security checks need to be performed.
+// When loading blobs via ResourceHandle or when reading blobs via FileReader
+// the loader conducts security checks that examine the origin of host page
+// encoded in the public blob url. The origin baked into internal blob urls
+// is a simple constant value, "blobinternal://", internal urls should not
+// be used with ResourceHandle or FileReader.
class BlobURL {
public:
- static KURL createURL(ScriptExecutionContext*);
+ static KURL createPublicURL(SecurityOrigin*);
+ static KURL createInternalURL();
static KURL getOrigin(const KURL&);
- static String getIdentifier(const KURL& url);
+ static String getIdentifier(const KURL&);
+ static const char* blobProtocol() { return kBlobProtocol; }
+
+private:
+ static KURL createBlobURL(const String& originString);
+ static const char kBlobProtocol[];
+ BlobURL() { }
};
}
diff --git a/WebCore/fileapi/File.cpp b/WebCore/fileapi/File.cpp
index 150a05b..51ada6c 100644
--- a/WebCore/fileapi/File.cpp
+++ b/WebCore/fileapi/File.cpp
@@ -26,7 +26,6 @@
#include "config.h"
#include "File.h"
-#include "BlobRegistry.h"
#include "FileSystem.h"
#include "MIMETypeRegistry.h"
@@ -45,23 +44,23 @@ static PassOwnPtr<BlobData> createBlobDataForFile(const String& path)
return blobData.release();
}
-File::File(ScriptExecutionContext* scriptExecutionContext, const String& path)
- : Blob(scriptExecutionContext, createBlobDataForFile(path), -1)
+File::File(const String& path)
+ : Blob(createBlobDataForFile(path), -1)
, m_path(path)
, m_name(pathGetFileName(path))
{
}
-File::File(ScriptExecutionContext* scriptExecutionContext, const String& path, const KURL& url, const String& type)
- : Blob(scriptExecutionContext, url, type, -1)
+File::File(const String& path, const KURL& url, const String& type)
+ : Blob(url, type, -1)
, m_path(path)
{
m_name = pathGetFileName(path);
}
#if ENABLE(DIRECTORY_UPLOAD)
-File::File(ScriptExecutionContext* scriptExecutionContext, const String& relativePath, const String& path)
- : Blob(scriptExecutionContext, createBlobDataForFile(path), -1)
+File::File(const String& relativePath, const String& path)
+ : Blob(createBlobDataForFile(path), -1)
, m_path(path)
, m_relativePath(relativePath)
{
diff --git a/WebCore/fileapi/File.h b/WebCore/fileapi/File.h
index d6446d3..06b03cd 100644
--- a/WebCore/fileapi/File.h
+++ b/WebCore/fileapi/File.h
@@ -34,25 +34,24 @@
namespace WebCore {
class KURL;
-class ScriptExecutionContext;
class File : public Blob {
public:
- static PassRefPtr<File> create(ScriptExecutionContext* scriptExecutionContext, const String& path)
+ static PassRefPtr<File> create(const String& path)
{
- return adoptRef(new File(scriptExecutionContext, path));
+ return adoptRef(new File(path));
}
// For deserialization.
- static PassRefPtr<File> create(ScriptExecutionContext* scriptExecutionContext, const String& path, const KURL& srcURL, const String& type)
+ static PassRefPtr<File> create(const String& path, const KURL& srcURL, const String& type)
{
- return adoptRef(new File(scriptExecutionContext, path, srcURL, type));
+ return adoptRef(new File(path, srcURL, type));
}
#if ENABLE(DIRECTORY_UPLOAD)
- static PassRefPtr<File> create(ScriptExecutionContext* scriptExecutionContext, const String& relativePath, const String& path)
+ static PassRefPtr<File> create(const String& relativePath, const String& path)
{
- return adoptRef(new File(scriptExecutionContext, relativePath, path));
+ return adoptRef(new File(relativePath, path));
}
#endif
@@ -74,13 +73,13 @@ public:
unsigned long long fileSize() const { return size(); }
private:
- File(ScriptExecutionContext*, const String& path);
+ File(const String& path);
// For deserialization.
- File(ScriptExecutionContext*, const String& path, const KURL& srcURL, const String& type);
+ File(const String& path, const KURL& srcURL, const String& type);
#if ENABLE(DIRECTORY_UPLOAD)
- File(ScriptExecutionContext*, const String& relativePath, const String& path);
+ File(const String& relativePath, const String& path);
#endif
String m_path;
diff --git a/WebCore/fileapi/FileReader.cpp b/WebCore/fileapi/FileReader.cpp
index 747b6ff..8036468 100644
--- a/WebCore/fileapi/FileReader.cpp
+++ b/WebCore/fileapi/FileReader.cpp
@@ -36,6 +36,7 @@
#include "Base64.h"
#include "Blob.h"
+#include "BlobURL.h"
#include "CrossThreadTask.h"
#include "File.h"
#include "Logging.h"
@@ -44,6 +45,7 @@
#include "ResourceRequest.h"
#include "ScriptExecutionContext.h"
#include "TextResourceDecoder.h"
+#include "ThreadableBlobRegistry.h"
#include "ThreadableLoader.h"
#include <wtf/CurrentTime.h>
@@ -154,17 +156,27 @@ void FileReader::terminate()
{
if (m_loader) {
m_loader->cancel();
- m_loader = 0;
+ cleanup();
}
m_state = Completed;
}
+void FileReader::cleanup()
+{
+ m_loader = 0;
+ ThreadableBlobRegistry::unregisterBlobURL(m_urlForReading);
+ m_urlForReading = KURL();
+}
+
void FileReader::start()
{
m_state = Opening;
- // The blob is read by routing through the request handling layer given the blob url.
- ResourceRequest request(m_blob->url());
+ // The blob is read by routing through the request handling layer given a temporary public url.
+ m_urlForReading = BlobURL::createPublicURL(scriptExecutionContext()->securityOrigin());
+ ThreadableBlobRegistry::registerBlobURL(m_urlForReading, m_blob->url());
+
+ ResourceRequest request(m_urlForReading);
request.setHTTPMethod("GET");
ThreadableLoaderOptions options;
@@ -230,7 +242,7 @@ void FileReader::didFinishLoading(unsigned long)
fireEvent(eventNames().loadEvent);
fireEvent(eventNames().loadendEvent);
- m_loader = 0;
+ cleanup();
}
void FileReader::didFail(const ResourceError&)
@@ -247,7 +259,7 @@ void FileReader::failed(int httpStatusCode)
fireEvent(eventNames().errorEvent);
fireEvent(eventNames().loadendEvent);
- m_loader = 0;
+ cleanup();
}
ExceptionCode FileReader::httpStatusCodeToExceptionCode(int httpStatusCode)
diff --git a/WebCore/fileapi/FileReader.h b/WebCore/fileapi/FileReader.h
index 48ce229..68c0f83 100644
--- a/WebCore/fileapi/FileReader.h
+++ b/WebCore/fileapi/FileReader.h
@@ -36,6 +36,7 @@
#include "ActiveDOMObject.h"
#include "EventTarget.h"
#include "FileError.h"
+#include "KURL.h"
#include "PlatformString.h"
#include "ScriptString.h"
#include "TextEncoding.h"
@@ -130,6 +131,7 @@ private:
virtual EventTargetData* ensureEventTargetData() { return &m_eventTargetData; }
void terminate();
+ void cleanup();
void readInternal(Blob*, ReadType);
void failed(int httpStatusCode);
void fireErrorEvent(int httpStatusCode);
@@ -141,6 +143,7 @@ private:
EventTargetData m_eventTargetData;
RefPtr<Blob> m_blob;
+ KURL m_urlForReading;
ReadType m_readType;
TextEncoding m_encoding;
diff --git a/WebCore/fileapi/FileReaderSync.cpp b/WebCore/fileapi/FileReaderSync.cpp
index a907044..6c76714 100644
--- a/WebCore/fileapi/FileReaderSync.cpp
+++ b/WebCore/fileapi/FileReaderSync.cpp
@@ -36,11 +36,13 @@
#include "Base64.h"
#include "Blob.h"
+#include "BlobURL.h"
#include "FileReader.h"
#include "ResourceRequest.h"
#include "ScriptExecutionContext.h"
#include "TextEncoding.h"
#include "TextResourceDecoder.h"
+#include "ThreadableBlobRegistry.h"
#include "ThreadableLoader.h"
namespace WebCore {
@@ -149,12 +151,16 @@ const ScriptString& FileReaderSync::readAsDataURL(ScriptExecutionContext* script
void FileReaderSync::read(ScriptExecutionContext* scriptExecutionContext, Blob* blob, ReadType readType, ExceptionCode& ec)
{
- // The blob is read by routing through the request handling layer given the blob url.
- ResourceRequest request(blob->url());
+ // The blob is read by routing through the request handling layer given the temporary public url.
+ KURL urlForReading = BlobURL::createPublicURL(scriptExecutionContext->securityOrigin());
+ ThreadableBlobRegistry::registerBlobURL(urlForReading, blob->url());
+
+ ResourceRequest request(urlForReading);
request.setHTTPMethod("GET");
FileReaderSyncLoader loader((readType == ReadAsBinaryString) ? &m_result : 0);
loader.start(scriptExecutionContext, request, ec);
+ ThreadableBlobRegistry::unregisterBlobURL(urlForReading);
if (ec)
return;
diff --git a/WebCore/fileapi/ThreadableBlobRegistry.cpp b/WebCore/fileapi/ThreadableBlobRegistry.cpp
index 034557b..7e0745f 100644
--- a/WebCore/fileapi/ThreadableBlobRegistry.cpp
+++ b/WebCore/fileapi/ThreadableBlobRegistry.cpp
@@ -34,7 +34,6 @@
#include "BlobData.h"
#include "BlobRegistry.h"
-#include "ScriptExecutionContext.h"
#include <wtf/MainThread.h>
namespace WebCore {
@@ -70,7 +69,7 @@ static void registerBlobURLTask(void* context)
blobRegistry().registerBlobURL(blobRegistryContext->url, blobRegistryContext->blobData.release());
}
-void ThreadableBlobRegistry::registerBlobURL(ScriptExecutionContext*, const KURL& url, PassOwnPtr<BlobData> blobData)
+void ThreadableBlobRegistry::registerBlobURL(const KURL& url, PassOwnPtr<BlobData> blobData)
{
if (isMainThread())
blobRegistry().registerBlobURL(url, blobData);
@@ -86,7 +85,7 @@ static void registerBlobURLFromTask(void* context)
blobRegistry().registerBlobURL(blobRegistryContext->url, blobRegistryContext->srcURL);
}
-void ThreadableBlobRegistry::registerBlobURL(ScriptExecutionContext*, const KURL& url, const KURL& srcURL)
+void ThreadableBlobRegistry::registerBlobURL(const KURL& url, const KURL& srcURL)
{
if (isMainThread())
blobRegistry().registerBlobURL(url, srcURL);
@@ -102,7 +101,7 @@ static void unregisterBlobURLTask(void* context)
blobRegistry().unregisterBlobURL(blobRegistryContext->url);
}
-void ThreadableBlobRegistry::unregisterBlobURL(ScriptExecutionContext*, const KURL& url)
+void ThreadableBlobRegistry::unregisterBlobURL(const KURL& url)
{
if (isMainThread())
blobRegistry().unregisterBlobURL(url);
@@ -114,15 +113,15 @@ void ThreadableBlobRegistry::unregisterBlobURL(ScriptExecutionContext*, const KU
#else
-void ThreadableBlobRegistry::registerBlobURL(ScriptExecutionContext*, const KURL&, PassOwnPtr<BlobData>)
+void ThreadableBlobRegistry::registerBlobURL(const KURL&, PassOwnPtr<BlobData>)
{
}
-void ThreadableBlobRegistry::registerBlobURL(ScriptExecutionContext*, const KURL&, const KURL&)
+void ThreadableBlobRegistry::registerBlobURL(const KURL&, const KURL&)
{
}
-void ThreadableBlobRegistry::unregisterBlobURL(ScriptExecutionContext*, const KURL&)
+void ThreadableBlobRegistry::unregisterBlobURL(const KURL&)
{
}
#endif // ENABL(BLOB)
diff --git a/WebCore/fileapi/ThreadableBlobRegistry.h b/WebCore/fileapi/ThreadableBlobRegistry.h
index 7dce6bb..fe7df7f 100644
--- a/WebCore/fileapi/ThreadableBlobRegistry.h
+++ b/WebCore/fileapi/ThreadableBlobRegistry.h
@@ -37,13 +37,12 @@ namespace WebCore {
class BlobData;
class KURL;
-class ScriptExecutionContext;
class ThreadableBlobRegistry {
public:
- static void registerBlobURL(ScriptExecutionContext*, const KURL&, PassOwnPtr<BlobData>);
- static void registerBlobURL(ScriptExecutionContext*, const KURL&, const KURL& srcURL);
- static void unregisterBlobURL(ScriptExecutionContext*, const KURL&);
+ static void registerBlobURL(const KURL&, PassOwnPtr<BlobData>);
+ static void registerBlobURL(const KURL&, const KURL& srcURL);
+ static void unregisterBlobURL(const KURL&);
};
} // namespace WebCore
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index a169918..bdce256 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -1453,7 +1453,7 @@ bool HTMLInputElement::appendFormData(FormDataList& encoding, bool multipart)
// If no filename at all is entered, return successful but empty.
// Null would be more logical, but Netscape posts an empty file. Argh.
if (!numFiles) {
- encoding.appendBlob(name(), File::create(document()->scriptExecutionContext(), ""));
+ encoding.appendBlob(name(), File::create(""));
return true;
}
@@ -2096,15 +2096,15 @@ void HTMLInputElement::setFileListFromRenderer(const Vector<String>& paths)
for (int i = 0; i < size; i++) {
// Normalize backslashes to slashes before exposing the relative path to script.
String relativePath = paths[i].substring(1 + rootPath.length()).replace('\\','/');
- m_fileList->append(File::create(document()->scriptExecutionContext(), relativePath, paths[i]));
+ m_fileList->append(File::create(relativePath, paths[i]));
}
} else {
for (int i = 0; i < size; i++)
- m_fileList->append(File::create(document()->scriptExecutionContext(), paths[i]));
+ m_fileList->append(File::create(paths[i]));
}
#else
for (int i = 0; i < size; i++)
- m_fileList->append(File::create(document()->scriptExecutionContext(), paths[i]));
+ m_fileList->append(File::create(paths[i]));
#endif
setFormControlValueMatchesRenderer(true);
diff --git a/WebCore/page/SecurityOrigin.cpp b/WebCore/page/SecurityOrigin.cpp
index b44a35e..14320e3 100644
--- a/WebCore/page/SecurityOrigin.cpp
+++ b/WebCore/page/SecurityOrigin.cpp
@@ -125,7 +125,7 @@ PassRefPtr<SecurityOrigin> SecurityOrigin::create(const KURL& url, SandboxFlags
if (!url.isValid())
return adoptRef(new SecurityOrigin(KURL(), sandboxFlags));
#if ENABLE(BLOB)
- if (url.protocolIs("blob"))
+ if (url.protocolIs(BlobURL::blobProtocol()))
return adoptRef(new SecurityOrigin(BlobURL::getOrigin(url), sandboxFlags));
#endif
return adoptRef(new SecurityOrigin(url, sandboxFlags));
@@ -240,7 +240,7 @@ bool SecurityOrigin::canRequest(const KURL& url) const
bool doUniqueOriginCheck = true;
#if ENABLE(BLOB)
// For blob scheme, we want to ignore this check.
- doUniqueOriginCheck = !url.protocolIs("blob");
+ doUniqueOriginCheck = !url.protocolIs(BlobURL::blobProtocol());
#endif
if (doUniqueOriginCheck && targetOrigin->isUnique())
return false;
@@ -287,7 +287,7 @@ bool SecurityOrigin::isAccessWhiteListed(const SecurityOrigin* targetOrigin) con
bool SecurityOrigin::canDisplay(const KURL& url, const String& referrer, Document* document)
{
#if ENABLE(BLOB)
- if (url.protocolIs("blob") && document) {
+ if (url.protocolIs(BlobURL::blobProtocol()) && document) {
SecurityOrigin* documentOrigin = document->securityOrigin();
RefPtr<SecurityOrigin> targetOrigin = SecurityOrigin::create(url);
return documentOrigin->isSameSchemeHostPort(targetOrigin.get());
diff --git a/WebCore/platform/chromium/ClipboardChromium.cpp b/WebCore/platform/chromium/ClipboardChromium.cpp
index aff1466..3d82aea 100644
--- a/WebCore/platform/chromium/ClipboardChromium.cpp
+++ b/WebCore/platform/chromium/ClipboardChromium.cpp
@@ -364,10 +364,9 @@ PassRefPtr<FileList> ClipboardChromium::files() const
if (!m_dataObject || m_dataObject->filenames.isEmpty())
return FileList::create();
- ScriptExecutionContext* scriptExecutionContext = m_frame->document()->scriptExecutionContext();
RefPtr<FileList> fileList = FileList::create();
for (size_t i = 0; i < m_dataObject->filenames.size(); ++i)
- fileList->append(File::create(scriptExecutionContext, m_dataObject->filenames.at(i)));
+ fileList->append(File::create(m_dataObject->filenames.at(i)));
return fileList.release();
}
diff --git a/WebCore/platform/gtk/ClipboardGtk.cpp b/WebCore/platform/gtk/ClipboardGtk.cpp
index 3fe5ba1..327f069 100644
--- a/WebCore/platform/gtk/ClipboardGtk.cpp
+++ b/WebCore/platform/gtk/ClipboardGtk.cpp
@@ -265,9 +265,8 @@ PassRefPtr<FileList> ClipboardGtk::files() const
RefPtr<FileList> fileList = FileList::create();
Vector<String> fileVector(m_dataObject->files());
- ScriptExecutionContext* scriptExecutionContext = m_frame->document()->scriptExecutionContext();
for (size_t i = 0; i < fileVector.size(); i++)
- fileList->append(File::create(scriptExecutionContext, fileVector[i]));
+ fileList->append(File::create(fileVector[i]));
return fileList.release();
}
diff --git a/WebCore/platform/mac/ClipboardMac.mm b/WebCore/platform/mac/ClipboardMac.mm
index 0cbb3f6..bdd190e 100644
--- a/WebCore/platform/mac/ClipboardMac.mm
+++ b/WebCore/platform/mac/ClipboardMac.mm
@@ -313,12 +313,11 @@ PassRefPtr<FileList> ClipboardMac::files() const
NSArray *absoluteURLs = absoluteURLsFromPasteboardFilenames(m_pasteboard.get());
NSUInteger count = [absoluteURLs count];
- ScriptExecutionContext* scriptExecutionContext = m_frame->document()->scriptExecutionContext();
RefPtr<FileList> fileList = FileList::create();
for (NSUInteger x = 0; x < count; x++) {
NSURL *absoluteURL = [NSURL URLWithString:[absoluteURLs objectAtIndex:x]];
ASSERT([absoluteURL isFileURL]);
- fileList->append(File::create(scriptExecutionContext, [absoluteURL path]));
+ fileList->append(File::create([absoluteURL path]));
}
return fileList.release(); // We will always return a FileList, sometimes empty
}
diff --git a/WebCore/platform/win/ClipboardWin.cpp b/WebCore/platform/win/ClipboardWin.cpp
index 6d9930c..b13473a 100644
--- a/WebCore/platform/win/ClipboardWin.cpp
+++ b/WebCore/platform/win/ClipboardWin.cpp
@@ -604,13 +604,12 @@ PassRefPtr<FileList> ClipboardWin::files() const
if (!hdrop)
return files.release();
- ScriptExecutionContext* scriptExecutionContext = m_frame->document()->scriptExecutionContext();
WCHAR filename[MAX_PATH];
UINT fileCount = DragQueryFileW(hdrop, 0xFFFFFFFF, 0, 0);
for (UINT i = 0; i < fileCount; i++) {
if (!DragQueryFileW(hdrop, i, filename, ARRAYSIZE(filename)))
continue;
- files->append(File::create(scriptExecutionContext, reinterpret_cast<UChar*>(filename)));
+ files->append(File::create(reinterpret_cast<UChar*>(filename)));
}
GlobalUnlock(medium.hGlobal);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list