| 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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 this._treeOutlines[i].setWordWrap(/** @type {boolean} */ (event.data)); | 561 this._treeOutlines[i].setWordWrap(/** @type {boolean} */ (event.data)); |
| 562 } | 562 } |
| 563 | 563 |
| 564 switchToAndFocus(node) { | 564 switchToAndFocus(node) { |
| 565 // Reset search restore. | 565 // Reset search restore. |
| 566 this._searchableView.cancelSearch(); | 566 this._searchableView.cancelSearch(); |
| 567 UI.viewManager.showView('elements').then(() => this.selectDOMNode(node, true
)); | 567 UI.viewManager.showView('elements').then(() => this.selectDOMNode(node, true
)); |
| 568 } | 568 } |
| 569 | 569 |
| 570 /** | 570 /** |
| 571 * @param {!Element} element | |
| 572 * @param {!Event} event | 571 * @param {!Event} event |
| 573 * @return {!Element|!AnchorBox|undefined} | 572 * @return {?UI.PopoverRequest} |
| 574 */ | 573 */ |
| 575 _getPopoverAnchor(element, event) { | 574 _getPopoverRequest(event) { |
| 576 var link = element; | 575 var link = event.target; |
| 577 while (link && !link[Elements.ElementsTreeElement.HrefSymbol]) | 576 while (link && !link[Elements.ElementsTreeElement.HrefSymbol]) |
| 578 link = link.parentElementOrShadowHost(); | 577 link = link.parentElementOrShadowHost(); |
| 579 return link ? link : undefined; | 578 if (!link) |
| 580 } | 579 return null; |
| 581 | 580 |
| 582 /** | 581 return { |
| 583 * @param {!Element|!AnchorBox} link | 582 box: link.boxInWindow(), |
| 584 * @param {!UI.GlassPane} popover | 583 show: async popover => { |
| 585 * @return {!Promise<boolean>} | 584 var node = this.selectedDOMNode(); |
| 586 */ | 585 if (!node) |
| 587 _showPopover(link, popover) { | 586 return false; |
| 588 var node = this.selectedDOMNode(); | 587 var preview = await Components.DOMPresentationUtils.buildImagePreviewCon
tents( |
| 589 if (!node) | 588 node.target(), link[Elements.ElementsTreeElement.HrefSymbol], true); |
| 590 return Promise.resolve(false); | 589 if (preview) |
| 591 | 590 popover.contentElement.appendChild(preview); |
| 592 var fulfill; | 591 return !!preview; |
| 593 var promise = new Promise(x => fulfill = x); | 592 } |
| 594 Components.DOMPresentationUtils.buildImagePreviewContents( | 593 }; |
| 595 node.target(), link[Elements.ElementsTreeElement.HrefSymbol], true, show
Popover); | |
| 596 return promise; | |
| 597 | |
| 598 /** | |
| 599 * @param {!Element=} contents | |
| 600 */ | |
| 601 function showPopover(contents) { | |
| 602 if (contents) | |
| 603 popover.contentElement.appendChild(contents); | |
| 604 fulfill(!!contents); | |
| 605 } | |
| 606 } | 594 } |
| 607 | 595 |
| 608 _jumpToSearchResult(index) { | 596 _jumpToSearchResult(index) { |
| 609 this._currentSearchResultIndex = (index + this._searchResults.length) % this
._searchResults.length; | 597 this._currentSearchResultIndex = (index + this._searchResults.length) % this
._searchResults.length; |
| 610 this._highlightCurrentSearchResult(); | 598 this._highlightCurrentSearchResult(); |
| 611 } | 599 } |
| 612 | 600 |
| 613 /** | 601 /** |
| 614 * @override | 602 * @override |
| 615 */ | 603 */ |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 if (tabId === Common.UIString('Computed')) | 888 if (tabId === Common.UIString('Computed')) |
| 901 showMetrics.call(this, true); | 889 showMetrics.call(this, true); |
| 902 else if (tabId === Common.UIString('Styles')) | 890 else if (tabId === Common.UIString('Styles')) |
| 903 showMetrics.call(this, false); | 891 showMetrics.call(this, false); |
| 904 } | 892 } |
| 905 | 893 |
| 906 this.sidebarPaneView = UI.viewManager.createTabbedLocation(() => UI.viewMana
ger.showView('elements')); | 894 this.sidebarPaneView = UI.viewManager.createTabbedLocation(() => UI.viewMana
ger.showView('elements')); |
| 907 var tabbedPane = this.sidebarPaneView.tabbedPane(); | 895 var tabbedPane = this.sidebarPaneView.tabbedPane(); |
| 908 if (this._popoverHelper) | 896 if (this._popoverHelper) |
| 909 this._popoverHelper.hidePopover(); | 897 this._popoverHelper.hidePopover(); |
| 910 this._popoverHelper = new UI.PopoverHelper(tabbedPane.element); | 898 this._popoverHelper = new UI.PopoverHelper(tabbedPane.element, this._getPopo
verRequest.bind(this)); |
| 911 this._popoverHelper.setHasPadding(true); | 899 this._popoverHelper.setHasPadding(true); |
| 912 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this), t
his._showPopover.bind(this)); | |
| 913 this._popoverHelper.setTimeout(0); | 900 this._popoverHelper.setTimeout(0); |
| 914 | 901 |
| 915 if (horizontally) { | 902 if (horizontally) { |
| 916 // Styles and computed are merged into a single tab. | 903 // Styles and computed are merged into a single tab. |
| 917 this._splitWidget.installResizer(tabbedPane.headerElement()); | 904 this._splitWidget.installResizer(tabbedPane.headerElement()); |
| 918 | 905 |
| 919 var stylesView = new UI.SimpleView(Common.UIString('Styles')); | 906 var stylesView = new UI.SimpleView(Common.UIString('Styles')); |
| 920 stylesView.element.classList.add('flex-auto'); | 907 stylesView.element.classList.add('flex-auto'); |
| 921 | 908 |
| 922 var splitWidget = new UI.SplitWidget(true, true, 'stylesPaneSplitViewState
', 215); | 909 var splitWidget = new UI.SplitWidget(true, true, 'stylesPaneSplitViewState
', 215); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 * @param {!SDK.DOMNode} node | 1099 * @param {!SDK.DOMNode} node |
| 1113 * @return {?{title: string, color: string}} | 1100 * @return {?{title: string, color: string}} |
| 1114 */ | 1101 */ |
| 1115 decorate(node) { | 1102 decorate(node) { |
| 1116 return { | 1103 return { |
| 1117 color: 'orange', | 1104 color: 'orange', |
| 1118 title: Common.UIString('Element state: %s', ':' + SDK.CSSModel.fromNode(no
de).pseudoState(node).join(', :')) | 1105 title: Common.UIString('Element state: %s', ':' + SDK.CSSModel.fromNode(no
de).pseudoState(node).join(', :')) |
| 1119 }; | 1106 }; |
| 1120 } | 1107 } |
| 1121 }; | 1108 }; |
| OLD | NEW |