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 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() { |
| 827 if (this.sidebarPaneView && this.sidebarPaneView.tabbedPane().shouldHideOnDe tach()) | |
| 828 return; // We can't reparent extension iframes. | |
| 829 | |
| 826 var horizontally; | 830 var horizontally; |
| 827 var position = Common.moduleSetting('sidebarPosition').get(); | 831 var position = Common.moduleSetting('sidebarPosition').get(); |
| 828 if (position === 'right') | 832 if (position === 'right') |
| 829 horizontally = false; | 833 horizontally = false; |
| 830 else if (position === 'bottom') | 834 else if (position === 'bottom') |
| 831 horizontally = true; | 835 horizontally = true; |
| 832 else | 836 else |
| 833 horizontally = UI.inspectorView.element.offsetWidth < 680; | 837 horizontally = UI.inspectorView.element.offsetWidth < 680; |
| 834 | 838 |
| 835 if (this.sidebarPaneView && horizontally === !this._splitWidget.isVertical() ) | 839 var splitMode = |
| 840 horizontally ? Elements.ElementsPanel._splitMode.Horizontal : Elements.E lementsPanel._splitMode.Vertical; | |
| 841 if (UI.inspectorView.element.offsetWidth < 415) | |
|
lushnikov
2017/05/10 21:30:52
you have to do this only in horizontal
luoe
2017/05/10 23:40:53
Done.
| |
| 842 splitMode = Elements.ElementsPanel._splitMode.Slim; | |
| 843 if (this.sidebarPaneView && splitMode === this._splitMode) | |
| 836 return; | 844 return; |
| 837 | 845 this._splitMode = splitMode; |
| 838 if (this.sidebarPaneView && this.sidebarPaneView.tabbedPane().shouldHideOnDe tach()) | |
| 839 return; // We can't reparent extension iframes. | |
| 840 | 846 |
| 841 var extensionSidebarPanes = Extensions.extensionServer.sidebarPanes(); | 847 var extensionSidebarPanes = Extensions.extensionServer.sidebarPanes(); |
| 842 if (this.sidebarPaneView) { | 848 if (this.sidebarPaneView) { |
| 843 this.sidebarPaneView.tabbedPane().detach(); | 849 this.sidebarPaneView.tabbedPane().detach(); |
| 844 this._splitWidget.uninstallResizer(this.sidebarPaneView.tabbedPane().heade rElement()); | 850 this._splitWidget.uninstallResizer(this.sidebarPaneView.tabbedPane().heade rElement()); |
| 845 } | 851 } |
| 846 | 852 |
| 847 this._splitWidget.setVertical(!horizontally); | 853 this._splitWidget.setVertical(!horizontally); |
| 848 this.showToolbarPane(null); | 854 this.showToolbarPane(null); |
| 849 | 855 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 882 } | 888 } |
| 883 | 889 |
| 884 this.sidebarPaneView = UI.viewManager.createTabbedLocation(() => UI.viewMana ger.showView('elements')); | 890 this.sidebarPaneView = UI.viewManager.createTabbedLocation(() => UI.viewMana ger.showView('elements')); |
| 885 var tabbedPane = this.sidebarPaneView.tabbedPane(); | 891 var tabbedPane = this.sidebarPaneView.tabbedPane(); |
| 886 if (this._popoverHelper) | 892 if (this._popoverHelper) |
| 887 this._popoverHelper.hidePopover(); | 893 this._popoverHelper.hidePopover(); |
| 888 this._popoverHelper = new UI.PopoverHelper(tabbedPane.element, this._getPopo verRequest.bind(this)); | 894 this._popoverHelper = new UI.PopoverHelper(tabbedPane.element, this._getPopo verRequest.bind(this)); |
| 889 this._popoverHelper.setHasPadding(true); | 895 this._popoverHelper.setHasPadding(true); |
| 890 this._popoverHelper.setTimeout(0); | 896 this._popoverHelper.setTimeout(0); |
| 891 | 897 |
| 892 if (horizontally) { | 898 if (horizontally) |
|
lushnikov
2017/05/10 21:30:52
i'm having hard times understanding what's horizon
luoe
2017/05/10 23:40:53
Done, just splitMode.
| |
| 893 // Styles and computed are merged into a single tab. | |
| 894 this._splitWidget.installResizer(tabbedPane.headerElement()); | 899 this._splitWidget.installResizer(tabbedPane.headerElement()); |
| 895 | 900 |
| 896 var stylesView = new UI.SimpleView(Common.UIString('Styles')); | 901 var stylesView = new UI.SimpleView(Common.UIString('Styles')); |
| 902 this.sidebarPaneView.appendView(stylesView); | |
| 903 if (splitMode === Elements.ElementsPanel._splitMode.Horizontal) { | |
| 904 // Styles and computed are merged into a single tab. | |
| 897 stylesView.element.classList.add('flex-auto'); | 905 stylesView.element.classList.add('flex-auto'); |
| 898 | 906 |
| 899 var splitWidget = new UI.SplitWidget(true, true, 'stylesPaneSplitViewState ', 215); | 907 var splitWidget = new UI.SplitWidget(true, true, 'stylesPaneSplitViewState ', 215); |
| 900 splitWidget.show(stylesView.element); | 908 splitWidget.show(stylesView.element); |
| 901 | |
| 902 splitWidget.setMainWidget(matchedStylesContainer); | 909 splitWidget.setMainWidget(matchedStylesContainer); |
| 903 splitWidget.setSidebarWidget(computedStylePanesWrapper); | 910 splitWidget.setSidebarWidget(computedStylePanesWrapper); |
| 904 | |
| 905 this.sidebarPaneView.appendView(stylesView); | |
| 906 this._stylesViewToReveal = stylesView; | |
| 907 } else { | 911 } else { |
| 908 // Styles and computed are in separate tabs. | 912 // 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'); | 913 stylesView.element.classList.add('flex-auto', 'metrics-and-styles'); |
| 911 matchedStylesContainer.show(stylesView.element); | 914 matchedStylesContainer.show(stylesView.element); |
| 912 | 915 |
| 913 var computedView = new UI.SimpleView(Common.UIString('Computed')); | 916 var computedView = new UI.SimpleView(Common.UIString('Computed')); |
| 914 computedView.element.classList.add('composite', 'fill', 'metrics-and-compu ted'); | 917 computedView.element.classList.add('composite', 'fill', 'metrics-and-compu ted'); |
| 915 computedStylePanesWrapper.show(computedView.element); | 918 computedStylePanesWrapper.show(computedView.element); |
| 916 | 919 |
| 917 tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, tabSelected, this); | 920 tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, tabSelected, this); |
| 918 this.sidebarPaneView.appendView(stylesView); | |
| 919 this.sidebarPaneView.appendView(computedView); | 921 this.sidebarPaneView.appendView(computedView); |
| 920 this._stylesViewToReveal = stylesView; | |
| 921 } | 922 } |
| 923 this._stylesViewToReveal = stylesView; | |
| 922 | 924 |
| 923 showMetrics.call(this, horizontally); | 925 showMetrics.call(this, horizontally); |
| 924 | 926 |
| 925 this.sidebarPaneView.appendApplicableItems('elements-sidebar'); | 927 this.sidebarPaneView.appendApplicableItems('elements-sidebar'); |
| 926 for (var i = 0; i < extensionSidebarPanes.length; ++i) | 928 for (var i = 0; i < extensionSidebarPanes.length; ++i) |
| 927 this._addExtensionSidebarPane(extensionSidebarPanes[i]); | 929 this._addExtensionSidebarPane(extensionSidebarPanes[i]); |
| 928 | 930 |
| 929 this._splitWidget.setSidebarWidget(this.sidebarPaneView.tabbedPane()); | 931 this._splitWidget.setSidebarWidget(this.sidebarPaneView.tabbedPane()); |
| 930 } | 932 } |
| 931 | 933 |
| 932 /** | 934 /** |
| 933 * @param {!Common.Event} event | 935 * @param {!Common.Event} event |
| 934 */ | 936 */ |
| 935 _extensionSidebarPaneAdded(event) { | 937 _extensionSidebarPaneAdded(event) { |
| 936 var pane = /** @type {!Extensions.ExtensionSidebarPane} */ (event.data); | 938 var pane = /** @type {!Extensions.ExtensionSidebarPane} */ (event.data); |
| 937 this._addExtensionSidebarPane(pane); | 939 this._addExtensionSidebarPane(pane); |
| 938 } | 940 } |
| 939 | 941 |
| 940 /** | 942 /** |
| 941 * @param {!Extensions.ExtensionSidebarPane} pane | 943 * @param {!Extensions.ExtensionSidebarPane} pane |
| 942 */ | 944 */ |
| 943 _addExtensionSidebarPane(pane) { | 945 _addExtensionSidebarPane(pane) { |
| 944 if (pane.panelName() === this.name) | 946 if (pane.panelName() === this.name) |
| 945 this.sidebarPaneView.appendView(pane); | 947 this.sidebarPaneView.appendView(pane); |
| 946 } | 948 } |
| 947 }; | 949 }; |
| 948 | 950 |
| 949 Elements.ElementsPanel._elementsSidebarViewTitleSymbol = Symbol('title'); | 951 Elements.ElementsPanel._elementsSidebarViewTitleSymbol = Symbol('title'); |
| 950 | 952 |
| 953 /** @enum {symbol} */ | |
| 954 Elements.ElementsPanel._splitMode = { | |
| 955 Vertical: Symbol('Vertical'), | |
| 956 Horizontal: Symbol('Horizontal'), | |
| 957 Slim: Symbol('Slim'), | |
| 958 }; | |
| 959 | |
| 951 /** | 960 /** |
| 952 * @implements {UI.ContextMenu.Provider} | 961 * @implements {UI.ContextMenu.Provider} |
| 953 * @unrestricted | 962 * @unrestricted |
| 954 */ | 963 */ |
| 955 Elements.ElementsPanel.ContextMenuProvider = class { | 964 Elements.ElementsPanel.ContextMenuProvider = class { |
| 956 /** | 965 /** |
| 957 * @override | 966 * @override |
| 958 * @param {!Event} event | 967 * @param {!Event} event |
| 959 * @param {!UI.ContextMenu} contextMenu | 968 * @param {!UI.ContextMenu} contextMenu |
| 960 * @param {!Object} object | 969 * @param {!Object} object |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1082 * @param {!SDK.DOMNode} node | 1091 * @param {!SDK.DOMNode} node |
| 1083 * @return {?{title: string, color: string}} | 1092 * @return {?{title: string, color: string}} |
| 1084 */ | 1093 */ |
| 1085 decorate(node) { | 1094 decorate(node) { |
| 1086 return { | 1095 return { |
| 1087 color: 'orange', | 1096 color: 'orange', |
| 1088 title: Common.UIString('Element state: %s', ':' + node.domModel().cssModel ().pseudoState(node).join(', :')) | 1097 title: Common.UIString('Element state: %s', ':' + node.domModel().cssModel ().pseudoState(node).join(', :')) |
| 1089 }; | 1098 }; |
| 1090 } | 1099 } |
| 1091 }; | 1100 }; |
| OLD | NEW |