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

Unified Diff: third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js

Issue 2623143002: DevTools: insert console message decorations in order
Patch Set: a Created 3 years, 11 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
Index: third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
diff --git a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
index 3215d2ac1e9de6663046caa125b4dcb3baf8e728..aeb492cec5b417fb2ad1565a9b187343014b9b70 100644
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
@@ -50,6 +50,10 @@ Console.ConsoleViewMessage = class {
this._searchRegex = null;
/** @type {?UI.Icon} */
this._messageLevelIcon = null;
+ /** @type {!Element|undefined} */
+ this._timestampElement;
luoe 2017/01/28 01:01:22 Drive by
+ /** @type {!Element|undefined} */
+ this._contextIcon;
}
/**
@@ -824,11 +828,12 @@ Console.ConsoleViewMessage = class {
var format = Common.moduleSetting('consoleTimestampFormat').get();
if (format !== Console.ConsoleViewMessage.TimestampFormat.None) {
var timestampText = formatTimestamp(this._message.timestamp, format);
- if (!this._timestampElement)
+ if (!this._timestampElement) {
this._timestampElement = createElementWithClass('span', 'console-timestamp');
+ this._contentElement.insertBefore(this._timestampElement, this._contentElement.firstChild);
+ }
luoe 2017/01/28 01:01:22 Drive by change
this._timestampElement.textContent = timestampText + ' ';
this._timestampElement.title = timestampText;
- this._contentElement.insertBefore(this._timestampElement, this._contentElement.firstChild);
} else if (this._timestampElement) {
this._timestampElement.remove();
delete this._timestampElement;
@@ -861,6 +866,46 @@ Console.ConsoleViewMessage = class {
}
}
+ updateContextLabel() {
+ var target = this._target();
+ if (!this._contentElement || !target)
+ return;
+
+ var show = Common.moduleSetting('consoleContextLabelsEnabled').get();
+ if (show && !this._contextIcon) {
+ var subTargetsManager = SDK.SubTargetsManager.fromTarget(target);
+ var mainTarget = target.targetManager().mainTarget();
+ var targetInfo;
+ if (subTargetsManager)
+ targetInfo = subTargetsManager.targetInfo(target);
+ else if (mainTarget && mainTarget.subTargetsManager)
+ targetInfo = mainTarget.subTargetsManager.targetInfo(target);
+ var targetType = targetInfo ? targetInfo.type : null;
+ var messageContext = target.runtimeModel.executionContext(this._message.executionContextId);
+
+ if (messageContext && messageContext.frameId && !Console.ConsoleContextSelector.isTopContext(messageContext)) {
+ if (messageContext.isDefault)
+ this._contextIcon = UI.Icon.create('smallicon-frame', 'console-context-icon');
+ else
+ this._contextIcon = UI.Icon.create('smallicon-extension', 'console-context-icon');
+ } else if (targetType === 'service_worker' || targetType === 'worker') {
+ this._contextIcon = UI.Icon.create('smallicon-worker', 'console-context-icon');
+ }
+
+ if (this._contextIcon) {
+ var subTargetName = subTargetsManager ? subTargetsManager.target().name() : null;
+ var title = subTargetName || target.name();
+ if (messageContext)
+ title = Console.ConsoleContextSelector.titleForContext(messageContext).trim();
+ this._contextIcon.title = title;
+ this._contentElement.insertBefore(this._contextIcon, this._contentElement.firstChild);
+ }
+ } else if (this._contextIcon && !show) {
+ this._contextIcon.remove();
+ delete this._contextIcon;
+ }
+ }
+
/**
* @return {number}
*/
@@ -920,6 +965,7 @@ Console.ConsoleViewMessage = class {
formattedMessage = this._buildMessage(consoleMessage);
contentElement.appendChild(formattedMessage);
+ this.updateContextLabel();
this.updateTimestamp();
return this._contentElement;
}

Powered by Google App Engine
This is Rietveld 408576698