Make disabling the database feature (ENABLE_DATABASE=0) work by
placing various #ifdefs into the code and making the compilation of
some files optional.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@26877 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c11dc28..7edea29 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2007-10-22  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars.
+
+        Make disabling the database feature (ENABLE_DATABASE=0) work by
+        placing various #ifdefs into the code and making the compilation of
+        some files optional.
+
+        * WebCore.pro:
+        * dom/Document.cpp:
+        (WebCore::Document::~Document):
+        (WebCore::Document::defaultEventHandler):
+        * dom/Document.h:
+        * page/DOMWindow.cpp:
+        * page/DOMWindow.h:
+        * page/DOMWindow.idl:
+        * page/InspectorController.cpp:
+        (WebCore::InspectorController::windowScriptObjectAvailable):
+        (WebCore::InspectorController::populateScriptResources):
+        (WebCore::InspectorController::clearDatabaseScriptResources):
+        (WebCore::InspectorController::didCommitLoad):
+        * page/InspectorController.h:
+
 2007-10-22  Alp Toker  <alp@atoker.com>
 
         Reviewed by Mark Rowe.
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 6e75ef7..9f83f5b 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -297,11 +297,6 @@
     page/DOMWindow.idl \
     page/History.idl \
     page/Screen.idl \
-    storage/Database.idl \
-    storage/SQLResultSetRowList.idl \
-    storage/VersionChangeCallback.idl \
-    storage/SQLCallback.idl \
-    storage/SQLResultSet.idl \
     xml/DOMParser.idl \
     xml/XMLSerializer.idl
 
@@ -315,9 +310,6 @@
     bindings/js/JSCSSValueCustom.cpp \
     bindings/js/JSCustomXPathNSResolver.cpp \
     bindings/js/JSCustomVersionChangeCallback.cpp \
-    bindings/js/JSCustomSQLCallback.cpp \
-    bindings/js/JSDatabaseCustom.cpp \
-    bindings/js/JSSQLResultSetRowListCustom.cpp \
     bindings/js/JSDocumentCustom.cpp \
     bindings/js/JSDOMExceptionConstructor.cpp \
     bindings/js/JSDOMWindowCustom.cpp \
@@ -982,7 +974,18 @@
         storage/DatabaseThread.cpp \
         storage/DatabaseTracker.cpp \
         storage/SQLResultSet.cpp \
-        storage/SQLResultSetRowList.cpp
+        storage/SQLResultSetRowList.cpp \
+        bindings/js/JSCustomSQLCallback.cpp \
+        bindings/js/JSDatabaseCustom.cpp \
+        bindings/js/JSSQLResultSetRowListCustom.cpp
+
+    IDL_BINDINGS += \
+        storage/Database.idl \
+        storage/SQLResultSetRowList.idl \
+        storage/VersionChangeCallback.idl \
+        storage/SQLCallback.idl \
+        storage/SQLResultSet.idl
+
 }
 
 contains(DEFINES, ENABLE_ICONDATABASE=1) {
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 3790b20..7ddc474 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -435,10 +435,12 @@
     for (unsigned i = 0; i < count; i++)
         deleteAllValues(m_nameCollectionInfo[i]);
 
+#if ENABLE(DATABASE)
     if (m_databaseThread) {
         m_databaseThread->documentGoingAway();
         m_databaseThread = 0;
     }
+#endif
 
     if (m_styleSheets)
         m_styleSheets->documentDestroyed();
@@ -3734,6 +3736,7 @@
         element->updateFocusAppearance(false);
 }
 
+#if ENABLE(DATABASE)
 DatabaseThread* Document::databaseThread()
 {
     if (!m_databaseThread) {
@@ -3744,5 +3747,6 @@
 
     return m_databaseThread.get();
 }
+#endif
 
 } // namespace WebCore
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index 3d863e8..8827ef3 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -856,7 +856,9 @@
 
     bool processingLoadEvent() const { return m_processingLoadEvent; }
 
+#if ENABLE(DATABASE)
     DatabaseThread* databaseThread();
+#endif
 protected:
     void clearXMLVersion() { m_xmlVersion = String(); }
 
@@ -922,7 +924,9 @@
 
     unsigned m_numNodeLists;
 
+#if ENABLE(DATABASE)
     RefPtr<DatabaseThread> m_databaseThread;
+#endif
 #if USE(LOW_BANDWIDTH_DISPLAY)
     bool m_inLowBandwidthDisplay;
 #endif
diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp
index 0d22da9..b09907f 100644
--- a/WebCore/page/DOMWindow.cpp
+++ b/WebCore/page/DOMWindow.cpp
@@ -550,6 +550,7 @@
     return page->chrome()->scaleFactor();
 }
 
+#if ENABLE(DATABASE)
 PassRefPtr<Database> DOMWindow::openDatabase(const String& name, const String& version, ExceptionCode& e)
 {
     if (!m_frame)
@@ -562,5 +563,6 @@
 
     return Database::openDatabase(doc, name, version, e);
 }
+#endif
 
 } // namespace WebCore
diff --git a/WebCore/page/DOMWindow.h b/WebCore/page/DOMWindow.h
index 763a13a..35913ab 100644
--- a/WebCore/page/DOMWindow.h
+++ b/WebCore/page/DOMWindow.h
@@ -131,8 +131,10 @@
         PassRefPtr<CSSRuleList> getMatchedCSSRules(Element*, const String& pseudoElt, bool authorOnly = true) const;
         double devicePixelRatio() const;
 
+#if ENABLE(DATABASE)
         // HTML 5 client-side database
         PassRefPtr<Database> openDatabase(const String& name, const String& version, ExceptionCode&);
+#endif
 
     private:
         Frame* m_frame;
diff --git a/WebCore/page/DOMWindow.idl b/WebCore/page/DOMWindow.idl
index b7149dd..1d0b3d9 100644
--- a/WebCore/page/DOMWindow.idl
+++ b/WebCore/page/DOMWindow.idl
@@ -110,8 +110,10 @@
                                        in [Optional] boolean authorOnly);
         readonly attribute double devicePixelRatio;
 
+#if defined(ENABLE_DATABASE)
         Database openDatabase(in DOMString name, in DOMString version)
             raises(DOMException);
+#endif
 
 #if defined(LANGUAGE_JAVASCRIPT)
         // Global constructors
diff --git a/WebCore/page/InspectorController.cpp b/WebCore/page/InspectorController.cpp
index e7da291..4a7dc41 100644
--- a/WebCore/page/InspectorController.cpp
+++ b/WebCore/page/InspectorController.cpp
@@ -479,6 +479,7 @@
     return array;
 }
 
+#if ENABLE(DATABASE)
 static JSValueRef databaseTableNames(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* /*exception*/)
 {
     InspectorController* controller = reinterpret_cast<InspectorController*>(JSObjectGetPrivate(thisObject));
@@ -517,6 +518,7 @@
 
     return result;
 }
+#endif
 
 static JSValueRef inspectedWindow(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef[] /*arguments[]*/, JSValueRef* /*exception*/)
 {
@@ -707,7 +709,9 @@
         { "detach", detach, kJSPropertyAttributeNone },
         { "log", log, kJSPropertyAttributeNone },
         { "search", search, kJSPropertyAttributeNone },
+#if ENABLE(DATABASE)
         { "databaseTableNames", databaseTableNames, kJSPropertyAttributeNone },
+#endif
         { "inspectedWindow", inspectedWindow, kJSPropertyAttributeNone },
         { 0, 0, 0 }
     };
@@ -1087,11 +1091,14 @@
     for (unsigned i = 0; i < messageCount; ++i)
         addScriptConsoleMessage(m_consoleMessages[i]);
 
+#if ENABLE(DATABASE)
     DatabaseResourcesSet::iterator databasesEnd = m_databaseResources.end();
     for (DatabaseResourcesSet::iterator it = m_databaseResources.begin(); it != databasesEnd; ++it)
         addDatabaseScriptResource((*it).get());
+#endif
 }
 
+#if ENABLE(DATABASE)
 JSObjectRef InspectorController::addDatabaseScriptResource(InspectorDatabaseResource* resource)
 {
     ASSERT_ARG(resource, resource);
@@ -1160,6 +1167,7 @@
 
     resource->setScriptObject(0, 0);
 }
+#endif
 
 void InspectorController::addScriptConsoleMessage(const ConsoleMessage* message)
 {
@@ -1217,6 +1225,7 @@
 
 void InspectorController::clearDatabaseScriptResources()
 {
+#if ENABLE(DATABASE)
     if (!m_scriptContext || !m_scriptObject)
         return;
 
@@ -1227,6 +1236,7 @@
     }
 
     callClearFunction(m_scriptContext, m_scriptObject, "clearDatabaseResources");
+#endif
 }
 
 void InspectorController::clearScriptConsoleMessages()
@@ -1278,11 +1288,15 @@
         deleteAllValues(m_consoleMessages);
         m_consoleMessages.clear();
 
+#if ENABLE(DATABASE)
         m_databaseResources.clear();
+#endif
 
         if (windowVisible()) {
             clearScriptConsoleMessages();
+#if ENABLE(DATABASE)
             clearDatabaseScriptResources();
+#endif
             clearNetworkTimeline();
 
             // We don't add the main resource until its load is committed. This
@@ -1488,6 +1502,7 @@
     }
 }
 
+#if ENABLE(DATABASE)
 void InspectorController::didOpenDatabase(Database* database, const String& domain, const String& name, const String& version)
 {
     if (!enabled())
@@ -1500,5 +1515,6 @@
     if (windowVisible())
         addDatabaseScriptResource(resource);
 }
+#endif
 
 } // namespace WebCore
diff --git a/WebCore/page/InspectorController.h b/WebCore/page/InspectorController.h
index 890c717..5bae5fa 100644
--- a/WebCore/page/InspectorController.h
+++ b/WebCore/page/InspectorController.h
@@ -99,7 +99,9 @@
     void didFinishLoading(DocumentLoader*, unsigned long identifier);
     void didFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&);
 
+#if ENABLE(DATABASE)
     void didOpenDatabase(Database*, const String& domain, const String& name, const String& version);
+#endif
 
     const ResourcesMap& resources() const { return m_resources; }
 
@@ -128,8 +130,10 @@
     void pruneResources(ResourcesMap*, DocumentLoader* loaderToKeep = 0);
     void removeAllResources(ResourcesMap* map) { pruneResources(map); }
 
+#if ENABLE(DATABASE)
     JSObjectRef addDatabaseScriptResource(InspectorDatabaseResource*);
     void removeDatabaseScriptResource(InspectorDatabaseResource*);
+#endif
 
     Page* m_inspectedPage;
     InspectorClient* m_client;
@@ -139,7 +143,9 @@
     ResourcesMap m_resources;
     FrameResourcesMap m_frameResources;
     Vector<ConsoleMessage*> m_consoleMessages;
+#if ENABLE(DATABASE)
     DatabaseResourcesSet m_databaseResources;
+#endif
     JSObjectRef m_scriptObject;
     JSObjectRef m_controllerScriptObject;
     JSContextRef m_scriptContext;