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

Unified Diff: third_party/WebKit/Source/devtools/front_end/components/DOMPresentationUtils.js

Issue 1418453009: Devtools UI: Colorize node links and make pseudo links clearer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | third_party/WebKit/Source/devtools/front_end/components/domUtils.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/components/DOMPresentationUtils.js
diff --git a/third_party/WebKit/Source/devtools/front_end/components/DOMPresentationUtils.js b/third_party/WebKit/Source/devtools/front_end/components/DOMPresentationUtils.js
index 2c17cfa8d5b5c7a0d4b55089b15d21948d6b5d2f..0bd8e37785b39403c8a703acfcf9a89fb64582e1 100644
--- a/third_party/WebKit/Source/devtools/front_end/components/DOMPresentationUtils.js
+++ b/third_party/WebKit/Source/devtools/front_end/components/DOMPresentationUtils.js
@@ -31,25 +31,31 @@
WebInspector.DOMPresentationUtils = {}
+/**
+ * @param {!WebInspector.DOMNode} node
+ * @param {!Element} parentElement
+ */
WebInspector.DOMPresentationUtils.decorateNodeLabel = function(node, parentElement)
{
+ var originalNode = node;
+ var isPseudo = node.nodeType() === Node.ELEMENT_NODE && node.pseudoType();
+ if (isPseudo && node.parentNode)
+ node = node.parentNode;
+
var title = node.nodeNameInCorrectCase();
- var nameElement = createElement("span");
+ var nameElement = parentElement.createChild("span", "node-label-name");
nameElement.textContent = title;
- parentElement.appendChild(nameElement);
var idAttribute = node.getAttribute("id");
if (idAttribute) {
- var idElement = createElement("span");
- parentElement.appendChild(idElement);
-
+ var idElement = parentElement.createChild("span", "node-label-id");
var part = "#" + idAttribute;
title += part;
idElement.createTextChild(part);
// Mark the name as extra, since the ID is more important.
- nameElement.className = "extra";
+ nameElement.classList.add("extra");
}
var classAttribute = node.getAttribute("class");
@@ -58,10 +64,7 @@ WebInspector.DOMPresentationUtils.decorateNodeLabel = function(node, parentEleme
var foundClasses = {};
if (classes.length) {
- var classesElement = createElement("span");
- classesElement.className = "extra";
- parentElement.appendChild(classesElement);
-
+ var classesElement = parentElement.createChild("span", "extra node-label-class");
for (var i = 0; i < classes.length; ++i) {
var className = classes[i];
if (className && !(className in foundClasses)) {
@@ -73,6 +76,13 @@ WebInspector.DOMPresentationUtils.decorateNodeLabel = function(node, parentEleme
}
}
}
+
+ if (isPseudo) {
+ var pseudoElement = parentElement.createChild("span", "extra node-label-pseudo");
+ var pseudoText = "::" + originalNode.pseudoType();
+ pseudoElement.createTextChild(pseudoText);
+ title += pseudoText;
+ }
parentElement.title = title;
}
@@ -99,7 +109,7 @@ WebInspector.DOMPresentationUtils.linkifyNodeReference = function(node)
if (!node)
return createTextNode(WebInspector.UIString("<node>"));
- var root = createElement("span");
+ var root = createElementWithClass("span", "monospace");
var shadowRoot = WebInspector.createShadowRootWithCoreStyles(root);
shadowRoot.appendChild(WebInspector.Widget.createStyleElement("components/domUtils.css"));
var link = shadowRoot.createChild("div", "node-link");
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/components/domUtils.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698