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

Side by Side Diff: Source/devtools/front_end/Placard.js

Issue 80383004: DevTools: Show asynchronous call stacks on frontend. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/DebuggerModel.js ('k') | Source/devtools/front_end/Script.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 4 *
4 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
6 * are met: 7 * are met:
7 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
12 * 13 *
(...skipping 10 matching lines...) Expand all
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 25 */
25 26
26 /** 27 /**
27 * @constructor 28 * @constructor
28 * @param {string} title 29 * @param {string} title
29 * @param {string} subtitle 30 * @param {string} subtitle
30 */ 31 */
31 WebInspector.Placard = function(title, subtitle) 32 WebInspector.Placard = function(title, subtitle)
32 { 33 {
33 this.element = document.createElement("div"); 34 this.element = document.createElementWithClass("div", "placard");
34 this.element.className = "placard";
35 this.element.placard = this; 35 this.element.placard = this;
36 36
37 this.titleElement = document.createElement("div"); 37 this.subtitleElement = this.element.createChild("div", "subtitle");
38 this.titleElement.className = "title"; 38 this.titleElement = this.element.createChild("div", "title");
39
40 this.subtitleElement = document.createElement("div");
41 this.subtitleElement.className = "subtitle";
42
43 this.element.appendChild(this.subtitleElement);
44 this.element.appendChild(this.titleElement);
45 39
46 this.title = title; 40 this.title = title;
47 this.subtitle = subtitle; 41 this.subtitle = subtitle;
48 this.selected = false; 42 this.selected = false;
49 } 43 }
50 44
51 WebInspector.Placard.prototype = { 45 WebInspector.Placard.prototype = {
52 /** @return {string} */ 46 /** @return {string} */
53 get title() 47 get title()
54 { 48 {
(...skipping 29 matching lines...) Expand all
84 }, 78 },
85 79
86 set selected(x) 80 set selected(x)
87 { 81 {
88 if (x) 82 if (x)
89 this.select(); 83 this.select();
90 else 84 else
91 this.deselect(); 85 this.deselect();
92 }, 86 },
93 87
88 /**
89 * @return {!WebInspector.PlacardGroup|undefined}
90 */
91 group: function()
92 {
93 return this._group;
94 },
95
96 /**
97 * @param {!WebInspector.PlacardGroup} group
98 */
99 setGroup: function(group)
100 {
101 this._group = group;
102 },
103
94 select: function() 104 select: function()
95 { 105 {
96 if (this._selected) 106 if (this._selected)
97 return; 107 return;
108 if (this._group)
109 this._group.setExpanded(true);
98 this._selected = true; 110 this._selected = true;
99 this.element.addStyleClass("selected"); 111 this.element.addStyleClass("selected");
100 }, 112 },
101 113
102 deselect: function() 114 deselect: function()
103 { 115 {
104 if (!this._selected) 116 if (!this._selected)
105 return; 117 return;
106 this._selected = false; 118 this._selected = false;
107 this.element.removeStyleClass("selected"); 119 this.element.removeStyleClass("selected");
108 }, 120 },
109 121
110 toggleSelected: function() 122 toggleSelected: function()
111 { 123 {
112 this.selected = !this.selected; 124 this.selected = !this.selected;
113 }, 125 },
114 126
115 discard: function() 127 discard: function()
116 { 128 {
117 } 129 }
118 } 130 }
131
132 /**
133 * @constructor
134 * @param {string} title
135 * @param {!Array.<!WebInspector.Placard>} placards
136 */
137 WebInspector.PlacardGroup = function(title, placards)
138 {
139 this.element = document.createElementWithClass("div", "placard placard-group ");
140 this.element.addEventListener("click", this._toggleExpanded.bind(this), fals e);
141 this.placards = placards;
142 this._expanded = false;
143 this.setTitle(title);
144
145 for (var i = 0; i < placards.length; ++i)
146 placards[i].setGroup(this);
147 }
148
149 WebInspector.PlacardGroup.prototype = {
150 /**
151 * @return {string}
152 */
153 title: function()
154 {
155 return this._title;
156 },
157
158 /**
159 * @param {string} title
160 */
161 setTitle: function(title)
162 {
163 this._title = title;
164 this.element.textContent = title;
165 },
166
167 /**
168 * @return {boolean}
169 */
170 expanded: function()
171 {
172 return this._expanded;
173 },
174
175 /**
176 * @param {boolean} x
177 */
178 setExpanded: function(x)
179 {
180 if (this._expanded === x)
181 return;
182 if (x) {
183 var parent = this.element.parentElement;
184 if (!parent)
185 return;
186 var sibling = this.element.nextSibling;
187 for (var i = 0; i < this.placards.length; ++i) {
188 var placard = this.placards[i];
189 placard.element.addStyleClass("grouped");
190 parent.insertBefore(placard.element, sibling);
191 }
192 } else {
193 if (this.selected())
194 return;
195 for (var i = 0; i < this.placards.length; ++i) {
196 var placard = this.placards[i];
197 placard.element.removeStyleClass("grouped");
198 placard.element.remove();
199 }
200 }
201 this._expanded = x;
202 },
203
204 /**
205 * @return {boolean}
206 */
207 selected: function()
208 {
209 for (var i = 0; i < this.placards.length; ++i) {
210 if (this.placards[i].selected)
211 return true;
212 }
213 return false;
214 },
215
216 _toggleExpanded: function()
217 {
218 this.setExpanded(!this._expanded);
219 this.element.enableStyleClass("expanded", this._expanded);
220 }
221 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/DebuggerModel.js ('k') | Source/devtools/front_end/Script.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698