Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 | 68 |
| 69 this._includeRootDOMNode = !omitRootDOMNode; | 69 this._includeRootDOMNode = !omitRootDOMNode; |
| 70 this._selectEnabled = selectEnabled; | 70 this._selectEnabled = selectEnabled; |
| 71 /** @type {?SDK.DOMNode} */ | 71 /** @type {?SDK.DOMNode} */ |
| 72 this._rootDOMNode = null; | 72 this._rootDOMNode = null; |
| 73 /** @type {?SDK.DOMNode} */ | 73 /** @type {?SDK.DOMNode} */ |
| 74 this._selectedDOMNode = null; | 74 this._selectedDOMNode = null; |
| 75 | 75 |
| 76 this._visible = false; | 76 this._visible = false; |
| 77 | 77 |
| 78 this._popoverHelper = new UI.PopoverHelper(this._element); | 78 this._popoverHelper = new UI.PopoverHelper(this._element, false, this._getPo poverContent.bind(this)); |
| 79 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this), t his._showPopover.bind(this)); | |
| 80 this._popoverHelper.setHasPadding(true); | 79 this._popoverHelper.setHasPadding(true); |
| 81 this._popoverHelper.setTimeout(0, 100); | 80 this._popoverHelper.setTimeout(0, 100); |
| 82 | 81 |
| 83 /** @type {!Map<!SDK.DOMNode, !Elements.ElementsTreeOutline.UpdateRecord>} * / | 82 /** @type {!Map<!SDK.DOMNode, !Elements.ElementsTreeOutline.UpdateRecord>} * / |
| 84 this._updateRecords = new Map(); | 83 this._updateRecords = new Map(); |
| 85 /** @type {!Set<!Elements.ElementsTreeElement>} */ | 84 /** @type {!Set<!Elements.ElementsTreeElement>} */ |
| 86 this._treeElementsBeingUpdated = new Set(); | 85 this._treeElementsBeingUpdated = new Set(); |
| 87 | 86 |
| 88 this._domModel.addEventListener(SDK.DOMModel.Events.MarkersChanged, this._ma rkersChanged, this); | 87 this._domModel.addEventListener(SDK.DOMModel.Events.MarkersChanged, this._ma rkersChanged, this); |
| 89 this._showHTMLCommentsSetting = Common.moduleSetting('showHTMLComments'); | 88 this._showHTMLCommentsSetting = Common.moduleSetting('showHTMLComments'); |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 var element; | 514 var element; |
| 516 if (elementUnderMouse === elementAboveMouse) | 515 if (elementUnderMouse === elementAboveMouse) |
| 517 element = elementUnderMouse; | 516 element = elementUnderMouse; |
| 518 else | 517 else |
| 519 element = this.treeElementFromPoint(x, y + 2); | 518 element = this.treeElementFromPoint(x, y + 2); |
| 520 | 519 |
| 521 return element; | 520 return element; |
| 522 } | 521 } |
| 523 | 522 |
| 524 /** | 523 /** |
| 525 * @param {!Element} element | |
| 526 * @param {!Event} event | 524 * @param {!Event} event |
| 527 * @return {!Element|!AnchorBox|undefined} | 525 * @return {?UI.PopoverContent} |
| 528 */ | 526 */ |
| 529 _getPopoverAnchor(element, event) { | 527 _getPopoverContent(event) { |
| 530 var link = element; | 528 var link = event.target; |
| 531 while (link && !link[Elements.ElementsTreeElement.HrefSymbol]) | 529 while (link && !link[Elements.ElementsTreeElement.HrefSymbol]) |
| 532 link = link.parentElementOrShadowHost(); | 530 link = link.parentElementOrShadowHost(); |
| 533 return link ? link : undefined; | 531 if (!link) |
| 532 return null; | |
| 533 | |
| 534 return { | |
| 535 box: link.boxInWindow(), | |
| 536 show: popover => { | |
| 537 var fulfill; | |
| 538 var promise = new Promise(x => fulfill = x); | |
| 539 var listItem = link.enclosingNodeOrSelfWithNodeName('li'); | |
| 540 var node = /** @type {!Elements.ElementsTreeElement} */ (listItem.treeEl ement).node(); | |
| 541 this._loadDimensionsForNode( | |
|
lushnikov
2017/03/14 01:44:03
the _loadDimensionsForNode is only used for a popo
dgozman
2017/03/14 21:34:01
Done.
| |
| 542 node, | |
| 543 Components.DOMPresentationUtils.buildImagePreviewContents.bind( | |
| 544 Components.DOMPresentationUtils, node.target(), link[Elements.El ementsTreeElement.HrefSymbol], true, | |
| 545 showPopover)); | |
| 546 return promise; | |
| 547 | |
| 548 /** | |
| 549 * @param {!Element=} contents | |
| 550 */ | |
| 551 function showPopover(contents) { | |
| 552 if (contents) | |
| 553 popover.contentElement.appendChild(contents); | |
| 554 fulfill(!!contents); | |
| 555 } | |
| 556 } | |
| 557 }; | |
| 534 } | 558 } |
| 535 | 559 |
| 536 /** | 560 /** |
| 537 * @param {!SDK.DOMNode} node | 561 * @param {!SDK.DOMNode} node |
| 538 * @param {function()} callback | 562 * @param {function()} callback |
| 539 */ | 563 */ |
| 540 _loadDimensionsForNode(node, callback) { | 564 _loadDimensionsForNode(node, callback) { |
| 541 if (!node.nodeName() || node.nodeName().toLowerCase() !== 'img') { | 565 if (!node.nodeName() || node.nodeName().toLowerCase() !== 'img') { |
| 542 callback(); | 566 callback(); |
| 543 return; | 567 return; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 564 offsetWidth: this.offsetWidth, | 588 offsetWidth: this.offsetWidth, |
| 565 offsetHeight: this.offsetHeight, | 589 offsetHeight: this.offsetHeight, |
| 566 naturalWidth: this.naturalWidth, | 590 naturalWidth: this.naturalWidth, |
| 567 naturalHeight: this.naturalHeight, | 591 naturalHeight: this.naturalHeight, |
| 568 currentSrc: this.currentSrc | 592 currentSrc: this.currentSrc |
| 569 }; | 593 }; |
| 570 } | 594 } |
| 571 } | 595 } |
| 572 } | 596 } |
| 573 | 597 |
| 574 /** | |
| 575 * @param {!Element|!AnchorBox} link | |
| 576 * @param {!UI.GlassPane} popover | |
| 577 * @return {!Promise<boolean>} | |
| 578 */ | |
| 579 _showPopover(link, popover) { | |
| 580 var fulfill; | |
| 581 var promise = new Promise(x => fulfill = x); | |
| 582 var listItem = link.enclosingNodeOrSelfWithNodeName('li'); | |
| 583 var node = /** @type {!Elements.ElementsTreeElement} */ (listItem.treeElemen t).node(); | |
| 584 this._loadDimensionsForNode( | |
| 585 node, Components.DOMPresentationUtils.buildImagePreviewContents.bind( | |
| 586 Components.DOMPresentationUtils, node.target(), link[Elements. ElementsTreeElement.HrefSymbol], true, | |
| 587 showPopover)); | |
| 588 return promise; | |
| 589 | |
| 590 /** | |
| 591 * @param {!Element=} contents | |
| 592 */ | |
| 593 function showPopover(contents) { | |
| 594 if (contents) | |
| 595 popover.contentElement.appendChild(contents); | |
| 596 fulfill(!!contents); | |
| 597 } | |
| 598 } | |
| 599 | |
| 600 _onmousedown(event) { | 598 _onmousedown(event) { |
| 601 var element = this._treeElementFromEvent(event); | 599 var element = this._treeElementFromEvent(event); |
| 602 | 600 |
| 603 if (!element || element.isEventWithinDisclosureTriangle(event)) | 601 if (!element || element.isEventWithinDisclosureTriangle(event)) |
| 604 return; | 602 return; |
| 605 | 603 |
| 606 element.select(); | 604 element.select(); |
| 607 } | 605 } |
| 608 | 606 |
| 609 /** | 607 /** |
| (...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1693 */ | 1691 */ |
| 1694 function resolved(node) { | 1692 function resolved(node) { |
| 1695 if (node) { | 1693 if (node) { |
| 1696 this.treeOutline._selectedDOMNode = node; | 1694 this.treeOutline._selectedDOMNode = node; |
| 1697 this.treeOutline._selectedNodeChanged(); | 1695 this.treeOutline._selectedNodeChanged(); |
| 1698 } | 1696 } |
| 1699 } | 1697 } |
| 1700 return true; | 1698 return true; |
| 1701 } | 1699 } |
| 1702 }; | 1700 }; |
| OLD | NEW |