Unreviewed, rolling out r105486.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jan 2012 05:07:14 +0000 (05:07 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jan 2012 05:07:14 +0000 (05:07 +0000)
http://trac.webkit.org/changeset/105486
https://bugs.webkit.org/show_bug.cgi?id=77182

This patch doesn't take web workers into account. (Requested
by dave_levin on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-01-26

Source/WebCore:

* html/DOMURL.cpp:
(WebCore::DOMURL::DOMURL):
(WebCore::DOMURL::~DOMURL):
(WebCore::DOMURL::contextDestroyed):
(WebCore):
(WebCore::DOMURL::createObjectURL):
(WebCore::DOMURL::revokeObjectURL):
* html/DOMURL.h:
(WebCore::DOMURL::create):
(DOMURL):
* html/DOMURL.idl:
* page/DOMWindow.cpp:
(WebCore):
(WebCore::DOMWindow::webkitURL):
* page/DOMWindow.h:
(DOMWindow):
():
* page/DOMWindow.idl:
* workers/WorkerContext.cpp:
(WebCore):
(WebCore::WorkerContext::webkitURL):
(WebCore::WorkerContext::webkitRequestFileSystem):
* workers/WorkerContext.h:
(WorkerContext):
():
* workers/WorkerContext.idl:

LayoutTests:

* fast/dom/DOMURL/check-instanceof-domurl-functions-expected.txt: Removed.
* fast/dom/DOMURL/check-instanceof-domurl-functions.html: Removed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106087 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/DOMURL/check-instanceof-domurl-functions-expected.txt [deleted file]
LayoutTests/fast/dom/DOMURL/check-instanceof-domurl-functions.html [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/html/DOMURL.cpp
Source/WebCore/html/DOMURL.h
Source/WebCore/html/DOMURL.idl
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DOMWindow.h
Source/WebCore/page/DOMWindow.idl
Source/WebCore/workers/WorkerContext.cpp
Source/WebCore/workers/WorkerContext.h
Source/WebCore/workers/WorkerContext.idl

index a85d232..9f669d2 100644 (file)
@@ -1,3 +1,15 @@
+2012-01-26  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r105486.
+        http://trac.webkit.org/changeset/105486
+        https://bugs.webkit.org/show_bug.cgi?id=77182
+
+        This patch doesn't take web workers into account. (Requested
+        by dave_levin on #webkit).
+
+        * fast/dom/DOMURL/check-instanceof-domurl-functions-expected.txt: Removed.
+        * fast/dom/DOMURL/check-instanceof-domurl-functions.html: Removed.
+
 2012-01-26  Yuzo Fujishima  <yuzo@google.com>
 
         [chromium] Unreviewed test expectation change.
diff --git a/LayoutTests/fast/dom/DOMURL/check-instanceof-domurl-functions-expected.txt b/LayoutTests/fast/dom/DOMURL/check-instanceof-domurl-functions-expected.txt
deleted file mode 100644 (file)
index 1d8c3b2..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-Test instanceof functions and properties of webkitURL.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS 'createObjectURL' in webkitURL is true
-PASS 'revokeObjectURL' in webkitURL is true
-PASS url.createObjectURL is undefined.
-PASS url.revokeObjectURL is undefined.
-PASS window.webkitURL.createObjectURL is defined.
-PASS window.webkitURL.revokeObjectURL is defined.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/fast/dom/DOMURL/check-instanceof-domurl-functions.html b/LayoutTests/fast/dom/DOMURL/check-instanceof-domurl-functions.html
deleted file mode 100644 (file)
index 3aa5c4d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-<script src="../../js/resources/js-test-pre.js"></script>
-</head>
-<body>
-<script>
-description("Test instanceof functions and properties of webkitURL.");
-
-var url = new webkitURL;
-
-shouldBeTrue("'createObjectURL' in webkitURL");
-shouldBeTrue("'revokeObjectURL' in webkitURL");
-
-shouldBeUndefined("url.createObjectURL");
-shouldBeUndefined("url.revokeObjectURL");
-
-shouldBeDefined("window.webkitURL.createObjectURL");
-shouldBeDefined("window.webkitURL.revokeObjectURL");
-
-
-</script>
-<script src="../../js/resources/js-test-post.js"></script>
-</body>
-</html>
index f63566f..1486d3e 100644 (file)
@@ -1,3 +1,39 @@
+2012-01-26  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r105486.
+        http://trac.webkit.org/changeset/105486
+        https://bugs.webkit.org/show_bug.cgi?id=77182
+
+        This patch doesn't take web workers into account. (Requested
+        by dave_levin on #webkit).
+
+        * html/DOMURL.cpp:
+        (WebCore::DOMURL::DOMURL):
+        (WebCore::DOMURL::~DOMURL):
+        (WebCore::DOMURL::contextDestroyed):
+        (WebCore):
+        (WebCore::DOMURL::createObjectURL):
+        (WebCore::DOMURL::revokeObjectURL):
+        * html/DOMURL.h:
+        (WebCore::DOMURL::create):
+        (DOMURL):
+        * html/DOMURL.idl:
+        * page/DOMWindow.cpp:
+        (WebCore):
+        (WebCore::DOMWindow::webkitURL):
+        * page/DOMWindow.h:
+        (DOMWindow):
+        ():
+        * page/DOMWindow.idl:
+        * workers/WorkerContext.cpp:
+        (WebCore):
+        (WebCore::WorkerContext::webkitURL):
+        (WebCore::WorkerContext::webkitRequestFileSystem):
+        * workers/WorkerContext.h:
+        (WorkerContext):
+        ():
+        * workers/WorkerContext.idl:
+
 2012-01-26  Noel Gordon  <noel.gordon@gmail.com>
 
         Cleanup JPEGImageDecoder includes
index 3b72ac9..e42060d 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
- * Copyright (C) 2011 Motorola Mobility Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #include "config.h"
-#include "DOMURL.h"
-
-#include "ActiveDOMObject.h"
-#include "KURL.h"
-#include "SecurityOrigin.h"
-#include <wtf/MainThread.h>
 
 #if ENABLE(BLOB)
+
+#include "DOMURL.h"
+
 #include "Blob.h"
 #include "BlobURL.h"
+#include "KURL.h"
 #include "ScriptExecutionContext.h"
 #include "ThreadableBlobRegistry.h"
-#include <wtf/PassOwnPtr.h>
+#include <wtf/MainThread.h>
+
 #if ENABLE(MEDIA_STREAM)
 #include "MediaStream.h"
 #include "MediaStreamRegistry.h"
 #endif
-#endif
 
 namespace WebCore {
 
-#if ENABLE(BLOB)
-class PublicURLManager;
-typedef HashMap<ScriptExecutionContext*, OwnPtr<PublicURLManager> > PublicURLManagerMap;
-static PublicURLManagerMap& publicURLManagerMap();
-
-class PublicURLManager : public ContextDestructionObserver {
-public:
-    explicit PublicURLManager(ScriptExecutionContext* scriptExecutionContext)
-        : ContextDestructionObserver(scriptExecutionContext) { }
-
-    virtual void contextDestroyed()
-    {
-        HashSet<String>::iterator blobURLsEnd = m_blobURLs.end();
-        for (HashSet<String>::iterator iter = m_blobURLs.begin(); iter != blobURLsEnd; ++iter)
-            ThreadableBlobRegistry::unregisterBlobURL(KURL(ParsedURLString, *iter));
-
-#if ENABLE(MEDIA_STREAM)
-        HashSet<String>::iterator streamURLsEnd = m_streamURLs.end();
-        for (HashSet<String>::iterator iter = m_streamURLs.begin(); iter != streamURLsEnd; ++iter)
-            MediaStreamRegistry::registry().unregisterMediaStreamURL(KURL(ParsedURLString, *iter));
-#endif
-
-        ScriptExecutionContext* context = scriptExecutionContext();
-        ContextDestructionObserver::contextDestroyed();
-        publicURLManagerMap().remove(context);
-    }
-
-    HashSet<String>& blobURLs() { return m_blobURLs; }
-#if ENABLE(MEDIA_STREAM)
-    HashSet<String>& streamURLs() { return m_streamURLs; }
-#endif
-
-private:
-    HashSet<String> m_blobURLs;
-#if ENABLE(MEDIA_STREAM)
-    HashSet<String> m_streamURLs;
-#endif
-};
-
-static PublicURLManagerMap& publicURLManagerMap()
+DOMURL::DOMURL(ScriptExecutionContext* scriptExecutionContext)
+    : ContextDestructionObserver(scriptExecutionContext)
 {
-    DEFINE_STATIC_LOCAL(PublicURLManagerMap, staticPublicURLManagers, ());
-    return staticPublicURLManagers;
 }
 
-static PublicURLManager& publicURLManager(ScriptExecutionContext* scriptExecutionContext)
+DOMURL::~DOMURL()
 {
-    PublicURLManagerMap& map = publicURLManagerMap();
-    OwnPtr<PublicURLManager>& manager = map.add(scriptExecutionContext, nullptr).first->second;
-    if (!manager)
-        manager = adoptPtr(new PublicURLManager(scriptExecutionContext));
-    return *manager;
 }
 
-static HashSet<String>& publicBlobURLs(ScriptExecutionContext* scriptExecutionContext)
+void DOMURL::contextDestroyed()
 {
-    return publicURLManager(scriptExecutionContext).blobURLs();
-}
+    ContextDestructionObserver::contextDestroyed();
+
+    HashSet<String>::iterator publicBlobURLsEnd = m_publicBlobURLs.end();
+    for (HashSet<String>::iterator iter = m_publicBlobURLs.begin(); iter != publicBlobURLsEnd; ++iter)
+        ThreadableBlobRegistry::unregisterBlobURL(KURL(ParsedURLString, *iter));
 
 #if ENABLE(MEDIA_STREAM)
-static HashSet<String>& publicStreamURLs(ScriptExecutionContext* scriptExecutionContext)
-{
-    return publicURLManager(scriptExecutionContext).streamURLs();
+    HashSet<String>::iterator publicStreamURLsEnd = m_publicStreamURLs.end();
+    for (HashSet<String>::iterator iter = m_publicStreamURLs.begin(); iter != publicStreamURLsEnd; ++iter)
+        MediaStreamRegistry::registry().unregisterMediaStreamURL(KURL(ParsedURLString, *iter));
+#endif
 }
 
-String DOMURL::createObjectURL(ScriptExecutionContext* scriptExecutionContext, MediaStream* stream)
+#if ENABLE(MEDIA_STREAM)
+String DOMURL::createObjectURL(MediaStream* stream)
 {
-    if (!scriptExecutionContext || !stream)
+    if (!m_scriptExecutionContext || !stream)
         return String();
 
-    KURL publicURL = BlobURL::createPublicURL(scriptExecutionContext->securityOrigin());
+    KURL publicURL = BlobURL::createPublicURL(scriptExecutionContext()->securityOrigin());
     if (publicURL.isEmpty())
         return String();
 
@@ -124,51 +81,50 @@ String DOMURL::createObjectURL(ScriptExecutionContext* scriptExecutionContext, M
     ASSERT(isMainThread());
 
     MediaStreamRegistry::registry().registerMediaStreamURL(publicURL, stream);
-    publicStreamURLs(scriptExecutionContext).add(publicURL.string());
+    m_publicStreamURLs.add(publicURL.string());
 
     return publicURL.string();
 }
 #endif
 
-String DOMURL::createObjectURL(ScriptExecutionContext* scriptExecutionContext, Blob* blob)
+String DOMURL::createObjectURL(Blob* blob)
 {
-    if (!scriptExecutionContext || !blob)
+    if (!m_scriptExecutionContext || !blob)
         return String();
 
-    KURL publicURL = BlobURL::createPublicURL(scriptExecutionContext->securityOrigin());
+    KURL publicURL = BlobURL::createPublicURL(scriptExecutionContext()->securityOrigin());
     if (publicURL.isEmpty())
         return String();
 
     ThreadableBlobRegistry::registerBlobURL(publicURL, blob->url());
-    publicBlobURLs(scriptExecutionContext).add(publicURL.string());
+    m_publicBlobURLs.add(publicURL.string());
 
     return publicURL.string();
 }
 
-void DOMURL::revokeObjectURL(ScriptExecutionContext* scriptExecutionContext, const String& urlString)
+void DOMURL::revokeObjectURL(const String& urlString)
 {
-    if (!scriptExecutionContext)
+    if (!m_scriptExecutionContext)
         return;
 
     KURL url(KURL(), urlString);
 
-    HashSet<String>& blobURLs = publicBlobURLs(scriptExecutionContext);
-    if (blobURLs.contains(url.string())) {
+    if (m_publicBlobURLs.contains(url.string())) {
         ThreadableBlobRegistry::unregisterBlobURL(url);
-        blobURLs.remove(url.string());
+        m_publicBlobURLs.remove(url.string());
     }
+
 #if ENABLE(MEDIA_STREAM)
-    HashSet<String>& streamURLs = publicStreamURLs(scriptExecutionContext);
-    if (streamURLs.contains(url.string())) {
+    if (m_publicStreamURLs.contains(url.string())) {
         // FIXME: make sure of this assertion below. Raise a spec question if required.
         // Since WebWorkers cannot obtain Stream objects, we should be on the main thread.
         ASSERT(isMainThread());
         MediaStreamRegistry::registry().unregisterMediaStreamURL(url);
-        streamURLs.remove(url.string());
+        m_publicStreamURLs.remove(url.string());
     }
 #endif
 }
-#endif // ENABLE(BLOB)
 
 } // namespace WebCore
 
+#endif // ENABLE(BLOB)
index bd4fe8b..d02fe88 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
- * Copyright (C) 2011 Motorola Mobility Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #ifndef DOMURL_h
 #define DOMURL_h
 
-#include "KURL.h"
+#if ENABLE(BLOB)
+
+#include "ActiveDOMObject.h"
 #include "PlatformString.h"
+#include <wtf/HashSet.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 
@@ -38,22 +40,30 @@ class Blob;
 class MediaStream;
 class ScriptExecutionContext;
 
-class DOMURL : public RefCounted<DOMURL> {
-
+class DOMURL : public RefCounted<DOMURL>, public ContextDestructionObserver {
 public:
-    static PassRefPtr<DOMURL> create() { return adoptRef(new DOMURL); }
-
-#if ENABLE(BLOB)
-    static void contextDestroyed(ScriptExecutionContext*);
+    static PassRefPtr<DOMURL> create(ScriptExecutionContext* scriptExecutionContext) { return adoptRef(new DOMURL(scriptExecutionContext)); }
+    ~DOMURL();
 
-    static String createObjectURL(ScriptExecutionContext*, Blob*);
-    static void revokeObjectURL(ScriptExecutionContext*, const String&);
 #if ENABLE(MEDIA_STREAM)
-    static String createObjectURL(ScriptExecutionContext*, MediaStream*);
+    String createObjectURL(MediaStream*);
 #endif
+    String createObjectURL(Blob*);
+    void revokeObjectURL(const String&);
+
+private:
+    explicit DOMURL(ScriptExecutionContext*);
+
+    virtual void contextDestroyed();
+
+    HashSet<String> m_publicBlobURLs;
+#if ENABLE(MEDIA_STREAM)
+    HashSet<String> m_publicStreamURLs;
 #endif
 };
 
 } // namespace WebCore
 
+#endif // ENABLE(BLOB)
+
 #endif // DOMURL_h
index d0acad6..d6d5579 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
- * Copyright (C) 2011 Motorola Mobility Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 module html {
     interface [
         Conditional=BLOB,
+        OmitConstructor,
         GenerateNativeConverter,
         GenerateToJS,
-        Constructor
+        NoStaticTables
     ] DOMURL {
 #if defined(ENABLE_MEDIA_STREAM) && ENABLE_MEDIA_STREAM
-        static [ConvertNullStringTo=Undefined,CallWith=ScriptExecutionContext] DOMString createObjectURL(in MediaStream stream);
+        [ConvertNullStringTo=Undefined] DOMString createObjectURL(in MediaStream stream);
 #endif
-        static [ConvertNullStringTo=Undefined,CallWith=ScriptExecutionContext] DOMString createObjectURL(in Blob blob);
-        static [CallWith=ScriptExecutionContext] void revokeObjectURL(in DOMString url);
+        [ConvertNullStringTo=Undefined] DOMString createObjectURL(in Blob blob);
+        void revokeObjectURL(in DOMString url);
     };
 }
index 12a099c..afc611f 100644 (file)
@@ -1887,6 +1887,15 @@ void DOMWindow::showModalDialog(const String& urlString, const String& dialogFea
     dialogFrame->page()->chrome()->runModal();
 }
 
+#if ENABLE(BLOB)
+DOMURL* DOMWindow::webkitURL() const
+{
+    if (!m_domURL && isCurrentlyDisplayedInFrame())
+        m_domURL = DOMURL::create(this->scriptExecutionContext());
+    return m_domURL.get();
+}
+#endif
+
 #if ENABLE(QUOTA)
 StorageInfo* DOMWindow::webkitStorageInfo() const
 {
index b58668e..0916bff 100644 (file)
@@ -351,6 +351,10 @@ namespace WebCore {
         using RefCounted<DOMWindow>::ref;
         using RefCounted<DOMWindow>::deref;
 
+#if ENABLE(BLOB)
+        DOMURL* webkitURL() const;
+#endif
+
 #if ENABLE(DEVICE_ORIENTATION)
         DEFINE_ATTRIBUTE_EVENT_LISTENER(devicemotion);
         DEFINE_ATTRIBUTE_EVENT_LISTENER(deviceorientation);
index 99e2bc4..14f6189 100644 (file)
@@ -783,7 +783,7 @@ module window {
 
         attribute [Conditional=BLOB] WebKitBlobBuilderConstructor WebKitBlobBuilder;
 
-        attribute [Conditional=BLOB] DOMURLConstructor webkitURL;
+        readonly attribute [Conditional=BLOB] DOMURL webkitURL;
 
 #if defined(ENABLE_QUOTA) && ENABLE_QUOTA
         readonly attribute [EnabledAtRuntime=Quota] StorageInfo webkitStorageInfo;
index 4aec69d..8f24330 100644 (file)
@@ -377,6 +377,15 @@ EventTargetData* WorkerContext::ensureEventTargetData()
     return &m_eventTargetData;
 }
 
+#if ENABLE(BLOB)
+DOMURL* WorkerContext::webkitURL() const
+{
+    if (!m_domURL)
+        m_domURL = DOMURL::create(this->scriptExecutionContext());
+    return m_domURL.get();
+}
+#endif
+
 #if ENABLE(FILE_SYSTEM)
 void WorkerContext::webkitRequestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
 {
index b55f392..5850374 100644 (file)
@@ -131,6 +131,10 @@ namespace WebCore {
         virtual bool isContextThread() const;
         virtual bool isJSExecutionForbidden() const;
 
+#if ENABLE(BLOB)
+        DOMURL* webkitURL() const;
+#endif
+
 #if ENABLE(FILE_SYSTEM)
         enum FileSystemType {
             TEMPORARY,
index c64027d..d04f06b 100644 (file)
@@ -101,7 +101,7 @@ module threads {
         attribute FileReaderSyncConstructor FileReaderSync;
 #endif
 
-        attribute [Conditional=BLOB] DOMURLConstructor webkitURL;
+        readonly attribute [Conditional=BLOB] DOMURL webkitURL;
 
 #if defined(ENABLE_FILE_SYSTEM) && ENABLE_FILE_SYSTEM
         const unsigned short TEMPORARY = 0;