Title: [121983] trunk/Source/WebCore
Revision
121983
Author
[email protected]
Date
2012-07-06 10:08:12 -0700 (Fri, 06 Jul 2012)

Log Message

Web Inspector: Snippet renaming behavior is not correct.
https://bugs.webkit.org/show_bug.cgi?id=90689

Reviewed by Pavel Feldman.

Navigator overlay is now not closed when editing is canceled.
Esc handler in NavigatorOverlayController is not installed as a shortcut anymore since
it should not be called until all underlying DOM elements handled the key down event.

* inspector/front-end/NavigatorOverlayController.js:
(WebInspector.NavigatorOverlayController.prototype.set showNavigatorOverlay):
(WebInspector.NavigatorOverlayController.prototype._keyDown):
(WebInspector.NavigatorOverlayController.prototype._innerHideNavigatorOverlay):
* inspector/front-end/NavigatorView.js:
(WebInspector.NavigatorView.prototype.rename.commitHandler):
(WebInspector.NavigatorView.prototype.rename.cancelHandler):
(WebInspector.NavigatorView.prototype.rename.afterEditing):
* inspector/front-end/ScriptsNavigator.js:
(WebInspector.ScriptsNavigator):
(WebInspector.ScriptsNavigator.prototype._itemRenamingRequested):
(WebInspector.SnippetsNavigatorView.prototype._handleRenameSnippet):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._itemRenamingRequested.callback):
(WebInspector.ScriptsPanel.prototype._itemRenamingRequested):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (121982 => 121983)


--- trunk/Source/WebCore/ChangeLog	2012-07-06 17:05:39 UTC (rev 121982)
+++ trunk/Source/WebCore/ChangeLog	2012-07-06 17:08:12 UTC (rev 121983)
@@ -1,3 +1,30 @@
+2012-07-06  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: Snippet renaming behavior is not correct.
+        https://bugs.webkit.org/show_bug.cgi?id=90689
+
+        Reviewed by Pavel Feldman.
+
+        Navigator overlay is now not closed when editing is canceled.
+        Esc handler in NavigatorOverlayController is not installed as a shortcut anymore since
+        it should not be called until all underlying DOM elements handled the key down event.
+
+        * inspector/front-end/NavigatorOverlayController.js:
+        (WebInspector.NavigatorOverlayController.prototype.set showNavigatorOverlay):
+        (WebInspector.NavigatorOverlayController.prototype._keyDown):
+        (WebInspector.NavigatorOverlayController.prototype._innerHideNavigatorOverlay):
+        * inspector/front-end/NavigatorView.js:
+        (WebInspector.NavigatorView.prototype.rename.commitHandler):
+        (WebInspector.NavigatorView.prototype.rename.cancelHandler):
+        (WebInspector.NavigatorView.prototype.rename.afterEditing):
+        * inspector/front-end/ScriptsNavigator.js:
+        (WebInspector.ScriptsNavigator):
+        (WebInspector.ScriptsNavigator.prototype._itemRenamingRequested):
+        (WebInspector.SnippetsNavigatorView.prototype._handleRenameSnippet):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._itemRenamingRequested.callback):
+        (WebInspector.ScriptsPanel.prototype._itemRenamingRequested):
+
 2012-07-06  Andreas Kling  <[email protected]>
 
         Separate mutating CSSStyleDeclaration operations.

Modified: trunk/Source/WebCore/inspector/front-end/NavigatorOverlayController.js (121982 => 121983)


--- trunk/Source/WebCore/inspector/front-end/NavigatorOverlayController.js	2012-07-06 17:05:39 UTC (rev 121982)
+++ trunk/Source/WebCore/inspector/front-end/NavigatorOverlayController.js	2012-07-06 17:08:12 UTC (rev 121983)
@@ -28,14 +28,12 @@
 
 /**
  * @constructor
- * @param {WebInspector.Panel} panel
  * @param {WebInspector.SplitView} parentSplitView
  * @param {WebInspector.View} navigatorView
  * @param {WebInspector.View} editorView
  */
-WebInspector.NavigatorOverlayController = function(panel, parentSplitView, navigatorView, editorView)
+WebInspector.NavigatorOverlayController = function(parentSplitView, navigatorView, editorView)
 {
-    this._panel = panel;
     this._parentSplitView = parentSplitView;
     this._navigatorView = navigatorView;
     this._editorView = editorView;
@@ -61,11 +59,6 @@
         window.setTimeout(this._maybeShowNavigatorOverlay.bind(this), 0);
     },
 
-    _escDownWhileNavigatorOverlayOpen: function(event)
-    {
-        this.hideNavigatorOverlay();
-    },
-
     _maybeShowNavigatorOverlay: function()
     {
         if (WebInspector.settings.navigatorHidden.get() && !WebInspector.settings.navigatorWasOnceHidden.get())
@@ -124,6 +117,8 @@
         this._navigatorShowHideButton.title = WebInspector.UIString("Pin navigator");
 
         this._sidebarOverlay = new WebInspector.SidebarOverlay(this._navigatorView, "scriptsPanelNavigatorOverlayWidth", Preferences.minScriptsSidebarWidth);
+        this._boundKeyDown = this._keyDown.bind(this);
+        this._sidebarOverlay.element.addEventListener("keydown", this._boundKeyDown, false);
         var navigatorOverlayResizeWidgetElement = document.createElement("div");
         navigatorOverlayResizeWidgetElement.addStyleClass("scripts-navigator-resizer-widget");
         this._sidebarOverlay.resizerWidgetElement = navigatorOverlayResizeWidgetElement;
@@ -131,12 +126,22 @@
         this._navigatorView.element.appendChild(this._navigatorShowHideButton.element);
         this._boundContainingElementFocused = this._containingElementFocused.bind(this);
         this._parentSplitView.element.addEventListener("mousedown", this._boundContainingElementFocused, false);
-        this._panel.registerShortcut(WebInspector.KeyboardShortcut.Keys.Esc.code, this._escDownWhileNavigatorOverlayOpen.bind(this));
 
         this._sidebarOverlay.show(this._parentSplitView.element);
         this._navigatorView.focus();
     },
 
+    _keyDown: function(event)
+    {
+        if (event.handled)
+            return;
+
+        if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.code) {
+            this.hideNavigatorOverlay();
+            event.consume(true);
+        }
+    },
+
     hideNavigatorOverlay: function()
     {
         if (this._navigatorShowHideButton.state !== "overlay")
@@ -153,7 +158,7 @@
     _innerHideNavigatorOverlay: function()
     {
         this._parentSplitView.element.removeEventListener("mousedown", this._boundContainingElementFocused, false);
-        this._panel.unregisterShortcut(WebInspector.KeyboardShortcut.Keys.Esc.code);
+        this._sidebarOverlay.element.removeEventListener("keydown", this._boundKeyDown, false);
         this._sidebarOverlay.hide();
     },
 

Modified: trunk/Source/WebCore/inspector/front-end/NavigatorView.js (121982 => 121983)


--- trunk/Source/WebCore/inspector/front-end/NavigatorView.js	2012-07-06 17:05:39 UTC (rev 121982)
+++ trunk/Source/WebCore/inspector/front-end/NavigatorView.js	2012-07-06 17:08:12 UTC (rev 121983)
@@ -252,21 +252,19 @@
             return;
 
         // Tree outline should be marked as edited as well as the tree element to prevent search from starting.
-        var treeOutlineElement = scriptTreeElement.treeOutline.element
+        var treeOutlineElement = scriptTreeElement.treeOutline.element;
         WebInspector.markBeingEdited(treeOutlineElement, true);
 
         function commitHandler(element, newTitle, oldTitle)
         {
             if (newTitle && newTitle !== oldTitle)
                 this._fileRenamed(uiSourceCode, newTitle);
-            else
-                this._updateScriptTitle(uiSourceCode);
-            afterEditing(true);
+            afterEditing.call(this, true);
         }
 
         function cancelHandler()
         {
-            afterEditing(false);
+            afterEditing.call(this, false);
         }
 
         /**
@@ -275,6 +273,7 @@
         function afterEditing(committed)
         {
             WebInspector.markBeingEdited(treeOutlineElement, false);
+            this._updateScriptTitle(uiSourceCode);
             if (callback)
                 callback(committed);
         }

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js (121982 => 121983)


--- trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js	2012-07-06 17:05:39 UTC (rev 121982)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js	2012-07-06 17:08:12 UTC (rev 121983)
@@ -48,6 +48,7 @@
     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._snippetsView.addEventListener(WebInspector.SnippetsNavigatorView.Events.ItemRenamingRequested, this._itemRenamingRequested, this);
 
     this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.ScriptsTab, WebInspector.UIString("Sources"), this._scriptsView);
     this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.ScriptsTab);
@@ -59,6 +60,7 @@
 WebInspector.ScriptsNavigator.Events = {
     ScriptSelected: "ScriptSelected",
     SnippetCreationRequested: "SnippetCreationRequested",
+    ItemRenamingRequested: "ItemRenamingRequested",
     FileRenamed: "FileRenamed"
 }
 
@@ -166,6 +168,14 @@
     /**
      * @param {WebInspector.Event} event
      */
+    _itemRenamingRequested: function(event)
+    {
+        this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.ItemRenamingRequested, event.data);
+    },
+
+    /**
+     * @param {WebInspector.Event} event
+     */
     _snippetCreationRequested: function(event)
     {    
         this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.SnippetCreationRequested, event.data);
@@ -192,7 +202,8 @@
 }
 
 WebInspector.SnippetsNavigatorView.Events = {
-    SnippetCreationRequested: "SnippetCreationRequested"
+    SnippetCreationRequested: "SnippetCreationRequested",
+    ItemRenamingRequested: "ItemRenamingRequested"
 }
 
 WebInspector.SnippetsNavigatorView.prototype = {
@@ -252,7 +263,7 @@
      */
     _handleRenameSnippet: function(uiSourceCode, event)
     {
-        this.rename(uiSourceCode);
+        this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.ItemRenamingRequested, uiSourceCode);
     },
 
     /**

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (121982 => 121983)


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-07-06 17:05:39 UTC (rev 121982)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-07-06 17:08:12 UTC (rev 121983)
@@ -80,10 +80,11 @@
     this._editorContainer = new WebInspector.TabbedEditorContainer(this, "previouslyViewedFiles");
     this._editorContainer.show(this.editorView.mainElement);
 
-    this._navigatorController = new WebInspector.NavigatorOverlayController(this, this.editorView, this._navigator.view, this._editorContainer.view);
+    this._navigatorController = new WebInspector.NavigatorOverlayController(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.ItemRenamingRequested, this._itemRenamingRequested, this);
     this._navigator.addEventListener(WebInspector.ScriptsNavigator.Events.FileRenamed, this._fileRenamed, this);
 
     this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Events.EditorSelected, this._editorSelected, this);
@@ -1025,7 +1026,10 @@
         WebInspector.scriptSnippetModel.renameScriptSnippet(snippetJavaScriptSource, name);
     },
         
-    _snippetCreationRequested: function()
+    /**
+     * @param {WebInspector.Event} event
+     */
+    _snippetCreationRequested: function(event)
     {
         var snippetJavaScriptSource = WebInspector.scriptSnippetModel.createScriptSnippet();
         this._showSourceLine(snippetJavaScriptSource);
@@ -1053,6 +1057,30 @@
     },
 
     /**
+     * @param {WebInspector.Event} event
+     */
+    _itemRenamingRequested: function(event)
+    {
+        var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
+        
+        var shouldHideNavigator = !this._navigatorController.isNavigatorPinned();
+        if (this._navigatorController.isNavigatorHidden())
+            this._navigatorController.showNavigatorOverlay();
+        this._navigator.rename(uiSourceCode, callback.bind(this));
+    
+        /**
+         * @param {boolean} committed
+         */
+        function callback(committed)
+        {
+            if (shouldHideNavigator && committed) {
+                this._navigatorController.hideNavigatorOverlay();
+                this._showSourceLine(uiSourceCode);
+            }
+        }
+    },
+
+    /**
      * @param {WebInspector.UISourceCode} uiSourceCode
      */
     _showLocalHistory: function(uiSourceCode)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to