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

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: rebased 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
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 /** @return {!WebInspector.PlacardGroup|undefined} */
89 get group()
yurys 2013/12/06 12:36:54 style nit: we've decided to avoid getters/setters
aandrey 2013/12/06 16:09:24 Done.
90 {
91 return this._group;
92 },
93
94 set group(x)
95 {
96 this._group = x;
97 },
98
94 select: function() 99 select: function()
95 { 100 {
96 if (this._selected) 101 if (this._selected)
97 return; 102 return;
103 if (this._group)
104 this._group.expanded = true;
98 this._selected = true; 105 this._selected = true;
99 this.element.addStyleClass("selected"); 106 this.element.addStyleClass("selected");
100 }, 107 },
101 108
102 deselect: function() 109 deselect: function()
103 { 110 {
104 if (!this._selected) 111 if (!this._selected)
105 return; 112 return;
106 this._selected = false; 113 this._selected = false;
107 this.element.removeStyleClass("selected"); 114 this.element.removeStyleClass("selected");
108 }, 115 },
109 116
110 toggleSelected: function() 117 toggleSelected: function()
111 { 118 {
112 this.selected = !this.selected; 119 this.selected = !this.selected;
113 }, 120 },
114 121
115 discard: function() 122 discard: function()
116 { 123 {
117 } 124 }
118 } 125 }
126
127 /**
128 * @constructor
129 * @param {string} title
130 * @param {!Array.<!WebInspector.Placard>} placards
131 */
132 WebInspector.PlacardGroup = function(title, placards)
133 {
134 this.element = document.createElementWithClass("div", "placard placard-group ");
135 this.element.addEventListener("click", this._clicked.bind(this), false);
136 this.placards = placards;
137 this._expanded = false;
138 this.title = title;
139
140 for (var i = 0; i < placards.length; ++i)
141 placards[i].group = this;
142 }
143
144 WebInspector.PlacardGroup.prototype = {
145 /** @return {string} */
146 get title()
yurys 2013/12/06 12:36:54 ditto.
aandrey 2013/12/06 16:09:24 Done.
147 {
148 return this._title;
149 },
150
151 set title(x)
152 {
153 this._title = x;
154 this.element.textContent = x;
155 },
156
157 /** @return {boolean} */
158 get expanded()
159 {
160 return this._expanded;
161 },
162
163 set expanded(x)
164 {
165 if (this._expanded === x)
166 return;
167 if (x) {
168 var parent = this.element.parentElement;
169 if (!parent)
170 return;
171 var sibling = this.element.nextSibling;
172 for (var i = 0, placard; placard = this.placards[i]; ++i) {
yurys 2013/12/06 12:36:54 style: i < this.placards.length, we don't use this
aandrey 2013/12/06 16:09:24 Done.
173 placard.element.addStyleClass("grouped");
174 parent.insertBefore(placard.element, sibling);
175 }
176 } else {
177 if (this.selected)
178 return;
179 for (var i = 0, placard; placard = this.placards[i]; ++i) {
yurys 2013/12/06 12:36:54 ditto.
aandrey 2013/12/06 16:09:24 Done.
180 placard.element.removeStyleClass("grouped");
181 placard.element.remove();
182 }
183 }
184 this._expanded = x;
185 },
186
187 /** @return {boolean} */
188 get selected()
189 {
190 for (var i = 0, placard; placard = this.placards[i]; ++i) {
yurys 2013/12/06 12:36:54 ditto
aandrey 2013/12/06 16:09:24 Done.
191 if (placard.selected)
192 return true;
193 }
194 return false;
195 },
196
197 _clicked: function()
198 {
199 this.expanded = !this._expanded;
200 this.element.enableStyleClass("expanded", this._expanded);
201 }
202 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698