Diff
Modified: trunk/Source/WebCore/ChangeLog (117273 => 117274)
--- trunk/Source/WebCore/ChangeLog 2012-05-16 13:25:53 UTC (rev 117273)
+++ trunk/Source/WebCore/ChangeLog 2012-05-16 13:40:58 UTC (rev 117274)
@@ -1,3 +1,50 @@
+2012-05-16 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Implement snippet creation/renaming in ScriptsNavigator.
+ https://bugs.webkit.org/show_bug.cgi?id=82622
+
+ Reviewed by Pavel Feldman.
+
+ Implemented snippet creation and renaming.
+ Added TitleChanged event to UISourceCode.
+
+ * inspector/front-end/NavigatorOverlayController.js:
+ (WebInspector.NavigatorOverlayController.prototype._containingElementFocused):
+ (WebInspector.NavigatorOverlayController.prototype.isNavigatorPinned):
+ (WebInspector.NavigatorOverlayController.prototype.isNavigatorHidden):
+ * inspector/front-end/NavigatorView.js:
+ (WebInspector.NavigatorView.prototype._uiSourceCodeTitleChanged):
+ (WebInspector.NavigatorView.prototype._updateScriptTitle):
+ (WebInspector.NavigatorView.prototype._addUISourceCodeListeners):
+ (WebInspector.NavigatorView.prototype._removeUISourceCodeListeners):
+ (WebInspector.NavigatorView.prototype._fileRenamed):
+ (WebInspector.NavigatorScriptTreeElement.prototype.onattach):
+ * inspector/front-end/ScriptSnippetModel.js:
+ (WebInspector.ScriptSnippetModel.prototype._addScriptSnippet):
+ * inspector/front-end/ScriptsNavigator.js:
+ (WebInspector.ScriptsNavigator):
+ (WebInspector.ScriptsNavigator.prototype._snippetsNavigatorViewForUISourceCode):
+ (WebInspector.ScriptsNavigator.prototype.addUISourceCode):
+ (WebInspector.ScriptsNavigator.prototype.isScriptSourceAdded):
+ (WebInspector.ScriptsNavigator.prototype.revealUISourceCode):
+ (WebInspector.ScriptsNavigator.prototype.replaceUISourceCode):
+ (WebInspector.ScriptsNavigator.prototype.rename):
+ (WebInspector.ScriptsNavigator.prototype._fileRenamed):
+ (WebInspector.ScriptsNavigator.prototype._snippetCreationRequested):
+ (WebInspector.SnippetsNavigatorView.prototype._handleCreateSnippet):
+ (WebInspector.SnippetsNavigatorView.prototype._snippetCreationRequested):
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype.set _hideDebuggerSidebar):
+ (WebInspector.ScriptsPanel.prototype.set _fileRenamed):
+ (WebInspector.ScriptsPanel.prototype._snippetCreationRequested.callback):
+ (WebInspector.ScriptsPanel.prototype._snippetCreationRequested):
+ * inspector/front-end/TabbedEditorContainer.js:
+ (WebInspector.TabbedEditorContainer.prototype._appendFileTab):
+ (WebInspector.TabbedEditorContainer.prototype._tabClosed):
+ (WebInspector.TabbedEditorContainer.prototype._uiSourceCodeTitleChanged):
+ * inspector/front-end/UISourceCode.js:
+ (WebInspector.UISourceCode.prototype.urlChanged):
+
2012-05-16 Alexander Pavlov <[email protected]>
Web Inspector: gradient properties are painful to inspect / author.
Modified: trunk/Source/WebCore/inspector/front-end/NavigatorOverlayController.js (117273 => 117274)
--- trunk/Source/WebCore/inspector/front-end/NavigatorOverlayController.js 2012-05-16 13:25:53 UTC (rev 117273)
+++ trunk/Source/WebCore/inspector/front-end/NavigatorOverlayController.js 2012-05-16 13:40:58 UTC (rev 117274)
@@ -161,5 +161,15 @@
{
if (!event.target.isSelfOrDescendant(this._sidebarOverlay.element))
this.hideNavigatorOverlay();
+ },
+
+ isNavigatorPinned: function()
+ {
+ return this._navigatorShowHideButton.state === "pinned";
+ },
+
+ isNavigatorHidden: function()
+ {
+ return this._navigatorShowHideButton.state === "hidden";
}
}
Modified: trunk/Source/WebCore/inspector/front-end/NavigatorView.js (117273 => 117274)
--- trunk/Source/WebCore/inspector/front-end/NavigatorView.js 2012-05-16 13:25:53 UTC (rev 117273)
+++ trunk/Source/WebCore/inspector/front-end/NavigatorView.js 2012-05-16 13:40:58 UTC (rev 117274)
@@ -60,7 +60,8 @@
WebInspector.NavigatorView.Events = {
- ItemSelected: "ItemSelected"
+ ItemSelected: "ItemSelected",
+ FileRenamed: "FileRenamed"
}
WebInspector.NavigatorView.prototype = {
@@ -81,12 +82,18 @@
folderTreeElement.appendChild(scriptTreeElement);
},
+ _uiSourceCodeTitleChanged: function(event)
+ {
+ var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target;
+ this._updateScriptTitle(uiSourceCode)
+ },
+
_uiSourceCodeWorkingCopyChanged: function(event)
{
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target;
this._updateScriptTitle(uiSourceCode)
},
-
+
_uiSourceCodeContentChanged: function(event)
{
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target;
@@ -95,8 +102,9 @@
/**
* @param {WebInspector.UISourceCode} uiSourceCode
+ * @param {boolean=} ignoreIsDirty
*/
- _updateScriptTitle: function(uiSourceCode)
+ _updateScriptTitle: function(uiSourceCode, ignoreIsDirty)
{
var scriptTreeElement = this._scriptTreeElementsByUISourceCode.get(uiSourceCode);
if (!scriptTreeElement)
@@ -111,7 +119,7 @@
titleText = uiSourceCode.parsedURL.url;
if (!titleText)
titleText = WebInspector.UIString("(program)");
- if (uiSourceCode.isDirty())
+ if (!ignoreIsDirty && uiSourceCode.isDirty())
titleText = "*" + titleText;
scriptTreeElement.titleText = titleText;
},
@@ -200,6 +208,7 @@
*/
_addUISourceCodeListeners: function(uiSourceCode)
{
+ uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this);
uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this);
uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this);
},
@@ -209,6 +218,7 @@
*/
_removeUISourceCodeListeners: function(uiSourceCode)
{
+ uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this);
uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this);
uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this);
},
@@ -226,8 +236,9 @@
},
_fileRenamed: function(uiSourceCode, newTitle)
- {
- // FIXME: To be implemented.
+ {
+ var data = { uiSourceCode: uiSourceCode, name: newTitle };
+ this.dispatchEventToListeners(WebInspector.NavigatorView.Events.FileRenamed, data);
},
/**
@@ -568,6 +579,7 @@
{
WebInspector.BaseNavigatorTreeElement.prototype.onattach.call(this);
this.listItemElement.addEventListener("click", this._onclick.bind(this), false);
+ this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), false);
},
onspace: function()
Modified: trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js (117273 => 117274)
--- trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-05-16 13:25:53 UTC (rev 117273)
+++ trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-05-16 13:40:58 UTC (rev 117274)
@@ -75,8 +75,7 @@
*/
_addScriptSnippet: function(snippet)
{
- var uiSourceCodeURL = ""; // FIXME: to be implemented.
- var uiSourceCode = new WebInspector._javascript_Source(uiSourceCodeURL, new WebInspector.SnippetContentProvider(snippet), this._snippetScriptMapping, true);
+ var uiSourceCode = new WebInspector._javascript_Source(snippet.name, new WebInspector.SnippetContentProvider(snippet), this._snippetScriptMapping, true);
uiSourceCode.isSnippet = true;
this._uiSourceCodeForSnippet.put(snippet, uiSourceCode);
this._snippetForUISourceCode.put(uiSourceCode, snippet);
@@ -103,7 +102,11 @@
*/
renameScriptSnippet: function(uiSourceCode, newName)
{
- this._snippetForUISourceCode.get(uiSourceCode).name = newName;
+ var snippet = this._snippetForUISourceCode.get(uiSourceCode)
+ if (!snippet || !newName || snippet.name === newName)
+ return;
+ snippet.name = newName;
+ uiSourceCode.urlChanged(snippet.name);
},
/**
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js (117273 => 117274)
--- trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js 2012-05-16 13:25:53 UTC (rev 117273)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js 2012-05-16 13:40:58 UTC (rev 117274)
@@ -46,6 +46,8 @@
this._snippetsView = new WebInspector.SnippetsNavigatorView();
this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.ItemSelected, this._scriptSelected, this);
+ this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.FileRenamed, this._fileRenamed, this);
+ this._snippetsView.addEventListener(WebInspector.SnippetsNavigatorView.Events.SnippetCreationRequested, this._snippetCreationRequested, this);
this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.ScriptsTab, WebInspector.UIString("Scripts"), this._scriptsView);
this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.ScriptsTab);
@@ -55,7 +57,9 @@
}
WebInspector.ScriptsNavigator.Events = {
- ScriptSelected: "ScriptSelected"
+ ScriptSelected: "ScriptSelected",
+ SnippetCreationRequested: "SnippetCreationRequested",
+ FileRenamed: "FileRenamed"
}
WebInspector.ScriptsNavigator.ScriptsTab = "scripts";
@@ -74,27 +78,31 @@
/**
* @param {WebInspector.UISourceCode} uiSourceCode
*/
- addUISourceCode: function(uiSourceCode)
+ _snippetsNavigatorViewForUISourceCode: function(uiSourceCode)
{
if (uiSourceCode.isContentScript)
- this._contentScriptsView.addUISourceCode(uiSourceCode);
+ return this._contentScriptsView;
else if (uiSourceCode.isSnippet || uiSourceCode.isSnippetEvaluation)
- this._snippetsView.addUISourceCode(uiSourceCode);
+ return this._snippetsView;
else
- this._scriptsView.addUISourceCode(uiSourceCode);
+ return this._scriptsView;
},
/**
* @param {WebInspector.UISourceCode} uiSourceCode
+ */
+ addUISourceCode: function(uiSourceCode)
+ {
+ this._snippetsNavigatorViewForUISourceCode(uiSourceCode).addUISourceCode(uiSourceCode);
+ },
+
+ /**
+ * @param {WebInspector.UISourceCode} uiSourceCode
* @return {boolean}
*/
isScriptSourceAdded: function(uiSourceCode)
{
- if (uiSourceCode.isContentScript)
- return this._contentScriptsView.isScriptSourceAdded(uiSourceCode);
- if (uiSourceCode.isSnippet || uiSourceCode.isSnippetEvaluation)
- return this._snippetsView.isScriptSourceAdded(uiSourceCode);
- return this._scriptsView.isScriptSourceAdded(uiSourceCode);
+ return this._snippetsNavigatorViewForUISourceCode(uiSourceCode).isScriptSourceAdded(uiSourceCode);
},
/**
@@ -102,36 +110,33 @@
*/
revealUISourceCode: function(uiSourceCode)
{
- if (uiSourceCode.isContentScript) {
- this._contentScriptsView.revealUISourceCode(uiSourceCode);
+ this._snippetsNavigatorViewForUISourceCode(uiSourceCode).revealUISourceCode(uiSourceCode);
+ if (uiSourceCode.isContentScript)
this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.ContentScriptsTab);
- } else if (uiSourceCode.isSnippet || uiSourceCode.isSnippetEvaluation) {
- this._snippetsView.revealUISourceCode(uiSourceCode);
+ else if (uiSourceCode.isSnippet || uiSourceCode.isSnippetEvaluation)
this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.SnippetsTab);
- } else {
- this._scriptsView.revealUISourceCode(uiSourceCode);
+ else
this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.ScriptsTab);
- }
},
/**
+ * @param {WebInspector.UISourceCode} oldUISourceCode
* @param {WebInspector.UISourceCode} uiSourceCode
- * @param {boolean} isDirty
*/
- setScriptSourceIsDirty: function(uiSourceCode, isDirty)
+ replaceUISourceCode: function(oldUISourceCode, uiSourceCode)
{
- // Do nothing.
+ this._scriptsView.replaceUISourceCode(oldUISourceCode, uiSourceCode);
+ this._contentScriptsView.replaceUISourceCode(oldUISourceCode, uiSourceCode);
+ this._snippetsView.replaceUISourceCode(oldUISourceCode, uiSourceCode);
},
/**
- * @param {WebInspector.UISourceCode} oldUISourceCode
* @param {WebInspector.UISourceCode} uiSourceCode
+ * @param {function()=} callback
*/
- replaceUISourceCode: function(oldUISourceCode, uiSourceCode)
+ rename: function(uiSourceCode, callback)
{
- this._scriptsView.replaceUISourceCode(oldUISourceCode, uiSourceCode);
- this._contentScriptsView.replaceUISourceCode(oldUISourceCode, uiSourceCode);
- this._snippetsView.replaceUISourceCode(oldUISourceCode, uiSourceCode);
+ this._snippetsNavigatorViewForUISourceCode(uiSourceCode).rename(uiSourceCode, callback);
},
/**
@@ -142,6 +147,22 @@
this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.ScriptSelected, event.data);
},
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _fileRenamed: function(event)
+ {
+ this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.FileRenamed, event.data);
+ },
+
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _snippetCreationRequested: function(event)
+ {
+ this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.SnippetCreationRequested, event.data);
+ },
+
reset: function()
{
this._scriptsView.reset();
@@ -162,6 +183,10 @@
this.element.addEventListener("contextmenu", this.handleContextMenu.bind(this), false);
}
+WebInspector.SnippetsNavigatorView.Events = {
+ SnippetCreationRequested: "SnippetCreationRequested"
+}
+
WebInspector.SnippetsNavigatorView.prototype = {
/**
* @param {WebInspector.UISourceCode} uiSourceCode
@@ -233,7 +258,12 @@
*/
_handleCreateSnippet: function(event)
{
- // FIXME: To be implemented.
+ this._snippetCreationRequested();
+ },
+
+ _snippetCreationRequested: function()
+ {
+ this.dispatchEventToListeners(WebInspector.SnippetsNavigatorView.Events.SnippetCreationRequested, null);
}
}
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (117273 => 117274)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-05-16 13:25:53 UTC (rev 117273)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-05-16 13:40:58 UTC (rev 117274)
@@ -84,6 +84,9 @@
this._navigatorController = new WebInspector.NavigatorOverlayController(this, this.editorView, this._navigator.view, this._editorContainer.view);
this._navigator.addEventListener(WebInspector.ScriptsNavigator.Events.ScriptSelected, this._scriptSelected, this);
+ this._navigator.addEventListener(WebInspector.ScriptsNavigator.Events.SnippetCreationRequested, this._snippetCreationRequested, this);
+ this._navigator.addEventListener(WebInspector.ScriptsNavigator.Events.FileRenamed, this._fileRenamed, this);
+
this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Events.EditorSelected, this._editorSelected, this);
this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Events.EditorClosed, this._editorClosed, this);
@@ -963,6 +966,33 @@
this._toggleDebuggerSidebarButton.title = WebInspector.UIString("Show debugger");
this.splitView.hideSidebarElement();
WebInspector.settings.debuggerSidebarHidden.set(true);
+ },
+
+ _fileRenamed: function(event)
+ {
+ var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data.uiSourceCode;
+ var name = /** @type {string} */ event.data.name;
+ if (!uiSourceCode.isSnippet)
+ return;
+ WebInspector.scriptSnippetModel.renameScriptSnippet(uiSourceCode, name);
+ },
+
+ _snippetCreationRequested: function()
+ {
+ var uiSourceCode = WebInspector.scriptSnippetModel.createScriptSnippet();
+ this._showSourceLine(uiSourceCode);
+
+ var shouldHideNavigator = !this._navigatorController.isNavigatorPinned();
+ if (this._navigatorController.isNavigatorHidden())
+ this._navigatorController.showNavigatorOverlay();
+ this._navigator.rename(uiSourceCode, callback.bind(this));
+
+ function callback()
+ {
+ if (shouldHideNavigator)
+ this._navigatorController.hideNavigatorOverlay();
+ this._showSourceLine(uiSourceCode);
+ }
}
}
Modified: trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js (117273 => 117274)
--- trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js 2012-05-16 13:25:53 UTC (rev 117273)
+++ trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js 2012-05-16 13:40:58 UTC (rev 117274)
@@ -224,9 +224,10 @@
var tabId = this._generateTabId();
this._tabIds.put(uiSourceCode, tabId);
this._files[tabId] = uiSourceCode;
-
+
this._tabbedPane.appendTab(tabId, title, view, tooltip, userGesture);
+ uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this);
uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this);
uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this);
return tabId;
@@ -238,7 +239,7 @@
_removeFileTab: function(uiSourceCode)
{
var tabId = this._tabIds.get(uiSourceCode);
-
+
if (tabId)
this._tabbedPane.closeTab(tabId);
},
@@ -255,6 +256,8 @@
this._tabIds.remove(uiSourceCode);
delete this._files[tabId];
delete this._currentFile;
+
+ uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this);
uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this);
uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this);
@@ -308,7 +311,13 @@
this._tabbedPane.changeTabTitle(tabId, title);
}
},
-
+
+ _uiSourceCodeTitleChanged: function(event)
+ {
+ var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target;
+ this._updateFileTitle(uiSourceCode);
+ },
+
_uiSourceCodeWorkingCopyChanged: function(event)
{
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target;
Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (117273 => 117274)
--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-05-16 13:25:53 UTC (rev 117273)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-05-16 13:40:58 UTC (rev 117274)
@@ -57,6 +57,7 @@
WebInspector.UISourceCode.Events = {
ContentChanged: "ContentChanged",
WorkingCopyChanged: "WorkingCopyChanged",
+ TitleChanged: "TitleChanged",
ConsoleMessageAdded: "ConsoleMessageAdded",
ConsoleMessageRemoved: "ConsoleMessageRemoved",
ConsoleMessagesCleared: "ConsoleMessagesCleared"
@@ -72,6 +73,16 @@
},
/**
+ * @param {string} url
+ */
+ urlChanged: function(url)
+ {
+ this._url = url;
+ this._parsedURL = new WebInspector.ParsedURL(this._url);
+ this.dispatchEventToListeners(WebInspector.UISourceCode.Events.TitleChanged, null);
+ },
+
+ /**
* @return {WebInspector.ParsedURL}
*/
get parsedURL()