2009-12-03 Pavel Feldman <pfeldman@dhcp-172-28-174-220.spb.corp.google.com>
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Dec 2009 12:46:59 +0000 (12:46 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Dec 2009 12:46:59 +0000 (12:46 +0000)
        Reviewed by Timothy Hatcher.

        Web Inspector: Simplify the settings support in inspector controller.

        https://bugs.webkit.org/show_bug.cgi?id=32076

        Test: inspector/settings-set-get.html

        * WebCore.Inspector.exp:
        * bindings/js/JSInspectorFrontendHostCustom.cpp:
        * bindings/v8/custom/V8InspectorFrontendHostCustom.cpp:
        * inspector/InspectorClient.h:
        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::~InspectorController):
        (WebCore::InspectorController::setting):
        (WebCore::InspectorController::setSetting):
        (WebCore::InspectorController::setWindowVisible):
        (WebCore::InspectorController::attachWindow):
        (WebCore::InspectorController::setAttachedWindowHeight):
        (WebCore::InspectorController::storeLastActivePanel):
        (WebCore::InspectorController::scriptObjectReady):
        (WebCore::InspectorController::showWindow):
        (WebCore::InspectorController::enableResourceTracking):
        (WebCore::InspectorController::disableResourceTracking):
        (WebCore::InspectorController::ensureResourceTrackingSettingsLoaded):
        (WebCore::InspectorController::enableProfiler):
        (WebCore::InspectorController::disableProfiler):
        (WebCore::InspectorController::enableDebuggerFromFrontend):
        (WebCore::InspectorController::disableDebugger):
        * inspector/InspectorController.h:
        * inspector/InspectorFrontendHost.cpp:
        (WebCore::InspectorFrontendHost::setting):
        (WebCore::InspectorFrontendHost::setSetting):
        * inspector/InspectorFrontendHost.h:
        * inspector/InspectorFrontendHost.idl:
        * loader/EmptyClients.h:
        (WebCore::EmptyInspectorClient::populateSetting):
        (WebCore::EmptyInspectorClient::storeSetting):

WebKit/chromium
        * src/InspectorClientImpl.cpp:
        (WebKit::InspectorClientImpl::hiddenPanels):
        (WebKit::InspectorClientImpl::populateSetting):
        (WebKit::InspectorClientImpl::storeSetting):
        (WebKit::InspectorClientImpl::loadSettings):
        (WebKit::InspectorClientImpl::saveSettings):
        * src/InspectorClientImpl.h:

WebKit/cf
        * WebCoreSupport/WebInspectorClientCF.cpp:
        (WebInspectorClient::populateSetting):
        (WebInspectorClient::storeSetting):

WebKit/gtk
        * WebCoreSupport/InspectorClientGtk.cpp:
        (WebKit::InspectorClient::populateSetting):
        (WebKit::InspectorClient::storeSetting):
        * WebCoreSupport/InspectorClientGtk.h:

WebKit/haiku
        * WebCoreSupport/InspectorClientHaiku.cpp:
        (WebCore::InspectorClientHaiku::populateSetting):
        (WebCore::InspectorClientHaiku::storeSetting):
        * WebCoreSupport/InspectorClientHaiku.h:

WebKit/mac
        * WebCoreSupport/WebInspectorClient.h:
        * WebCoreSupport/WebInspectorClient.mm:
        (-[WebInspectorWindowController showWindow:]):
        (-[WebInspectorWindowController attach]):
        (-[WebInspectorWindowController detach]):

WebKit/qt
        * WebCoreSupport/InspectorClientQt.cpp:
        (WebCore::InspectorClientQt::populateSetting):
        (WebCore::InspectorClientQt::storeSetting):
        (WebCore::variantToSetting):
        (WebCore::settingToVariant):
        * WebCoreSupport/InspectorClientQt.h:

WebKit/win
        * WebCoreSupport/WebInspectorClient.cpp:
        (WebInspectorClient::attachWindow):
        (WebInspectorClient::detachWindow):
        (WebInspectorClient::showWindowWithoutNotifications):
        * WebCoreSupport/WebInspectorClient.h:

WebKit/wx
        * WebKitSupport/InspectorClientWx.cpp:
        (WebCore::InspectorClientWx::populateSetting):
        (WebCore::InspectorClientWx::storeSetting):
        * WebKitSupport/InspectorClientWx.h:

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

37 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/settings-set-get-expected.txt [new file with mode: 0644]
LayoutTests/inspector/settings-set-get.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.Inspector.exp
WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp
WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
WebCore/inspector/InspectorClient.h
WebCore/inspector/InspectorController.cpp
WebCore/inspector/InspectorController.h
WebCore/inspector/InspectorFrontendHost.cpp
WebCore/inspector/InspectorFrontendHost.h
WebCore/inspector/InspectorFrontendHost.idl
WebCore/loader/EmptyClients.h
WebKit/cf/ChangeLog
WebKit/cf/WebCoreSupport/WebInspectorClientCF.cpp
WebKit/chromium/ChangeLog
WebKit/chromium/src/InspectorClientImpl.cpp
WebKit/chromium/src/InspectorClientImpl.h
WebKit/gtk/ChangeLog
WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp
WebKit/gtk/WebCoreSupport/InspectorClientGtk.h
WebKit/haiku/ChangeLog
WebKit/haiku/WebCoreSupport/InspectorClientHaiku.cpp
WebKit/haiku/WebCoreSupport/InspectorClientHaiku.h
WebKit/mac/ChangeLog
WebKit/mac/WebCoreSupport/WebInspectorClient.h
WebKit/mac/WebCoreSupport/WebInspectorClient.mm
WebKit/qt/ChangeLog
WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
WebKit/qt/WebCoreSupport/InspectorClientQt.h
WebKit/win/ChangeLog
WebKit/win/WebCoreSupport/WebInspectorClient.cpp
WebKit/win/WebCoreSupport/WebInspectorClient.h
WebKit/wx/ChangeLog
WebKit/wx/WebKitSupport/InspectorClientWx.cpp
WebKit/wx/WebKitSupport/InspectorClientWx.h

index d166f7a1cdc64fcb7d33221eb46bb325d25f8651..31a945afd9d7efa7ee0fa3d0eeea34a00cf465ab 100644 (file)
@@ -1,3 +1,14 @@
+2009-12-03  Pavel Feldman  <pfeldman@dhcp-172-28-174-220.spb.corp.google.com>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: Simplify the settings support in inspector controller.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32076
+
+        * inspector/settings-set-get-expected.txt: Added.
+        * inspector/settings-set-get.html: Added.
+
 2009-12-03  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Maciej Stachowiak.
diff --git a/LayoutTests/inspector/settings-set-get-expected.txt b/LayoutTests/inspector/settings-set-get-expected.txt
new file mode 100644 (file)
index 0000000..bac9643
--- /dev/null
@@ -0,0 +1,5 @@
+Tests front-end settings read/write.
+
+Setting should have 'bar' value, was: 'bar'
+Setting should have 'baz' value, was: 'baz'
+
diff --git a/LayoutTests/inspector/settings-set-get.html b/LayoutTests/inspector/settings-set-get.html
new file mode 100644 (file)
index 0000000..8341d7d
--- /dev/null
@@ -0,0 +1,45 @@
+<html>
+<head>
+<script src="inspector-test.js"></script>
+<script>
+
+function doit()
+{
+    evaluateInWebInspector("frontend_setSetting('foo', 'bar')");
+    function callback(result)
+    {
+        output("Setting should have 'bar' value, was: '" + result + "'");
+    }
+    evaluateInWebInspector("frontend_setting('foo')", callback);
+
+    evaluateInWebInspector("frontend_setSetting('foo', 'baz')");
+    function callback2(result)
+    {
+        output("Setting should have 'baz' value, was: '" + result + "'");
+        notifyDone();
+    }
+    evaluateInWebInspector("frontend_setting('foo')", callback2);
+}
+
+// Frontend functions.
+
+function frontend_setSetting(key, value)
+{
+    InspectorFrontendHost.setSetting(key, value);
+}
+
+function frontend_setting(key)
+{
+    return InspectorFrontendHost.setting(key);
+}
+
+</script>
+</head>
+
+<body onload="onload()">
+<p id="test-topic">
+Tests front-end settings read/write.
+</p>
+
+</body>
+</html>
index 787105e1367389076ac287cee4fe89c43087e1f8..f9448b9dfd6c75d50032ccd8f6161166c2dd5967 100644 (file)
@@ -1,3 +1,44 @@
+2009-12-03  Pavel Feldman  <pfeldman@dhcp-172-28-174-220.spb.corp.google.com>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: Simplify the settings support in inspector controller.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32076
+
+        Test: inspector/settings-set-get.html
+
+        * WebCore.Inspector.exp:
+        * bindings/js/JSInspectorFrontendHostCustom.cpp:
+        * bindings/v8/custom/V8InspectorFrontendHostCustom.cpp:
+        * inspector/InspectorClient.h:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::~InspectorController):
+        (WebCore::InspectorController::setting):
+        (WebCore::InspectorController::setSetting):
+        (WebCore::InspectorController::setWindowVisible):
+        (WebCore::InspectorController::attachWindow):
+        (WebCore::InspectorController::setAttachedWindowHeight):
+        (WebCore::InspectorController::storeLastActivePanel):
+        (WebCore::InspectorController::scriptObjectReady):
+        (WebCore::InspectorController::showWindow):
+        (WebCore::InspectorController::enableResourceTracking):
+        (WebCore::InspectorController::disableResourceTracking):
+        (WebCore::InspectorController::ensureResourceTrackingSettingsLoaded):
+        (WebCore::InspectorController::enableProfiler):
+        (WebCore::InspectorController::disableProfiler):
+        (WebCore::InspectorController::enableDebuggerFromFrontend):
+        (WebCore::InspectorController::disableDebugger):
+        * inspector/InspectorController.h:
+        * inspector/InspectorFrontendHost.cpp:
+        (WebCore::InspectorFrontendHost::setting):
+        (WebCore::InspectorFrontendHost::setSetting):
+        * inspector/InspectorFrontendHost.h:
+        * inspector/InspectorFrontendHost.idl:
+        * loader/EmptyClients.h:
+        (WebCore::EmptyInspectorClient::populateSetting):
+        (WebCore::EmptyInspectorClient::storeSetting):
+
 2009-12-03  Ben Murdoch  <benm@google.com>
 
         Reviewed by Brady Eidson.
index 000594d11d0d665722ca0be3135d15804782430f..379b7a2673f1c637a6678cb576e0e033d87d4ab6 100644 (file)
@@ -1,4 +1,4 @@
-__ZN7WebCore19InspectorController10setSettingERKNS_6StringERKNS0_7SettingE
+__ZN7WebCore19InspectorController10setSettingERKNS_6StringES3_
 __ZN7WebCore19InspectorController12attachWindowEv
 __ZN7WebCore19InspectorController12detachWindowEv
 __ZN7WebCore19InspectorController14enableDebuggerEv
index 5b44134fefe719bbc2b53ca667940ca661418c50..56f85ec7d46b8713ede5d07e0fed4cb1b738d335 100644 (file)
@@ -89,88 +89,6 @@ JSValue JSInspectorFrontendHost::search(ExecState* exec, const ArgList& args)
     return constructArray(exec, result);
 }
 
-JSValue JSInspectorFrontendHost::setting(ExecState* exec, const ArgList& args)
-{
-    if (args.size() < 1)
-        return jsUndefined();
-
-    String key = args.at(0).toString(exec);
-    if (exec->hadException())
-        return jsUndefined();
-
-    InspectorController* ic = impl()->inspectorController();
-    if (!ic)
-        return jsUndefined();
-    const InspectorController::Setting& setting = ic->setting(key);
-
-    switch (setting.type()) {
-        default:
-        case InspectorController::Setting::NoType:
-            return jsUndefined();
-        case InspectorController::Setting::StringType:
-            return jsString(exec, setting.string());
-        case InspectorController::Setting::DoubleType:
-            return jsNumber(exec, setting.doubleValue());
-        case InspectorController::Setting::IntegerType:
-            return jsNumber(exec, setting.integerValue());
-        case InspectorController::Setting::BooleanType:
-            return jsBoolean(setting.booleanValue());
-        case InspectorController::Setting::StringVectorType: {
-            MarkedArgumentBuffer stringsArray;
-            const Vector<String>& strings = setting.stringVector();
-            const unsigned length = strings.size();
-            for (unsigned i = 0; i < length; ++i)
-                stringsArray.append(jsString(exec, strings[i]));
-            return constructArray(exec, stringsArray);
-        }
-    }
-}
-
-JSValue JSInspectorFrontendHost::setSetting(ExecState* exec, const ArgList& args)
-{
-    if (args.size() < 2)
-        return jsUndefined();
-
-    String key = args.at(0).toString(exec);
-    if (exec->hadException())
-        return jsUndefined();
-
-    InspectorController::Setting setting;
-
-    JSValue value = args.at(1);
-    if (value.isUndefined() || value.isNull()) {
-        // Do nothing. The setting is already NoType.
-        ASSERT(setting.type() == InspectorController::Setting::NoType);
-    } else if (value.isString())
-        setting.set(value.toString(exec));
-    else if (value.isNumber())
-        setting.set(value.toNumber(exec));
-    else if (value.isBoolean())
-        setting.set(value.toBoolean(exec));
-    else {
-        JSArray* jsArray = asArray(value);
-        if (!jsArray)
-            return jsUndefined();
-        Vector<String> strings;
-        for (unsigned i = 0; i < jsArray->length(); ++i) {
-            String item = jsArray->get(exec, i).toString(exec);
-            if (exec->hadException())
-                return jsUndefined();
-            strings.append(item);
-        }
-        setting.set(strings);
-    }
-
-    if (exec->hadException())
-        return jsUndefined();
-
-    InspectorController* ic = impl()->inspectorController();
-    if (ic)
-        ic->setSetting(key, setting);
-
-    return jsUndefined();
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index 08cb8895a4584b0b3f905ef4d39d0df0e6f69fb6..afbd9ac860c8d01c3df53cc0ff5693f0a7779dfe 100644 (file)
@@ -84,87 +84,4 @@ CALLBACK_FUNC_DECL(InspectorFrontendHostSearch)
     return result;
 }
 
-CALLBACK_FUNC_DECL(InspectorFrontendHostSetting)
-{
-    INC_STATS("InspectorFrontendHost.setting()");
-
-    if (args.Length() < 1)
-        return v8::Undefined();
-
-    String key = toWebCoreStringWithNullCheck(args[0]);
-    if (key.isEmpty())
-        return v8::Undefined();
-
-    InspectorFrontendHost* inspectorHost = V8DOMWrapper::convertToNativeObject<InspectorFrontendHost>(V8ClassIndex::INSPECTORFRONTENDHOST, args.Holder());
-    InspectorController* ic = inspectorHost->inspectorController();
-    if (!ic)
-        return v8::Undefined();
-    const InspectorController::Setting& setting = ic->setting(key);
-
-    switch (setting.type()) {
-        default:
-        case InspectorController::Setting::NoType:
-            return v8::Undefined();
-        case InspectorController::Setting::StringType:
-            return v8String(setting.string());
-        case InspectorController::Setting::DoubleType:
-            return v8::Number::New(setting.doubleValue());
-        case InspectorController::Setting::IntegerType:
-            return v8::Number::New(setting.integerValue());
-        case InspectorController::Setting::BooleanType:
-            return v8Boolean(setting.booleanValue());
-        case InspectorController::Setting::StringVectorType: {
-            const Vector<String>& strings = setting.stringVector();
-            v8::Local<v8::Array> stringsArray = v8::Array::New(strings.size());
-            const unsigned length = strings.size();
-            for (unsigned i = 0; i < length; ++i)
-                stringsArray->Set(v8::Number::New(i), v8String(strings[i]));
-            return stringsArray;
-        }
-    }
-}
-
-CALLBACK_FUNC_DECL(InspectorFrontendHostSetSetting)
-{
-    INC_STATS("InspectorFrontendHost.setSetting()");
-    if (args.Length() < 2)
-        return v8::Undefined();
-
-    String key = toWebCoreStringWithNullCheck(args[0]);
-    if (key.isEmpty())
-        return v8::Undefined();
-
-    InspectorController::Setting setting;
-
-    v8::Local<v8::Value> value = args[1];
-    if (value->IsUndefined() || value->IsNull()) {
-        // Do nothing. The setting is already NoType.
-        ASSERT(setting.type() == InspectorController::Setting::NoType);
-    } else if (value->IsString())
-        setting.set(toWebCoreStringWithNullCheck(value));
-    else if (value->IsNumber())
-        setting.set(value->NumberValue());
-    else if (value->IsBoolean())
-        setting.set(value->BooleanValue());
-    else if (value->IsArray()) {
-        v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast(value);
-        Vector<String> strings;
-        for (unsigned i = 0; i < v8Array->Length(); ++i) {
-            String item = toWebCoreString(v8Array->Get(v8::Integer::New(i)));
-            if (item.isEmpty())
-                return v8::Undefined();
-            strings.append(item);
-        }
-        setting.set(strings);
-    } else
-        return v8::Undefined();
-
-    InspectorFrontendHost* inspectorHost = V8DOMWrapper::convertToNativeObject<InspectorFrontendHost>(V8ClassIndex::INSPECTORFRONTENDHOST, args.Holder());
-    InspectorController* ic = inspectorHost->inspectorController();
-    if (ic)
-        inspectorHost->inspectorController()->setSetting(key, setting);
-
-    return v8::Undefined();
-}
-
 } // namespace WebCore
index f96662a7f7f4f9812944c6bcde789d940c950118..e448cd2b7e80c572dcff90b76235352abd5be8f3 100644 (file)
@@ -59,9 +59,8 @@ public:
 
     virtual void inspectedURLChanged(const String& newURL) = 0;
 
-    virtual void populateSetting(const String& key, InspectorController::Setting&) = 0;
-    virtual void storeSetting(const String& key, const InspectorController::Setting&) = 0;
-    virtual void removeSetting(const String& key) = 0;
+    virtual void populateSetting(const String& key, String* value) = 0;
+    virtual void storeSetting(const String& key, const String& value) = 0;
 
     virtual void inspectorWindowObjectCleared() = 0;
 };
index b86eda388f50458b5b4a653a83df7d7a3681686a..c269825d8a21f0badb6be9d625f1be2dd242b91f 100644 (file)
@@ -121,7 +121,6 @@ static const float minimumAttachedHeight = 250.0f;
 static const float maximumAttachedHeightRatio = 0.75f;
 
 static unsigned s_inspectorControllerCount;
-static HashMap<String, InspectorController::Setting*>* s_settingCache;
 
 InspectorController::InspectorController(Page* page, InspectorClient* client)
     : m_inspectedPage(page)
@@ -168,12 +167,6 @@ InspectorController::~InspectorController()
     ASSERT(s_inspectorControllerCount);
     --s_inspectorControllerCount;
 
-    if (!s_inspectorControllerCount && s_settingCache) {
-        deleteAllValues(*s_settingCache);
-        delete s_settingCache;
-        s_settingCache = 0;
-    }
-    
     releaseDOMAgent();
 
     m_inspectorBackend->disconnectController();
@@ -204,46 +197,22 @@ bool InspectorController::enabled() const
     return m_inspectedPage->settings()->developerExtrasEnabled();
 }
 
-const InspectorController::Setting& InspectorController::setting(const String& key) const
+String InspectorController::setting(const String& key) const
 {
-    if (!s_settingCache)
-        s_settingCache = new HashMap<String, Setting*>;
-
-    if (Setting* cachedSetting = s_settingCache->get(key))
-        return *cachedSetting;
-
-    Setting* newSetting = new Setting;
-    s_settingCache->set(key, newSetting);
-
-    m_client->populateSetting(key, *newSetting);
+    Settings::iterator it = m_settings.find(key);
+    if (it != m_settings.end())
+        return it->second;
 
-    return *newSetting;
+    String value;
+    m_client->populateSetting(key, &value);
+    m_settings.set(key, value);
+    return value;
 }
 
-void InspectorController::setSetting(const String& key, const Setting& setting)
+void InspectorController::setSetting(const String& key, const String& value)
 {
-    if (setting.type() == Setting::NoType) {
-        if (s_settingCache) {
-            Setting* cachedSetting = s_settingCache->get(key);
-            if (cachedSetting) {
-                s_settingCache->remove(key);
-                delete cachedSetting;
-            }
-        }
-
-        m_client->removeSetting(key);
-        return;
-    }
-
-    if (!s_settingCache)
-        s_settingCache = new HashMap<String, Setting*>;
-
-    if (Setting* cachedSetting = s_settingCache->get(key))
-        *cachedSetting = setting;
-    else
-        s_settingCache->set(key, new Setting(setting));
-
-    m_client->storeSetting(key, setting);
+    m_settings.set(key, value);
+    m_client->storeSetting(key, value);
 }
 
 // Trying to inspect something in a frame with JavaScript disabled would later lead to
@@ -323,11 +292,8 @@ void InspectorController::setWindowVisible(bool visible, bool attached)
         populateScriptObjects();
 
         if (m_showAfterVisible == CurrentPanel) {
-          Setting lastActivePanelSetting = setting(lastActivePanelSettingName);
-          if (lastActivePanelSetting.type() == Setting::StringType)
-              m_showAfterVisible = specialPanelForJSName(lastActivePanelSetting.string());
-          else
-              m_showAfterVisible = ElementsPanel;
+          String lastActivePanelSetting = setting(lastActivePanelSettingName);
+          m_showAfterVisible = specialPanelForJSName(lastActivePanelSetting);
         }
 
         if (m_nodeToFocus)
@@ -439,8 +405,10 @@ void InspectorController::attachWindow()
 
     m_client->attachWindow();
 
-    Setting attachedHeight = setting(inspectorAttachedHeightName);
-    unsigned preferredHeight = attachedHeight.type() == Setting::IntegerType ? attachedHeight.integerValue() : defaultAttachedHeight;
+    String attachedHeight = setting(inspectorAttachedHeightName);
+    bool success = true;
+    int height = attachedHeight.toInt(&success);
+    unsigned preferredHeight = success ? height : defaultAttachedHeight;
 
     // We need to constrain the window height here in case the user has resized the inspected page's window so that
     // the user's preferred height would be too big to display.
@@ -470,14 +438,14 @@ void InspectorController::setAttachedWindowHeight(unsigned height)
     unsigned totalHeight = m_page->mainFrame()->view()->visibleHeight() + m_inspectedPage->mainFrame()->view()->visibleHeight();
     unsigned attachedHeight = constrainedAttachedWindowHeight(height, totalHeight);
     
-    setSetting(inspectorAttachedHeightName, Setting(attachedHeight));
+    setSetting(inspectorAttachedHeightName, String::number(attachedHeight));
     
     m_client->setAttachedWindowHeight(attachedHeight);
 }
 
 void InspectorController::storeLastActivePanel(const String& panelName)
 {
-    setSetting(lastActivePanelSettingName, Setting(panelName));
+    setSetting(lastActivePanelSettingName, panelName);
 }
 
 void InspectorController::toggleSearchForNodeInPage()
@@ -549,11 +517,11 @@ void InspectorController::scriptObjectReady()
     setFrontendProxyObject(m_scriptState, webInspectorObj, injectedScriptObj);
 
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    Setting debuggerEnabled = setting(debuggerEnabledSettingName);
-    if (debuggerEnabled.type() == Setting::BooleanType && debuggerEnabled.booleanValue())
+    String debuggerEnabled = setting(debuggerEnabledSettingName);
+    if (debuggerEnabled == "true")
         enableDebugger();
-    Setting profilerEnabled = setting(profilerEnabledSettingName);
-    if (profilerEnabled.type() == Setting::BooleanType && profilerEnabled.booleanValue())
+    String profilerEnabled = setting(profilerEnabledSettingName);
+    if (profilerEnabled == "true")
         enableProfiler();
 #endif
 
@@ -645,8 +613,10 @@ void InspectorController::showWindow()
 
     m_client->showWindow();
 
-    Setting attachedHeight = setting(inspectorAttachedHeightName);
-    unsigned preferredHeight = attachedHeight.type() == Setting::IntegerType ? attachedHeight.integerValue() : defaultAttachedHeight;
+    String attachedHeight = setting(inspectorAttachedHeightName);
+    bool success = true;
+    int height = attachedHeight.toInt(&success);
+    unsigned preferredHeight = success ? height : defaultAttachedHeight;
 
     // This call might not go through (if the window starts out detached), but if the window is initially created attached,
     // InspectorController::attachWindow is never called, so we need to make sure to set the attachedWindowHeight.
@@ -1077,7 +1047,7 @@ void InspectorController::enableResourceTracking(bool always, bool reload)
         return;
 
     if (always)
-        setSetting(resourceTrackingEnabledSettingName, Setting(true));
+        setSetting(resourceTrackingEnabledSettingName, "true");
 
     if (m_resourceTrackingEnabled)
         return;
@@ -1097,7 +1067,7 @@ void InspectorController::disableResourceTracking(bool always)
         return;
 
     if (always)
-        setSetting(resourceTrackingEnabledSettingName, Setting(false));
+        setSetting(resourceTrackingEnabledSettingName, "false");
 
     ASSERT(m_inspectedPage);
     m_resourceTrackingEnabled = false;
@@ -1111,8 +1081,8 @@ void InspectorController::ensureResourceTrackingSettingsLoaded()
         return;
     m_resourceTrackingSettingsLoaded = true;
 
-    Setting resourceTracking = setting(resourceTrackingEnabledSettingName);
-    if (resourceTracking.type() == Setting::BooleanType && resourceTracking.booleanValue())
+    String resourceTracking = setting(resourceTrackingEnabledSettingName);
+    if (resourceTracking == "true")
         m_resourceTrackingEnabled = true;
 }
 
@@ -1500,7 +1470,7 @@ void InspectorController::toggleRecordButton(bool isProfiling)
 void InspectorController::enableProfiler(bool always, bool skipRecompile)
 {
     if (always)
-        setSetting(profilerEnabledSettingName, Setting(true));
+        setSetting(profilerEnabledSettingName, "true");
 
     if (m_profilerEnabled)
         return;
@@ -1517,7 +1487,7 @@ void InspectorController::enableProfiler(bool always, bool skipRecompile)
 void InspectorController::disableProfiler(bool always)
 {
     if (always)
-        setSetting(profilerEnabledSettingName, Setting(false));
+        setSetting(profilerEnabledSettingName, "false");
 
     if (!m_profilerEnabled)
         return;
@@ -1533,7 +1503,7 @@ void InspectorController::disableProfiler(bool always)
 void InspectorController::enableDebuggerFromFrontend(bool always)
 {
     if (always)
-        setSetting(debuggerEnabledSettingName, Setting(true));
+        setSetting(debuggerEnabledSettingName, "true");
 
     ASSERT(m_inspectedPage);
 
@@ -1566,7 +1536,7 @@ void InspectorController::disableDebugger(bool always)
         return;
 
     if (always)
-        setSetting(debuggerEnabledSettingName, Setting(false));
+        setSetting(debuggerEnabledSettingName, "false");
 
     ASSERT(m_inspectedPage);
 
index 6f261ec609773a798f53389d46a68caf01283b5c..0dd6fb15b3db88d930f2ef645eb6ed0c3abb9e54 100644 (file)
@@ -110,60 +110,6 @@ public:
         StoragePanel
     } SpecialPanels;
 
-    struct Setting {
-        enum Type {
-            NoType, StringType, StringVectorType, DoubleType, IntegerType, BooleanType
-        };
-
-        Setting()
-            : m_type(NoType)
-        {
-        }
-
-        explicit Setting(bool value)
-            : m_type(BooleanType)
-        {
-            m_simpleContent.m_boolean = value;
-        }
-
-        explicit Setting(unsigned value)
-            : m_type(IntegerType)
-        {
-            m_simpleContent.m_integer = value;
-        }
-
-        explicit Setting(const String& value)
-            : m_type(StringType)
-        {
-            m_string = value;
-        }
-
-        Type type() const { return m_type; }
-
-        String string() const { ASSERT(m_type == StringType); return m_string; }
-        const Vector<String>& stringVector() const { ASSERT(m_type == StringVectorType); return m_stringVector; }
-        double doubleValue() const { ASSERT(m_type == DoubleType); return m_simpleContent.m_double; }
-        long integerValue() const { ASSERT(m_type == IntegerType); return m_simpleContent.m_integer; }
-        bool booleanValue() const { ASSERT(m_type == BooleanType); return m_simpleContent.m_boolean; }
-
-        void set(const String& value) { m_type = StringType; m_string = value; }
-        void set(const Vector<String>& value) { m_type = StringVectorType; m_stringVector = value; }
-        void set(double value) { m_type = DoubleType; m_simpleContent.m_double = value; }
-        void set(long value) { m_type = IntegerType; m_simpleContent.m_integer = value; }
-        void set(bool value) { m_type = BooleanType; m_simpleContent.m_boolean = value; }
-
-    private:
-        Type m_type;
-
-        String m_string;
-        Vector<String> m_stringVector;
-
-        union {
-            double m_double;
-            long m_integer;
-            bool m_boolean;
-        } m_simpleContent;
-    };
     InspectorController(Page*, InspectorClient*);
     ~InspectorController();
 
@@ -178,8 +124,8 @@ public:
 
     Page* inspectedPage() const { return m_inspectedPage; }
 
-    const Setting& setting(const String& key) const;
-    void setSetting(const String& key, const Setting&);
+    String setting(const String& key) const;
+    void setSetting(const String& key, const String& value);
 
     void inspect(Node*);
     void highlight(Node*);
@@ -397,8 +343,11 @@ private:
     RefPtr<InjectedScriptHost> m_injectedScriptHost;
     HashMap<String, ScriptValue> m_idToWrappedObject;
     ObjectGroupsMap m_objectGroups;
-
     long m_lastBoundObjectId;
+
+    typedef HashMap<String, String> Settings;
+    mutable Settings m_settings;
+
     Vector<pair<long, String> > m_pendingEvaluateTestCommands;
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     bool m_debuggerEnabled;
index 138a4df38854c503584502db66e9c4862c52a3d7..8d3b3a194b123f2ba2b001a061bf9f9ce6d9db2d 100644 (file)
@@ -188,6 +188,17 @@ bool InspectorFrontendHost::addSourceToFrame(const String& mimeType, const Strin
     return true;
 }
 
+String InspectorFrontendHost::setting(const String& key)
+{
+    return m_inspectorController ? m_inspectorController->setting(key) : "";
+}
+
+void InspectorFrontendHost::setSetting(const String& key, const String& value)
+{
+    if (m_inspectorController)
+        m_inspectorController->setSetting(key, value);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index dcbec6b8d387bf2bce6a4c9e86be28b2af94dfe9..0915fbe19f171e6450f934320cd8ea5e7b66d546 100644 (file)
@@ -70,6 +70,9 @@ public:
     void addResourceSourceToFrame(long identifier, Node* frame);
     bool addSourceToFrame(const String& mimeType, const String& source, Node* frame);
 
+    String setting(const String& key);
+    void setSetting(const String& key, const String& value);
+
 private:
     InspectorFrontendHost(InspectorController* inspectorController, InspectorClient* client);
 
index 9a7581d56836c109b75d184ed66d682f8c48b4bd..fad83e8fdf4131f2f910381f6b46fcfaef54bba5 100644 (file)
@@ -51,8 +51,9 @@ module core {
         void addResourceSourceToFrame(in long identifier, in Node frame);
         boolean addSourceToFrame(in DOMString mimeType, in DOMString sourceValue, in Node frame);
 
+        DOMString setting(in DOMString key);
+        void setSetting(in DOMString key, in DOMString value);
+
         [Custom] void search(in Node node, in DOMString query);
-        [Custom] DOMObject setting(in DOMString key);
-        [Custom] void setSetting(in DOMString key, in DOMObject  value);
     };
 }
index 99777ada860f947021058de198f8bd323bcb232d..bf34a1bb85e2db6e1b3752a8dd8f23b88b377e10 100644 (file)
@@ -482,9 +482,8 @@ public:
     virtual void hideHighlight() { }
     virtual void inspectedURLChanged(const String&) { }
 
-    virtual void populateSetting(const String&, InspectorController::Setting&) { }
-    virtual void storeSetting(const String&, const InspectorController::Setting&) { }
-    virtual void removeSetting(const String&) { }
+    virtual void populateSetting(const String&, String*) { }
+    virtual void storeSetting(const String&, const String&) { }
 
     virtual void inspectorWindowObjectCleared() { }
 };
index 27caf1cb78da9c9f71decb4e8c8d2cda5a433e91..1d061fb484eb8adbe0ae70cfa2de9017d7436127 100644 (file)
@@ -1,3 +1,15 @@
+2009-12-03  Pavel Feldman  <pfeldman@dhcp-172-28-174-220.spb.corp.google.com>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: Simplify the settings support in inspector controller.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32076
+
+        * WebCoreSupport/WebInspectorClientCF.cpp:
+        (WebInspectorClient::populateSetting):
+        (WebInspectorClient::storeSetting):
+
 2009-04-20  Steve Falkenburg  <sfalken@apple.com>
 
         Separate JavaScriptCore.dll from WebKit.dll.
index 600d58d64b7ff7fabdeaa07a89fc555654c9d328..cb4720576982286445c062ac786448e77d2ef7f5 100644 (file)
@@ -64,7 +64,7 @@ static inline CFStringRef createKeyForPreferences(const String& key)
     return CFStringCreateWithFormat(0, 0, CFSTR("WebKit Web Inspector Setting - %@"), keyCFString.get());
 }
 
-void WebInspectorClient::populateSetting(const String& key, InspectorController::Setting& setting)
+void WebInspectorClient::populateSetting(const String& key, String* setting)
 {
     RetainPtr<CFStringRef> preferencesKey(AdoptCF, createKeyForPreferences(key));
     RetainPtr<CFPropertyListRef> value(AdoptCF, CFPreferencesCopyAppValue(preferencesKey.get(), kCFPreferencesCurrentApplication));
@@ -74,88 +74,19 @@ void WebInspectorClient::populateSetting(const String& key, InspectorController:
 
     CFTypeID type = CFGetTypeID(value.get());
     if (type == CFStringGetTypeID())
-        setting.set(static_cast<String>(static_cast<CFStringRef>(value.get())));
+        *setting = static_cast<String>(static_cast<CFStringRef>(value.get()));
     else if (type == CFBooleanGetTypeID())
-        setting.set(static_cast<bool>(CFBooleanGetValue(static_cast<CFBooleanRef>(value.get()))));
-    else if (type == CFNumberGetTypeID()) {
-        CFNumberRef number = static_cast<CFNumberRef>(value.get());
-        if (CFNumberIsFloatType(number)) {
-            double doubleNumber = 0.0;
-            CFNumberGetValue(static_cast<CFNumberRef>(value.get()), kCFNumberDoubleType, &doubleNumber);
-            setting.set(doubleNumber);
-        } else {
-            long longNumber = 0;
-            CFNumberGetValue(static_cast<CFNumberRef>(value.get()), kCFNumberLongType, &longNumber);
-            setting.set(longNumber);
-        }
-    } else if (type == CFArrayGetTypeID()) {
-        Vector<String> strings;
-
-        CFArrayRef array = static_cast<CFArrayRef>(value.get());
-        unsigned length = CFArrayGetCount(array);
-        for (unsigned i = 0; i < length; ++i) {
-            CFStringRef string = static_cast<CFStringRef>(CFArrayGetValueAtIndex(array, i));
-            if (CFGetTypeID(string) == CFStringGetTypeID())
-                strings.append(static_cast<String>(static_cast<CFStringRef>(string)));
-        }
-
-        setting.set(strings);
-    } else
-        ASSERT_NOT_REACHED();
+        *setting = static_cast<bool>(CFBooleanGetValue(static_cast<CFBooleanRef>(value.get()))) ? "true" : "false";
+    else
+        *setting = "";
 }
 
-void WebInspectorClient::storeSetting(const String& key, const InspectorController::Setting& setting)
+void WebInspectorClient::storeSetting(const String& key, const String& setting)
 {
     RetainPtr<CFPropertyListRef> objectToStore;
-
-    switch (setting.type()) {
-        default:
-        case InspectorController::Setting::NoType:
-            ASSERT_NOT_REACHED();
-            break;
-        case InspectorController::Setting::StringType:
-            objectToStore.adoptCF(setting.string().createCFString());
-            break;
-        case InspectorController::Setting::BooleanType:
-            objectToStore = (setting.booleanValue() ? kCFBooleanTrue : kCFBooleanFalse);
-            break;
-
-        case InspectorController::Setting::DoubleType: {
-            double value = setting.doubleValue();
-            objectToStore.adoptCF(CFNumberCreate(0, kCFNumberDoubleType, &value));
-            break;
-        }
-
-        case InspectorController::Setting::IntegerType: {
-            long value = setting.integerValue();
-            objectToStore.adoptCF(CFNumberCreate(0, kCFNumberLongType, &value));
-            break;
-        }
-
-        case InspectorController::Setting::StringVectorType: {
-            const Vector<String>& strings = setting.stringVector();
-            const unsigned length = strings.size();
-
-            RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, length, &kCFTypeArrayCallBacks));
-
-            for (unsigned i = 0; i < length; ++i) {
-                RetainPtr<CFStringRef> string(AdoptCF, strings[i].createCFString());
-                CFArraySetValueAtIndex(array.get(), i, string.get());
-            }
-
-            objectToStore = array;
-            break;
-        }
-    }
-
+    objectToStore.adoptCF(setting.createCFString());
     ASSERT(objectToStore);
 
     RetainPtr<CFStringRef> preferencesKey(AdoptCF, createKeyForPreferences(key));
     CFPreferencesSetAppValue(preferencesKey.get(), objectToStore.get(), kCFPreferencesCurrentApplication);
 }
-
-void WebInspectorClient::removeSetting(const String& key)
-{
-    RetainPtr<CFStringRef> preferencesKey(AdoptCF, createKeyForPreferences(key));
-    CFPreferencesSetAppValue(preferencesKey.get(), 0, kCFPreferencesCurrentApplication);
-}
index 073fe8dcd817c807f7189eeb7503e92bf200fe8d..487615910bd5d8d2921a7d3ef7413a9a290480ac 100644 (file)
@@ -1,3 +1,19 @@
+2009-12-03  Pavel Feldman  <pfeldman@dhcp-172-28-174-220.spb.corp.google.com>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: Simplify the settings support in inspector controller.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32076
+
+        * src/InspectorClientImpl.cpp:
+        (WebKit::InspectorClientImpl::hiddenPanels):
+        (WebKit::InspectorClientImpl::populateSetting):
+        (WebKit::InspectorClientImpl::storeSetting):
+        (WebKit::InspectorClientImpl::loadSettings):
+        (WebKit::InspectorClientImpl::saveSettings):
+        * src/InspectorClientImpl.h:
+
 2009-12-03  Ben Murdoch  <benm@google.com>
 
         Reviewed by Brady Eidson.
index ed4329a94e4fc6c96ea7c311512e4fd9f94be3c3..2a69daa7bcf547fc08cdf7b404504f5e4705247a 100644 (file)
@@ -143,28 +143,21 @@ String InspectorClientImpl::localizedStringsURL()
 
 String InspectorClientImpl::hiddenPanels()
 {
-    // Enumerate tabs that are currently disabled.
-    return "scripts,profiles,databases";
+    notImplemented();
+    return "";
 }
 
-void InspectorClientImpl::populateSetting(const String& key, InspectorController::Setting& setting)
+void InspectorClientImpl::populateSetting(const String& key, String* value)
 {
     loadSettings();
     if (m_settings->contains(key))
-        setting = m_settings->get(key);
-}
-
-void InspectorClientImpl::storeSetting(const String& key, const InspectorController::Setting& setting)
-{
-    loadSettings();
-    m_settings->set(key, setting);
-    saveSettings();
+        *value = m_settings->get(key);
 }
 
-void InspectorClientImpl::removeSetting(const String& key)
+void InspectorClientImpl::storeSetting(const String& key, const String& value)
 {
     loadSettings();
-    m_settings->remove(key);
+    m_settings->set(key, value);
     saveSettings();
 }
 
@@ -193,21 +186,15 @@ void InspectorClientImpl::loadSettings()
 
         String name = decodeURLEscapeSequences(tokens[0]);
         String type = tokens[1];
-        InspectorController::Setting setting;
-        bool ok = true;
+        String setting;
         if (type == "string")
-            setting.set(decodeURLEscapeSequences(tokens[2]));
-        else if (type == "double")
-            setting.set(tokens[2].toDouble(&ok));
-        else if (type == "integer")
-            setting.set(static_cast<long>(tokens[2].toInt(&ok)));
+            setting = decodeURLEscapeSequences(tokens[2]);
         else if (type == "boolean")
-            setting.set(tokens[2] == "true");
+            setting = tokens[2];
         else
             continue;
 
-        if (ok)
-            m_settings->set(name, setting);
+        m_settings->set(name, setting);
     }
 }
 
@@ -215,40 +202,12 @@ void InspectorClientImpl::saveSettings()
 {
     String data;
     for (SettingsMap::iterator it = m_settings->begin(); it != m_settings->end(); ++it) {
-        String entry;
-        InspectorController::Setting value = it->second;
         String name = encodeWithURLEscapeSequences(it->first);
-        switch (value.type()) {
-        case InspectorController::Setting::StringType:
-            entry = String::format(
-                "%s:string:%s",
-                name.utf8().data(),
-                encodeWithURLEscapeSequences(value.string()).utf8().data());
-            break;
-        case InspectorController::Setting::DoubleType:
-            entry = String::format(
-                "%s:double:%f",
-                name.utf8().data(),
-                value.doubleValue());
-            break;
-        case InspectorController::Setting::IntegerType:
-            entry = String::format(
-                "%s:integer:%ld",
-                name.utf8().data(),
-                value.integerValue());
-            break;
-        case InspectorController::Setting::BooleanType:
-            entry = String::format("%s:boolean:%s",
-                                   name.utf8().data(),
-                                   value.booleanValue() ? "true" : "false");
-            break;
-        case InspectorController::Setting::StringVectorType:
-            notImplemented();
-            break;
-        default:
-            ASSERT_NOT_REACHED();
-            break;
-        }
+        String value = it->second;
+        String entry = String::format(
+            "%s:string:%s",
+            name.utf8().data(),
+            encodeWithURLEscapeSequences(value).utf8().data());
         data.append(entry);
         data.append("\n");
     }
index 62216b28cf28252b8ae542e0fd0a6f0c25853376..6f7f8b1bf8f3f3f60ca6b371e3916c1daeed5bfa 100644 (file)
@@ -59,11 +59,10 @@ public:
     virtual void inspectedURLChanged(const WebCore::String& newURL);
     virtual void populateSetting(
         const WebCore::String& key,
-        WebCore::InspectorController::Setting&);
+        WebCore::String* value);
     virtual void storeSetting(
         const WebCore::String& key,
-        const WebCore::InspectorController::Setting&);
-    virtual void removeSetting(const WebCore::String& key);
+        const WebCore::String& value);
     virtual void inspectorWindowObjectCleared();
 
 private:
@@ -73,7 +72,7 @@ private:
     // The WebViewImpl of the page being inspected; gets passed to the constructor
     WebViewImpl* m_inspectedWebView;
 
-    typedef HashMap<WebCore::String, WebCore::InspectorController::Setting> SettingsMap;
+    typedef HashMap<WebCore::String, WebCore::String> SettingsMap;
     OwnPtr<SettingsMap> m_settings;
 };
 
index 216cc727d657828b00b3bbefedf0f8e40ac6399a..4142116820037cd0edbf3a7ddc992f6ea20aae88 100644 (file)
@@ -1,3 +1,16 @@
+2009-12-03  Pavel Feldman  <pfeldman@dhcp-172-28-174-220.spb.corp.google.com>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: Simplify the settings support in inspector controller.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32076
+
+        * WebCoreSupport/InspectorClientGtk.cpp:
+        (WebKit::InspectorClient::populateSetting):
+        (WebKit::InspectorClient::storeSetting):
+        * WebCoreSupport/InspectorClientGtk.h:
+
 2009-12-03  Ben Murdoch  <benm@google.com>
 
         Reviewed by Brady Eidson.
index 78f55437956c9736d8be91b7d54767caa1b23891..a06ff50e97386f3049b7ce4dcfd2ae00e28d9b19 100644 (file)
@@ -204,18 +204,12 @@ void InspectorClient::inspectorWindowObjectCleared()
     notImplemented();
 }
 
-
-void InspectorClient::populateSetting(const String& key, InspectorController::Setting& setting)
-{
-    notImplemented();
-}
-
-void InspectorClient::storeSetting(const String& key, const InspectorController::Setting& setting)
+void InspectorClient::populateSetting(const String& key, String* value)
 {
     notImplemented();
 }
 
-void InspectorClient::removeSetting(const String& key)
+void InspectorClient::storeSetting(const String& key, const String& value)
 {
     notImplemented();
 }
index ed9fe08f2d1a1fc26896cf9c23f252b3128c82d3..297fd8f8a7b2a8c8cf960323f43c75ba12694460 100644 (file)
@@ -66,9 +66,8 @@ namespace WebKit {
         virtual void hideHighlight();
         virtual void inspectedURLChanged(const WebCore::String& newURL);
 
-        virtual void populateSetting(const WebCore::String& key, WebCore::InspectorController::Setting&);
-        virtual void storeSetting(const WebCore::String& key, const WebCore::InspectorController::Setting&);
-        virtual void removeSetting(const WebCore::String& key);
+        virtual void populateSetting(const WebCore::String& key, WebCore::String* value);
+        virtual void storeSetting(const WebCore::String& key, const WebCore::String& value);
 
         virtual void inspectorWindowObjectCleared();
 
index 26c0ad0910e49b43cf28e489ff819f1ea1beff10..7ee29bd4a2d851f4ba4ad00995daee0045c4e400 100644 (file)
@@ -1,3 +1,16 @@
+2009-12-03  Pavel Feldman  <pfeldman@dhcp-172-28-174-220.spb.corp.google.com>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: Simplify the settings support in inspector controller.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32076
+
+        * WebCoreSupport/InspectorClientHaiku.cpp:
+        (WebCore::InspectorClientHaiku::populateSetting):
+        (WebCore::InspectorClientHaiku::storeSetting):
+        * WebCoreSupport/InspectorClientHaiku.h:
+
 2009-12-03  Ben Murdoch  <benm@google.com>
 
         Reviewed by Brady Eidson.
index 4064c5192f3196744672a19c57d6ef4fc6a5f50e..f06e96bff12a4154b8e9e2cabccdf5c6e61b1922 100644 (file)
@@ -105,17 +105,12 @@ void InspectorClientHaiku::inspectorWindowObjectCleared()
     notImplemented();
 }
 
-void InspectorClientHaiku::populateSetting(const String& key, InspectorController::Setting&)
+void InspectorClientHaiku::populateSetting(const String& key, String* value)
 {
     notImplemented();
 }
 
-void InspectorClientHaiku::storeSetting(const String& key, const InspectorController::Setting&)
-{
-    notImplemented();
-}
-
-void InspectorClientHaiku::removeSetting(const String& key)
+void InspectorClientHaiku::storeSetting(const String& key, const String& value)
 {
     notImplemented();
 }
index 792ef4002b383b0c704ddd738cb2cefd3e90a5aa..8788a5fab3b50aac2a7881e61c760ceb3068e95d 100644 (file)
@@ -61,9 +61,8 @@ namespace WebCore {
 
         virtual void inspectedURLChanged(const String& newURL);
 
-        virtual void populateSetting(const String& key, InspectorController::Setting&);
-        virtual void storeSetting(const String& key, const InspectorController::Setting&);
-        virtual void removeSetting(const String& key);
+        virtual void populateSetting(const WebCore::String& key, WebCore::String* value);
+        virtual void storeSetting(const WebCore::String& key, const WebCore::String& value);
 
         virtual void inspectorWindowObjectCleared();
     };
index acabcb5850a1a55025bef468fd78da54dc49da19..af84eaac753c06dcf9eb5b30d9d552021e376a27 100644 (file)
@@ -1,3 +1,17 @@
+2009-12-03  Pavel Feldman  <pfeldman@dhcp-172-28-174-220.spb.corp.google.com>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: Simplify the settings support in inspector controller.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32076
+
+        * WebCoreSupport/WebInspectorClient.h:
+        * WebCoreSupport/WebInspectorClient.mm:
+        (-[WebInspectorWindowController showWindow:]):
+        (-[WebInspectorWindowController attach]):
+        (-[WebInspectorWindowController detach]):
+
 2009-12-03  Ben Murdoch  <benm@google.com>
 
         Reviewed by Brady Eidson.
index 7487728351a4d9b75118544a40006333164af413..64621f86cfba3c96dd2333dbc8443197253410ff 100644 (file)
@@ -62,9 +62,8 @@ public:
     virtual void hideHighlight();
     virtual void inspectedURLChanged(const WebCore::String& newURL);
 
-    virtual void populateSetting(const WebCore::String& key, WebCore::InspectorController::Setting&);
-    virtual void storeSetting(const WebCore::String& key, const WebCore::InspectorController::Setting&);
-    virtual void removeSetting(const WebCore::String& key);
+    virtual void populateSetting(const WebCore::String& key, WebCore::String* value);
+    virtual void storeSetting(const WebCore::String& key, const WebCore::String& value);
 
     virtual void inspectorWindowObjectCleared();
 
index 6a4f67d88d627381018492581965e2098de8b167..01515b11ee98e0c08af3ba57b445ebc8fa717345 100644 (file)
@@ -327,8 +327,8 @@ void WebInspectorClient::inspectorWindowObjectCleared()
     _visible = YES;
     
     // If no preference is set - default to an attached window. This is important for inspector LayoutTests.
-    InspectorController::Setting shouldAttach = [_inspectedWebView page]->inspectorController()->setting(inspectorStartsAttachedName);
-    _shouldAttach = (shouldAttach.type() == InspectorController::Setting::BooleanType) ? shouldAttach.booleanValue() : true;
+    String shouldAttach = [_inspectedWebView page]->inspectorController()->setting(inspectorStartsAttachedName);
+    _shouldAttach = shouldAttach != "false";
 
     if (_shouldAttach) {
         WebFrameView *frameView = [[_inspectedWebView mainFrame] frameView];
@@ -362,7 +362,7 @@ void WebInspectorClient::inspectorWindowObjectCleared()
     if (_attachedToInspectedWebView)
         return;
 
-    [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, InspectorController::Setting(true));
+    [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, "true");
     _movingWindows = YES;
 
     [self close];
@@ -376,7 +376,7 @@ void WebInspectorClient::inspectorWindowObjectCleared()
     if (!_attachedToInspectedWebView)
         return;
 
-    [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, InspectorController::Setting(false));
+    [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, "false");
     _movingWindows = YES;
 
     [self close];
index e17b02f07af4d5bbd23fd310bcd3f83a6cbab5de..4fef0ac0414e1c640f9cef83f2b6cca731175a84 100644 (file)
@@ -1,3 +1,18 @@
+2009-12-03  Pavel Feldman  <pfeldman@dhcp-172-28-174-220.spb.corp.google.com>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: Simplify the settings support in inspector controller.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32076
+
+        * WebCoreSupport/InspectorClientQt.cpp:
+        (WebCore::InspectorClientQt::populateSetting):
+        (WebCore::InspectorClientQt::storeSetting):
+        (WebCore::variantToSetting):
+        (WebCore::settingToVariant):
+        * WebCoreSupport/InspectorClientQt.h:
+
 2009-12-03  Ben Murdoch  <benm@google.com>
 
         Reviewed by Brady Eidson.
index 7a1bfd579e39675da931a29c73dabbbf960fc5ab..bafdb8415ce73bfd4a2fe5eb10af046a3ef56ee2 100644 (file)
@@ -50,8 +50,8 @@ namespace WebCore {
 static const QLatin1String settingStoragePrefix("Qt/QtWebKit/QWebInspector/");
 static const QLatin1String settingStorageTypeSuffix(".type");
 
-static InspectorController::Setting variantToSetting(const QVariant& qvariant);
-static QVariant settingToVariant(const InspectorController::Setting& icSetting);
+static String variantToSetting(const QVariant& qvariant);
+static QVariant settingToVariant(const String& value);
 
 class InspectorClientWebPage : public QWebPage {
     Q_OBJECT
@@ -169,7 +169,7 @@ void InspectorClientQt::updateWindowTitle()
     }
 }
 
-void InspectorClientQt::populateSetting(const String& key, InspectorController::Setting& setting)
+void InspectorClientQt::populateSetting(const String& key, String* setting)
 {
     QSettings qsettings;
     if (qsettings.status() == QSettings::AccessError) {
@@ -183,10 +183,10 @@ void InspectorClientQt::populateSetting(const String& key, InspectorController::
     QString storedValueType = qsettings.value(settingKey + settingStorageTypeSuffix).toString();
     QVariant storedValue = qsettings.value(settingKey);
     storedValue.convert(QVariant::nameToType(storedValueType.toAscii().data()));
-    setting = variantToSetting(storedValue);
+    *setting = variantToSetting(storedValue);
 }
 
-void InspectorClientQt::storeSetting(const String& key, const InspectorController::Setting& setting)
+void InspectorClientQt::storeSetting(const String& key, const String& setting)
 {
     QSettings qsettings;
     if (qsettings.status() == QSettings::AccessError) {
@@ -201,70 +201,24 @@ void InspectorClientQt::storeSetting(const String& key, const InspectorControlle
     qsettings.setValue(settingKey + settingStorageTypeSuffix, QVariant::typeToName(valueToStore.type()));
 }
 
-void InspectorClientQt::removeSetting(const String&)
+static String variantToSetting(const QVariant& qvariant)
 {
-    notImplemented();
-}
-
-static InspectorController::Setting variantToSetting(const QVariant& qvariant)
-{
-    InspectorController::Setting retVal;
+    String retVal;
 
     switch (qvariant.type()) {
     case QVariant::Bool:
-        retVal.set(qvariant.toBool());
-        break;
-    case QVariant::Double:
-        retVal.set(qvariant.toDouble());
-        break;
-    case QVariant::Int:
-        retVal.set((long)qvariant.toInt());
-        break;
+        retVal = qvariant.toBool() ? "true" : "false";
     case QVariant::String:
-        retVal.set(qvariant.toString());
-        break;
-    case QVariant::StringList: {
-        QStringList qsList = qvariant.toStringList();
-        int listCount = qsList.count();
-        Vector<String> vector(listCount);
-        for (int i = 0; i < listCount; ++i)
-            vector[i] = qsList[i];
-        retVal.set(vector);
-        break;
-    }
+        retVal = qvariant.toString();
     }
 
     return retVal;
 }
 
-static QVariant settingToVariant(const InspectorController::Setting& icSetting)
+static QVariant settingToVariant(const String& setting)
 {
     QVariant retVal;
-
-    switch (icSetting.type()) {
-    case InspectorController::Setting::StringType:
-        retVal.setValue(static_cast<QString>(icSetting.string()));
-        break;
-    case InspectorController::Setting::StringVectorType: {
-        const Vector<String>& vector = icSetting.stringVector();
-        Vector<String>::const_iterator iter;
-        QStringList qsList;
-        for (iter = vector.begin(); iter != vector.end(); ++iter)
-            qsList << *iter;
-        retVal.setValue(qsList);
-        break;
-    }
-    case InspectorController::Setting::DoubleType:
-        retVal.setValue(icSetting.doubleValue());
-        break;
-    case InspectorController::Setting::IntegerType:
-        retVal.setValue((int)icSetting.integerValue());
-        break;
-    case InspectorController::Setting::BooleanType:
-        retVal.setValue(icSetting.booleanValue());
-        break;
-    }
-
+    retVal.setValue(static_cast<QString>(setting));
     return retVal;
 }
 
index ccf8b69b46794c594ef449b1c909d8e8bba116df..923bab4bf543994764d677bf57a005d7620f283f 100644 (file)
@@ -66,9 +66,8 @@ namespace WebCore {
         virtual void hideHighlight();
         virtual void inspectedURLChanged(const String& newURL);
 
-        virtual void populateSetting(const String& key, InspectorController::Setting&);
-        virtual void storeSetting(const String& key, const InspectorController::Setting&);
-        virtual void removeSetting(const String& key);
+        virtual void populateSetting(const String& key, String* value);
+        virtual void storeSetting(const String& key, const String& value);
 
         virtual void inspectorWindowObjectCleared();
 
index 46926495e5f8c9617f8fc92555eec5c352f744fb..16abcae862649dcccaeb2e712c88f79cf7ecb7d4 100644 (file)
@@ -1,3 +1,17 @@
+2009-12-03  Pavel Feldman  <pfeldman@dhcp-172-28-174-220.spb.corp.google.com>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: Simplify the settings support in inspector controller.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32076
+
+        * WebCoreSupport/WebInspectorClient.cpp:
+        (WebInspectorClient::attachWindow):
+        (WebInspectorClient::detachWindow):
+        (WebInspectorClient::showWindowWithoutNotifications):
+        * WebCoreSupport/WebInspectorClient.h:
+
 2009-12-03  Ben Murdoch  <benm@google.com>
 
         Reviewed by Brady Eidson.
index 75a76f256fd0708d9911f946c66d6ef600a6efe1..0dd6e58585a8f1cbfbcdc1f1fd86a65d8b2fc7a2 100644 (file)
@@ -233,7 +233,7 @@ void WebInspectorClient::attachWindow()
     if (m_attached)
         return;
 
-    m_inspectedWebView->page()->inspectorController()->setSetting(inspectorStartsAttachedName, InspectorController::Setting(true));
+    m_inspectedWebView->page()->inspectorController()->setSetting(inspectorStartsAttachedName, "true");
 
     closeWindowWithoutNotifications();
     showWindowWithoutNotifications();
@@ -244,7 +244,7 @@ void WebInspectorClient::detachWindow()
     if (!m_attached)
         return;
 
-    m_inspectedWebView->page()->inspectorController()->setSetting(inspectorStartsAttachedName, InspectorController::Setting(false));
+    m_inspectedWebView->page()->inspectorController()->setSetting(inspectorStartsAttachedName, "false");
 
     closeWindowWithoutNotifications();
     showWindowWithoutNotifications();
@@ -350,8 +350,8 @@ void WebInspectorClient::showWindowWithoutNotifications()
     ASSERT(m_inspectedWebViewHwnd);
 
     // If no preference is set - default to an attached window. This is important for inspector LayoutTests.
-    InspectorController::Setting shouldAttach = m_inspectedWebView->page()->inspectorController()->setting(inspectorStartsAttachedName);
-    m_shouldAttachWhenShown = shouldAttach.type() == InspectorController::Setting::BooleanType ? shouldAttach.booleanValue() : true;
+    String shouldAttach = m_inspectedWebView->page()->inspectorController()->setting(inspectorStartsAttachedName);
+    m_shouldAttachWhenShown = shouldAttach != "false";
 
     if (!m_shouldAttachWhenShown) {
         // Put the Inspector's WebView inside our window and show it.
index 8965e87c775240a6f8d61596cec19b140746e570..3f65b0afd8160181f9f3ea4c965480b57abd4bde 100644 (file)
@@ -66,9 +66,8 @@ public:
 
     virtual void inspectedURLChanged(const WebCore::String& newURL);
 
-    virtual void populateSetting(const WebCore::String& key, WebCore::InspectorController::Setting&);
-    virtual void storeSetting(const WebCore::String& key, const WebCore::InspectorController::Setting&);
-    virtual void removeSetting(const WebCore::String& key);
+    virtual void populateSetting(const WebCore::String& key, WebCore::String* value);
+    virtual void storeSetting(const WebCore::String& key, const WebCore::String& value);
 
     virtual void inspectorWindowObjectCleared();
 
index daba0b9dfe599513f6dfbc149fb98e5ca85510bf..5d0ca0e203563131ab9c61282230821f66e07126 100644 (file)
@@ -1,3 +1,16 @@
+2009-12-03  Pavel Feldman  <pfeldman@dhcp-172-28-174-220.spb.corp.google.com>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: Simplify the settings support in inspector controller.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32076
+
+        * WebKitSupport/InspectorClientWx.cpp:
+        (WebCore::InspectorClientWx::populateSetting):
+        (WebCore::InspectorClientWx::storeSetting):
+        * WebKitSupport/InspectorClientWx.h:
+
 2009-12-03  Ben Murdoch  <benm@google.com>
 
         Reviewed by Brady Eidson.
index d55ad04423aa0b93d702a8b25837484bc1b0054e..ff21ae04acd12cd0c3410bc54c45cddc7c5fecd5 100644 (file)
@@ -105,17 +105,12 @@ void InspectorClientWx::inspectedURLChanged(const String& newURL)
     notImplemented();
 }
 
-void InspectorClientWx::populateSetting(const String& key, InspectorController::Setting& setting)
+void InspectorClientWx::populateSetting(const String& key, String* setting)
 {
     notImplemented();
 }
 
-void InspectorClientWx::storeSetting(const String& key, const InspectorController::Setting& setting)
-{
-    notImplemented();
-}
-
-void InspectorClientWx::removeSetting(const String& key)
+void InspectorClientWx::storeSetting(const String& key, const String& setting)
 {
     notImplemented();
 }
index 182df1bbda96deae3332fb215a16c4e01143820d..f905817222898e66ad6638e51c63606c479dc1a9 100644 (file)
@@ -60,10 +60,9 @@ public:
 
     virtual void inspectedURLChanged(const String& newURL);
 
-    virtual void populateSetting(const String& key, InspectorController::Setting&);
-    virtual void storeSetting(const String& key, const InspectorController::Setting&);
-    virtual void removeSetting(const String& key);
-    
+    virtual void populateSetting(const String& key, String* value);
+    virtual void storeSetting(const String& key, const String& value);
+
     virtual void inspectorWindowObjectCleared();
 };