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

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

Issue 27204002: Implement copy css path in elements panel. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Removing duplicate code. Created 7 years, 2 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
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 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 { 1171 {
1172 this.expandedChildrenLimit = Math.max(this._visibleChildCount(), this.ex pandedChildrenLimit + WebInspector.ElementsTreeElement.InitialChildrenLimit); 1172 this.expandedChildrenLimit = Math.max(this._visibleChildCount(), this.ex pandedChildrenLimit + WebInspector.ElementsTreeElement.InitialChildrenLimit);
1173 }, 1173 },
1174 1174
1175 expandRecursively: function() 1175 expandRecursively: function()
1176 { 1176 {
1177 function callback() 1177 function callback()
1178 { 1178 {
1179 TreeElement.prototype.expandRecursively.call(this, Number.MAX_VALUE) ; 1179 TreeElement.prototype.expandRecursively.call(this, Number.MAX_VALUE) ;
1180 } 1180 }
1181 1181
1182 this._node.getSubtree(-1, callback.bind(this)); 1182 this._node.getSubtree(-1, callback.bind(this));
1183 }, 1183 },
1184 1184
1185 onexpand: function() 1185 onexpand: function()
1186 { 1186 {
1187 if (this._elementCloseTag) 1187 if (this._elementCloseTag)
1188 return; 1188 return;
1189 1189
1190 this.updateTitle(); 1190 this.updateTitle();
1191 this.treeOutline.updateSelection(); 1191 this.treeOutline.updateSelection();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 this.treeOutline._populateContextMenu(contextMenu, this._node); 1338 this.treeOutline._populateContextMenu(contextMenu, this._node);
1339 this._populateScrollIntoView(contextMenu); 1339 this._populateScrollIntoView(contextMenu);
1340 }, 1340 },
1341 1341
1342 /** 1342 /**
1343 * @param {WebInspector.ContextMenu} contextMenu 1343 * @param {WebInspector.ContextMenu} contextMenu
1344 */ 1344 */
1345 _populateScrollIntoView: function(contextMenu) 1345 _populateScrollIntoView: function(contextMenu)
1346 { 1346 {
1347 contextMenu.appendSeparator(); 1347 contextMenu.appendSeparator();
1348 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Scroll into view" : "Scroll into View"), this._scrollIntoView.bind (this)); 1348 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Scroll into view" : "Scroll into View"), this._scrollIntoView.bind (this));
1349 }, 1349 },
1350 1350
1351 _populateForcedPseudoStateItems: function(subMenu) 1351 _populateForcedPseudoStateItems: function(subMenu)
1352 { 1352 {
1353 const pseudoClasses = ["active", "hover", "focus", "visited"]; 1353 const pseudoClasses = ["active", "hover", "focus", "visited"];
1354 var node = this._node; 1354 var node = this._node;
1355 var forcedPseudoState = (node ? node.getUserProperty("pseudoState") : nu ll) || []; 1355 var forcedPseudoState = (node ? node.getUserProperty("pseudoState") : nu ll) || [];
1356 for (var i = 0; i < pseudoClasses.length; ++i) { 1356 for (var i = 0; i < pseudoClasses.length; ++i) {
1357 var pseudoClassForced = forcedPseudoState.indexOf(pseudoClasses[i]) >= 0; 1357 var pseudoClassForced = forcedPseudoState.indexOf(pseudoClasses[i]) >= 0;
1358 subMenu.appendCheckboxItem(":" + pseudoClasses[i], this.treeOutline. _setPseudoClassCallback.bind(null, node.id, pseudoClasses[i], !pseudoClassForced ), pseudoClassForced, false); 1358 subMenu.appendCheckboxItem(":" + pseudoClasses[i], this.treeOutline. _setPseudoClassCallback.bind(null, node.id, pseudoClasses[i], !pseudoClassForced ), pseudoClassForced, false);
1359 } 1359 }
1360 }, 1360 },
1361 1361
1362 _populateTextContextMenu: function(contextMenu, textNode) 1362 _populateTextContextMenu: function(contextMenu, textNode)
1363 { 1363 {
1364 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Edit text" : "Edit Text"), this._startEditingTextNode.bind(this, t extNode)); 1364 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Edit text" : "Edit Text"), this._startEditingTextNode.bind(this, t extNode));
1365 this._populateNodeContextMenu(contextMenu); 1365 this._populateNodeContextMenu(contextMenu);
1366 }, 1366 },
1367 1367
1368 _populateNodeContextMenu: function(contextMenu) 1368 _populateNodeContextMenu: function(contextMenu)
1369 { 1369 {
1370 // Add free-form node-related actions. 1370 // Add free-form node-related actions.
1371 var openTagElement = this.treeOutline.getCachedTreeElement(this.represen tedObject) || this; 1371 var openTagElement = this.treeOutline.getCachedTreeElement(this.represen tedObject) || this;
1372 contextMenu.appendItem(WebInspector.UIString("Edit as HTML"), openTagEle ment._editAsHTML.bind(openTagElement)); 1372 contextMenu.appendItem(WebInspector.UIString("Edit as HTML"), openTagEle ment._editAsHTML.bind(openTagElement));
1373 contextMenu.appendItem(WebInspector.UIString("Copy as HTML"), this._copy HTML.bind(this)); 1373 contextMenu.appendItem(WebInspector.UIString("Copy as HTML"), this._copy HTML.bind(this));
1374 contextMenu.appendItem(WebInspector.UIString("Copy XPath"), this._copyXP ath.bind(this)); 1374 contextMenu.appendItem(WebInspector.UIString("Copy XPath"), this._copyXP ath.bind(this));
1375 contextMenu.appendItem(WebInspector.UIString("Copy CSS Path"), this._cop yCSSPath.bind(this));
apavlov 2013/10/15 07:55:11 This should go into _populateTagContextMenu(). Cop
1375 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Delete node" : "Delete Node"), this.remove.bind(this)); 1376 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Delete node" : "Delete Node"), this.remove.bind(this));
1376 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Inspect DOM properties" : "Inspect DOM Properties"), this._inspect DOMProperties.bind(this)); 1377 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Inspect DOM properties" : "Inspect DOM Properties"), this._inspect DOMProperties.bind(this));
1377 }, 1378 },
1378 1379
1379 _startEditing: function() 1380 _startEditing: function()
1380 { 1381 {
1381 if (this.treeOutline.selectedDOMNode() !== this._node) 1382 if (this.treeOutline.selectedDOMNode() !== this._node)
1382 return; 1383 return;
1383 1384
1384 var listItem = this._listItemNode; 1385 var listItem = this._listItemNode;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 if (attributeName && attributeValueElement && listItemElement && listIte mElement.treeElement) 1463 if (attributeName && attributeValueElement && listItemElement && listIte mElement.treeElement)
1463 domNode = listItemElement.treeElement.representedObject; 1464 domNode = listItemElement.treeElement.representedObject;
1464 var attributeValue = domNode ? domNode.getAttribute(attributeName) : und efined; 1465 var attributeValue = domNode ? domNode.getAttribute(attributeName) : und efined;
1465 if (typeof attributeValue !== "undefined") 1466 if (typeof attributeValue !== "undefined")
1466 attributeValueElement.textContent = attributeValue; 1467 attributeValueElement.textContent = attributeValue;
1467 1468
1468 // Remove zero-width spaces that were added by nodeTitleInfo. 1469 // Remove zero-width spaces that were added by nodeTitleInfo.
1469 removeZeroWidthSpaceRecursive(attribute); 1470 removeZeroWidthSpaceRecursive(attribute);
1470 1471
1471 var config = new WebInspector.EditingConfig(this._attributeEditingCommit ted.bind(this), this._editingCancelled.bind(this), attributeName); 1472 var config = new WebInspector.EditingConfig(this._attributeEditingCommit ted.bind(this), this._editingCancelled.bind(this), attributeName);
1472 1473
1473 function handleKeyDownEvents(event) 1474 function handleKeyDownEvents(event)
1474 { 1475 {
1475 var isMetaOrCtrl = WebInspector.isMac() ? 1476 var isMetaOrCtrl = WebInspector.isMac() ?
1476 event.metaKey && !event.shiftKey && !event.ctrlKey && !event.alt Key : 1477 event.metaKey && !event.shiftKey && !event.ctrlKey && !event.alt Key :
1477 event.ctrlKey && !event.shiftKey && !event.metaKey && !event.alt Key; 1478 event.ctrlKey && !event.shiftKey && !event.metaKey && !event.alt Key;
1478 if (isEnterKey(event) && (event.isMetaOrCtrlForTest || !config.multi line || isMetaOrCtrl)) 1479 if (isEnterKey(event) && (event.isMetaOrCtrlForTest || !config.multi line || isMetaOrCtrl))
1479 return "commit"; 1480 return "commit";
1480 else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.co de || event.keyIdentifier === "U+001B") 1481 else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.co de || event.keyIdentifier === "U+001B")
1481 return "cancel"; 1482 return "cancel";
1482 else if (event.keyIdentifier === "U+0009") // Tab key 1483 else if (event.keyIdentifier === "U+0009") // Tab key
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 } 2178 }
2178 2179
2179 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange)); 2180 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange));
2180 }, 2181 },
2181 2182
2182 _copyHTML: function() 2183 _copyHTML: function()
2183 { 2184 {
2184 this._node.copyNode(); 2185 this._node.copyNode();
2185 }, 2186 },
2186 2187
2188 _copyCSSPath: function()
2189 {
2190 this._node.copyCSSPath();
2191 },
2192
2187 _copyXPath: function() 2193 _copyXPath: function()
2188 { 2194 {
2189 this._node.copyXPath(true); 2195 this._node.copyXPath(true);
2190 }, 2196 },
2191 2197
2192 _inspectDOMProperties: function() 2198 _inspectDOMProperties: function()
2193 { 2199 {
2194 WebInspector.RemoteObject.resolveNode(this._node, "console", callback); 2200 WebInspector.RemoteObject.resolveNode(this._node, "console", callback);
2195 2201
2196 /** 2202 /**
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2240 function scrollIntoViewCallback(object) 2246 function scrollIntoViewCallback(object)
2241 { 2247 {
2242 function scrollIntoView() 2248 function scrollIntoView()
2243 { 2249 {
2244 this.scrollIntoViewIfNeeded(true); 2250 this.scrollIntoViewIfNeeded(true);
2245 } 2251 }
2246 2252
2247 if (object) 2253 if (object)
2248 object.callFunction(scrollIntoView); 2254 object.callFunction(scrollIntoView);
2249 } 2255 }
2250 2256
2251 WebInspector.RemoteObject.resolveNode(this._node, "", scrollIntoViewCall back); 2257 WebInspector.RemoteObject.resolveNode(this._node, "", scrollIntoViewCall back);
2252 }, 2258 },
2253 2259
2254 /** 2260 /**
2255 * @return {Array.<WebInspector.DOMNode>} visibleChildren 2261 * @return {Array.<WebInspector.DOMNode>} visibleChildren
2256 */ 2262 */
2257 _visibleChildren: function() 2263 _visibleChildren: function()
2258 { 2264 {
2259 var visibleChildren = WebInspector.ElementsTreeOutline.showShadowDOM() ? this._node.shadowRoots() : []; 2265 var visibleChildren = WebInspector.ElementsTreeOutline.showShadowDOM() ? this._node.shadowRoots() : [];
2260 if (this._node.templateContent()) 2266 if (this._node.templateContent())
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 * @constructor 2456 * @constructor
2451 * @param {boolean} isUpdated 2457 * @param {boolean} isUpdated
2452 * @param {WebInspector.DOMNode=} parent 2458 * @param {WebInspector.DOMNode=} parent
2453 */ 2459 */
2454 WebInspector.ElementsTreeUpdater.UpdateEntry = function(isUpdated, parent) 2460 WebInspector.ElementsTreeUpdater.UpdateEntry = function(isUpdated, parent)
2455 { 2461 {
2456 this.isUpdated = isUpdated; 2462 this.isUpdated = isUpdated;
2457 if (parent) 2463 if (parent)
2458 this.parent = parent; 2464 this.parent = parent;
2459 } 2465 }
OLDNEW
« Source/devtools/front_end/DOMAgent.js ('K') | « Source/devtools/front_end/DOMAgent.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698