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

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

Issue 2217783002: DevTools: use view locations in the elements and sources sidebars. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ready for review Created 4 years, 4 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 WebInspector.ElementsPanel._elementsSidebarViewTitleSymbol = Symbol("title"); 95 WebInspector.ElementsPanel._elementsSidebarViewTitleSymbol = Symbol("title");
96 96
97 WebInspector.ElementsPanel.prototype = { 97 WebInspector.ElementsPanel.prototype = {
98 /** 98 /**
99 * @param {!WebInspector.CSSProperty} cssProperty 99 * @param {!WebInspector.CSSProperty} cssProperty
100 */ 100 */
101 _revealProperty: function(cssProperty) 101 _revealProperty: function(cssProperty)
102 { 102 {
103 var stylesSidebarPane = this.sidebarPanes.styles; 103 var stylesSidebarPane = this.sidebarPanes.styles;
104 this.sidebarPaneView.selectTab(WebInspector.UIString("Styles")); 104 this.sidebarPaneView.showView(stylesSidebarPane);
105 stylesSidebarPane.revealProperty(/** @type {!WebInspector.CSSProperty} * /(cssProperty)); 105 stylesSidebarPane.revealProperty(/** @type {!WebInspector.CSSProperty} * /(cssProperty));
106 return Promise.resolve(); 106 return Promise.resolve();
107 }, 107 },
108 108
109 /** 109 /**
110 * @param {!WebInspector.StylesSidebarPane} ssp 110 * @param {!WebInspector.StylesSidebarPane} ssp
111 * @return {!Element} 111 * @return {!Element}
112 */ 112 */
113 _createStylesSidebarToolbar: function(ssp) 113 _createStylesSidebarToolbar: function(ssp)
114 { 114 {
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 if (position === "right") 856 if (position === "right")
857 horizontally = false; 857 horizontally = false;
858 else if (position === "bottom") 858 else if (position === "bottom")
859 horizontally = true; 859 horizontally = true;
860 else 860 else
861 horizontally = WebInspector.inspectorView.element.offsetWidth < 680; 861 horizontally = WebInspector.inspectorView.element.offsetWidth < 680;
862 862
863 if (this.sidebarPaneView && horizontally === !this._splitWidget.isVertic al()) 863 if (this.sidebarPaneView && horizontally === !this._splitWidget.isVertic al())
864 return; 864 return;
865 865
866 if (this.sidebarPaneView && this.sidebarPaneView.shouldHideOnDetach()) 866 if (this.sidebarPaneView && this.sidebarPaneView.tabbedPane().shouldHide OnDetach())
867 return; // We can't reparent extension iframes. 867 return; // We can't reparent extension iframes.
868 868
869 var selectedTabId = this.sidebarPaneView ? this.sidebarPaneView.selected TabId : null;
870
871 var extensionSidebarPanes = WebInspector.extensionServer.sidebarPanes(); 869 var extensionSidebarPanes = WebInspector.extensionServer.sidebarPanes();
872 if (this.sidebarPaneView) { 870 if (this.sidebarPaneView) {
873 this.sidebarPaneView.detach(); 871 this.sidebarPaneView.tabbedPane().detach();
874 this._splitWidget.uninstallResizer(this.sidebarPaneView.headerElemen t()); 872 this._splitWidget.uninstallResizer(this.sidebarPaneView.tabbedPane() .headerElement());
875 } 873 }
876 874
877 this._splitWidget.setVertical(!horizontally); 875 this._splitWidget.setVertical(!horizontally);
878 this.showToolbarPane(null); 876 this.showToolbarPane(null);
879 877
880 var computedPane = new WebInspector.View(WebInspector.UIString("Computed ")); 878 var computedPane = new WebInspector.SimpleView(WebInspector.UIString("Co mputed"));
881 computedPane.element.classList.add("composite"); 879 computedPane.element.classList.add("composite");
882 computedPane.element.classList.add("fill"); 880 computedPane.element.classList.add("fill");
883 computedPane.element.classList.add("metrics-and-computed"); 881 computedPane.element.classList.add("metrics-and-computed");
884 882
885 var matchedStylesContainer = new WebInspector.VBox(); 883 var matchedStylesContainer = new WebInspector.VBox();
886 matchedStylesContainer.element.appendChild(this._stylesSidebarToolbar); 884 matchedStylesContainer.element.appendChild(this._stylesSidebarToolbar);
887 var matchedStylePanesWrapper = new WebInspector.VBox(); 885 var matchedStylePanesWrapper = new WebInspector.VBox();
888 matchedStylePanesWrapper.element.classList.add("style-panes-wrapper"); 886 matchedStylePanesWrapper.element.classList.add("style-panes-wrapper");
889 matchedStylePanesWrapper.show(matchedStylesContainer.element); 887 matchedStylePanesWrapper.show(matchedStylesContainer.element);
890 var computedStylePanesWrapper = new WebInspector.VBox(); 888 var computedStylePanesWrapper = new WebInspector.VBox();
(...skipping 17 matching lines...) Expand all
908 */ 906 */
909 function tabSelected(event) 907 function tabSelected(event)
910 { 908 {
911 var tabId = /** @type {string} */ (event.data.tabId); 909 var tabId = /** @type {string} */ (event.data.tabId);
912 if (tabId === WebInspector.UIString("Computed")) 910 if (tabId === WebInspector.UIString("Computed"))
913 showMetrics.call(this, true); 911 showMetrics.call(this, true);
914 else if (tabId === WebInspector.UIString("Styles")) 912 else if (tabId === WebInspector.UIString("Styles"))
915 showMetrics.call(this, false); 913 showMetrics.call(this, false);
916 } 914 }
917 915
918 this.sidebarPaneView = new WebInspector.View.TabbedPaneContainer(); 916 this.sidebarPaneView = WebInspector.viewManager.createTabbedLocation(() => WebInspector.inspectorView.setCurrentPanel(this), "elements-sidebar");
919 this.sidebarPaneView.element.addEventListener("contextmenu", this._sideb arContextMenuEventFired.bind(this), false); 917 var tabbedPane = this.sidebarPaneView.tabbedPane();
918 tabbedPane.element.addEventListener("contextmenu", this._sidebarContextM enuEventFired.bind(this), false);
920 if (this._popoverHelper) 919 if (this._popoverHelper)
921 this._popoverHelper.hidePopover(); 920 this._popoverHelper.hidePopover();
922 this._popoverHelper = new WebInspector.PopoverHelper(this.sidebarPaneVie w.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this)); 921 this._popoverHelper = new WebInspector.PopoverHelper(tabbedPane.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this));
923 this._popoverHelper.setTimeout(0); 922 this._popoverHelper.setTimeout(0);
924 923
925 if (horizontally) { 924 if (horizontally) {
926 this._splitWidget.installResizer(this.sidebarPaneView.headerElement( )); 925 this._splitWidget.installResizer(tabbedPane.headerElement());
927 926
928 var compositePane = new WebInspector.View(WebInspector.UIString("Sty les")); 927 var compositePane = new WebInspector.SimpleView(WebInspector.UIStrin g("Styles"));
929 compositePane.element.classList.add("flex-auto"); 928 compositePane.element.classList.add("flex-auto");
930 929
931 var splitWidget = new WebInspector.SplitWidget(true, true, "stylesPa neSplitViewState", 215); 930 var splitWidget = new WebInspector.SplitWidget(true, true, "stylesPa neSplitViewState", 215);
932 splitWidget.show(compositePane.element); 931 splitWidget.show(compositePane.element);
933 932
934 splitWidget.setMainWidget(matchedStylesContainer); 933 splitWidget.setMainWidget(matchedStylesContainer);
935 splitWidget.setSidebarWidget(computedStylePanesWrapper); 934 splitWidget.setSidebarWidget(computedStylePanesWrapper);
936 935
937 computedPane.show(computedStylePanesWrapper.element); 936 computedPane.show(computedStylePanesWrapper.element);
938 this.sidebarPaneView.appendView(compositePane); 937 this.sidebarPaneView.appendView(compositePane);
938
939 // TODO: remove
940 this.sidebarPanes.styles.setParentViewForReveal(compositePane);
941 this.sidebarPanes.computedStyle.setParentViewForReveal(compositePane );
942 this.sidebarPanes.metrics.setParentViewForReveal(compositePane);
939 } else { 943 } else {
940 var stylesPane = new WebInspector.View(WebInspector.UIString("Styles ")); 944 var stylesPane = new WebInspector.SimpleView(WebInspector.UIString(" Styles"));
941 stylesPane.element.classList.add("flex-auto", "metrics-and-styles"); 945 stylesPane.element.classList.add("flex-auto", "metrics-and-styles");
942 946
943 matchedStylesContainer.show(stylesPane.element); 947 matchedStylesContainer.show(stylesPane.element);
944 computedStylePanesWrapper.show(computedPane.element); 948 computedStylePanesWrapper.show(computedPane.element);
945 949
946 this.sidebarPaneView.addEventListener(WebInspector.TabbedPane.EventT ypes.TabSelected, tabSelected, this); 950 tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSe lected, tabSelected, this);
947 this.sidebarPaneView.appendView(stylesPane); 951 this.sidebarPaneView.appendView(stylesPane);
948 this.sidebarPaneView.appendView(computedPane); 952 this.sidebarPaneView.appendView(computedPane);
953 this.sidebarPanes.metrics.setParentViewForReveal(computedPane);
dgozman 2016/08/06 00:56:10 nit: move next to others under TODO
954
955 // TODO: remove
956 this.sidebarPanes.styles.setParentViewForReveal(stylesPane);
957 this.sidebarPanes.computedStyle.setParentViewForReveal(computedPane) ;
949 } 958 }
950 959
951 this.sidebarPanes.styles.show(matchedStylePanesWrapper.element); 960 this.sidebarPanes.styles.show(matchedStylePanesWrapper.element);
952 this.sidebarPanes.computedStyle.show(computedStylePanesWrapper.element); 961 this.sidebarPanes.computedStyle.show(computedStylePanesWrapper.element);
953 showMetrics.call(this, horizontally); 962 showMetrics.call(this, horizontally);
954 963
955 this.sidebarPaneView.appendView(this.sidebarPanes.eventListeners); 964 this.sidebarPaneView.appendView(this.sidebarPanes.eventListeners);
956 this.sidebarPaneView.appendView(this.sidebarPanes.domBreakpoints); 965 this.sidebarPaneView.appendView(this.sidebarPanes.domBreakpoints);
957 this.sidebarPaneView.appendView(this.sidebarPanes.properties); 966 this.sidebarPaneView.appendView(this.sidebarPanes.properties);
958 967
959 for (var sidebarViewWrapper of this._elementsSidebarViews) 968 for (var sidebarViewWrapper of this._elementsSidebarViews)
960 this.sidebarPaneView.appendView(sidebarViewWrapper); 969 this.sidebarPaneView.appendView(sidebarViewWrapper);
961 970
962 this._extensionSidebarPanesContainer = this.sidebarPaneView; 971 this._extensionSidebarPanesContainer = this.sidebarPaneView;
963 972
964 for (var i = 0; i < extensionSidebarPanes.length; ++i) 973 for (var i = 0; i < extensionSidebarPanes.length; ++i)
965 this._addExtensionSidebarPane(extensionSidebarPanes[i]); 974 this._addExtensionSidebarPane(extensionSidebarPanes[i]);
966 975
967 this._splitWidget.setSidebarWidget(this.sidebarPaneView); 976 this._splitWidget.setSidebarWidget(this.sidebarPaneView.tabbedPane());
968
969 if (selectedTabId)
970 this.sidebarPaneView.selectTab(selectedTabId);
971 }, 977 },
972 978
973 /** 979 /**
974 * @param {!WebInspector.Event} event 980 * @param {!WebInspector.Event} event
975 */ 981 */
976 _extensionSidebarPaneAdded: function(event) 982 _extensionSidebarPaneAdded: function(event)
977 { 983 {
978 var pane = /** @type {!WebInspector.ExtensionSidebarPane} */ (event.data ); 984 var pane = /** @type {!WebInspector.ExtensionSidebarPane} */ (event.data );
979 this._addExtensionSidebarPane(pane); 985 this._addExtensionSidebarPane(pane);
980 }, 986 },
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 /** 1170 /**
1165 * @override 1171 * @override
1166 * @param {!WebInspector.DOMNode} node 1172 * @param {!WebInspector.DOMNode} node
1167 * @return {?{title: string, color: string}} 1173 * @return {?{title: string, color: string}}
1168 */ 1174 */
1169 decorate: function(node) 1175 decorate: function(node)
1170 { 1176 {
1171 return { color: "orange", title: WebInspector.UIString("Element state: % s", ":" + WebInspector.CSSModel.fromNode(node).pseudoState(node).join(", :")) }; 1177 return { color: "orange", title: WebInspector.UIString("Element state: % s", ":" + WebInspector.CSSModel.fromNode(node).pseudoState(node).join(", :")) };
1172 } 1178 }
1173 } 1179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698