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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/elements/ElementsTreeOutline.js

Issue 2527763003: [DevTools] Turn links into spans to prevent default behavior. (Closed)
Patch Set: fixed comments Created 4 years 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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 524
525 return element; 525 return element;
526 } 526 }
527 527
528 /** 528 /**
529 * @param {!Element} element 529 * @param {!Element} element
530 * @param {!Event} event 530 * @param {!Event} event
531 * @return {!Element|!AnchorBox|undefined} 531 * @return {!Element|!AnchorBox|undefined}
532 */ 532 */
533 _getPopoverAnchor(element, event) { 533 _getPopoverAnchor(element, event) {
534 var anchor = element.enclosingNodeOrSelfWithClass('webkit-html-resource-link '); 534 var link = element;
535 if (!anchor || !anchor.href) 535 while (link && !link[Elements.ElementsTreeElement.HrefSymbol])
536 return; 536 link = link.parentElementOrShadowHost();
537 537 return link ? link : undefined;
538 return anchor;
539 } 538 }
540 539
541 /** 540 /**
542 * @param {!SDK.DOMNode} node 541 * @param {!SDK.DOMNode} node
543 * @param {function()} callback 542 * @param {function()} callback
544 */ 543 */
545 _loadDimensionsForNode(node, callback) { 544 _loadDimensionsForNode(node, callback) {
546 if (!node.nodeName() || node.nodeName().toLowerCase() !== 'img') { 545 if (!node.nodeName() || node.nodeName().toLowerCase() !== 'img') {
547 callback(); 546 callback();
548 return; 547 return;
(...skipping 21 matching lines...) Expand all
570 offsetHeight: this.offsetHeight, 569 offsetHeight: this.offsetHeight,
571 naturalWidth: this.naturalWidth, 570 naturalWidth: this.naturalWidth,
572 naturalHeight: this.naturalHeight, 571 naturalHeight: this.naturalHeight,
573 currentSrc: this.currentSrc 572 currentSrc: this.currentSrc
574 }; 573 };
575 } 574 }
576 } 575 }
577 } 576 }
578 577
579 /** 578 /**
580 * @param {!Element} anchor 579 * @param {!Element} link
581 * @param {!UI.Popover} popover 580 * @param {!UI.Popover} popover
582 */ 581 */
583 _showPopover(anchor, popover) { 582 _showPopover(link, popover) {
584 var listItem = anchor.enclosingNodeOrSelfWithNodeName('li'); 583 var listItem = link.enclosingNodeOrSelfWithNodeName('li');
585 var node = /** @type {!Elements.ElementsTreeElement} */ (listItem.treeElemen t).node(); 584 var node = /** @type {!Elements.ElementsTreeElement} */ (listItem.treeElemen t).node();
586 this._loadDimensionsForNode( 585 this._loadDimensionsForNode(
587 node, Components.DOMPresentationUtils.buildImagePreviewContents.bind( 586 node, Components.DOMPresentationUtils.buildImagePreviewContents.bind(
588 Components.DOMPresentationUtils, node.target(), anchor.href, t rue, showPopover)); 587 Components.DOMPresentationUtils, node.target(), link[Elements. ElementsTreeElement.HrefSymbol], true,
588 showPopover));
589 589
590 /** 590 /**
591 * @param {!Element=} contents 591 * @param {!Element=} contents
592 */ 592 */
593 function showPopover(contents) { 593 function showPopover(contents) {
594 if (!contents) 594 if (!contents)
595 return; 595 return;
596 popover.setCanShrink(false); 596 popover.setCanShrink(false);
597 popover.showForAnchor(contents, anchor); 597 popover.showForAnchor(contents, link);
598 } 598 }
599 } 599 }
600 600
601 _onmousedown(event) { 601 _onmousedown(event) {
602 var element = this._treeElementFromEvent(event); 602 var element = this._treeElementFromEvent(event);
603 603
604 if (!element || element.isEventWithinDisclosureTriangle(event)) 604 if (!element || element.isEventWithinDisclosureTriangle(event))
605 return; 605 return;
606 606
607 element.select(); 607 element.select();
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 */ 1693 */
1694 function resolved(node) { 1694 function resolved(node) {
1695 if (node) { 1695 if (node) {
1696 this.treeOutline._selectedDOMNode = node; 1696 this.treeOutline._selectedDOMNode = node;
1697 this.treeOutline._selectedNodeChanged(); 1697 this.treeOutline._selectedNodeChanged();
1698 } 1698 }
1699 } 1699 }
1700 return true; 1700 return true;
1701 } 1701 }
1702 }; 1702 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698