1// Copyright (c) 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5'use strict';
6
7base.requireStylesheet('tracing.tracks.heading_track');
8
9base.require('tracing.constants');
10base.require('tracing.tracks.track');
11base.require('ui');
12
13base.exportTo('tracing.tracks', function() {
14  /**
15   * A track with a header. Provides the basic heading and tooltip
16   * infrastructure. Subclasses must implement drawing code.
17   * @constructor
18   * @extends {HTMLDivElement}
19   */
20  var HeadingTrack = ui.define('heading-track', tracing.tracks.Track);
21
22  HeadingTrack.prototype = {
23    __proto__: tracing.tracks.Track.prototype,
24
25    decorate: function(viewport) {
26      tracing.tracks.Track.prototype.decorate.call(this, viewport);
27      this.classList.add('heading-track');
28
29      this.headingDiv_ = document.createElement('heading');
30      this.headingDiv_.style.width = tracing.constants.HEADING_WIDTH + 'px';
31      this.appendChild(this.headingDiv_);
32    },
33
34    get heading() {
35      return this.headingDiv_.textContent;
36    },
37
38    set heading(text) {
39      this.headingDiv_.textContent = text;
40    },
41
42    set tooltip(text) {
43      this.headingDiv_.title = text;
44    },
45
46    draw: function(type, viewLWorld, viewRWorld) {
47      throw new Error('draw implementation missing');
48    }
49  };
50
51  return {
52    HeadingTrack: HeadingTrack
53  };
54});
55