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

Side by Side 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: Forbid moving node into self or descendant 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 /** 247 /**
248 * @param {!WebInspector.DOMNode} node 248 * @param {!WebInspector.DOMNode} node
249 * @param {string} pseudoClass 249 * @param {string} pseudoClass
250 * @param {boolean} enable 250 * @param {boolean} enable
251 */ 251 */
252 _setPseudoClassForNode: function(node, pseudoClass, enable) 252 _setPseudoClassForNode: function(node, pseudoClass, enable)
253 { 253 {
254 if (!node || !node.target().cssModel.forcePseudoState(node, pseudoClass, enable)) 254 if (!node || !node.target().cssModel.forcePseudoState(node, pseudoClass, enable))
255 return; 255 return;
256 256
257 this._targetToTreeOutline.get(node.target()).updateOpenCloseTags(node); 257 this._treeOutlineForNode(node).updateOpenCloseTags(node);
258 this._metricsPaneEdited(); 258 this._metricsPaneEdited();
259 this._stylesPaneEdited(); 259 this._stylesPaneEdited();
260 260
261 WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMet rics.UserAction, { 261 WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMet rics.UserAction, {
262 action: WebInspector.UserMetrics.UserActionNames.ForcedElementState, 262 action: WebInspector.UserMetrics.UserActionNames.ForcedElementState,
263 selector: WebInspector.DOMPresentationUtils.fullQualifiedSelector(no de, false), 263 selector: WebInspector.DOMPresentationUtils.fullQualifiedSelector(no de, false),
264 enabled: enable, 264 enabled: enable,
265 state: pseudoClass 265 state: pseudoClass
266 }); 266 });
267 }, 267 },
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 { 451 {
452 if (event.data) 452 if (event.data)
453 this.contentElement.classList.remove("nowrap"); 453 this.contentElement.classList.remove("nowrap");
454 else 454 else
455 this.contentElement.classList.add("nowrap"); 455 this.contentElement.classList.add("nowrap");
456 456
457 var selectedNode = this.selectedDOMNode(); 457 var selectedNode = this.selectedDOMNode();
458 if (!selectedNode) 458 if (!selectedNode)
459 return; 459 return;
460 460
461 var treeOutline = this._targetToTreeOutline.get(selectedNode.target()); 461 var treeElement = this._treeElementForNode(selectedNode);
462 var treeElement = treeOutline.findTreeElement(selectedNode);
463 if (treeElement) 462 if (treeElement)
464 treeElement.updateSelection(); // Recalculate selection highlight di mensions. 463 treeElement.updateSelection(); // Recalculate selection highlight di mensions.
465 }, 464 },
466 465
467 switchToAndFocus: function(node) 466 switchToAndFocus: function(node)
468 { 467 {
469 // Reset search restore. 468 // Reset search restore.
470 this._searchableView.cancelSearch(); 469 this._searchableView.cancelSearch();
471 WebInspector.inspectorView.setCurrentPanel(this); 470 WebInspector.inspectorView.setCurrentPanel(this);
472 this.selectDOMNode(node, true); 471 this.selectDOMNode(node, true);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 } 613 }
615 614
616 if (typeof searchResult.node === "undefined") { 615 if (typeof searchResult.node === "undefined") {
617 // No data for slot, request it. 616 // No data for slot, request it.
618 searchResult.target.domModel.searchResult(searchResult.index, search Callback.bind(this)); 617 searchResult.target.domModel.searchResult(searchResult.index, search Callback.bind(this));
619 return; 618 return;
620 } 619 }
621 620
622 this._searchableView.updateCurrentMatchIndex(index); 621 this._searchableView.updateCurrentMatchIndex(index);
623 622
624 var treeOutline = this._targetToTreeOutline.get(searchResult.target); 623 var treeElement = this._treeElementForNode(searchResult.node);
625 var treeElement = treeOutline.findTreeElement(searchResult.node);
626 if (treeElement) { 624 if (treeElement) {
627 treeElement.highlightSearchResults(this._searchQuery); 625 treeElement.highlightSearchResults(this._searchQuery);
628 treeElement.reveal(); 626 treeElement.reveal();
629 var matches = treeElement.listItemElement.getElementsByClassName("hi ghlighted-search-result"); 627 var matches = treeElement.listItemElement.getElementsByClassName("hi ghlighted-search-result");
630 if (matches.length) 628 if (matches.length)
631 matches[0].scrollIntoViewIfNeeded(); 629 matches[0].scrollIntoViewIfNeeded();
632 } 630 }
633 }, 631 },
634 632
635 _hideSearchHighlights: function() 633 _hideSearchHighlights: function()
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 1188
1191 if (!treeOutline.editing()) { 1189 if (!treeOutline.editing()) {
1192 handleUndoRedo.call(this, treeOutline); 1190 handleUndoRedo.call(this, treeOutline);
1193 if (event.handled) 1191 if (event.handled)
1194 return; 1192 return;
1195 } 1193 }
1196 1194
1197 treeOutline.handleShortcut(event); 1195 treeOutline.handleShortcut(event);
1198 }, 1196 },
1199 1197
1200 handleCopyEvent: function(event) 1198 /**
1199 * @param {?WebInspector.DOMNode} node
1200 * @return {?WebInspector.ElementsTreeOutline}
1201 */
1202 _treeOutlineForNode: function(node)
1201 { 1203 {
1202 var currentFocusElement = WebInspector.currentFocusElement(); 1204 if (!node)
1203 if (currentFocusElement && WebInspector.isBeingEdited(currentFocusElemen t)) 1205 return null;
1204 return; 1206 return this._targetToTreeOutline.get(node.target()) || null;
1205
1206 // Don't prevent the normal copy if the user has a selection.
1207 if (!window.getSelection().isCollapsed)
1208 return;
1209 event.clipboardData.clearData();
1210 event.preventDefault();
1211 this.selectedDOMNode().copyNode();
1212 }, 1207 },
1213 1208
1214 /** 1209 /**
1210 * @param {!WebInspector.DOMNode} node
1211 * @return {?WebInspector.ElementsTreeElement}
1212 */
1213 _treeElementForNode: function(node)
1214 {
1215 var treeOutline = this._treeOutlineForNode(node);
1216 return /** @type {?WebInspector.ElementsTreeElement} */ (treeOutline.fin dTreeElement(node));
1217 },
1218
1219 /**
1220 * @param {!Event} event
1221 */
1222 handleCopyEvent: function(event)
1223 {
1224 var treeOutline = this._treeOutlineForNode(this.selectedDOMNode());
1225 if (treeOutline)
1226 treeOutline.handleCopyOrCutEvent(false, event);
1227 },
1228
1229 /**
1230 * @param {!Event} event
1231 */
1232 handleCutEvent: function(event)
1233 {
1234 var treeOutline = this._treeOutlineForNode(this.selectedDOMNode());
1235 if (treeOutline)
1236 treeOutline.handleCopyOrCutEvent(true, event);
1237 },
1238
1239 /**
1240 * @param {!Event} event
1241 */
1242 handlePasteEvent: function(event)
1243 {
1244 var treeOutline = this._treeOutlineForNode(this.selectedDOMNode());
1245 if (treeOutline)
1246 treeOutline.handlePasteEvent(event);
1247 },
1248
1249 /**
1215 * @param {!WebInspector.DOMNode} node 1250 * @param {!WebInspector.DOMNode} node
1216 * @return {!WebInspector.DOMNode} 1251 * @return {!WebInspector.DOMNode}
1217 */ 1252 */
1218 _leaveUserAgentShadowDOM: function(node) 1253 _leaveUserAgentShadowDOM: function(node)
1219 { 1254 {
1220 var userAgentShadowRoot = node.ancestorUserAgentShadowRoot(); 1255 var userAgentShadowRoot = node.ancestorUserAgentShadowRoot();
1221 return userAgentShadowRoot ? /** @type {!WebInspector.DOMNode} */ (userA gentShadowRoot.parentNode) : node; 1256 return userAgentShadowRoot ? /** @type {!WebInspector.DOMNode} */ (userA gentShadowRoot.parentNode) : node;
1222 }, 1257 },
1223 1258
1224 /** 1259 /**
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 /** 1536 /**
1502 * @suppressReceiverCheck 1537 * @suppressReceiverCheck
1503 * @this {Element} 1538 * @this {Element}
1504 */ 1539 */
1505 function parentElement() 1540 function parentElement()
1506 { 1541 {
1507 return this.parentElement; 1542 return this.parentElement;
1508 } 1543 }
1509 } 1544 }
1510 } 1545 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698