Switch indexeddb to use supplemental IDL for DOMWindow
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jan 2012 06:06:50 +0000 (06:06 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jan 2012 06:06:50 +0000 (06:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76723

Patch by Mark Pilgrim <pilgrim@chromium.org> on 2012-01-20
Reviewed by Adam Barth.

No new tests required, all existing tests pass.

* Modules/indexeddb: Added.
* Modules/indexeddb/DOMWindowIndexedDatabase.cpp: Added. webkitIndexedDB() method previously in DOMWindow.cpp
(WebCore::DOMWindowIndexedDatabase::DOMWindowIndexedDatabase):
(WebCore::DOMWindowIndexedDatabase::~DOMWindowIndexedDatabase):
(WebCore::DOMWindowIndexedDatabase::webkitIndexedDB):
* Modules/indexeddb/DOMWindowIndexedDatabase.h: Added.
* Modules/indexeddb/DOMWindowIndexedDatabase.idl: Added. attributes previously in DOMWindow.idl
* WebCore.gyp/WebCore.gyp: add Modules/indexeddb/ directory
* WebCore.gypi: add Modules/indexeddb/*
* page/DOMWindow.cpp: remove webkitIndexedDB() method, add accessor methods for m_idbFactory
(WebCore::DOMWindow::getIDBFactory):
(WebCore::DOMWindow::setIDBFactory):
* page/DOMWindow.h:
* page/DOMWindow.idl:

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp [new file with mode: 0644]
Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.h [new file with mode: 0644]
Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.idl [new file with mode: 0644]
Source/WebCore/WebCore.gyp/WebCore.gyp
Source/WebCore/WebCore.gypi
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DOMWindow.h
Source/WebCore/page/DOMWindow.idl

index d2b740c..4b7d5ab 100644 (file)
@@ -1,3 +1,27 @@
+2012-01-20  Mark Pilgrim  <pilgrim@chromium.org>
+
+        Switch indexeddb to use supplemental IDL for DOMWindow
+        https://bugs.webkit.org/show_bug.cgi?id=76723
+
+        Reviewed by Adam Barth.
+
+        No new tests required, all existing tests pass.
+
+        * Modules/indexeddb: Added.
+        * Modules/indexeddb/DOMWindowIndexedDatabase.cpp: Added. webkitIndexedDB() method previously in DOMWindow.cpp
+        (WebCore::DOMWindowIndexedDatabase::DOMWindowIndexedDatabase):
+        (WebCore::DOMWindowIndexedDatabase::~DOMWindowIndexedDatabase):
+        (WebCore::DOMWindowIndexedDatabase::webkitIndexedDB):
+        * Modules/indexeddb/DOMWindowIndexedDatabase.h: Added.
+        * Modules/indexeddb/DOMWindowIndexedDatabase.idl: Added. attributes previously in DOMWindow.idl
+        * WebCore.gyp/WebCore.gyp: add Modules/indexeddb/ directory
+        * WebCore.gypi: add Modules/indexeddb/*
+        * page/DOMWindow.cpp: remove webkitIndexedDB() method, add accessor methods for m_idbFactory
+        (WebCore::DOMWindow::getIDBFactory):
+        (WebCore::DOMWindow::setIDBFactory):
+        * page/DOMWindow.h:
+        * page/DOMWindow.idl:
+
 2012-01-20  David Levin  <levin@chromium.org>
 
         Allow isContextThread to be called while in ~ScriptExecutionContext.
diff --git a/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp b/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp
new file mode 100644 (file)
index 0000000..9b40c5a
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2011, Google 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 "config.h"
+#include "DOMWindowIndexedDatabase.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "DOMWindow.h"
+#include "Document.h"
+#include "IDBFactory.h"
+#include "Page.h"
+#include "PageGroup.h"
+#include "SecurityOrigin.h"
+
+namespace WebCore {
+
+DOMWindowIndexedDatabase::DOMWindowIndexedDatabase()
+{
+}
+
+DOMWindowIndexedDatabase::~DOMWindowIndexedDatabase()
+{
+}
+
+IDBFactory* DOMWindowIndexedDatabase::webkitIndexedDB(DOMWindow* window)
+{
+    Document* document = window->document();
+    if (!document)
+        return 0;
+
+    Page* page = document->page();
+    if (!page)
+        return 0;
+
+    if (!document->securityOrigin()->canAccessDatabase())
+        return 0;
+
+    if (!window->idbFactory() && window->isCurrentlyDisplayedInFrame())
+        window->setIDBFactory(IDBFactory::create(page->group().idbFactory()));
+    return window->idbFactory();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.h b/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.h
new file mode 100644 (file)
index 0000000..960c144
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2011, Google 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 DOMWindowIndexedDatabase_h
+#define DOMWindowIndexedDatabase_h
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+class IDBFactory;
+class DOMWindow;
+
+class DOMWindowIndexedDatabase {
+public:
+    static IDBFactory* webkitIndexedDB(DOMWindow*);
+
+private:
+    DOMWindowIndexedDatabase();
+    ~DOMWindowIndexedDatabase();
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
+
+#endif // DOMWindowIndexedDatabase_h
diff --git a/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.idl b/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.idl
new file mode 100644 (file)
index 0000000..6caaf45
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Google 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 COMPUTER, INC. ``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.
+ */
+
+module window {
+
+    interface [
+        Conditional=INDEXED_DATABASE,
+        Supplemental=DOMWindow
+    ] DOMWindowIndexedDatabase {
+        readonly attribute IDBFactory webkitIndexedDB;
+
+        attribute IDBCursorConstructor webkitIDBCursor;
+        attribute IDBDatabaseConstructor webkitIDBDatabase;
+        attribute IDBDatabaseErrorConstructor webkitIDBDatabaseError;
+        attribute IDBDatabaseExceptionConstructor webkitIDBDatabaseException;
+        attribute IDBFactoryConstructor webkitIDBFactory;
+        attribute IDBIndexConstructor webkitIDBIndex;
+        attribute IDBKeyRangeConstructor webkitIDBKeyRange;
+        attribute IDBObjectStoreConstructor webkitIDBObjectStore;
+        attribute IDBRequestConstructor webkitIDBRequest;
+        attribute IDBTransactionConstructor webkitIDBTransaction;
+    };
+
+}
index 3b9715c..0cfd0e4 100644 (file)
@@ -53,6 +53,7 @@
       '../..',
       '../Modules/gamepad',
       '../Modules/intents',
+      '../Modules/indexeddb',
       '../accessibility',
       '../accessibility/chromium',
       '../bindings',
index bbcc948..2f10937 100644 (file)
             'Modules/gamepad/Gamepad.idl',
             'Modules/gamepad/GamepadList.idl',
             'Modules/gamepad/NavigatorGamepad.idl',
+            'Modules/indexeddb/DOMWindowIndexedDatabase.idl',
             'Modules/intents/DOMWindowIntents.idl',
             'Modules/intents/Intent.idl',
             'Modules/intents/IntentResultCallback.idl',
             'Modules/gamepad/GamepadList.h',
             'Modules/gamepad/NavigatorGamepad.cpp',
             'Modules/gamepad/NavigatorGamepad.h',
+            'Modules/indexeddb/DOMWindowIndexedDatabase.cpp',
+            'Modules/indexeddb/DOMWindowIndexedDatabase.h',
             'Modules/intents/Intent.cpp',
             'Modules/intents/Intent.h',
             'Modules/intents/IntentRequest.cpp',
index dfc2eb9..12a099c 100644 (file)
@@ -750,22 +750,9 @@ void DOMWindow::resetGeolocation()
 }
 
 #if ENABLE(INDEXED_DATABASE)
-IDBFactory* DOMWindow::webkitIndexedDB() const
+void DOMWindow::setIDBFactory(PassRefPtr<IDBFactory> idbFactory)
 {
-    Document* document = this->document();
-    if (!document)
-        return 0;
-
-    Page* page = document->page();
-    if (!page)
-        return 0;
-
-    if (!document->securityOrigin()->canAccessDatabase())
-        return 0;
-
-    if (!m_idbFactory && isCurrentlyDisplayedInFrame())
-        m_idbFactory = IDBFactory::create(page->group().idbFactory());
-    return m_idbFactory.get();
+    m_idbFactory = idbFactory;
 }
 #endif
 
index 5d2f363..b58668e 100644 (file)
@@ -372,10 +372,6 @@ namespace WebCore {
         void webkitResolveLocalFileSystemURL(const String&, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
 #endif
 
-#if ENABLE(INDEXED_DATABASE)
-        IDBFactory* webkitIndexedDB() const;
-#endif
-
 #if ENABLE(NOTIFICATIONS)
         NotificationCenter* webkitNotifications() const;
         // Renders webkitNotifications object safely inoperable, disconnects
@@ -416,6 +412,11 @@ namespace WebCore {
         // by the document that is currently active in m_frame.
         bool isCurrentlyDisplayedInFrame() const;
 
+#if ENABLE(INDEXED_DATABASE)
+        IDBFactory* idbFactory() { return m_idbFactory.get(); }
+        void setIDBFactory(PassRefPtr<IDBFactory>);
+#endif
+
     private:
         explicit DOMWindow(Frame*);
 
index e5f1278..14228d7 100644 (file)
@@ -172,20 +172,6 @@ module window {
 #if defined(ENABLE_NOTIFICATIONS) && ENABLE_NOTIFICATIONS
         readonly attribute [EnabledAtRuntime] NotificationCenter webkitNotifications;
 #endif
-#if defined(ENABLE_INDEXED_DATABASE) && ENABLE_INDEXED_DATABASE
-        readonly attribute IDBFactory webkitIndexedDB;
-
-        attribute IDBCursorConstructor webkitIDBCursor;
-        attribute IDBDatabaseConstructor webkitIDBDatabase;
-        attribute IDBDatabaseErrorConstructor webkitIDBDatabaseError;
-        attribute IDBDatabaseExceptionConstructor webkitIDBDatabaseException;
-        attribute IDBFactoryConstructor webkitIDBFactory;
-        attribute IDBIndexConstructor webkitIDBIndex;
-        attribute IDBKeyRangeConstructor webkitIDBKeyRange;
-        attribute IDBObjectStoreConstructor webkitIDBObjectStore;
-        attribute IDBRequestConstructor webkitIDBRequest;
-        attribute IDBTransactionConstructor webkitIDBTransaction;
-#endif
 #if defined(ENABLE_FILE_SYSTEM) && ENABLE_FILE_SYSTEM
         const unsigned short TEMPORARY = 0;
         const unsigned short PERSISTENT = 1;