3ecb86b1de8a38f1cab4ac65e49a4a1d6f751cf3
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / tracks / heading_track.html
1 <!DOCTYPE html>
2 <!--
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.
6 -->
7
8 <link rel="stylesheet" href="/tracing/tracks/heading_track.css">
9
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="/tvcm/ui.html">
14
15 <script>
16 'use strict';
17
18 tvcm.exportTo('tracing.tracks', function() {
19   /**
20    * A track with a header. Provides the basic heading and tooltip
21    * infrastructure. Subclasses must implement drawing code.
22    * @constructor
23    * @extends {HTMLDivElement}
24    */
25   var HeadingTrack = tvcm.ui.define('heading-track', tracing.tracks.Track);
26
27   HeadingTrack.prototype = {
28     __proto__: tracing.tracks.Track.prototype,
29
30     decorate: function(viewport) {
31       tracing.tracks.Track.prototype.decorate.call(this, viewport);
32       this.classList.add('heading-track');
33
34       this.headingDiv_ = document.createElement('heading');
35       this.headingDiv_.style.width = tracing.constants.HEADING_WIDTH + 'px';
36       this.heading_ = '';
37       this.selectionGenerator_ = undefined;
38       this.updateContents_();
39     },
40
41     get heading() {
42       return this.heading_;
43     },
44
45     set heading(text) {
46       this.heading_ = text;
47       this.updateContents_();
48     },
49
50     set tooltip(text) {
51       this.headingDiv_.title = text;
52     },
53
54     set selectionGenerator(generator) {
55       this.selectionGenerator_ = generator;
56       this.updateContents_();
57     },
58
59     updateContents_: function() {
60       /**
61        * If this is a heading track of a sampling thread, we add a link to
62        * the heading text ("Sampling Thread"). We associate a selection
63        * generator with the link so that sampling profiling results are
64        * displayed in the bottom frame when you click the link.
65        */
66       this.headingDiv_.innerHTML = '';
67       if (this.selectionGenerator_) {
68         this.headingLink_ = document.createElement('a');
69         tracing.analysis.AnalysisLink.decorate(this.headingLink_);
70         this.headingLink_.selectionGenerator = this.selectionGenerator_;
71         this.headingDiv_.appendChild(this.headingLink_);
72         this.headingLink_.appendChild(document.createTextNode(this.heading_));
73       } else {
74         this.headingDiv_.appendChild(document.createTextNode(this.heading_));
75       }
76       this.appendChild(this.headingDiv_);
77     },
78
79     draw: function(type, viewLWorld, viewRWorld) {
80       throw new Error('draw implementation missing');
81     }
82   };
83
84   return {
85     HeadingTrack: HeadingTrack
86   };
87 });
88 </script>