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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/DebuggerModel.js ('k') | Source/devtools/front_end/Script.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/Placard.js
diff --git a/Source/devtools/front_end/Placard.js b/Source/devtools/front_end/Placard.js
index 4e91a66907c1a5580f935cd4ad73113884493557..69635e81b50feb6270a3fecf8f21a1b35225e106 100644
--- a/Source/devtools/front_end/Placard.js
+++ b/Source/devtools/front_end/Placard.js
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,18 +31,11 @@
*/
WebInspector.Placard = function(title, subtitle)
{
- this.element = document.createElement("div");
- this.element.className = "placard";
+ this.element = document.createElementWithClass("div", "placard");
this.element.placard = this;
- this.titleElement = document.createElement("div");
- this.titleElement.className = "title";
-
- this.subtitleElement = document.createElement("div");
- this.subtitleElement.className = "subtitle";
-
- this.element.appendChild(this.subtitleElement);
- this.element.appendChild(this.titleElement);
+ this.subtitleElement = this.element.createChild("div", "subtitle");
+ this.titleElement = this.element.createChild("div", "title");
this.title = title;
this.subtitle = subtitle;
@@ -91,10 +85,28 @@ WebInspector.Placard.prototype = {
this.deselect();
},
+ /**
+ * @return {!WebInspector.PlacardGroup|undefined}
+ */
+ group: function()
+ {
+ return this._group;
+ },
+
+ /**
+ * @param {!WebInspector.PlacardGroup} group
+ */
+ setGroup: function(group)
+ {
+ this._group = group;
+ },
+
select: function()
{
if (this._selected)
return;
+ if (this._group)
+ this._group.setExpanded(true);
this._selected = true;
this.element.addStyleClass("selected");
},
@@ -116,3 +128,94 @@ WebInspector.Placard.prototype = {
{
}
}
+
+/**
+ * @constructor
+ * @param {string} title
+ * @param {!Array.<!WebInspector.Placard>} placards
+ */
+WebInspector.PlacardGroup = function(title, placards)
+{
+ this.element = document.createElementWithClass("div", "placard placard-group");
+ this.element.addEventListener("click", this._toggleExpanded.bind(this), false);
+ this.placards = placards;
+ this._expanded = false;
+ this.setTitle(title);
+
+ for (var i = 0; i < placards.length; ++i)
+ placards[i].setGroup(this);
+}
+
+WebInspector.PlacardGroup.prototype = {
+ /**
+ * @return {string}
+ */
+ title: function()
+ {
+ return this._title;
+ },
+
+ /**
+ * @param {string} title
+ */
+ setTitle: function(title)
+ {
+ this._title = title;
+ this.element.textContent = title;
+ },
+
+ /**
+ * @return {boolean}
+ */
+ expanded: function()
+ {
+ return this._expanded;
+ },
+
+ /**
+ * @param {boolean} x
+ */
+ setExpanded: function(x)
+ {
+ if (this._expanded === x)
+ return;
+ if (x) {
+ var parent = this.element.parentElement;
+ if (!parent)
+ return;
+ var sibling = this.element.nextSibling;
+ for (var i = 0; i < this.placards.length; ++i) {
+ var placard = this.placards[i];
+ placard.element.addStyleClass("grouped");
+ parent.insertBefore(placard.element, sibling);
+ }
+ } else {
+ if (this.selected())
+ return;
+ for (var i = 0; i < this.placards.length; ++i) {
+ var placard = this.placards[i];
+ placard.element.removeStyleClass("grouped");
+ placard.element.remove();
+ }
+ }
+ this._expanded = x;
+ },
+
+ /**
+ * @return {boolean}
+ */
+ selected: function()
+ {
+ for (var i = 0; i < this.placards.length; ++i) {
+ if (this.placards[i].selected)
+ return true;
+ }
+ return false;
+ },
+
+ _toggleExpanded: function()
+ {
+ this.setExpanded(!this._expanded);
+ this.element.enableStyleClass("expanded", this._expanded);
+ }
+}
« 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