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

Unified Diff: Source/devtools/front_end/elements/ElementsTreeElement.js

Issue 1300743002: DevTools: render DOM markers with their colors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: for landing Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/elements/ElementsPanel.js ('k') | Source/devtools/front_end/ui/tooltip.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/elements/ElementsTreeElement.js
diff --git a/Source/devtools/front_end/elements/ElementsTreeElement.js b/Source/devtools/front_end/elements/ElementsTreeElement.js
index edfc44cb1ef4a7a12a21083d283a1be1a2028c6f..c3e98a2659a5b5ccdd9d0d885ddcc7e58c1bfdd4 100644
--- a/Source/devtools/front_end/elements/ElementsTreeElement.js
+++ b/Source/devtools/front_end/elements/ElementsTreeElement.js
@@ -1127,12 +1127,51 @@ WebInspector.ElementsTreeElement.prototype = {
*/
function setTitle()
{
- this._decorationsElement.classList.toggle("elements-gutter-decoration", decorations.length || (descendantDecorations.length && !this.expanded));
- this._decorationsElement.classList.toggle("elements-has-decorated-children", descendantDecorations.length && !this.expanded);
- var title = decorations.join("\n");
- if (descendantDecorations.length)
- title += WebInspector.UIString("\nChildren:\n") + descendantDecorations.join("\n");
- this._decorationsElement.title = title;
+ this._decorationsElement.removeChildren();
+ if (!decorations.length && !descendantDecorations.length)
+ return;
+
+ var colors = new Set();
+ var titles = [];
+
+ for (var decoration of decorations) {
+ titles.push(decoration.title);
+ colors.add(decoration.color);
+ }
+ if (this.expanded && !decorations.length)
+ return;
+
+ var descendantColors = new Set();
+ if (descendantDecorations.length) {
+ titles.push(WebInspector.UIString("Children:"));
+ for (var decoration of descendantDecorations) {
+ titles.push(decoration.title);
+ descendantColors.add(decoration.color);
+ }
+ }
+
+ var offset = 0;
+ processColors.call(this, colors, "elements-gutter-decoration");
+ if (!this.expanded)
+ processColors.call(this, descendantColors, "elements-gutter-decoration elements-has-decorated-children");
+ WebInspector.Tooltip.install(this._decorationsElement, titles.join("\n"));
+
+ /**
+ * @param {!Set<string>} colors
+ * @param {string} className
+ * @this {WebInspector.ElementsTreeElement}
+ */
+ function processColors(colors, className)
+ {
+ for (var color of colors) {
+ var child = this._decorationsElement.createChild("div", className);
+ child.style.backgroundColor = color;
+ child.style.borderColor = color;
+ if (offset)
+ child.style.marginLeft = offset + "px";
+ offset += 3;
+ }
+ }
}
},
« no previous file with comments | « Source/devtools/front_end/elements/ElementsPanel.js ('k') | Source/devtools/front_end/ui/tooltip.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698