Changeset 70622 in webkit
- Timestamp:
- Oct 27, 2010 1:52:13 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r70619 r70622 1 2010-10-27 Pavel Podivilov <podivilov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: move frontend settings to local storage 6 https://bugs.webkit.org/show_bug.cgi?id=47715 7 8 * inspector/Inspector.idl: 9 * inspector/InspectorController.cpp: 10 (WebCore::InspectorController::InspectorController): 11 (WebCore::InspectorController::didCommitLoad): 12 * inspector/InspectorController.h: 13 * inspector/InspectorState.cpp: 14 (WebCore::InspectorState::InspectorState): 15 * inspector/InspectorState.h: 16 * inspector/front-end/ConsoleView.js: 17 * inspector/front-end/EventListenersSidebarPane.js: 18 * inspector/front-end/NetworkPanel.js: 19 (WebInspector.NetworkPanel.prototype._createStatusbarButtons): 20 * inspector/front-end/Panel.js: 21 (WebInspector.Panel): 22 * inspector/front-end/ResourcesPanel.js: 23 (WebInspector.ResourcesPanel.prototype._createStatusbarButtons): 24 * inspector/front-end/Settings.js: 25 (WebInspector.Settings): 26 (WebInspector.Settings.prototype.installApplicationSetting): 27 (WebInspector.Settings.prototype.installProjectSetting): 28 (WebInspector.Settings.prototype._get): 29 (WebInspector.Settings.prototype._set): 30 (WebInspector.Settings.prototype._getProjectSetting): 31 (WebInspector.Settings.prototype._setProjectSetting): 32 (WebInspector.Settings.prototype._formatProjectKey): 33 * inspector/front-end/StylesSidebarPane.js: 34 * inspector/front-end/WatchExpressionsSidebarPane.js: 35 (WebInspector.WatchExpressionsSidebarPane): 36 (WebInspector.WatchExpressionsSidebarPane.prototype.reset): 37 * inspector/front-end/inspector.js: 38 (WebInspector.reset): 39 1 40 2010-10-27 Andy Estes <aestes@apple.com> 2 41 -
trunk/WebCore/inspector/Inspector.idl
r70519 r70622 95 95 [handler=Controller] void populateScriptObjects(); 96 96 97 [handler=Controller] void getSettings(out Object settings);98 97 [handler=Controller] void getInspectorState(out Object state); 99 98 [handler=Controller] void storeLastActivePanel(in String panelName); 100 101 [handler=Controller] void saveApplicationSettings(in String settings);102 [handler=Controller] void saveSessionSettings(in String settings);103 99 104 100 [handler=Controller] void setSearchingForNode(in boolean enabled, out boolean newState); -
trunk/WebCore/inspector/InspectorController.cpp
r70566 r70622 145 145 , m_expiredConsoleMessageCount(0) 146 146 , m_showAfterVisible(LastActivePanel) 147 , m_sessionSettings(InspectorObject::create())148 147 , m_groupLevel(0) 149 148 , m_previousMessage(0) … … 232 231 } 233 232 234 void InspectorController::saveApplicationSettings(const String& settings)235 {236 m_state->setString(InspectorState::frontendSettings, settings);237 }238 239 void InspectorController::saveSessionSettings(const String& settingsJSON)240 {241 m_sessionSettings = InspectorValue::parseJSON(settingsJSON);242 }243 244 233 void InspectorController::getInspectorState(RefPtr<InspectorObject>* state) 245 234 { … … 256 245 if (m_state->getBoolean(InspectorState::timelineProfilerEnabled)) 257 246 startTimelineProfiler(); 258 }259 260 void InspectorController::getSettings(RefPtr<InspectorObject>* settings)261 {262 *settings = InspectorObject::create();263 (*settings)->setString("application", m_state->getString(InspectorState::frontendSettings));264 (*settings)->setString("session", m_sessionSettings->toJSONString());265 247 } 266 248 … … 786 768 787 769 m_cssStore->reset(); 788 m_sessionSettings = InspectorObject::create();789 770 if (m_frontend) { 790 771 m_frontend->reset(); -
trunk/WebCore/inspector/InspectorController.h
r70300 r70622 125 125 void reloadPage(); 126 126 127 void saveApplicationSettings(const String& settings);128 void saveSessionSettings(const String&);129 void getSettings(RefPtr<InspectorObject>*);130 131 127 void restoreInspectorStateFromCookie(const String& inspectorCookie); 132 128 … … 375 371 String m_showAfterVisible; 376 372 RefPtr<Node> m_highlightedNode; 377 #if ENABLE(INSPECTOR)378 RefPtr<InspectorValue> m_sessionSettings;379 #endif380 373 unsigned m_groupLevel; 381 374 ConsoleMessage* m_previousMessage; -
trunk/WebCore/inspector/InspectorState.cpp
r69956 r70622 46 46 registerBoolean(searchingForNode, false, "searchingForNodeEnabled", (const char*)0); 47 47 registerBoolean(profilerAlwaysEnabled, false, (const char*)0, "profilerEnabled"); 48 registerString(frontendSettings, "", (const char*)0, "frontendSettings");49 48 registerBoolean(debuggerAlwaysEnabled, false, (const char*)0, "debuggerEnabled"); 50 49 registerString(lastActivePanel, InspectorController::LastActivePanel, (const char*)0, "lastActivePanel"); -
trunk/WebCore/inspector/InspectorState.h
r69916 r70622 51 51 searchingForNode, 52 52 profilerAlwaysEnabled, 53 frontendSettings,54 53 debuggerAlwaysEnabled, 55 54 lastActivePanel, -
trunk/WebCore/inspector/front-end/ConsoleView.js
r70532 r70622 49 49 this.promptElement.addEventListener("keydown", this._promptKeyDown.bind(this), true); 50 50 this.prompt = new WebInspector.TextPrompt(this.promptElement, this.completions.bind(this), ExpressionStopCharacters + "."); 51 WebInspector.applicationSettings.addEventListener("loaded", this._settingsLoaded, this);51 this.prompt.history = WebInspector.applicationSettings.consoleHistory; 52 52 53 53 this.topGroup = new WebInspector.ConsoleGroup(null, 0); … … 103 103 104 104 WebInspector.ConsoleView.prototype = { 105 _settingsLoaded: function()106 {107 this.prompt.history = WebInspector.applicationSettings.consoleHistory;108 },109 110 105 _updateFilter: function(e) 111 106 { -
trunk/WebCore/inspector/front-end/EventListenersSidebarPane.js
r69203 r70622 47 47 this.settingsSelectElement.appendChild(option); 48 48 49 WebInspector.applicationSettings.addEventListener("loaded", this._settingsLoaded, this); 49 var filter = WebInspector.applicationSettings.eventListenersFilter; 50 if (filter === "all") 51 this.settingsSelectElement[0].selected = true; 52 else if (filter === "selected") 53 this.settingsSelectElement[1].selected = true; 50 54 this.settingsSelectElement.addEventListener("click", function(event) { event.stopPropagation() }, false); 51 55 this.settingsSelectElement.addEventListener("change", this._changeSetting.bind(this), false); … … 55 59 56 60 WebInspector.EventListenersSidebarPane.prototype = { 57 _settingsLoaded: function()58 {59 var filter = WebInspector.applicationSettings.eventListenersFilter;60 if (filter === "all")61 this.settingsSelectElement[0].selected = true;62 if (filter === "selected")63 this.settingsSelectElement[1].selected = true;64 },65 66 61 update: function(node) 67 62 { -
trunk/WebCore/inspector/front-end/NetworkPanel.js
r70532 r70622 612 612 613 613 this._largerResourcesButton = new WebInspector.StatusBarButton(WebInspector.UIString("Use small resource rows."), "network-larger-resources-status-bar-item"); 614 WebInspector.applicationSettings.addEventListener("loaded", this._settingsLoaded, this);615 this._largerResourcesButton.addEventListener("click", this._toggleLargerResources.bind(this), false);616 },617 618 _settingsLoaded: function()619 {620 614 this._largerResourcesButton.toggled = WebInspector.applicationSettings.resourcesLargeRows; 621 615 if (!WebInspector.applicationSettings.resourcesLargeRows) 622 616 this._setLargerResources(WebInspector.applicationSettings.resourcesLargeRows); 617 this._largerResourcesButton.addEventListener("click", this._toggleLargerResources.bind(this), false); 623 618 }, 624 619 -
trunk/WebCore/inspector/front-end/Panel.js
r66601 r70622 35 35 this._panelName = name; 36 36 37 WebInspector.applicationSettings.install Setting(this._sidebarWidthSettingName(), this._panelName + "-sidebar-width", undefined);37 WebInspector.applicationSettings.installApplicationSetting(this._sidebarWidthSettingName(), undefined); 38 38 } 39 39 -
trunk/WebCore/inspector/front-end/ResourcesPanel.js
r70532 r70622 447 447 this.largerResourcesButton = new WebInspector.StatusBarButton(WebInspector.UIString("Use small resource rows."), "resources-larger-resources-status-bar-item"); 448 448 449 WebInspector.applicationSettings.addEventListener("loaded", this._settingsLoaded, this); 449 this.largerResourcesButton.toggled = WebInspector.applicationSettings.resourcesLargeRows; 450 if (!WebInspector.applicationSettings.resourcesLargeRows) 451 this._setLargerResources(WebInspector.applicationSettings.resourcesLargeRows); 452 this._loadSortOptions(); 453 450 454 this.largerResourcesButton.addEventListener("click", this._toggleLargerResources.bind(this), false); 451 455 this.sortingSelectElement = document.createElement("select"); 452 456 this.sortingSelectElement.className = "status-bar-item"; 453 457 this.sortingSelectElement.addEventListener("change", this._changeSortingFunction.bind(this), false); 454 },455 456 _settingsLoaded: function()457 {458 this.largerResourcesButton.toggled = WebInspector.applicationSettings.resourcesLargeRows;459 if (!WebInspector.applicationSettings.resourcesLargeRows)460 this._setLargerResources(WebInspector.applicationSettings.resourcesLargeRows);461 this._loadSortOptions();462 458 }, 463 459 -
trunk/WebCore/inspector/front-end/Settings.js
r70519 r70622 50 50 } 51 51 52 WebInspector.Settings = function( sessionScope)52 WebInspector.Settings = function() 53 53 { 54 this._sessionScope = sessionScope; 55 this._store = {}; 56 } 54 this.installApplicationSetting("colorFormat", "hex"); 55 this.installApplicationSetting("consoleHistory", []); 56 this.installApplicationSetting("eventListenersFilter", "all"); 57 this.installApplicationSetting("lastViewedScriptFile", "application"); 58 this.installApplicationSetting("resourcesLargeRows", true); 59 this.installApplicationSetting("resourcesSortOptions", {timeOption: "responseTime", sizeOption: "transferSize"}); 60 this.installApplicationSetting("resourceViewTab", "content"); 61 this.installApplicationSetting("showInheritedComputedStyleProperties", false); 62 this.installApplicationSetting("showUserAgentStyles", true); 63 this.installApplicationSetting("watchExpressions", []); 57 64 58 WebInspector.Settings.initialize = function() 59 { 60 WebInspector.applicationSettings = new WebInspector.Settings(false); 61 WebInspector.sessionSettings = new WebInspector.Settings(true); 62 63 function populateApplicationSettings(settingsString) 64 { 65 WebInspector.applicationSettings._load(settingsString); 66 WebInspector.applicationSettings.installSetting("eventListenersFilter", "event-listeners-filter", "all"); 67 WebInspector.applicationSettings.installSetting("colorFormat", "color-format", "hex"); 68 WebInspector.applicationSettings.installSetting("resourcesLargeRows", "resources-large-rows", true); 69 WebInspector.applicationSettings.installSetting("watchExpressions", "watch-expressions", []); 70 WebInspector.applicationSettings.installSetting("lastViewedScriptFile", "last-viewed-script-file"); 71 WebInspector.applicationSettings.installSetting("showInheritedComputedStyleProperties", "show-inherited-computed-style-properties", false); 72 WebInspector.applicationSettings.installSetting("showUserAgentStyles", "show-user-agent-styles", true); 73 WebInspector.applicationSettings.installSetting("resourceViewTab", "resource-view-tab", "content"); 74 WebInspector.applicationSettings.installSetting("consoleHistory", "console-history", []); 75 WebInspector.applicationSettings.installSetting("resourcesSortOptions", "resources-sort-options", {timeOption: "responseTime", sizeOption: "transferSize"}); 76 77 WebInspector.applicationSettings.dispatchEventToListeners("loaded"); 78 } 79 80 function populateSessionSettings(settingsString) 81 { 82 WebInspector.sessionSettings._load(settingsString); 83 WebInspector.sessionSettings.dispatchEventToListeners("loaded"); 84 } 85 86 InspectorBackend.getSettings(function(settings) { 87 populateApplicationSettings(settings.application); 88 populateSessionSettings(settings.session); 89 }); 65 this.installProjectSetting("breakpoints", {}); 90 66 } 91 67 92 68 WebInspector.Settings.prototype = { 93 reset: function()69 installApplicationSetting: function(key, defaultValue) 94 70 { 95 this._store = {}; 96 // FIXME: restore default values (bug 42820) 97 this.dispatchEventToListeners("loaded"); 71 this.__defineGetter__(key, this._get.bind(this, key, defaultValue)); 72 this.__defineSetter__(key, this._set.bind(this, key)); 98 73 }, 99 74 100 _load: function(settingsString)75 installProjectSetting: function(key, defaultValue) 101 76 { 102 try { 103 var loadedStore = JSON.parse(settingsString); 104 } catch (e) { 105 // May fail; 106 loadedStore = {}; 107 } 108 if (!loadedStore) 109 return; 110 for (var propertyName in loadedStore) 111 this._store[propertyName] = loadedStore[propertyName]; 77 this.__defineGetter__(key, this._getProjectSetting.bind(this, key, defaultValue)); 78 this.__defineSetter__(key, this._setProjectSetting.bind(this, key)); 112 79 }, 113 80 114 installSetting: function(name, propertyName, defaultValue)81 _get: function(key, defaultValue) 115 82 { 116 this.__defineGetter__(name, this._get.bind(this, propertyName)); 117 this.__defineSetter__(name, this._set.bind(this, propertyName)); 118 if (!(propertyName in this._store)) 119 this._store[propertyName] = defaultValue; 83 if (key in window.localStorage) { 84 try { 85 return JSON.parse(window.localStorage[key]); 86 } catch(e) { 87 window.localStorage.removeItem(key); 88 } 89 } 90 return defaultValue; 120 91 }, 121 92 122 _ get: function(propertyName)93 _set: function(key, value) 123 94 { 124 return this._store[propertyName];95 window.localStorage[key] = JSON.stringify(value); 125 96 }, 126 97 127 _ set: function(propertyName, newValue)98 _getProjectSetting: function(key, defaultValue) 128 99 { 129 this._store[propertyName] = newValue; 130 try { 131 var store = JSON.stringify(this._store); 132 if (this._sessionScope) 133 InspectorBackend.saveSessionSettings(store); 134 else 135 InspectorBackend.saveApplicationSettings(store); 136 } catch (e) { 137 // May fail; 138 } 100 return this._get(this._formatProjectKey(key), defaultValue); 101 }, 102 103 _setProjectSetting: function(key, value) 104 { 105 return this._set(this._formatProjectKey(key), value); 106 }, 107 108 _formatProjectKey: function(key) 109 { 110 var url = this._mainResourceURL; 111 var fragmentIndex = url.indexOf("#"); 112 if (fragmentIndex !== -1) 113 url = url.substring(0, fragmentIndex); 114 return key + "." + url; 139 115 } 140 116 } -
trunk/WebCore/inspector/front-end/StylesSidebarPane.js
r70532 r70622 61 61 this.settingsSelectElement.addEventListener("click", function(event) { event.stopPropagation() }, false); 62 62 this.settingsSelectElement.addEventListener("change", this._changeSetting.bind(this), false); 63 WebInspector.applicationSettings.addEventListener("loaded", this._settingsLoaded, this); 63 var format = WebInspector.applicationSettings.colorFormat; 64 if (format === "hex") 65 this.settingsSelectElement[0].selected = true; 66 else if (format === "rgb") 67 this.settingsSelectElement[1].selected = true; 68 else if (format === "hsl") 69 this.settingsSelectElement[2].selected = true; 64 70 65 71 this.titleElement.appendChild(this.settingsSelectElement); … … 96 102 97 103 WebInspector.StylesSidebarPane.prototype = { 98 _settingsLoaded: function()99 {100 var format = WebInspector.applicationSettings.colorFormat;101 if (format === "hex")102 this.settingsSelectElement[0].selected = true;103 if (format === "rgb")104 this.settingsSelectElement[1].selected = true;105 if (format === "hsl")106 this.settingsSelectElement[2].selected = true;107 },108 109 104 _contextMenuEventFired: function(event) 110 105 { … … 591 586 this.titleElement.appendChild(showInheritedCheckbox.element); 592 587 593 function settingsLoaded() 594 { 595 if (WebInspector.applicationSettings.showInheritedComputedStyleProperties) { 596 this.bodyElement.addStyleClass("show-inherited"); 597 showInheritedCheckbox.checked = true; 598 } 588 if (WebInspector.applicationSettings.showInheritedComputedStyleProperties) { 589 this.bodyElement.addStyleClass("show-inherited"); 590 showInheritedCheckbox.checked = true; 599 591 } 600 601 WebInspector.applicationSettings.addEventListener("loaded", settingsLoaded.bind(this));602 592 603 593 function showInheritedToggleFunction(event) -
trunk/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js
r65248 r70622 32 32 { 33 33 WebInspector.SidebarPane.call(this, WebInspector.UIString("Watch Expressions")); 34 WebInspector.applicationSettings.addEventListener("loaded", this._settingsLoaded, this);34 this.reset(); 35 35 } 36 36 37 37 WebInspector.WatchExpressionsSidebarPane.prototype = { 38 _settingsLoaded: function()38 reset: function() 39 39 { 40 40 this.bodyElement.removeChildren(); -
trunk/WebCore/inspector/front-end/inspector.js
r70532 r70622 531 531 532 532 InspectorFrontendHost.loaded(); 533 WebInspector. Settings.initialize();534 533 WebInspector.applicationSettings = new WebInspector.Settings(); 534 535 535 this._registerShortcuts(); 536 536 … … 1505 1505 panel.reset(); 1506 1506 } 1507 1508 this.sessionSettings.reset();1509 1507 1510 1508 this.resources = {};
Note: See TracChangeset
for help on using the changeset viewer.