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

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

Issue 2747553002: [DevTools] Rework Popover API (Closed)
Patch Set: await Created 3 years, 9 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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.PopoverContent}
574 */ 573 */
575 _getPopoverAnchor(element, event) { 574 _getPopoverContent(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: popover => {
585 * @return {!Promise<boolean>} 584 var node = this.selectedDOMNode();
586 */ 585 if (!node)
587 _showPopover(link, popover) { 586 return Promise.resolve(false);
588 var node = this.selectedDOMNode();
589 if (!node)
590 return Promise.resolve(false);
591 587
592 var fulfill; 588 var fulfill;
593 var promise = new Promise(x => fulfill = x); 589 var promise = new Promise(x => fulfill = x);
594 Components.DOMPresentationUtils.buildImagePreviewContents( 590 Components.DOMPresentationUtils.buildImagePreviewContents(
595 node.target(), link[Elements.ElementsTreeElement.HrefSymbol], true, show Popover); 591 node.target(), link[Elements.ElementsTreeElement.HrefSymbol], true, showPopover);
596 return promise; 592 return promise;
597 593
598 /** 594 /**
599 * @param {!Element=} contents 595 * @param {!Element=} contents
600 */ 596 */
601 function showPopover(contents) { 597 function showPopover(contents) {
602 if (contents) 598 if (contents)
603 popover.contentElement.appendChild(contents); 599 popover.contentElement.appendChild(contents);
604 fulfill(!!contents); 600 fulfill(!!contents);
605 } 601 }
602 }
603 };
606 } 604 }
607 605
608 _jumpToSearchResult(index) { 606 _jumpToSearchResult(index) {
609 this._currentSearchResultIndex = (index + this._searchResults.length) % this ._searchResults.length; 607 this._currentSearchResultIndex = (index + this._searchResults.length) % this ._searchResults.length;
610 this._highlightCurrentSearchResult(); 608 this._highlightCurrentSearchResult();
611 } 609 }
612 610
613 /** 611 /**
614 * @override 612 * @override
615 */ 613 */
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 if (tabId === Common.UIString('Computed')) 898 if (tabId === Common.UIString('Computed'))
901 showMetrics.call(this, true); 899 showMetrics.call(this, true);
902 else if (tabId === Common.UIString('Styles')) 900 else if (tabId === Common.UIString('Styles'))
903 showMetrics.call(this, false); 901 showMetrics.call(this, false);
904 } 902 }
905 903
906 this.sidebarPaneView = UI.viewManager.createTabbedLocation(() => UI.viewMana ger.showView('elements')); 904 this.sidebarPaneView = UI.viewManager.createTabbedLocation(() => UI.viewMana ger.showView('elements'));
907 var tabbedPane = this.sidebarPaneView.tabbedPane(); 905 var tabbedPane = this.sidebarPaneView.tabbedPane();
908 if (this._popoverHelper) 906 if (this._popoverHelper)
909 this._popoverHelper.hidePopover(); 907 this._popoverHelper.hidePopover();
910 this._popoverHelper = new UI.PopoverHelper(tabbedPane.element); 908 this._popoverHelper = new UI.PopoverHelper(tabbedPane.element, false, this._ getPopoverContent.bind(this));
911 this._popoverHelper.setHasPadding(true); 909 this._popoverHelper.setHasPadding(true);
912 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this), t his._showPopover.bind(this));
913 this._popoverHelper.setTimeout(0); 910 this._popoverHelper.setTimeout(0);
914 911
915 if (horizontally) { 912 if (horizontally) {
916 // Styles and computed are merged into a single tab. 913 // Styles and computed are merged into a single tab.
917 this._splitWidget.installResizer(tabbedPane.headerElement()); 914 this._splitWidget.installResizer(tabbedPane.headerElement());
918 915
919 var stylesView = new UI.SimpleView(Common.UIString('Styles')); 916 var stylesView = new UI.SimpleView(Common.UIString('Styles'));
920 stylesView.element.classList.add('flex-auto'); 917 stylesView.element.classList.add('flex-auto');
921 918
922 var splitWidget = new UI.SplitWidget(true, true, 'stylesPaneSplitViewState ', 215); 919 var splitWidget = new UI.SplitWidget(true, true, 'stylesPaneSplitViewState ', 215);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 * @param {!SDK.DOMNode} node 1109 * @param {!SDK.DOMNode} node
1113 * @return {?{title: string, color: string}} 1110 * @return {?{title: string, color: string}}
1114 */ 1111 */
1115 decorate(node) { 1112 decorate(node) {
1116 return { 1113 return {
1117 color: 'orange', 1114 color: 'orange',
1118 title: Common.UIString('Element state: %s', ':' + SDK.CSSModel.fromNode(no de).pseudoState(node).join(', :')) 1115 title: Common.UIString('Element state: %s', ':' + SDK.CSSModel.fromNode(no de).pseudoState(node).join(', :'))
1119 }; 1116 };
1120 } 1117 }
1121 }; 1118 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698