Title: [98233] trunk/Source/WebCore
Revision
98233
Author
[email protected]
Date
2011-10-24 05:08:39 -0700 (Mon, 24 Oct 2011)

Log Message

Web Inspector: add "Add to Watch" option to context menu on selection in source frame
https://bugs.webkit.org/show_bug.cgi?id=69924

Reviewed by Pavel Feldman.

- added 'Add to Watch' context menu item in scripts panel;
- include both default and custom items into a context menu if selection is present;

* inspector/front-end/ScriptsPanel.js:
(WebInspector.SourceFrameDelegateForScriptsPanel.prototype.suggestedFileName):
(WebInspector.SourceFrameDelegateForScriptsPanel.prototype.addToWatch):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype.populateSelectionContextMenu):
(WebInspector.TextViewerDelegateForSourceFrame.prototype.populateSelectionContextMenu):
(WebInspector.SourceFrameDelegate.prototype.suggestedFileName):
(WebInspector.SourceFrameDelegate.prototype.addToWatch):
* inspector/front-end/TextViewer.js:
(WebInspector.TextViewer.prototype._contextMenu):
(WebInspector.TextViewerDelegate.prototype.populateSelectionContextMenu):
* inspector/front-end/WatchExpressionsSidebarPane.js:
(WebInspector.WatchExpressionsSidebarPane.prototype.addExpression):
(WebInspector.WatchExpressionsSidebarPane.prototype._addButtonClicked):
(WebInspector.WatchExpressionsSection.prototype.addExpression):
(WebInspector.WatchExpressionsSection.prototype.addNewExpressionAndEdit):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::showContextMenu):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (98232 => 98233)


--- trunk/Source/WebCore/ChangeLog	2011-10-24 11:04:55 UTC (rev 98232)
+++ trunk/Source/WebCore/ChangeLog	2011-10-24 12:08:39 UTC (rev 98233)
@@ -1,3 +1,32 @@
+2011-10-17  Andrey Kosyakov  <[email protected]>
+
+        Web Inspector: add "Add to Watch" option to context menu on selection in source frame
+        https://bugs.webkit.org/show_bug.cgi?id=69924
+
+        Reviewed by Pavel Feldman.
+
+        - added 'Add to Watch' context menu item in scripts panel;
+        - include both default and custom items into a context menu if selection is present;
+
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.suggestedFileName):
+        (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.addToWatch):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame.prototype.populateSelectionContextMenu):
+        (WebInspector.TextViewerDelegateForSourceFrame.prototype.populateSelectionContextMenu):
+        (WebInspector.SourceFrameDelegate.prototype.suggestedFileName):
+        (WebInspector.SourceFrameDelegate.prototype.addToWatch):
+        * inspector/front-end/TextViewer.js:
+        (WebInspector.TextViewer.prototype._contextMenu):
+        (WebInspector.TextViewerDelegate.prototype.populateSelectionContextMenu):
+        * inspector/front-end/WatchExpressionsSidebarPane.js:
+        (WebInspector.WatchExpressionsSidebarPane.prototype.addExpression):
+        (WebInspector.WatchExpressionsSidebarPane.prototype._addButtonClicked):
+        (WebInspector.WatchExpressionsSection.prototype.addExpression):
+        (WebInspector.WatchExpressionsSection.prototype.addNewExpressionAndEdit):
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::showContextMenu):
+
 2011-10-21  Alexander Pavlov  <[email protected]>
 
         Web Inspector: Audits hang on pages without img[src] elements

Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js


(Binary files differ)

Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (98232 => 98233)


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2011-10-24 11:04:55 UTC (rev 98232)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2011-10-24 12:08:39 UTC (rev 98233)
@@ -121,6 +121,14 @@
             container.appendChild(tokens[i]);
         parentElement.insertBefore(container, nextElement);
         return container;
+    },
+
+    populateTextAreaContextMenu: function(contextMenu)
+    {
+        var selection = window.getSelection();
+        if (selection.type !== "Range" || selection.isCollapsed)
+            return;
+        contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Add to watch" : "Add to Watch"), this._delegate.addToWatch.bind(this._delegate, selection.toString()));
     }
 }
 

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


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2011-10-24 11:04:55 UTC (rev 98232)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2011-10-24 12:08:39 UTC (rev 98233)
@@ -1275,6 +1275,11 @@
     {
         var names = this._scriptsPanel._folderAndDisplayNameForScriptURL(this._uiSourceCode.url);
         return names.displayName || "untitled.js";
+    },
+
+    addToWatch: function(_expression_)
+    {
+        this._scriptsPanel.sidebarPanes.watchExpressions.addExpression(_expression_);
     }
 }
 

Modified: trunk/Source/WebCore/inspector/front-end/SourceFrame.js (98232 => 98233)


--- trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2011-10-24 11:04:55 UTC (rev 98232)
+++ trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2011-10-24 12:08:39 UTC (rev 98233)
@@ -829,7 +829,6 @@
         this._delegate.requestContent(this._initializeTextViewer.bind(this));
     },
 
-
     shouldShowPopover: function(element) { },
 
     onShowPopover: function(element, showCallback) { },
@@ -920,7 +919,9 @@
 
     setScriptSourceIsBeingEdited: function(inEditMode) { },
 
-    suggestedFileName: function() { }
+    suggestedFileName: function() { },
+
+    addToWatch: function() { }
 }
 
 /**

Modified: trunk/Source/WebCore/inspector/front-end/TextViewer.js (98232 => 98233)


--- trunk/Source/WebCore/inspector/front-end/TextViewer.js	2011-10-24 11:04:55 UTC (rev 98232)
+++ trunk/Source/WebCore/inspector/front-end/TextViewer.js	2011-10-24 12:08:39 UTC (rev 98233)
@@ -293,12 +293,8 @@
         var target = event.target.enclosingNodeOrSelfWithClass("webkit-line-number");
         if (target)
             this._delegate.populateLineGutterContextMenu(target.lineNumber, contextMenu);
-        else {
-            var selection = this._mainPanel._getSelection();
-            if (selection && !selection.isEmpty())
-                return; // Show default context menu for selection.
+        else
             this._delegate.populateTextAreaContextMenu(contextMenu);
-        }
 
         var fileName = this._delegate.suggestedFileName();
         if (fileName)

Modified: trunk/Source/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js (98232 => 98233)


--- trunk/Source/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js	2011-10-24 11:04:55 UTC (rev 98232)
+++ trunk/Source/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js	2011-10-24 12:08:39 UTC (rev 98233)
@@ -84,6 +84,12 @@
         this._refreshExpressionsIfNeeded();
     },
 
+    addExpression: function(_expression_)
+    {
+        this.section.addExpression(_expression_);
+        this.expanded = true;
+    },
+
     _refreshExpressionsIfNeeded: function()
     {
         if (this._requiresUpdate && this._visible) {
@@ -97,7 +103,7 @@
     {
         event.stopPropagation();
         this.expanded = true;
-        this.section.addExpression();
+        this.section.addNewExpressionAndEdit();
     },
 
     _refreshButtonClicked: function(event)
@@ -216,8 +222,15 @@
         this.expanded = (propertyCount != 0);
     },
 
-    addExpression: function()
+    addExpression: function(_expression_)
     {
+        this.watchExpressions.push(_expression_);
+        this.saveExpressions();
+        this.update();
+    },
+
+    addNewExpressionAndEdit: function()
+    {
         this._newExpressionAdded = true;
         this.watchExpressions.push(WebInspector.WatchExpressionsSection.NewWatchExpression);
         this.update();

Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (98232 => 98233)


--- trunk/Source/WebCore/page/ContextMenuController.cpp	2011-10-24 11:04:55 UTC (rev 98232)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp	2011-10-24 12:08:39 UTC (rev 98233)
@@ -106,6 +106,11 @@
     showContextMenu(event);
 }
 
+static PassOwnPtr<ContextMenuItem> separatorItem()
+{
+    return adoptPtr(new ContextMenuItem(SeparatorType, ContextMenuItemTagNoAction, String()));
+}
+
 void ContextMenuController::showContextMenu(Event* event, PassRefPtr<ContextMenuProvider> menuProvider)
 {
     m_menuProvider = menuProvider;
@@ -117,6 +122,10 @@
     }
 
     m_menuProvider->populateContextMenu(m_contextMenu.get());
+    if (m_hitTestResult.isSelected()) {
+        appendItem(*separatorItem(), m_contextMenu.get());
+        populate();
+    }
     showContextMenu(event);
 }
 
@@ -429,11 +438,6 @@
         parentMenu->appendItem(menuItem);
 }
 
-static PassOwnPtr<ContextMenuItem> separatorItem()
-{
-    return adoptPtr(new ContextMenuItem(SeparatorType, ContextMenuItemTagNoAction, String()));
-}
-
 void ContextMenuController::createAndAppendFontSubMenu(ContextMenuItem& fontMenuItem)
 {
     ContextMenu fontMenu;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to