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

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

Issue 397303002: DevTools: [Elements] Implement shortcut-based node cut-copy-pasting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Reset clipboard if node on it is removed Created 6 years, 5 months 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
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 e73235cc7c83a2ef992c0afd8d17c391572252a0..73a19a5d02b6f8c2b42231325f488d525a599ca7 100644
--- a/Source/devtools/front_end/elements/ElementsPanel.js
+++ b/Source/devtools/front_end/elements/ElementsPanel.js
@@ -250,7 +250,7 @@ WebInspector.ElementsPanel.prototype = {
if (!node || !node.target().cssModel.forcePseudoState(node, pseudoClass, enable))
return;
- this._targetToTreeOutline.get(node.target()).updateOpenCloseTags(node);
+ this._treeOutlineForNode(node).updateOpenCloseTags(node);
this._metricsPaneEdited();
this._stylesPaneEdited();
@@ -454,8 +454,7 @@ WebInspector.ElementsPanel.prototype = {
if (!selectedNode)
return;
- var treeOutline = this._targetToTreeOutline.get(selectedNode.target());
- var treeElement = treeOutline.findTreeElement(selectedNode);
+ var treeElement = this._treeElementForNode(selectedNode);
if (treeElement)
treeElement.updateSelection(); // Recalculate selection highlight dimensions.
},
@@ -617,8 +616,7 @@ WebInspector.ElementsPanel.prototype = {
this._searchableView.updateCurrentMatchIndex(index);
- var treeOutline = this._targetToTreeOutline.get(searchResult.target);
- var treeElement = treeOutline.findTreeElement(searchResult.node);
+ var treeElement = this._treeElementForNode(searchResult.node);
if (treeElement) {
treeElement.highlightSearchResults(this._searchQuery);
treeElement.reveal();
@@ -1193,18 +1191,55 @@ WebInspector.ElementsPanel.prototype = {
treeOutline.handleShortcut(event);
},
+ /**
+ * @param {?WebInspector.DOMNode} node
+ * @return {?WebInspector.ElementsTreeOutline}
+ */
+ _treeOutlineForNode: function(node)
+ {
+ if (!node)
+ return null;
+ return this._targetToTreeOutline.get(node.target()) || null;
+ },
+
+ /**
+ * @param {!WebInspector.DOMNode} node
+ * @return {?WebInspector.ElementsTreeElement}
+ */
+ _treeElementForNode: function(node)
+ {
+ var treeOutline = this._treeOutlineForNode(node);
+ return /** @type {?WebInspector.ElementsTreeElement} */ (treeOutline.findTreeElement(node));
+ },
+
+ /**
+ * @param {!Event} event
+ */
handleCopyEvent: function(event)
{
- var currentFocusElement = WebInspector.currentFocusElement();
- if (currentFocusElement && WebInspector.isBeingEdited(currentFocusElement))
- return;
+ var treeOutline = this._treeOutlineForNode(this.selectedDOMNode());
+ if (treeOutline)
+ treeOutline.handleCopyOrCutKeyboardEvent(false, event);
+ },
- // Don't prevent the normal copy if the user has a selection.
- if (!window.getSelection().isCollapsed)
- return;
- event.clipboardData.clearData();
- event.preventDefault();
- this.selectedDOMNode().copyNode();
+ /**
+ * @param {!Event} event
+ */
+ handleCutEvent: function(event)
+ {
+ var treeOutline = this._treeOutlineForNode(this.selectedDOMNode());
+ if (treeOutline)
+ treeOutline.handleCopyOrCutKeyboardEvent(true, event);
+ },
+
+ /**
+ * @param {!Event} event
+ */
+ handlePasteEvent: function(event)
+ {
+ var treeOutline = this._treeOutlineForNode(this.selectedDOMNode());
+ if (treeOutline)
+ treeOutline.handlePasteKeyboardEvent(event);
},
/**
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.cpp ('k') | Source/devtools/front_end/elements/ElementsTreeOutline.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698