OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. |
3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 copyNode: function() | 406 copyNode: function() |
407 { | 407 { |
408 function copy(error, text) | 408 function copy(error, text) |
409 { | 409 { |
410 if (!error) | 410 if (!error) |
411 InspectorFrontendHost.copyText(text); | 411 InspectorFrontendHost.copyText(text); |
412 } | 412 } |
413 DOMAgent.getOuterHTML(this.id, copy); | 413 DOMAgent.getOuterHTML(this.id, copy); |
414 }, | 414 }, |
415 | 415 |
416 _cssPathValue: function() { | |
apavlov
2013/10/15 07:55:11
AFAIU, in general a "CSS path" should be as short
apavlov
2013/10/15 07:55:11
Please add a JSDoc
ericduran
2013/11/05 14:00:59
Hmm, Same assumption but that wasn't what I was go
apavlov
2013/11/05 14:05:51
Hmm, I'm not sure why Firebug does this, but as I
| |
417 if (!this._localName) | |
418 return "null"; | |
apavlov
2013/10/15 07:55:11
Blink indents are 4 spaces wide
apavlov
2013/10/15 07:55:11
I believe this should be
return null;
| |
419 | |
420 var label = this.nodeNameInCorrectCase(); | |
421 | |
422 var id = this.getAttribute("id"); | |
423 if (id) | |
424 label += "#" + id; | |
425 | |
426 var className = this.getAttribute("class"); | |
427 if (className) { | |
apavlov
2013/10/15 07:55:11
This will break for <span class=" ">. You should
| |
428 var selector = "." + className.trim().replace(/\s+/g, "."); | |
429 label = label + selector; | |
430 } | |
431 | |
432 return label; | |
433 }, | |
434 | |
435 copyCSSPath: function() | |
436 { | |
437 InspectorFrontendHost.copyText(this.cssPath()); | |
438 }, | |
439 | |
416 /** | 440 /** |
417 * @param {boolean} optimized | 441 * @param {boolean} optimized |
418 */ | 442 */ |
419 copyXPath: function(optimized) | 443 copyXPath: function(optimized) |
420 { | 444 { |
421 InspectorFrontendHost.copyText(this.xPath(optimized)); | 445 InspectorFrontendHost.copyText(this.xPath(optimized)); |
422 }, | 446 }, |
423 | 447 |
448 cssPath: function() { | |
449 | |
apavlov
2013/10/15 07:55:11
You should check if the node is Node.ELEMENT_NODE
| |
450 var selectors = [], | |
451 contextNode = this; | |
apavlov
2013/10/15 07:55:11
DevTools use a "var" per each declaration. But in
| |
452 for (; contextNode && contextNode._nodeType == Node.ELEMENT_NODE; contextN ode = contextNode.parentNode) { | |
453 var selector = contextNode._cssPathValue(); | |
apavlov
2013/10/15 07:55:11
You should check if the selector is valid (i.e. !=
| |
454 selectors.push(selector); | |
455 } | |
456 | |
457 selectors.reverse(); | |
458 return selectors.length ? selectors.join(" ") : ""; | |
apavlov
2013/10/15 07:55:11
If you implement the early bailout above, you shou
| |
459 | |
460 }, | |
461 | |
424 /** | 462 /** |
425 * @param {string} objectGroupId | 463 * @param {string} objectGroupId |
426 * @param {function(?Protocol.Error)=} callback | 464 * @param {function(?Protocol.Error)=} callback |
427 */ | 465 */ |
428 eventListeners: function(objectGroupId, callback) | 466 eventListeners: function(objectGroupId, callback) |
429 { | 467 { |
430 DOMAgent.getEventListenersForNode(this.id, objectGroupId, callback); | 468 DOMAgent.getEventListenersForNode(this.id, objectGroupId, callback); |
431 }, | 469 }, |
432 | 470 |
433 /** | 471 /** |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1735 setInspectModeEnabled: function(enabled, inspectShadowDOM, config, callback) | 1773 setInspectModeEnabled: function(enabled, inspectShadowDOM, config, callback) |
1736 { | 1774 { |
1737 DOMAgent.setInspectModeEnabled(enabled, inspectShadowDOM, config, callba ck); | 1775 DOMAgent.setInspectModeEnabled(enabled, inspectShadowDOM, config, callba ck); |
1738 } | 1776 } |
1739 } | 1777 } |
1740 | 1778 |
1741 /** | 1779 /** |
1742 * @type {?WebInspector.DOMAgent} | 1780 * @type {?WebInspector.DOMAgent} |
1743 */ | 1781 */ |
1744 WebInspector.domAgent = null; | 1782 WebInspector.domAgent = null; |
OLD | NEW |