Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1502)

Unified Diff: Source/devtools/front_end/elements/ElementsPanel.js

Issue 688513004: DevTools: Migrate elements panel undo/redo shortcuts to declarative actions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Comments addressed Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/devtools/front_end/elements/module.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/elements/ElementsPanel.js
diff --git a/Source/devtools/front_end/elements/ElementsPanel.js b/Source/devtools/front_end/elements/ElementsPanel.js
index a86493dae54c2e2a4adf8ee3ee0f29bcde80dcb9..fcebcf18380f10802525ccc3618effddca4d1f9a 100644
--- a/Source/devtools/front_end/elements/ElementsPanel.js
+++ b/Source/devtools/front_end/elements/ElementsPanel.js
@@ -204,7 +204,7 @@ WebInspector.ElementsPanel.prototype = {
else
treeOutline.domModel().requestDocument();
}
-
+ WebInspector.context.setFlavor(WebInspector.ElementsPanel, this);
},
willHide: function()
@@ -218,6 +218,7 @@ WebInspector.ElementsPanel.prototype = {
}
this._popoverHelper.hidePopover();
WebInspector.Panel.prototype.willHide.call(this);
+ WebInspector.context.setFlavor(WebInspector.ElementsPanel, null);
},
onResize: function()
@@ -689,45 +690,31 @@ WebInspector.ElementsPanel.prototype = {
this.sidebarPanes.platformFonts.setNode(selectedDOMNode);
},
+ _undo: function()
+ {
+ var treeOutline = this._treeOutlineForNode(this._lastValidSelectedNode);
+ if (!treeOutline || WebInspector.isEditing())
+ return;
+ treeOutline.target().domModel.undo(this._updateSidebars.bind(this));
+ },
+
+ _redo: function()
+ {
+ var treeOutline = this._treeOutlineForNode(this._lastValidSelectedNode);
+ if (!treeOutline || WebInspector.isEditing())
apavlov 2014/11/07 19:43:43 Great. IIRC, this will also handle the case of "Ed
+ return;
+ treeOutline.target().domModel.redo(this._updateSidebars.bind(this));
+ },
+
/**
* @param {!KeyboardEvent} event
*/
handleShortcut: function(event)
{
- /**
- * @param {!WebInspector.ElementsTreeOutline} treeOutline
- * @this {WebInspector.ElementsPanel}
- */
- function handleUndoRedo(treeOutline)
- {
- if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && !event.shiftKey && event.keyIdentifier === "U+005A") { // Z key
- treeOutline.target().domModel.undo(this._updateSidebars.bind(this));
- event.handled = true;
- return;
- }
-
- var isRedoKey = WebInspector.isMac() ? event.metaKey && event.shiftKey && event.keyIdentifier === "U+005A" : // Z key
- event.ctrlKey && event.keyIdentifier === "U+0059"; // Y key
- if (isRedoKey) {
- treeOutline.target().domModel.redo(this._updateSidebars.bind(this));
- event.handled = true;
- }
- }
-
- var treeOutline = null;
- for (var i = 0; i < this._treeOutlines.length; ++i) {
- if (this._treeOutlines[i].selectedDOMNode() === this._lastValidSelectedNode)
- treeOutline = this._treeOutlines[i];
- }
+ var treeOutline = this._treeOutlineForNode(this._lastValidSelectedNode);
if (!treeOutline)
return;
- if (!treeOutline.editing()) {
- handleUndoRedo.call(this, treeOutline);
- if (event.handled)
- return;
- }
-
treeOutline.handleShortcut(event);
if (event.handled)
return;
@@ -1111,3 +1098,44 @@ WebInspector.ElementsPanelFactory.prototype = {
return WebInspector.ElementsPanel.instance();
}
}
+
+/**
+ * @constructor
+ * @implements {WebInspector.ActionDelegate}
+ */
+WebInspector.ElementsPanel.UndoActionDelegate = function()
+{
+}
+
+WebInspector.ElementsPanel.UndoActionDelegate.prototype = {
+ /**
+ * @return {boolean}
+ */
+ handleAction: function()
+ {
+ var panel = WebInspector.ElementsPanel.instance();
+ panel._undo();
+ return true;
+ }
+}
+
+/**
+ * @constructor
+ * @implements {WebInspector.ActionDelegate}
+ */
+WebInspector.ElementsPanel.RedoActionDelegate = function()
+{
+}
+
+WebInspector.ElementsPanel.RedoActionDelegate.prototype = {
+ /**
+ * @return {boolean}
+ */
+ handleAction: function()
+ {
+ var panel = WebInspector.ElementsPanel.instance();
+ panel._redo();
+ return true;
+ }
+}
+
« no previous file with comments | « no previous file | Source/devtools/front_end/elements/module.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698