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

Side by Side Diff: Source/devtools/front_end/ElementsTreeOutline.js

Issue 75253002: DevTools: [Elements] Implement "Copy CSS Path" context menu item for elements (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Tentatively fix xpath test on Windows bot Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/DOMPresentationUtils.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 var attribute = event.target.enclosingNodeOrSelfWithClass("webkit-html-a ttribute"); 1328 var attribute = event.target.enclosingNodeOrSelfWithClass("webkit-html-a ttribute");
1329 var newAttribute = event.target.enclosingNodeOrSelfWithClass("add-attrib ute"); 1329 var newAttribute = event.target.enclosingNodeOrSelfWithClass("add-attrib ute");
1330 if (attribute && !newAttribute) 1330 if (attribute && !newAttribute)
1331 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCa seMenuTitles() ? "Edit attribute" : "Edit Attribute"), this._startEditingAttribu te.bind(this, attribute, event.target)); 1331 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCa seMenuTitles() ? "Edit attribute" : "Edit Attribute"), this._startEditingAttribu te.bind(this, attribute, event.target));
1332 contextMenu.appendSeparator(); 1332 contextMenu.appendSeparator();
1333 if (this.treeOutline._setPseudoClassCallback) { 1333 if (this.treeOutline._setPseudoClassCallback) {
1334 var pseudoSubMenu = contextMenu.appendSubMenuItem(WebInspector.UIStr ing(WebInspector.useLowerCaseMenuTitles() ? "Force element state" : "Force Eleme nt State")); 1334 var pseudoSubMenu = contextMenu.appendSubMenuItem(WebInspector.UIStr ing(WebInspector.useLowerCaseMenuTitles() ? "Force element state" : "Force Eleme nt State"));
1335 this._populateForcedPseudoStateItems(pseudoSubMenu); 1335 this._populateForcedPseudoStateItems(pseudoSubMenu);
1336 contextMenu.appendSeparator(); 1336 contextMenu.appendSeparator();
1337 } 1337 }
1338
1339 this._populateNodeContextMenu(contextMenu); 1338 this._populateNodeContextMenu(contextMenu);
1340 this.treeOutline._populateContextMenu(contextMenu, this._node); 1339 this.treeOutline._populateContextMenu(contextMenu, this._node);
1341 this._populateScrollIntoView(contextMenu); 1340 this._populateScrollIntoView(contextMenu);
1342 }, 1341 },
1343 1342
1344 /** 1343 /**
1345 * @param {WebInspector.ContextMenu} contextMenu 1344 * @param {WebInspector.ContextMenu} contextMenu
1346 */ 1345 */
1347 _populateScrollIntoView: function(contextMenu) 1346 _populateScrollIntoView: function(contextMenu)
1348 { 1347 {
(...skipping 17 matching lines...) Expand all
1366 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Edit text" : "Edit Text"), this._startEditingTextNode.bind(this, t extNode)); 1365 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Edit text" : "Edit Text"), this._startEditingTextNode.bind(this, t extNode));
1367 this._populateNodeContextMenu(contextMenu); 1366 this._populateNodeContextMenu(contextMenu);
1368 }, 1367 },
1369 1368
1370 _populateNodeContextMenu: function(contextMenu) 1369 _populateNodeContextMenu: function(contextMenu)
1371 { 1370 {
1372 // Add free-form node-related actions. 1371 // Add free-form node-related actions.
1373 var openTagElement = this.treeOutline.getCachedTreeElement(this.represen tedObject) || this; 1372 var openTagElement = this.treeOutline.getCachedTreeElement(this.represen tedObject) || this;
1374 contextMenu.appendItem(WebInspector.UIString("Edit as HTML"), openTagEle ment._editAsHTML.bind(openTagElement)); 1373 contextMenu.appendItem(WebInspector.UIString("Edit as HTML"), openTagEle ment._editAsHTML.bind(openTagElement));
1375 contextMenu.appendItem(WebInspector.UIString("Copy as HTML"), this._copy HTML.bind(this)); 1374 contextMenu.appendItem(WebInspector.UIString("Copy as HTML"), this._copy HTML.bind(this));
1375
1376 // Place it here so that all "Copy"-ing items stick together.
1377 if (this.representedObject.nodeType() === Node.ELEMENT_NODE)
1378 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCa seMenuTitles() ? "Copy CSS path" : "Copy CSS Path"), this._copyCSSPath.bind(this ));
1376 contextMenu.appendItem(WebInspector.UIString("Copy XPath"), this._copyXP ath.bind(this)); 1379 contextMenu.appendItem(WebInspector.UIString("Copy XPath"), this._copyXP ath.bind(this));
1377 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Delete node" : "Delete Node"), this.remove.bind(this)); 1380 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Delete node" : "Delete Node"), this.remove.bind(this));
1378 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Inspect DOM properties" : "Inspect DOM Properties"), this._inspect DOMProperties.bind(this)); 1381 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Inspect DOM properties" : "Inspect DOM Properties"), this._inspect DOMProperties.bind(this));
1379 }, 1382 },
1380 1383
1381 _startEditing: function() 1384 _startEditing: function()
1382 { 1385 {
1383 if (this.treeOutline.selectedDOMNode() !== this._node) 1386 if (this.treeOutline.selectedDOMNode() !== this._node)
1384 return; 1387 return;
1385 1388
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 } 2192 }
2190 2193
2191 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange)); 2194 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange));
2192 }, 2195 },
2193 2196
2194 _copyHTML: function() 2197 _copyHTML: function()
2195 { 2198 {
2196 this._node.copyNode(); 2199 this._node.copyNode();
2197 }, 2200 },
2198 2201
2202 _copyCSSPath: function()
2203 {
2204 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.cssPath (this._node, true));
2205 },
2206
2199 _copyXPath: function() 2207 _copyXPath: function()
2200 { 2208 {
2201 this._node.copyXPath(true); 2209 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.xPath(t his._node, true));
2202 }, 2210 },
2203 2211
2204 _inspectDOMProperties: function() 2212 _inspectDOMProperties: function()
2205 { 2213 {
2206 WebInspector.RemoteObject.resolveNode(this._node, "console", callback); 2214 WebInspector.RemoteObject.resolveNode(this._node, "console", callback);
2207 2215
2208 /** 2216 /**
2209 * @param {WebInspector.RemoteObject} nodeObject 2217 * @param {WebInspector.RemoteObject} nodeObject
2210 */ 2218 */
2211 function callback(nodeObject) 2219 function callback(nodeObject)
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2462 * @constructor 2470 * @constructor
2463 * @param {boolean} isUpdated 2471 * @param {boolean} isUpdated
2464 * @param {WebInspector.DOMNode=} parent 2472 * @param {WebInspector.DOMNode=} parent
2465 */ 2473 */
2466 WebInspector.ElementsTreeUpdater.UpdateEntry = function(isUpdated, parent) 2474 WebInspector.ElementsTreeUpdater.UpdateEntry = function(isUpdated, parent)
2467 { 2475 {
2468 this.isUpdated = isUpdated; 2476 this.isUpdated = isUpdated;
2469 if (parent) 2477 if (parent)
2470 this.parent = parent; 2478 this.parent = parent;
2471 } 2479 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/DOMPresentationUtils.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698