Index: chrome/browser/resources/tracing/timeline_track.js |
diff --git a/chrome/browser/resources/tracing/timeline_track.js b/chrome/browser/resources/tracing/timeline_track.js |
index 0d00b1e822c3630c3bd8a521c46e2fad0c9fe086..3f571858ea37957239d51b25ad51f7ba6d5c175e 100644 |
--- a/chrome/browser/resources/tracing/timeline_track.js |
+++ b/chrome/browser/resources/tracing/timeline_track.js |
@@ -111,6 +111,17 @@ cr.define('tracing', function() { |
} |
}; |
+ function addCloseButtonElement(el) { |
+ var closeEl = document.createElement('div'); |
+ closeEl.classList.add('timeline-track-button'); |
+ closeEl.classList.add('timeline-track-close-button'); |
+ closeEl.textContent = String.fromCharCode(215); // × |
+ closeEl.addEventListener('click', function() { |
+ el.style.display = 'None'; |
+ }); |
+ el.appendChild(closeEl); |
+ } |
+ |
/** |
* Visualizes a TimelineThread using a series of of TimelineSliceTracks. |
* @constructor |
@@ -181,12 +192,18 @@ cr.define('tracing', function() { |
track.height = '4px'; |
} |
- for (var srI = 0; srI < this.thread_.nonNestedSubRows.length; ++srI) { |
- this.addTrack_(this.thread_.nonNestedSubRows[srI]); |
+ if (this.thread_.asyncSlices.length) { |
+ var subRows = this.thread_.asyncSlices.subRows; |
+ for (var srI = 0; srI < subRows.length; srI++) { |
+ var track = this.addTrack_(subRows[srI]); |
+ track.asyncStyle = true; |
+ } |
} |
- for (var srI = 0; srI < this.thread_.subRows.length; ++srI) { |
+ |
+ for (var srI = 0; srI < this.thread_.subRows.length; srI++) { |
this.addTrack_(this.thread_.subRows[srI]); |
} |
+ |
if (this.tracks_.length > 0) { |
if (this.thread_.cpuSlices) { |
this.tracks_[1].heading = this.heading_; |
@@ -197,6 +214,7 @@ cr.define('tracing', function() { |
} |
} |
} |
+ addCloseButtonElement(this); |
} |
}; |
@@ -264,6 +282,7 @@ cr.define('tracing', function() { |
this.tracks_[0].heading = this.heading_; |
this.tracks_[0].tooltip = this.tooltip_; |
} |
+ addCloseButtonElement(this); |
} |
}; |
@@ -366,58 +385,63 @@ cr.define('tracing', function() { |
}; |
- /** |
- * A pair representing an elided string and world-coordinate width |
- * to draw it. |
- * @constructor |
+ /** |
+ * A pair representing an elided string and world-coordinate width |
+ * to draw it. |
+ * @constructor |
*/ |
- function ElidedStringWidthPair(string, width) { |
- this.string = string; |
- this.width = width; |
- } |
+ function ElidedStringWidthPair(string, width) { |
+ this.string = string; |
+ this.width = width; |
+ } |
+ /** |
+ * A cache for elided strings. |
+ * @constructor |
+ */ |
+ function ElidedTitleCache() { |
+ } |
+ |
+ ElidedTitleCache.prototype = { |
/** |
- * A cache for elided strings. |
- * @constructor |
- */ |
- function ElidedTitleCache() { |
- } |
- |
- ElidedTitleCache.prototype = { |
- /** |
- * Return elided text. |
- * @param {track} A timeline slice track or other object that defines |
- * functions labelWidth() and labelWidthWorld(). |
- * @param {pixWidth} Pixel width. |
- * @param {title} Original title text. |
- * @param {width} Drawn width in world coords. |
- * @param {sliceDuration} Where the title must fit (in world coords). |
- * @return {ElidedStringWidthPair} Elided string and width. |
- */ |
- get: function(track, pixWidth, title, width, sliceDuration) { |
- var elidedDict = elidedTitleCacheDict[title]; |
- if (!elidedDict) { |
- elidedDict = {}; |
- elidedTitleCacheDict[title] = elidedDict; |
- } |
- var stringWidthPair = elidedDict[sliceDuration]; |
- if (stringWidthPair === undefined) { |
- var newtitle = title; |
- var elided = false; |
- while (track.labelWidthWorld(newtitle, pixWidth) > sliceDuration) { |
- newtitle = newtitle.substring(0, newtitle.length * 0.75); |
- elided = true; |
- } |
- if (elided && newtitle.length > 3) |
- newtitle = newtitle.substring(0, newtitle.length - 3) + '...'; |
- stringWidthPair = new ElidedStringWidthPair( |
- newtitle, |
- track.labelWidth(newtitle)); |
- elidedDict[sliceDuration] = stringWidthPair; |
- } |
- return stringWidthPair; |
- }, |
- }; |
+ * Return elided text. |
+ * @param {track} A timeline slice track or other object that defines |
+ * functions labelWidth() and labelWidthWorld(). |
+ * @param {pixWidth} Pixel width. |
+ * @param {title} Original title text. |
+ * @param {width} Drawn width in world coords. |
+ * @param {sliceDuration} Where the title must fit (in world coords). |
+ * @return {ElidedStringWidthPair} Elided string and width. |
+ */ |
+ get: function(track, pixWidth, title, width, sliceDuration) { |
+ var elidedDict = elidedTitleCacheDict[title]; |
+ if (!elidedDict) { |
+ elidedDict = {}; |
+ elidedTitleCacheDict[title] = elidedDict; |
+ } |
+ var elidedDictForPixWidth = elidedDict[pixWidth]; |
+ if (!elidedDictForPixWidth) { |
+ elidedDict[pixWidth] = {}; |
+ elidedDictForPixWidth = elidedDict[pixWidth]; |
+ } |
+ var stringWidthPair = elidedDictForPixWidth[sliceDuration]; |
+ if (stringWidthPair === undefined) { |
+ var newtitle = title; |
+ var elided = false; |
+ while (track.labelWidthWorld(newtitle, pixWidth) > sliceDuration) { |
+ newtitle = newtitle.substring(0, newtitle.length * 0.75); |
+ elided = true; |
+ } |
+ if (elided && newtitle.length > 3) |
+ newtitle = newtitle.substring(0, newtitle.length - 3) + '...'; |
+ stringWidthPair = new ElidedStringWidthPair( |
+ newtitle, |
+ track.labelWidth(newtitle)); |
+ elidedDictForPixWidth[sliceDuration] = stringWidthPair; |
+ } |
+ return stringWidthPair; |
+ } |
+ }; |
/** |
* A track that displays an array of TimelineSlice objects. |
@@ -431,18 +455,28 @@ cr.define('tracing', function() { |
__proto__: CanvasBasedTrack.prototype, |
- /** |
- * Should we elide text on trace labels? |
- * Without eliding, text that is too wide isn't drawn at all. |
- * Disable if you feel this causes a performance problem. |
- * This is a default value that can be overridden in tracks for testing. |
- * @const |
- */ |
+ /** |
+ * Should we elide text on trace labels? |
+ * Without eliding, text that is too wide isn't drawn at all. |
+ * Disable if you feel this causes a performance problem. |
+ * This is a default value that can be overridden in tracks for testing. |
+ * @const |
+ */ |
SHOULD_ELIDE_TEXT: true, |
decorate: function() { |
this.classList.add('timeline-slice-track'); |
this.elidedTitleCache = new ElidedTitleCache(); |
+ this.asyncStyle_ = false; |
+ }, |
+ |
+ get asyncStyle() { |
+ return this.asyncStyle_; |
+ }, |
+ |
+ set asyncStyle(v) { |
+ this.asyncStyle_ = !!v; |
+ this.invalidate(); |
}, |
get slices() { |
@@ -503,6 +537,8 @@ cr.define('tracing', function() { |
vp.applyTransformToCanavs(ctx); |
// Slices. |
+ if (this.asyncStyle_) |
+ ctx.globalAlpha = 0.25; |
var tr = new tracing.FastRectRenderer(ctx, viewLWorld, 2 * pixWidth, |
2 * pixWidth, viewRWorld, pallette); |
tr.setYandH(0, canvasH); |
@@ -560,12 +596,12 @@ cr.define('tracing', function() { |
var drawnWidth = this.labelWidth(drawnTitle); |
if (shouldElide && |
this.labelWidthWorld(drawnTitle, pixWidth) > slice.duration) { |
- var elidedValues = this.elidedTitleCache.get( |
- this, pixWidth, |
- drawnTitle, drawnWidth, |
- slice.duration); |
- drawnTitle = elidedValues.string; |
- drawnWidth = elidedValues.width; |
+ var elidedValues = this.elidedTitleCache.get( |
+ this, pixWidth, |
+ drawnTitle, drawnWidth, |
+ slice.duration); |
+ drawnTitle = elidedValues.string; |
+ drawnWidth = elidedValues.width; |
} |
if (drawnWidth * pixWidth < slice.duration) { |
var cX = vp.xWorldToView(slice.start + 0.5 * slice.duration); |
@@ -691,7 +727,7 @@ cr.define('tracing', function() { |
const logOf10 = Math.log(10); |
function log10(x) { |
- return Math.log(x) / logOf10;; |
+ return Math.log(x) / logOf10; |
} |
TimelineViewportTrack.prototype = { |
@@ -729,10 +765,10 @@ cr.define('tracing', function() { |
// exceeds the ideal mark distance. |
var divisors = [10, 5, 2, 1]; |
for (var i = 0; i < divisors.length; ++i) { |
- var tightenedGuess = conservativeGuess / divisors[i] |
+ var tightenedGuess = conservativeGuess / divisors[i]; |
if (vp.xWorldVectorToView(tightenedGuess) < idealMajorMarkDistancePix) |
continue; |
- majorMarkDistanceWorld = conservativeGuess / divisors[i-1]; |
+ majorMarkDistanceWorld = conservativeGuess / divisors[i - 1]; |
break; |
} |
if (majorMarkDistanceWorld < 100) { |
@@ -748,8 +784,8 @@ cr.define('tracing', function() { |
var minorMarkDistancePx = vp.xWorldVectorToView(minorMarkDistanceWorld); |
var firstMajorMark = |
- Math.floor(viewLWorld / majorMarkDistanceWorld) * |
- majorMarkDistanceWorld; |
+ Math.floor(viewLWorld / majorMarkDistanceWorld) * |
+ majorMarkDistanceWorld; |
var minorTickH = Math.floor(canvasH * 0.25); |
@@ -841,6 +877,7 @@ cr.define('tracing', function() { |
decorate: function() { |
this.classList.add('timeline-counter-track'); |
+ addCloseButtonElement(this); |
}, |
get counter() { |