[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

pfeldman at chromium.org pfeldman at chromium.org
Thu Apr 8 00:48:41 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 60a5f40722ed9f225c4305c326869ff3a3c4d0e7
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 24 12:33:39 2009 +0000

    2009-12-24  Pavel Feldman  <pfeldman at chromium.org>
    
            Reviewed by Timothy Hatcher.
    
            Web Inspector: add Settings.js class that would manage
            frontend settings.
    
            This change:
            - Splits preferences and settings
            - Pushes settings to the frontend on load
            - Stores settings on each change
            - Stores showInheritedStyles as setting.
    
            https://bugs.webkit.org/show_bug.cgi?id=32832
    
            * WebCore.gypi:
            * WebCore.vcproj/WebCore.vcproj:
            * inspector/InspectorBackend.cpp:
            (WebCore::InspectorBackend::saveFrontendSettings):
            * inspector/InspectorBackend.h:
            * inspector/InspectorBackend.idl:
            * inspector/InspectorController.cpp:
            (WebCore::InspectorController::populateScriptObjects):
            * inspector/InspectorController.h:
            * inspector/InspectorFrontend.cpp:
            (WebCore::InspectorFrontend::populateFrontendSettings):
            * inspector/InspectorFrontend.h:
            * inspector/InspectorFrontendHost.cpp:
            * inspector/InspectorFrontendHost.h:
            * inspector/InspectorFrontendHost.idl:
            * inspector/front-end/EventListenersSidebarPane.js:
            (WebInspector.EventListenersSidebarPane.prototype._settingsLoaded):
            (WebInspector.EventListenersSidebarPane.prototype):
            ():
            * inspector/front-end/InspectorBackendStub.js:
            (.WebInspector.InspectorBackendStub):
            (.WebInspector.InspectorBackendStub.prototype.saveFrontendSettings):
            (.WebInspector.InspectorBackendStub.prototype.releaseWrapperObjectGroup):
            * inspector/front-end/InspectorFrontendHostStub.js:
            (.WebInspector.InspectorFrontendHostStub):
            (.WebInspector.InspectorFrontendHostStub.prototype.hiddenPanels):
            * inspector/front-end/ResourcesPanel.js:
            (WebInspector.ResourcesPanel.prototype._createStatusbarButtons):
            (WebInspector.ResourcesPanel.prototype._settingsLoaded):
            (WebInspector.ResourcesPanel.prototype._toggleLargerResources):
            (WebInspector.ResourcesPanel.prototype._setLargerResources):
            * inspector/front-end/ScriptsPanel.js:
            (WebInspector.ScriptsPanel.prototype._showScriptOrResource):
            (WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu):
            * inspector/front-end/Settings.js: Added.
            (WebInspector.populateFrontendSettings):
            (WebInspector.Settings):
            (WebInspector.Settings.prototype._load):
            (WebInspector.Settings.prototype._installSetting):
            (WebInspector.Settings.prototype._get):
            (WebInspector.Settings.prototype._set):
            * inspector/front-end/StylesSidebarPane.js:
            (WebInspector.StylesSidebarPane.prototype._settingsLoaded):
            (WebInspector.StylesSidebarPane.prototype.update):
            (WebInspector.StylesSidebarPane.prototype._changeSetting):
            (WebInspector.StylesSidebarPane.prototype._changeColorFormat):
            (WebInspector.StylePropertiesSection.showInheritedToggleFunction):
            (WebInspector.StylePropertiesSection):
            * inspector/front-end/WatchExpressionsSidebarPane.js:
            (WebInspector.WatchExpressionsSidebarPane):
            (WebInspector.WatchExpressionsSidebarPane.prototype._settingsLoaded):
            (WebInspector.WatchExpressionsSidebarPane.prototype.refreshExpressions):
            (WebInspector.WatchExpressionsSection):
            (WebInspector.WatchExpressionsSection.prototype.saveExpressions):
            * inspector/front-end/WebKit.qrc:
            * inspector/front-end/inspector.html:
            * inspector/front-end/inspector.js:
            (WebInspector.loaded):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52547 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 27b9507..51c25b1 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2009-12-21  Pavel Feldman  <pfeldman at chromium.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: add Settings.js class that would manage
+        frontend settings.
+
+        This change:
+        - Splits preferences and settings
+        - Pushes settings to the frontend on load
+        - Stores settings on each change
+        - Stores showInheritedStyles as setting.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32832
+
+        * inspector/settings-set-get-expected.txt: Removed.
+        * inspector/settings-set-get.html: Removed.
+
 2009-12-24  Pavel Feldman  <pfeldman at chromium.org>
 
         Not reviewed: follow up to r52545, adding missing tests.
diff --git a/LayoutTests/inspector/settings-set-get-expected.txt b/LayoutTests/inspector/settings-set-get-expected.txt
deleted file mode 100644
index bac9643..0000000
--- a/LayoutTests/inspector/settings-set-get-expected.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-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
deleted file mode 100644
index 8341d7d..0000000
--- a/LayoutTests/inspector/settings-set-get.html
+++ /dev/null
@@ -1,45 +0,0 @@
-<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>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index bdfd82a..50dd919 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,77 @@
+2009-12-24  Pavel Feldman  <pfeldman at chromium.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: add Settings.js class that would manage
+        frontend settings.
+
+        This change:
+        - Splits preferences and settings
+        - Pushes settings to the frontend on load
+        - Stores settings on each change
+        - Stores showInheritedStyles as setting.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32832
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/InspectorBackend.cpp:
+        (WebCore::InspectorBackend::saveFrontendSettings):
+        * inspector/InspectorBackend.h:
+        * inspector/InspectorBackend.idl:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::populateScriptObjects):
+        * inspector/InspectorController.h:
+        * inspector/InspectorFrontend.cpp:
+        (WebCore::InspectorFrontend::populateFrontendSettings):
+        * inspector/InspectorFrontend.h:
+        * inspector/InspectorFrontendHost.cpp:
+        * inspector/InspectorFrontendHost.h:
+        * inspector/InspectorFrontendHost.idl:
+        * inspector/front-end/EventListenersSidebarPane.js:
+        (WebInspector.EventListenersSidebarPane.prototype._settingsLoaded):
+        (WebInspector.EventListenersSidebarPane.prototype):
+        ():
+        * inspector/front-end/InspectorBackendStub.js:
+        (.WebInspector.InspectorBackendStub):
+        (.WebInspector.InspectorBackendStub.prototype.saveFrontendSettings):
+        (.WebInspector.InspectorBackendStub.prototype.releaseWrapperObjectGroup):
+        * inspector/front-end/InspectorFrontendHostStub.js:
+        (.WebInspector.InspectorFrontendHostStub):
+        (.WebInspector.InspectorFrontendHostStub.prototype.hiddenPanels):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype._createStatusbarButtons):
+        (WebInspector.ResourcesPanel.prototype._settingsLoaded):
+        (WebInspector.ResourcesPanel.prototype._toggleLargerResources):
+        (WebInspector.ResourcesPanel.prototype._setLargerResources):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._showScriptOrResource):
+        (WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu):
+        * inspector/front-end/Settings.js: Added.
+        (WebInspector.populateFrontendSettings):
+        (WebInspector.Settings):
+        (WebInspector.Settings.prototype._load):
+        (WebInspector.Settings.prototype._installSetting):
+        (WebInspector.Settings.prototype._get):
+        (WebInspector.Settings.prototype._set):
+        * inspector/front-end/StylesSidebarPane.js:
+        (WebInspector.StylesSidebarPane.prototype._settingsLoaded):
+        (WebInspector.StylesSidebarPane.prototype.update):
+        (WebInspector.StylesSidebarPane.prototype._changeSetting):
+        (WebInspector.StylesSidebarPane.prototype._changeColorFormat):
+        (WebInspector.StylePropertiesSection.showInheritedToggleFunction):
+        (WebInspector.StylePropertiesSection):
+        * inspector/front-end/WatchExpressionsSidebarPane.js:
+        (WebInspector.WatchExpressionsSidebarPane):
+        (WebInspector.WatchExpressionsSidebarPane.prototype._settingsLoaded):
+        (WebInspector.WatchExpressionsSidebarPane.prototype.refreshExpressions):
+        (WebInspector.WatchExpressionsSection):
+        (WebInspector.WatchExpressionsSection.prototype.saveExpressions):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+        * inspector/front-end/inspector.js:
+        (WebInspector.loaded):
+
 2009-12-23  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 836e33d..668f823 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -3700,6 +3700,7 @@
             'inspector/front-end/ScriptsPanel.js',
             'inspector/front-end/ScriptView.js',
             'inspector/front-end/Section.js',
+            'inspector/front-end/Settings.js',
             'inspector/front-end/SidebarPane.js',
             'inspector/front-end/SidebarTreeElement.js',
             'inspector/front-end/SourceFrame.js',
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index eca22dc..57e3dac 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -42924,6 +42924,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\Settings.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\SidebarPane.js"
 					>
 				</File>
diff --git a/WebCore/inspector/InspectorBackend.cpp b/WebCore/inspector/InspectorBackend.cpp
index 47c3a03..025ca87 100644
--- a/WebCore/inspector/InspectorBackend.cpp
+++ b/WebCore/inspector/InspectorBackend.cpp
@@ -77,6 +77,12 @@ InspectorBackend::~InspectorBackend()
 {
 }
 
+void InspectorBackend::saveFrontendSettings(const String& settings)
+{
+    if (m_inspectorController)
+        m_inspectorController->setSetting(InspectorController::FrontendSettingsSettingName, settings);
+}
+
 void InspectorBackend::storeLastActivePanel(const String& panelName)
 {
     if (m_inspectorController)
diff --git a/WebCore/inspector/InspectorBackend.h b/WebCore/inspector/InspectorBackend.h
index 937c026..05b5799 100644
--- a/WebCore/inspector/InspectorBackend.h
+++ b/WebCore/inspector/InspectorBackend.h
@@ -58,6 +58,8 @@ public:
     InspectorController* inspectorController() { return m_inspectorController; }
     void disconnectController() { m_inspectorController = 0; }
 
+    void saveFrontendSettings(const String&);
+
     void storeLastActivePanel(const String& panelName);
 
     void toggleNodeSearch();
diff --git a/WebCore/inspector/InspectorBackend.idl b/WebCore/inspector/InspectorBackend.idl
index 2e2a3f5..40d1006 100644
--- a/WebCore/inspector/InspectorBackend.idl
+++ b/WebCore/inspector/InspectorBackend.idl
@@ -34,6 +34,8 @@ module core {
     interface InspectorBackend {
         void storeLastActivePanel(in DOMString panelName);
 
+        void saveFrontendSettings(in DOMString settings);
+
         void toggleNodeSearch();
         boolean searchingForNode();
 
diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp
index d1e9e12..5018dd1 100644
--- a/WebCore/inspector/InspectorController.cpp
+++ b/WebCore/inspector/InspectorController.cpp
@@ -117,6 +117,7 @@ static const char* const debuggerEnabledSettingName = "debuggerEnabled";
 static const char* const profilerEnabledSettingName = "profilerEnabled";
 static const char* const inspectorAttachedHeightName = "inspectorAttachedHeight";
 static const char* const lastActivePanelSettingName = "lastActivePanel";
+const char* const InspectorController::FrontendSettingsSettingName = "frontendSettings";
 
 static const unsigned defaultAttachedHeight = 300;
 static const float minimumAttachedHeight = 250.0f;
@@ -657,6 +658,7 @@ void InspectorController::populateScriptObjects()
     if (!m_frontend)
         return;
 
+    m_frontend->populateFrontendSettings(setting(FrontendSettingsSettingName));
     m_domAgent->setDocument(m_inspectedPage->mainFrame()->document());
 
     ResourcesMap::iterator resourcesEnd = m_resources.end();
diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h
index 1abd933..18a191d 100644
--- a/WebCore/inspector/InspectorController.h
+++ b/WebCore/inspector/InspectorController.h
@@ -245,6 +245,7 @@ public:
     void evaluateForTestInFrontend(long callId, const String& script);
 
 private:
+    static const char* const FrontendSettingsSettingName;
     friend class InspectorBackend;
     friend class InspectorFrontendHost;
     friend class InjectedScriptHost;
diff --git a/WebCore/inspector/InspectorFrontend.cpp b/WebCore/inspector/InspectorFrontend.cpp
index 6a2c629..4da69f4 100644
--- a/WebCore/inspector/InspectorFrontend.cpp
+++ b/WebCore/inspector/InspectorFrontend.cpp
@@ -77,6 +77,14 @@ void InspectorFrontend::didCommitLoad()
     callSimpleFunction("didCommitLoad");
 }
 
+void InspectorFrontend::populateFrontendSettings(const String& settings)
+{
+    ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
+    function.appendArgument("populateFrontendSettings");
+    function.appendArgument(settings);
+    function.call();
+}
+
 void InspectorFrontend::updateConsoleMessageExpiredCount(unsigned count)
 {
     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch"); 
diff --git a/WebCore/inspector/InspectorFrontend.h b/WebCore/inspector/InspectorFrontend.h
index 7160f50..c1c4db5 100644
--- a/WebCore/inspector/InspectorFrontend.h
+++ b/WebCore/inspector/InspectorFrontend.h
@@ -64,6 +64,8 @@ namespace WebCore {
 
         void didCommitLoad();
 
+        void populateFrontendSettings(const String& settings);
+
         void updateConsoleMessageExpiredCount(unsigned count);
         void addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, const Vector<ScriptValue> wrappedArguments, const String& message);
         void updateConsoleMessageRepeatCount(unsigned count);
diff --git a/WebCore/inspector/InspectorFrontendHost.cpp b/WebCore/inspector/InspectorFrontendHost.cpp
index d067346..5bc5ac1 100644
--- a/WebCore/inspector/InspectorFrontendHost.cpp
+++ b/WebCore/inspector/InspectorFrontendHost.cpp
@@ -197,17 +197,6 @@ 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);
-}
-
 void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMenuItem*>& items)
 {
     if (!m_inspectorController)
diff --git a/WebCore/inspector/InspectorFrontendHost.h b/WebCore/inspector/InspectorFrontendHost.h
index 3b6aeb7..84a54ad 100644
--- a/WebCore/inspector/InspectorFrontendHost.h
+++ b/WebCore/inspector/InspectorFrontendHost.h
@@ -76,9 +76,6 @@ 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);
-
     // Called from [Custom] implementations.
     void showContextMenu(Event*, const Vector<ContextMenuItem*>& items);
 
diff --git a/WebCore/inspector/InspectorFrontendHost.idl b/WebCore/inspector/InspectorFrontendHost.idl
index 2143409..52510f4 100644
--- a/WebCore/inspector/InspectorFrontendHost.idl
+++ b/WebCore/inspector/InspectorFrontendHost.idl
@@ -49,9 +49,6 @@ 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] void showContextMenu(in MouseEvent event, in DOMObject items);
     };
diff --git a/WebCore/inspector/front-end/EventListenersSidebarPane.js b/WebCore/inspector/front-end/EventListenersSidebarPane.js
index c083c0e..38e7fc2 100644
--- a/WebCore/inspector/front-end/EventListenersSidebarPane.js
+++ b/WebCore/inspector/front-end/EventListenersSidebarPane.js
@@ -38,18 +38,15 @@ WebInspector.EventListenersSidebarPane = function()
 
     var option = document.createElement("option");
     option.value = "all";
-    if (Preferences.eventListenersFilter === "all")
-        option.selected = true;
     option.label = WebInspector.UIString("All Nodes");
     this.settingsSelectElement.appendChild(option);
 
     option = document.createElement("option");
     option.value = "selected";
-    if (Preferences.eventListenersFilter === "selected")
-        option.selected = true;
     option.label = WebInspector.UIString("Selected Node Only");
     this.settingsSelectElement.appendChild(option);
 
+    WebInspector.settings.addEventListener("loaded", this._settingsLoaded, this);
     this.settingsSelectElement.addEventListener("click", function(event) { event.stopPropagation() }, false);
     this.settingsSelectElement.addEventListener("change", this._changeSetting.bind(this), false);
 
@@ -57,6 +54,15 @@ WebInspector.EventListenersSidebarPane = function()
 }
 
 WebInspector.EventListenersSidebarPane.prototype = {
+    _settingsLoaded: function()
+    {
+        var filter = WebInspector.settings.eventListenersFilter;
+        if (filter === "all")
+            this.settingsSelectElement[0].selected = true;
+        if (filter === "selected")
+            this.settingsSelectElement[1].selected = true;
+    },
+
     update: function(node)
     {
         var body = this.bodyElement;
@@ -106,9 +112,7 @@ WebInspector.EventListenersSidebarPane.prototype = {
     _changeSetting: function(event)
     {
         var selectedOption = this.settingsSelectElement[this.settingsSelectElement.selectedIndex];
-        Preferences.eventListenersFilter = selectedOption.value;
-
-        InspectorFrontendHost.setSetting("event-listeners-filter", Preferences.eventListenersFilter);
+        WebInspector.settings.eventListenersFilter = selectedOption.value;
 
         for (var i = 0; i < this.sections.length; ++i)
             this.sections[i].update();
@@ -138,7 +142,7 @@ WebInspector.EventListenersSection.prototype = {
     {
         // A Filtered Array simplifies when to create connectors
         var filteredEventListeners = this.eventListeners;
-        if (Preferences.eventListenersFilter === "selected") {
+        if (WebInspector.settings.eventListenersFilter === "selected") {
             filteredEventListeners = [];
             for (var i = 0; i < this.eventListeners.length; ++i) {
                 var eventListener = this.eventListeners[i];
diff --git a/WebCore/inspector/front-end/InspectorBackendStub.js b/WebCore/inspector/front-end/InspectorBackendStub.js
index 1710b12..5844a23 100644
--- a/WebCore/inspector/front-end/InspectorBackendStub.js
+++ b/WebCore/inspector/front-end/InspectorBackendStub.js
@@ -38,7 +38,6 @@ WebInspector.InspectorBackendStub = function()
     this._profilerEnabled = true;
     this._resourceTrackingEnabled = false;
     this._timelineEnabled = false;
-    this._settings = {};
 }
 
 WebInspector.InspectorBackendStub.prototype = {
@@ -266,9 +265,8 @@ WebInspector.InspectorBackendStub.prototype = {
     {
     },
 
-    setSetting: function(setting, value)
+    saveFrontendSettings: function()
     {
-        this._settings[setting] = value;
     },
 
     dispatchOnInjectedScript: function()
@@ -277,11 +275,6 @@ WebInspector.InspectorBackendStub.prototype = {
 
     releaseWrapperObjectGroup: function()
     {
-    },
-
-    setting: function(setting)
-    {
-        return this._settings[setting];
     }
 }
 
diff --git a/WebCore/inspector/front-end/InspectorFrontendHostStub.js b/WebCore/inspector/front-end/InspectorFrontendHostStub.js
index facea4e..fb91794 100644
--- a/WebCore/inspector/front-end/InspectorFrontendHostStub.js
+++ b/WebCore/inspector/front-end/InspectorFrontendHostStub.js
@@ -33,7 +33,6 @@ if (!window.InspectorFrontendHost) {
 WebInspector.InspectorFrontendHostStub = function()
 {
     this._attachedWindowHeight = 0;
-    this._settings = {};
 }
 
 WebInspector.InspectorFrontendHostStub.prototype = {
@@ -93,16 +92,6 @@ WebInspector.InspectorFrontendHostStub.prototype = {
     hiddenPanels: function()
     {
         return "";
-    },
-
-    setSetting: function(setting, value)
-    {
-        this._settings[setting] = value;
-    },
-
-    setting: function(setting)
-    {
-        return this._settings[setting];
     }
 }
 
diff --git a/WebCore/inspector/front-end/ResourcesPanel.js b/WebCore/inspector/front-end/ResourcesPanel.js
index 4e71328..13bc1f2 100644
--- a/WebCore/inspector/front-end/ResourcesPanel.js
+++ b/WebCore/inspector/front-end/ResourcesPanel.js
@@ -141,18 +141,21 @@ WebInspector.ResourcesPanel.prototype = {
     _createStatusbarButtons: function()
     {
         this.largerResourcesButton = new WebInspector.StatusBarButton(WebInspector.UIString("Use small resource rows."), "resources-larger-resources-status-bar-item");
-        this.largerResourcesButton.toggled = Preferences.resourcesLargeRows;
-        this.largerResourcesButton.addEventListener("click", this._toggleLargerResources.bind(this), false);
-        if (!Preferences.resourcesLargeRows) {
-            Preferences.resourcesLargeRows = !Preferences.resourcesLargeRows;
-            this._toggleLargerResources(); // this will toggle the preference back to the original
-        }
 
+        WebInspector.settings.addEventListener("loaded", this._settingsLoaded, this);
+        this.largerResourcesButton.addEventListener("click", this._toggleLargerResources.bind(this), false);
         this.sortingSelectElement = document.createElement("select");
         this.sortingSelectElement.className = "status-bar-item";
         this.sortingSelectElement.addEventListener("change", this._changeSortingFunction.bind(this), false);
     },
 
+    _settingsLoaded: function()
+    {
+        this.largerResourcesButton.toggled = WebInspector.settings.resourcesLargeRows;
+        if (!WebInspector.settings.resourcesLargeRows)
+            this._setLargerResources(WebInspector.settings.resourcesLargeRows);
+    },
+
     get mainResourceLoadTime()
     {
         return this._mainResourceLoadTime || -1;
@@ -624,19 +627,21 @@ WebInspector.ResourcesPanel.prototype = {
         if (!this.itemsTreeElement._childrenListNode)
             return;
 
-        this.itemsTreeElement.smallChildren = !this.itemsTreeElement.smallChildren;
-        Preferences.resourcesLargeRows = !Preferences.resourcesLargeRows;
-        InspectorFrontendHost.setSetting("resources-large-rows", Preferences.resourcesLargeRows);
+        WebInspector.settings.resourcesLargeRows = !WebInspector.settings.resourcesLargeRows;
+        this._setLargerResources(this.itemsTreeElement.smallChildren);
+    },
 
-        if (this.itemsTreeElement.smallChildren) {
+    _setLargerResources: function(enabled)
+    {
+        this.largerResourcesButton.toggled = enabled;
+        this.itemsTreeElement.smallChildren = !enabled;
+        if (!enabled) {
             this.itemsGraphsElement.addStyleClass("small");
             this.largerResourcesButton.title = WebInspector.UIString("Use large resource rows.");
-            this.largerResourcesButton.toggled = false;
             this.adjustScrollPosition();
         } else {
             this.itemsGraphsElement.removeStyleClass("small");
             this.largerResourcesButton.title = WebInspector.UIString("Use small resource rows.");
-            this.largerResourcesButton.toggled = true;
         }
     },
 
diff --git a/WebCore/inspector/front-end/ScriptsPanel.js b/WebCore/inspector/front-end/ScriptsPanel.js
index b36536b..20d5882 100644
--- a/WebCore/inspector/front-end/ScriptsPanel.js
+++ b/WebCore/inspector/front-end/ScriptsPanel.js
@@ -623,7 +623,7 @@ WebInspector.ScriptsPanel.prototype = {
 
         var url = scriptOrResource.url || scriptOrResource.sourceURL;
         if (url && !options.initialLoad)
-            InspectorFrontendHost.setSetting("LastViewedScriptFile", url);
+            WebInspector.settings.lastViewedScriptFile = url;
 
         if (!options.fromBackForwardAction) {
             var oldIndex = this._currentBackForwardIndex;
@@ -726,7 +726,7 @@ WebInspector.ScriptsPanel.prototype = {
         else {
             // if not first item, check to see if this was the last viewed
             var url = option.representedObject.url || option.representedObject.sourceURL;
-            var lastURL = InspectorFrontendHost.setting("LastViewedScriptFile");
+            var lastURL = WebInspector.settings.lastViewedScriptFile;
             if (url && url === lastURL)
                 this._showScriptOrResource(option.representedObject, {initialLoad: true});
         }
diff --git a/WebCore/inspector/front-end/Settings.js b/WebCore/inspector/front-end/Settings.js
new file mode 100644
index 0000000..6cd4497
--- /dev/null
+++ b/WebCore/inspector/front-end/Settings.js
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2009 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER 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.
+ */
+
+
+var Preferences = {
+    maxInlineTextChildLength: 80,
+    minConsoleHeight: 75,
+    minSidebarWidth: 100,
+    minElementsSidebarWidth: 200,
+    minScriptsSidebarWidth: 200,
+    styleRulesExpandedState: {},
+    showMissingLocalizedStrings: false,
+    heapProfilerPresent: false,
+    samplingCPUProfiler: false,
+    showColorNicknames: true
+}
+
+WebInspector.populateFrontendSettings = function(settingsString)
+{
+    WebInspector.settings._load(settingsString);
+}
+
+WebInspector.Settings = function()
+{
+}
+
+WebInspector.Settings.prototype = {
+    _load: function(settingsString)
+    {
+        try {
+            this._store = JSON.parse(settingsString);
+        } catch (e) {
+            // May fail;
+            this._store = {};
+        }
+
+        this._installSetting("eventListenersFilter", "event-listeners-filter", "all");
+        this._installSetting("colorFormat", "color-format", "hex");
+        this._installSetting("resourcesLargeRows", "resources-large-rows", true);
+        this._installSetting("watchExpressions", "watch-expressions", []);
+        this._installSetting("lastViewedScriptFile", "last-viewed-script-file");
+        this._installSetting("showInheritedComputedStyleProperties", "show-inherited-computed-style-properties", false);
+        this._installSetting("showUserAgentStyles", "show-user-agent-styles", true);
+        this.dispatchEventToListeners("loaded");
+    },
+
+    _installSetting: function(name, propertyName, defaultValue)
+    {
+        this.__defineGetter__(name, this._get.bind(this, propertyName));
+        this.__defineSetter__(name, this._set.bind(this, propertyName));
+        if (!(propertyName in this._store)) {
+            this._store[propertyName] = defaultValue;
+        }
+    },
+
+    _get: function(propertyName)
+    {
+        return this._store[propertyName];
+    },
+
+    _set: function(propertyName, newValue)
+    {
+        this._store[propertyName] = newValue;
+        try {
+            InspectorBackend.saveFrontendSettings(JSON.stringify(this._store));
+        } catch (e) {
+            // May fail;
+        }
+    }
+}
+
+WebInspector.Settings.prototype.__proto__ = WebInspector.Object.prototype;
diff --git a/WebCore/inspector/front-end/StylesSidebarPane.js b/WebCore/inspector/front-end/StylesSidebarPane.js
index 5178a98..a6f23b5 100644
--- a/WebCore/inspector/front-end/StylesSidebarPane.js
+++ b/WebCore/inspector/front-end/StylesSidebarPane.js
@@ -36,24 +36,18 @@ WebInspector.StylesSidebarPane = function()
     var option = document.createElement("option");
     option.value = "hex";
     option.action = this._changeColorFormat.bind(this);
-    if (Preferences.colorFormat === "hex")
-        option.selected = true;
     option.label = WebInspector.UIString("Hex Colors");
     this.settingsSelectElement.appendChild(option);
 
     option = document.createElement("option");
     option.value = "rgb";
     option.action = this._changeColorFormat.bind(this);
-    if (Preferences.colorFormat === "rgb")
-        option.selected = true;
     option.label = WebInspector.UIString("RGB Colors");
     this.settingsSelectElement.appendChild(option);
 
     option = document.createElement("option");
     option.value = "hsl";
     option.action = this._changeColorFormat.bind(this);
-    if (Preferences.colorFormat === "hsl")
-        option.selected = true;
     option.label = WebInspector.UIString("HSL Colors");
     this.settingsSelectElement.appendChild(option);
 
@@ -66,11 +60,23 @@ WebInspector.StylesSidebarPane = function()
 
     this.settingsSelectElement.addEventListener("click", function(event) { event.stopPropagation() }, false);
     this.settingsSelectElement.addEventListener("change", this._changeSetting.bind(this), false);
-
+    WebInspector.settings.addEventListener("loaded", this._settingsLoaded, this);        
+    
     this.titleElement.appendChild(this.settingsSelectElement);
 }
 
 WebInspector.StylesSidebarPane.prototype = {
+    _settingsLoaded: function()
+    {
+        var format = WebInspector.settings.colorFormat;
+        if (format === "hex")
+            this.settingsSelectElement[0].selected = true;
+        if (format === "rgb")
+            this.settingsSelectElement[1].selected = true;
+        if (format === "hsl")
+            this.settingsSelectElement[2].selected = true;
+    },
+
     update: function(node, editedSection, forceUpdate)
     {
         var refresh = false;
@@ -109,7 +115,7 @@ WebInspector.StylesSidebarPane.prototype = {
             self._update(refresh, body, node, editedSection, forceUpdate);
         }
 
-        InjectedScriptAccess.getStyles(node.id, !Preferences.showUserAgentStyles, callback);
+        InjectedScriptAccess.getStyles(node.id, !WebInspector.settings.showUserAgentStyles, callback);
     },
 
     _update: function(refresh, body, node, editedSection, forceUpdate)
@@ -156,7 +162,7 @@ WebInspector.StylesSidebarPane.prototype = {
                 styleRules.push(inlineStyle);
             }
 
-            var matchedStyleRules = node.ownerDocument.defaultView.getMatchedCSSRules(node, "", !Preferences.showUserAgentStyles);
+            var matchedStyleRules = node.ownerDocument.defaultView.getMatchedCSSRules(node, "", !WebInspector.settings.showUserAgentStyles);
             if (matchedStyleRules) {
                 // Add rules in reverse order to match the cascade order.
                 for (var i = (matchedStyleRules.length - 1); i >= 0; --i) {
@@ -320,7 +326,7 @@ WebInspector.StylesSidebarPane.prototype = {
         // Select the correct color format setting again, since it needs to be selected.
         var selectedIndex = 0;
         for (var i = 0; i < options.length; ++i) {
-            if (options[i].value === Preferences.colorFormat) {
+            if (options[i].value === WebInspector.settings.colorFormat) {
                 selectedIndex = i;
                 break;
             }
@@ -332,9 +338,7 @@ WebInspector.StylesSidebarPane.prototype = {
     _changeColorFormat: function(event)
     {
         var selectedOption = this.settingsSelectElement[this.settingsSelectElement.selectedIndex];
-        Preferences.colorFormat = selectedOption.value;
-
-        InspectorFrontendHost.setSetting("color-format", Preferences.colorFormat);
+        WebInspector.settings.colorFormat = selectedOption.value;
 
         for (var i = 0; i < this.sections.length; ++i)
             this.sections[i].update(true);
@@ -397,18 +401,18 @@ WebInspector.StylePropertiesSection = function(styleRule, subtitle, computedStyl
     if (computedStyle) {
         this.element.addStyleClass("computed-style");
 
-        if (Preferences.showInheritedComputedStyleProperties)
+        if (WebInspector.settings.showInheritedComputedStyleProperties)
             this.element.addStyleClass("show-inherited");
 
         var showInheritedLabel = document.createElement("label");
         var showInheritedInput = document.createElement("input");
         showInheritedInput.type = "checkbox";
-        showInheritedInput.checked = Preferences.showInheritedComputedStyleProperties;
+        showInheritedInput.checked = WebInspector.settings.showInheritedComputedStyleProperties;
 
         var computedStyleSection = this;
         var showInheritedToggleFunction = function(event) {
-            Preferences.showInheritedComputedStyleProperties = showInheritedInput.checked;
-            if (Preferences.showInheritedComputedStyleProperties)
+            WebInspector.settings.showInheritedComputedStyleProperties = showInheritedInput.checked;
+            if (WebInspector.settings.showInheritedComputedStyleProperties)
                 computedStyleSection.element.addStyleClass("show-inherited");
             else
                 computedStyleSection.element.removeStyleClass("show-inherited");
@@ -916,9 +920,9 @@ WebInspector.StylePropertyTreeElement.prototype = {
                 var format;
                 if (Preferences.showColorNicknames && color.nickname)
                     format = "nickname";
-                else if (Preferences.colorFormat === "rgb")
+                else if (WebInspector.settings.colorFormat === "rgb")
                     format = (color.simple ? "rgb" : "rgba");
-                else if (Preferences.colorFormat === "hsl")
+                else if (WebInspector.settings.colorFormat === "hsl")
                     format = (color.simple ? "hsl" : "hsla");
                 else if (color.simple)
                     format = (color.hasShortHex() ? "shorthex" : "hex");
diff --git a/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js b/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js
index 4804897..81d6106 100644
--- a/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js
+++ b/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js
@@ -31,35 +31,39 @@
 WebInspector.WatchExpressionsSidebarPane = function()
 {
     WebInspector.SidebarPane.call(this, WebInspector.UIString("Watch Expressions"));
-
-    this.section = new WebInspector.WatchExpressionsSection();
-
-    this.bodyElement.appendChild(this.section.element);
-
-    var addElement = document.createElement("button");
-    addElement.setAttribute("type", "button");
-    addElement.textContent = WebInspector.UIString("Add");
-    addElement.addEventListener("click", this.section.addExpression.bind(this.section), false);
-
-    var refreshElement = document.createElement("button");
-    refreshElement.setAttribute("type", "button");
-    refreshElement.textContent = WebInspector.UIString("Refresh");
-    refreshElement.addEventListener("click", this.section.update.bind(this.section), false);
-
-    var centerElement = document.createElement("div");
-    centerElement.addStyleClass("watch-expressions-buttons-container");
-    centerElement.appendChild(addElement);
-    centerElement.appendChild(refreshElement);
-    this.bodyElement.appendChild(centerElement);
-
-    this.expanded = this.section.loadSavedExpressions().length > 0;
-    this.onexpand = this.refreshExpressions.bind(this);
+    WebInspector.settings.addEventListener("loaded", this._settingsLoaded, this);
 }
 
 WebInspector.WatchExpressionsSidebarPane.prototype = {
+    _settingsLoaded: function()
+    {
+        this.expanded = WebInspector.settings.watchExpressions.length > 0;
+        this.section = new WebInspector.WatchExpressionsSection();
+        this.bodyElement.appendChild(this.section.element);
+
+        var addElement = document.createElement("button");
+        addElement.setAttribute("type", "button");
+        addElement.textContent = WebInspector.UIString("Add");
+        addElement.addEventListener("click", this.section.addExpression.bind(this.section), false);
+
+        var refreshElement = document.createElement("button");
+        refreshElement.setAttribute("type", "button");
+        refreshElement.textContent = WebInspector.UIString("Refresh");
+        refreshElement.addEventListener("click", this.section.update.bind(this.section), false);
+
+        var centerElement = document.createElement("div");
+        centerElement.addStyleClass("watch-expressions-buttons-container");
+        centerElement.appendChild(addElement);
+        centerElement.appendChild(refreshElement);
+        this.bodyElement.appendChild(centerElement);
+
+        this.onexpand = this.refreshExpressions.bind(this);
+    },
+
     refreshExpressions: function()
     {
-        this.section.update();
+        if (this.section)
+            this.section.update();
     }
 }
 
@@ -71,7 +75,7 @@ WebInspector.WatchExpressionsSection = function()
 
     WebInspector.ObjectPropertiesSection.call(this);
 
-    this.watchExpressions = this.loadSavedExpressions();
+    this.watchExpressions = WebInspector.settings.watchExpressions;
 
     this.headerElement.className = "hidden";
     this.editable = true;
@@ -181,21 +185,6 @@ WebInspector.WatchExpressionsSection.prototype = {
                 return children[i];
     },
 
-    loadSavedExpressions: function()
-    {
-        var json = InspectorFrontendHost.setting("watchExpressions");
-        if (!json)
-            return [];
-
-        try {
-            json = JSON.parse(json);
-        } catch(e) {
-            return [];
-        }
-
-        return json.expressions || [];
-    },
-
     saveExpressions: function()
     {
         var toSave = [];
@@ -203,9 +192,7 @@ WebInspector.WatchExpressionsSection.prototype = {
             if (this.watchExpressions[i])
                 toSave.push(this.watchExpressions[i]);
 
-        var json = JSON.stringify({expressions: toSave});
-        InspectorFrontendHost.setSetting("watchExpressions", json);
-
+        WebInspector.settings.watchExpressions = toSave;
         return toSave.length;
     }
 }
diff --git a/WebCore/inspector/front-end/WebKit.qrc b/WebCore/inspector/front-end/WebKit.qrc
index 2800a7e..5885eba 100644
--- a/WebCore/inspector/front-end/WebKit.qrc
+++ b/WebCore/inspector/front-end/WebKit.qrc
@@ -56,6 +56,7 @@
     <file>ScriptsPanel.js</file>
     <file>ScriptView.js</file>
     <file>Section.js</file>
+    <file>Settings.js</file>
     <file>SidebarPane.js</file>
     <file>SidebarTreeElement.js</file>
     <file>SourceFrame.js</file>
diff --git a/WebCore/inspector/front-end/inspector.html b/WebCore/inspector/front-end/inspector.html
index dd85cac..3b5aa08 100644
--- a/WebCore/inspector/front-end/inspector.html
+++ b/WebCore/inspector/front-end/inspector.html
@@ -37,6 +37,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="InspectorBackendStub.js"></script>
     <script type="text/javascript" src="InspectorFrontendHostStub.js"></script>
     <script type="text/javascript" src="Object.js"></script>
+    <script type="text/javascript" src="Settings.js"></script>
     <script type="text/javascript" src="ContextMenu.js"></script>
     <script type="text/javascript" src="KeyboardShortcut.js"></script>
     <script type="text/javascript" src="TextPrompt.js"></script>
diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js
index 8097ff6..7237ba9 100644
--- a/WebCore/inspector/front-end/inspector.js
+++ b/WebCore/inspector/front-end/inspector.js
@@ -28,24 +28,6 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-var Preferences = {
-    showUserAgentStyles: true,
-    maxInlineTextChildLength: 80,
-    minConsoleHeight: 75,
-    minSidebarWidth: 100,
-    minElementsSidebarWidth: 200,
-    minScriptsSidebarWidth: 200,
-    showInheritedComputedStyleProperties: false,
-    styleRulesExpandedState: {},
-    showMissingLocalizedStrings: false,
-    heapProfilerPresent: false,
-    samplingCPUProfiler: false,
-    showColorNicknames: true,
-    colorFormat: "hex",
-    eventListenersFilter: "all",
-    resourcesLargeRows: true
-}
-
 function preloadImages()
 {
     (new Image()).src = "Images/clearConsoleButtonGlyph.png";
@@ -199,21 +181,6 @@ var WebInspector = {
             this.panels.console = new WebInspector.ConsolePanel();
     },
 
-    _loadPreferences: function()
-    {
-        var colorFormat = InspectorFrontendHost.setting("color-format");
-        if (colorFormat)
-            Preferences.colorFormat = colorFormat;
-
-        var eventListenersFilter = InspectorFrontendHost.setting("event-listeners-filter");
-        if (eventListenersFilter)
-            Preferences.eventListenersFilter = eventListenersFilter;
-
-        var resourcesLargeRows = InspectorFrontendHost.setting("resources-large-rows");
-        if (typeof resourcesLargeRows !== "undefined")
-            Preferences.resourcesLargeRows = resourcesLargeRows;
-    },
-
     get attached()
     {
         return this._attached;
@@ -422,7 +389,7 @@ WebInspector.loaded = function()
     var port = WebInspector.port;
     document.body.addStyleClass("port-" + port);
 
-    this._loadPreferences();
+    this.settings = new WebInspector.Settings();
 
     this.drawer = new WebInspector.Drawer();
     this.console = new WebInspector.ConsoleView(this.drawer);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list