3 Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
8 <link rel="stylesheet" href="/tracing/tracks/heading_track.css">
10 <link rel="import" href="/tracing/analysis/analysis_link.html">
11 <link rel="import" href="/tracing/constants.html">
12 <link rel="import" href="/tracing/tracks/track.html">
13 <link rel="import" href="/base/ui.html">
18 tv.exportTo('tracing.tracks', function() {
19 var DOWN_ARROW = String.fromCharCode(0x25BE);
20 var RIGHT_ARROW = String.fromCharCode(0x25B8);
23 * A track with a header. Provides the basic heading and tooltip
24 * infrastructure. Subclasses must implement drawing code.
26 * @extends {HTMLDivElement}
28 var HeadingTrack = tv.ui.define('heading-track', tracing.tracks.Track);
30 HeadingTrack.prototype = {
31 __proto__: tracing.tracks.Track.prototype,
33 decorate: function(viewport) {
34 tracing.tracks.Track.prototype.decorate.call(this, viewport);
35 this.classList.add('heading-track');
37 this.headingDiv_ = document.createElement('heading');
38 this.headingDiv_.style.width = tracing.constants.HEADING_WIDTH + 'px';
39 this.headingDiv_.addEventListener(
40 'click', this.onHeadingDivClicked_.bind(this));
42 this.expanded_ = undefined;
43 this.selectionGenerator_ = undefined;
44 this.updateContents_();
53 this.updateContents_();
57 this.headingDiv_.title = text;
60 set selectionGenerator(generator) {
61 this.selectionGenerator_ = generator;
62 this.updateContents_();
66 return this.expanded_;
69 set expanded(expanded) {
71 if (this.expanded_ == expanded)
73 this.expanded_ = expanded;
74 this.expandedStateChanged_();
77 expandedStateChanged_: function() {
78 this.updateHeadigDiv_();
81 onHeadingDivClicked_: function() {
82 var e = new Event('heading-clicked', true, false);
83 this.dispatchEvent(e);
86 updateContents_: function() {
87 this.updateHeadigDiv_();
90 updateHeadigDiv_: function() {
92 * If this is a heading track of a sampling thread, we add a link to
93 * the heading text ("Sampling Thread"). We associate a selection
94 * generator with the link so that sampling profiling results are
95 * displayed in the bottom frame when you click the link.
97 this.headingDiv_.innerHTML = '';
98 var span = document.createElement('span');
99 span.classList.add('heading-arrow');
100 if (this.expanded === true)
101 span.textContent = DOWN_ARROW;
102 else if (this.expanded === false)
103 span.textContent = RIGHT_ARROW;
105 span.textContent = '';
106 this.headingDiv_.appendChild(span);
108 if (this.selectionGenerator_) {
109 this.headingLink_ = document.createElement('a');
110 tracing.analysis.AnalysisLink.decorate(this.headingLink_);
111 this.headingLink_.selectionGenerator = this.selectionGenerator_;
112 this.headingDiv_.appendChild(this.headingLink_);
113 this.headingLink_.appendChild(document.createTextNode(this.heading_));
115 span = document.createElement('span');
116 span.textContent = this.heading_;
117 this.headingDiv_.appendChild(span);
119 this.appendChild(this.headingDiv_);
122 draw: function(type, viewLWorld, viewRWorld) {
123 throw new Error('draw implementation missing');
128 HeadingTrack: HeadingTrack