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

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

Issue 2157713002: DevTools: introduce View: a named widget with the toolbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lcean Created 4 years, 5 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 if (WebInspector.moduleSetting("domWordWrap").get()) 60 if (WebInspector.moduleSetting("domWordWrap").get())
61 this._contentElement.classList.add("elements-wrap"); 61 this._contentElement.classList.add("elements-wrap");
62 WebInspector.moduleSetting("domWordWrap").addChangeListener(this._domWordWra pSettingChanged.bind(this)); 62 WebInspector.moduleSetting("domWordWrap").addChangeListener(this._domWordWra pSettingChanged.bind(this));
63 63
64 crumbsContainer.id = "elements-crumbs"; 64 crumbsContainer.id = "elements-crumbs";
65 this._breadcrumbs = new WebInspector.ElementsBreadcrumbs(); 65 this._breadcrumbs = new WebInspector.ElementsBreadcrumbs();
66 this._breadcrumbs.show(crumbsContainer); 66 this._breadcrumbs.show(crumbsContainer);
67 this._breadcrumbs.addEventListener(WebInspector.ElementsBreadcrumbs.Events.N odeSelected, this._crumbNodeSelected, this); 67 this._breadcrumbs.addEventListener(WebInspector.ElementsBreadcrumbs.Events.N odeSelected, this._crumbNodeSelected, this);
68 68
69 this.sidebarPanes = {}; 69 this.sidebarPanes = {};
70 /** @type !Array<!WebInspector.ElementsSidebarViewWrapperPane> */ 70 /** @type !Array<!WebInspector.View> */
71 this._elementsSidebarViewWrappers = []; 71 this._elementsSidebarViews = [];
72 this._currentToolbarPane = null; 72 this._currentToolbarPane = null;
73 73
74 this.sidebarPanes.styles = new WebInspector.StylesSidebarPane(); 74 this.sidebarPanes.styles = new WebInspector.StylesSidebarPane();
75 this.sidebarPanes.computedStyle = WebInspector.ComputedStyleWidget.createSid ebarWrapper(); 75 this.sidebarPanes.computedStyle = new WebInspector.ComputedStyleWidget();
76 this.sidebarPanes.metrics = new WebInspector.MetricsSidebarPane(); 76 this.sidebarPanes.metrics = new WebInspector.MetricsSidebarPane();
77 this.sidebarPanes.properties = WebInspector.PropertiesWidget.createSidebarWr apper(); 77 this.sidebarPanes.properties = new WebInspector.PropertiesWidget();
78 this.sidebarPanes.domBreakpoints = WebInspector.domBreakpointsSidebarPane.cr eateProxy(this); 78 this.sidebarPanes.domBreakpoints = WebInspector.domBreakpointsSidebarPane.cr eateProxy(this);
79 this.sidebarPanes.eventListeners = WebInspector.EventListenersWidget.createS idebarWrapper(); 79 this.sidebarPanes.eventListeners = new WebInspector.EventListenersWidget();
80 80
81 this._stylesSidebarToolbar = this._createStylesSidebarToolbar(this.sidebarPa nes.styles); 81 this._stylesSidebarToolbar = this._createStylesSidebarToolbar(this.sidebarPa nes.styles);
82 82
83 WebInspector.moduleSetting("sidebarPosition").addChangeListener(this._update SidebarPosition.bind(this)); 83 WebInspector.moduleSetting("sidebarPosition").addChangeListener(this._update SidebarPosition.bind(this));
84 this._updateSidebarPosition(); 84 this._updateSidebarPosition();
85 this._loadSidebarViews(); 85 this._loadSidebarViews();
86 86
87 /** @type {!Array.<!WebInspector.ElementsTreeOutline>} */ 87 /** @type {!Array.<!WebInspector.ElementsTreeOutline>} */
88 this._treeOutlines = []; 88 this._treeOutlines = [];
89 WebInspector.targetManager.observeTargets(this); 89 WebInspector.targetManager.observeTargets(this);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 if (this._pendingWidget !== undefined) { 193 if (this._pendingWidget !== undefined) {
194 this._startToolbarPaneAnimation(this._pendingWidget); 194 this._startToolbarPaneAnimation(this._pendingWidget);
195 delete this._pendingWidget; 195 delete this._pendingWidget;
196 } 196 }
197 } 197 }
198 }, 198 },
199 199
200 _loadSidebarViews: function() 200 _loadSidebarViews: function()
201 { 201 {
202 var extensions = self.runtime.extensions("@WebInspector.Widget"); 202 var extensions = self.runtime.extensions("@WebInspector.View");
203 203
204 for (var i = 0; i < extensions.length; ++i) { 204 for (var i = 0; i < extensions.length; ++i) {
205 var descriptor = extensions[i].descriptor(); 205 var descriptor = extensions[i].descriptor();
206 if (descriptor["location"] !== "elements-panel") 206 if (descriptor["location"] !== "elements-panel")
207 continue; 207 continue;
208 208
209 var title = WebInspector.UIString(descriptor["title"]); 209 var title = WebInspector.UIString(descriptor["title"]);
210 extensions[i].instancePromise().then(addSidebarView.bind(this, title )); 210 extensions[i].instancePromise().then(addSidebarView.bind(this, title ));
211 } 211 }
212 212
213 /** 213 /**
214 * @param {string} title 214 * @param {string} title
215 * @param {!Object} object 215 * @param {!Object} object
216 * @this {WebInspector.ElementsPanel} 216 * @this {WebInspector.ElementsPanel}
217 */ 217 */
218 function addSidebarView(title, object) 218 function addSidebarView(title, object)
219 { 219 {
220 var widget = /** @type {!WebInspector.Widget} */ (object); 220 var view = /** @type {!WebInspector.View} */ (object);
221 var elementsSidebarViewWrapperPane = new WebInspector.ElementsSideba rViewWrapperPane(title, widget); 221 this._elementsSidebarViews.push(view);
222 this._elementsSidebarViewWrappers.push(elementsSidebarViewWrapperPan e);
223 222
224 if (this.sidebarPaneView) 223 if (this.sidebarPaneView)
225 this.sidebarPaneView.addPane(elementsSidebarViewWrapperPane); 224 this.sidebarPaneView.addPane(view);
226 } 225 }
227 }, 226 },
228 227
229 /** 228 /**
230 * @override 229 * @override
231 * @param {!WebInspector.Target} target 230 * @param {!WebInspector.Target} target
232 */ 231 */
233 targetAdded: function(target) 232 targetAdded: function(target)
234 { 233 {
235 var domModel = WebInspector.DOMModel.fromTarget(target); 234 var domModel = WebInspector.DOMModel.fromTarget(target);
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 862
864 var extensionSidebarPanes = WebInspector.extensionServer.sidebarPanes(); 863 var extensionSidebarPanes = WebInspector.extensionServer.sidebarPanes();
865 if (this.sidebarPaneView) { 864 if (this.sidebarPaneView) {
866 this.sidebarPaneView.detach(); 865 this.sidebarPaneView.detach();
867 this._splitWidget.uninstallResizer(this.sidebarPaneView.headerElemen t()); 866 this._splitWidget.uninstallResizer(this.sidebarPaneView.headerElemen t());
868 } 867 }
869 868
870 this._splitWidget.setVertical(!horizontally); 869 this._splitWidget.setVertical(!horizontally);
871 this.showToolbarPane(null); 870 this.showToolbarPane(null);
872 871
873 var computedPane = new WebInspector.SidebarPane(WebInspector.UIString("C omputed")); 872 var computedPane = new WebInspector.View(WebInspector.UIString("Computed "));
874 computedPane.element.classList.add("composite"); 873 computedPane.element.classList.add("composite");
875 computedPane.element.classList.add("fill"); 874 computedPane.element.classList.add("fill");
876 computedPane.element.classList.add("metrics-and-computed"); 875 computedPane.element.classList.add("metrics-and-computed");
877 876
878 var matchedStylesContainer = new WebInspector.VBox(); 877 var matchedStylesContainer = new WebInspector.VBox();
879 matchedStylesContainer.element.appendChild(this._stylesSidebarToolbar); 878 matchedStylesContainer.element.appendChild(this._stylesSidebarToolbar);
880 var matchedStylePanesWrapper = new WebInspector.VBox(); 879 var matchedStylePanesWrapper = new WebInspector.VBox();
881 matchedStylePanesWrapper.element.classList.add("style-panes-wrapper"); 880 matchedStylePanesWrapper.element.classList.add("style-panes-wrapper");
882 matchedStylePanesWrapper.show(matchedStylesContainer.element); 881 matchedStylePanesWrapper.show(matchedStylesContainer.element);
883 var computedStylePanesWrapper = new WebInspector.VBox(); 882 var computedStylePanesWrapper = new WebInspector.VBox();
(...skipping 27 matching lines...) Expand all
911 this.sidebarPaneView = new WebInspector.SidebarTabbedPane(); 910 this.sidebarPaneView = new WebInspector.SidebarTabbedPane();
912 this.sidebarPaneView.element.addEventListener("contextmenu", this._sideb arContextMenuEventFired.bind(this), false); 911 this.sidebarPaneView.element.addEventListener("contextmenu", this._sideb arContextMenuEventFired.bind(this), false);
913 if (this._popoverHelper) 912 if (this._popoverHelper)
914 this._popoverHelper.hidePopover(); 913 this._popoverHelper.hidePopover();
915 this._popoverHelper = new WebInspector.PopoverHelper(this.sidebarPaneVie w.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this)); 914 this._popoverHelper = new WebInspector.PopoverHelper(this.sidebarPaneVie w.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this));
916 this._popoverHelper.setTimeout(0); 915 this._popoverHelper.setTimeout(0);
917 916
918 if (horizontally) { 917 if (horizontally) {
919 this._splitWidget.installResizer(this.sidebarPaneView.headerElement( )); 918 this._splitWidget.installResizer(this.sidebarPaneView.headerElement( ));
920 919
921 var compositePane = new WebInspector.SidebarPane(WebInspector.UIStri ng("Styles")); 920 var compositePane = new WebInspector.View(WebInspector.UIString("Sty les"));
922 compositePane.element.classList.add("composite"); 921 compositePane.element.classList.add("composite");
923 compositePane.element.classList.add("fill"); 922 compositePane.element.classList.add("fill");
924 923
925 var splitWidget = new WebInspector.SplitWidget(true, true, "stylesPa neSplitViewState", 215); 924 var splitWidget = new WebInspector.SplitWidget(true, true, "stylesPa neSplitViewState", 215);
926 splitWidget.show(compositePane.element); 925 splitWidget.show(compositePane.element);
927 926
928 splitWidget.setMainWidget(matchedStylesContainer); 927 splitWidget.setMainWidget(matchedStylesContainer);
929 splitWidget.setSidebarWidget(computedStylePanesWrapper); 928 splitWidget.setSidebarWidget(computedStylePanesWrapper);
930 929
931 computedPane.show(computedStylePanesWrapper.element); 930 computedPane.show(computedStylePanesWrapper.element);
932 this.sidebarPaneView.addPane(compositePane); 931 this.sidebarPaneView.addPane(compositePane);
933 } else { 932 } else {
934 var stylesPane = new WebInspector.SidebarPane(WebInspector.UIString( "Styles")); 933 var stylesPane = new WebInspector.View(WebInspector.UIString("Styles "));
935 stylesPane.element.classList.add("composite", "fill", "metrics-and-s tyles"); 934 stylesPane.element.classList.add("composite", "fill", "metrics-and-s tyles");
936 935
937 matchedStylesContainer.show(stylesPane.element); 936 matchedStylesContainer.show(stylesPane.element);
938 computedStylePanesWrapper.show(computedPane.element); 937 computedStylePanesWrapper.show(computedPane.element);
939 938
940 this.sidebarPaneView.addEventListener(WebInspector.TabbedPane.EventT ypes.TabSelected, tabSelected, this); 939 this.sidebarPaneView.addEventListener(WebInspector.TabbedPane.EventT ypes.TabSelected, tabSelected, this);
941 this.sidebarPaneView.addPane(stylesPane); 940 this.sidebarPaneView.addPane(stylesPane);
942 this.sidebarPaneView.addPane(computedPane); 941 this.sidebarPaneView.addPane(computedPane);
943 } 942 }
944 943
945 this.sidebarPanes.styles.show(matchedStylePanesWrapper.element); 944 this.sidebarPanes.styles.show(matchedStylePanesWrapper.element);
946 this.sidebarPanes.computedStyle.show(computedStylePanesWrapper.element); 945 this.sidebarPanes.computedStyle.show(computedStylePanesWrapper.element);
947 showMetrics.call(this, horizontally); 946 showMetrics.call(this, horizontally);
948 947
949 this.sidebarPaneView.addPane(this.sidebarPanes.eventListeners); 948 this.sidebarPaneView.addPane(this.sidebarPanes.eventListeners);
950 this.sidebarPaneView.addPane(this.sidebarPanes.domBreakpoints); 949 this.sidebarPaneView.addPane(this.sidebarPanes.domBreakpoints);
951 this.sidebarPaneView.addPane(this.sidebarPanes.properties); 950 this.sidebarPaneView.addPane(this.sidebarPanes.properties);
952 951
953 for (var sidebarViewWrapper of this._elementsSidebarViewWrappers) 952 for (var sidebarViewWrapper of this._elementsSidebarViews)
954 this.sidebarPaneView.addPane(sidebarViewWrapper); 953 this.sidebarPaneView.addPane(sidebarViewWrapper);
955 954
956 this._extensionSidebarPanesContainer = this.sidebarPaneView; 955 this._extensionSidebarPanesContainer = this.sidebarPaneView;
957 956
958 for (var i = 0; i < extensionSidebarPanes.length; ++i) 957 for (var i = 0; i < extensionSidebarPanes.length; ++i)
959 this._addExtensionSidebarPane(extensionSidebarPanes[i]); 958 this._addExtensionSidebarPane(extensionSidebarPanes[i]);
960 959
961 this._splitWidget.setSidebarWidget(this.sidebarPaneView); 960 this._splitWidget.setSidebarWidget(this.sidebarPaneView);
962 this.sidebarPanes.styles.expandPane();
963 961
964 if (selectedTabId) 962 if (selectedTabId)
965 this.sidebarPaneView.selectTab(selectedTabId); 963 this.sidebarPaneView.selectTab(selectedTabId);
966 }, 964 },
967 965
968 /** 966 /**
969 * @param {!WebInspector.Event} event 967 * @param {!WebInspector.Event} event
970 */ 968 */
971 _extensionSidebarPaneAdded: function(event) 969 _extensionSidebarPaneAdded: function(event)
972 { 970 {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 /** 1178 /**
1181 * @override 1179 * @override
1182 * @param {!WebInspector.DOMNode} node 1180 * @param {!WebInspector.DOMNode} node
1183 * @return {?{title: string, color: string}} 1181 * @return {?{title: string, color: string}}
1184 */ 1182 */
1185 decorate: function(node) 1183 decorate: function(node)
1186 { 1184 {
1187 return { color: "orange", title: WebInspector.UIString("Element state: % s", ":" + WebInspector.CSSModel.fromNode(node).pseudoState(node).join(", :")) }; 1185 return { color: "orange", title: WebInspector.UIString("Element state: % s", ":" + WebInspector.CSSModel.fromNode(node).pseudoState(node).join(", :")) };
1188 } 1186 }
1189 } 1187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698