| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 this._searchableView.setMinimumSize(25, 28); | 47 this._searchableView.setMinimumSize(25, 28); |
| 48 this._searchableView.setPlaceholder(Common.UIString('Find by string, selecto
r, or XPath')); | 48 this._searchableView.setPlaceholder(Common.UIString('Find by string, selecto
r, or XPath')); |
| 49 var stackElement = this._searchableView.element; | 49 var stackElement = this._searchableView.element; |
| 50 | 50 |
| 51 this._contentElement = createElement('div'); | 51 this._contentElement = createElement('div'); |
| 52 var crumbsContainer = createElement('div'); | 52 var crumbsContainer = createElement('div'); |
| 53 stackElement.appendChild(this._contentElement); | 53 stackElement.appendChild(this._contentElement); |
| 54 stackElement.appendChild(crumbsContainer); | 54 stackElement.appendChild(crumbsContainer); |
| 55 | 55 |
| 56 this._splitWidget.setMainWidget(this._searchableView); | 56 this._splitWidget.setMainWidget(this._searchableView); |
| 57 /** @type {?Elements.ElementsPanel._splitMode} */ |
| 58 this._splitMode = null; |
| 57 | 59 |
| 58 this._contentElement.id = 'elements-content'; | 60 this._contentElement.id = 'elements-content'; |
| 59 // FIXME: crbug.com/425984 | 61 // FIXME: crbug.com/425984 |
| 60 if (Common.moduleSetting('domWordWrap').get()) | 62 if (Common.moduleSetting('domWordWrap').get()) |
| 61 this._contentElement.classList.add('elements-wrap'); | 63 this._contentElement.classList.add('elements-wrap'); |
| 62 Common.moduleSetting('domWordWrap').addChangeListener(this._domWordWrapSetti
ngChanged.bind(this)); | 64 Common.moduleSetting('domWordWrap').addChangeListener(this._domWordWrapSetti
ngChanged.bind(this)); |
| 63 | 65 |
| 64 crumbsContainer.id = 'elements-crumbs'; | 66 crumbsContainer.id = 'elements-crumbs'; |
| 65 this._breadcrumbs = new Elements.ElementsBreadcrumbs(); | 67 this._breadcrumbs = new Elements.ElementsBreadcrumbs(); |
| 66 this._breadcrumbs.show(crumbsContainer); | 68 this._breadcrumbs.show(crumbsContainer); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 344 } |
| 343 if (this._popoverHelper) | 345 if (this._popoverHelper) |
| 344 this._popoverHelper.hidePopover(); | 346 this._popoverHelper.hidePopover(); |
| 345 super.willHide(); | 347 super.willHide(); |
| 346 } | 348 } |
| 347 | 349 |
| 348 /** | 350 /** |
| 349 * @override | 351 * @override |
| 350 */ | 352 */ |
| 351 onResize() { | 353 onResize() { |
| 352 if (Common.moduleSetting('sidebarPosition').get() === 'auto') | 354 this.element.window().requestAnimationFrame(this._updateSidebarPosition.bind
(this)); // Do not force layout. |
| 353 this.element.window().requestAnimationFrame(this._updateSidebarPosition.bi
nd(this)); // Do not force layout. | |
| 354 this._updateTreeOutlineVisibleWidth(); | 355 this._updateTreeOutlineVisibleWidth(); |
| 355 } | 356 } |
| 356 | 357 |
| 357 /** | 358 /** |
| 358 * @param {!Common.Event} event | 359 * @param {!Common.Event} event |
| 359 */ | 360 */ |
| 360 _selectedNodeChanged(event) { | 361 _selectedNodeChanged(event) { |
| 361 var selectedNode = /** @type {?SDK.DOMNode} */ (event.data.node); | 362 var selectedNode = /** @type {?SDK.DOMNode} */ (event.data.node); |
| 362 var focus = /** @type {boolean} */ (event.data.focus); | 363 var focus = /** @type {boolean} */ (event.data.focus); |
| 363 for (var i = 0; i < this._treeOutlines.length; ++i) { | 364 for (var i = 0; i < this._treeOutlines.length; ++i) { |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 this._notFirstInspectElement = true; | 817 this._notFirstInspectElement = true; |
| 817 }); | 818 }); |
| 818 } | 819 } |
| 819 | 820 |
| 820 _showUAShadowDOMChanged() { | 821 _showUAShadowDOMChanged() { |
| 821 for (var i = 0; i < this._treeOutlines.length; ++i) | 822 for (var i = 0; i < this._treeOutlines.length; ++i) |
| 822 this._treeOutlines[i].update(); | 823 this._treeOutlines[i].update(); |
| 823 } | 824 } |
| 824 | 825 |
| 825 _updateSidebarPosition() { | 826 _updateSidebarPosition() { |
| 826 var horizontally; | |
| 827 var position = Common.moduleSetting('sidebarPosition').get(); | |
| 828 if (position === 'right') | |
| 829 horizontally = false; | |
| 830 else if (position === 'bottom') | |
| 831 horizontally = true; | |
| 832 else | |
| 833 horizontally = UI.inspectorView.element.offsetWidth < 680; | |
| 834 | |
| 835 if (this.sidebarPaneView && horizontally === !this._splitWidget.isVertical()
) | |
| 836 return; | |
| 837 | |
| 838 if (this.sidebarPaneView && this.sidebarPaneView.tabbedPane().shouldHideOnDe
tach()) | 827 if (this.sidebarPaneView && this.sidebarPaneView.tabbedPane().shouldHideOnDe
tach()) |
| 839 return; // We can't reparent extension iframes. | 828 return; // We can't reparent extension iframes. |
| 840 | 829 |
| 830 var splitMode; |
| 831 var position = Common.moduleSetting('sidebarPosition').get(); |
| 832 if (position === 'right' || (position === 'auto' && UI.inspectorView.element
.offsetWidth > 680)) |
| 833 splitMode = Elements.ElementsPanel._splitMode.Vertical; |
| 834 else if (UI.inspectorView.element.offsetWidth > 415) |
| 835 splitMode = Elements.ElementsPanel._splitMode.Horizontal; |
| 836 else |
| 837 splitMode = Elements.ElementsPanel._splitMode.Slim; |
| 838 |
| 839 if (this.sidebarPaneView && splitMode === this._splitMode) |
| 840 return; |
| 841 this._splitMode = splitMode; |
| 842 |
| 841 var extensionSidebarPanes = Extensions.extensionServer.sidebarPanes(); | 843 var extensionSidebarPanes = Extensions.extensionServer.sidebarPanes(); |
| 842 if (this.sidebarPaneView) { | 844 if (this.sidebarPaneView) { |
| 843 this.sidebarPaneView.tabbedPane().detach(); | 845 this.sidebarPaneView.tabbedPane().detach(); |
| 844 this._splitWidget.uninstallResizer(this.sidebarPaneView.tabbedPane().heade
rElement()); | 846 this._splitWidget.uninstallResizer(this.sidebarPaneView.tabbedPane().heade
rElement()); |
| 845 } | 847 } |
| 846 | 848 |
| 847 this._splitWidget.setVertical(!horizontally); | 849 this._splitWidget.setVertical(this._splitMode === Elements.ElementsPanel._sp
litMode.Vertical); |
| 848 this.showToolbarPane(null); | 850 this.showToolbarPane(null); |
| 849 | 851 |
| 850 var matchedStylesContainer = new UI.VBox(); | 852 var matchedStylesContainer = new UI.VBox(); |
| 851 matchedStylesContainer.element.appendChild(this._stylesSidebarToolbar); | 853 matchedStylesContainer.element.appendChild(this._stylesSidebarToolbar); |
| 852 var matchedStylePanesWrapper = new UI.VBox(); | 854 var matchedStylePanesWrapper = new UI.VBox(); |
| 853 matchedStylePanesWrapper.element.classList.add('style-panes-wrapper'); | 855 matchedStylePanesWrapper.element.classList.add('style-panes-wrapper'); |
| 854 matchedStylePanesWrapper.show(matchedStylesContainer.element); | 856 matchedStylePanesWrapper.show(matchedStylesContainer.element); |
| 855 this._stylesWidget.show(matchedStylePanesWrapper.element); | 857 this._stylesWidget.show(matchedStylePanesWrapper.element); |
| 856 | 858 |
| 857 var computedStylePanesWrapper = new UI.VBox(); | 859 var computedStylePanesWrapper = new UI.VBox(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 882 } | 884 } |
| 883 | 885 |
| 884 this.sidebarPaneView = UI.viewManager.createTabbedLocation(() => UI.viewMana
ger.showView('elements')); | 886 this.sidebarPaneView = UI.viewManager.createTabbedLocation(() => UI.viewMana
ger.showView('elements')); |
| 885 var tabbedPane = this.sidebarPaneView.tabbedPane(); | 887 var tabbedPane = this.sidebarPaneView.tabbedPane(); |
| 886 if (this._popoverHelper) | 888 if (this._popoverHelper) |
| 887 this._popoverHelper.hidePopover(); | 889 this._popoverHelper.hidePopover(); |
| 888 this._popoverHelper = new UI.PopoverHelper(tabbedPane.element, this._getPopo
verRequest.bind(this)); | 890 this._popoverHelper = new UI.PopoverHelper(tabbedPane.element, this._getPopo
verRequest.bind(this)); |
| 889 this._popoverHelper.setHasPadding(true); | 891 this._popoverHelper.setHasPadding(true); |
| 890 this._popoverHelper.setTimeout(0); | 892 this._popoverHelper.setTimeout(0); |
| 891 | 893 |
| 892 if (horizontally) { | 894 if (this._splitMode !== Elements.ElementsPanel._splitMode.Vertical) |
| 893 // Styles and computed are merged into a single tab. | |
| 894 this._splitWidget.installResizer(tabbedPane.headerElement()); | 895 this._splitWidget.installResizer(tabbedPane.headerElement()); |
| 895 | 896 |
| 896 var stylesView = new UI.SimpleView(Common.UIString('Styles')); | 897 var stylesView = new UI.SimpleView(Common.UIString('Styles')); |
| 898 this.sidebarPaneView.appendView(stylesView); |
| 899 if (splitMode === Elements.ElementsPanel._splitMode.Horizontal) { |
| 900 // Styles and computed are merged into a single tab. |
| 897 stylesView.element.classList.add('flex-auto'); | 901 stylesView.element.classList.add('flex-auto'); |
| 898 | 902 |
| 899 var splitWidget = new UI.SplitWidget(true, true, 'stylesPaneSplitViewState
', 215); | 903 var splitWidget = new UI.SplitWidget(true, true, 'stylesPaneSplitViewState
', 215); |
| 900 splitWidget.show(stylesView.element); | 904 splitWidget.show(stylesView.element); |
| 901 | |
| 902 splitWidget.setMainWidget(matchedStylesContainer); | 905 splitWidget.setMainWidget(matchedStylesContainer); |
| 903 splitWidget.setSidebarWidget(computedStylePanesWrapper); | 906 splitWidget.setSidebarWidget(computedStylePanesWrapper); |
| 904 | |
| 905 this.sidebarPaneView.appendView(stylesView); | |
| 906 this._stylesViewToReveal = stylesView; | |
| 907 } else { | 907 } else { |
| 908 // Styles and computed are in separate tabs. | 908 // Styles and computed are in separate tabs. |
| 909 var stylesView = new UI.SimpleView(Common.UIString('Styles')); | |
| 910 stylesView.element.classList.add('flex-auto', 'metrics-and-styles'); | 909 stylesView.element.classList.add('flex-auto', 'metrics-and-styles'); |
| 911 matchedStylesContainer.show(stylesView.element); | 910 matchedStylesContainer.show(stylesView.element); |
| 912 | 911 |
| 913 var computedView = new UI.SimpleView(Common.UIString('Computed')); | 912 var computedView = new UI.SimpleView(Common.UIString('Computed')); |
| 914 computedView.element.classList.add('composite', 'fill', 'metrics-and-compu
ted'); | 913 computedView.element.classList.add('composite', 'fill', 'metrics-and-compu
ted'); |
| 915 computedStylePanesWrapper.show(computedView.element); | 914 computedStylePanesWrapper.show(computedView.element); |
| 916 | 915 |
| 917 tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, tabSelected,
this); | 916 tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, tabSelected,
this); |
| 918 this.sidebarPaneView.appendView(stylesView); | |
| 919 this.sidebarPaneView.appendView(computedView); | 917 this.sidebarPaneView.appendView(computedView); |
| 920 this._stylesViewToReveal = stylesView; | |
| 921 } | 918 } |
| 919 this._stylesViewToReveal = stylesView; |
| 922 | 920 |
| 923 showMetrics.call(this, horizontally); | 921 showMetrics.call(this, this._splitMode === Elements.ElementsPanel._splitMode
.Horizontal); |
| 924 | 922 |
| 925 this.sidebarPaneView.appendApplicableItems('elements-sidebar'); | 923 this.sidebarPaneView.appendApplicableItems('elements-sidebar'); |
| 926 for (var i = 0; i < extensionSidebarPanes.length; ++i) | 924 for (var i = 0; i < extensionSidebarPanes.length; ++i) |
| 927 this._addExtensionSidebarPane(extensionSidebarPanes[i]); | 925 this._addExtensionSidebarPane(extensionSidebarPanes[i]); |
| 928 | 926 |
| 929 this._splitWidget.setSidebarWidget(this.sidebarPaneView.tabbedPane()); | 927 this._splitWidget.setSidebarWidget(this.sidebarPaneView.tabbedPane()); |
| 930 } | 928 } |
| 931 | 929 |
| 932 /** | 930 /** |
| 933 * @param {!Common.Event} event | 931 * @param {!Common.Event} event |
| 934 */ | 932 */ |
| 935 _extensionSidebarPaneAdded(event) { | 933 _extensionSidebarPaneAdded(event) { |
| 936 var pane = /** @type {!Extensions.ExtensionSidebarPane} */ (event.data); | 934 var pane = /** @type {!Extensions.ExtensionSidebarPane} */ (event.data); |
| 937 this._addExtensionSidebarPane(pane); | 935 this._addExtensionSidebarPane(pane); |
| 938 } | 936 } |
| 939 | 937 |
| 940 /** | 938 /** |
| 941 * @param {!Extensions.ExtensionSidebarPane} pane | 939 * @param {!Extensions.ExtensionSidebarPane} pane |
| 942 */ | 940 */ |
| 943 _addExtensionSidebarPane(pane) { | 941 _addExtensionSidebarPane(pane) { |
| 944 if (pane.panelName() === this.name) | 942 if (pane.panelName() === this.name) |
| 945 this.sidebarPaneView.appendView(pane); | 943 this.sidebarPaneView.appendView(pane); |
| 946 } | 944 } |
| 947 }; | 945 }; |
| 948 | 946 |
| 949 Elements.ElementsPanel._elementsSidebarViewTitleSymbol = Symbol('title'); | 947 Elements.ElementsPanel._elementsSidebarViewTitleSymbol = Symbol('title'); |
| 950 | 948 |
| 949 /** @enum {symbol} */ |
| 950 Elements.ElementsPanel._splitMode = { |
| 951 Vertical: Symbol('Vertical'), |
| 952 Horizontal: Symbol('Horizontal'), |
| 953 Slim: Symbol('Slim'), |
| 954 }; |
| 955 |
| 951 /** | 956 /** |
| 952 * @implements {UI.ContextMenu.Provider} | 957 * @implements {UI.ContextMenu.Provider} |
| 953 * @unrestricted | 958 * @unrestricted |
| 954 */ | 959 */ |
| 955 Elements.ElementsPanel.ContextMenuProvider = class { | 960 Elements.ElementsPanel.ContextMenuProvider = class { |
| 956 /** | 961 /** |
| 957 * @override | 962 * @override |
| 958 * @param {!Event} event | 963 * @param {!Event} event |
| 959 * @param {!UI.ContextMenu} contextMenu | 964 * @param {!UI.ContextMenu} contextMenu |
| 960 * @param {!Object} object | 965 * @param {!Object} object |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 * @param {!SDK.DOMNode} node | 1087 * @param {!SDK.DOMNode} node |
| 1083 * @return {?{title: string, color: string}} | 1088 * @return {?{title: string, color: string}} |
| 1084 */ | 1089 */ |
| 1085 decorate(node) { | 1090 decorate(node) { |
| 1086 return { | 1091 return { |
| 1087 color: 'orange', | 1092 color: 'orange', |
| 1088 title: Common.UIString('Element state: %s', ':' + node.domModel().cssModel
().pseudoState(node).join(', :')) | 1093 title: Common.UIString('Element state: %s', ':' + node.domModel().cssModel
().pseudoState(node).join(', :')) |
| 1089 }; | 1094 }; |
| 1090 } | 1095 } |
| 1091 }; | 1096 }; |
| OLD | NEW |