1<!DOCTYPE html>
2<!--
3Copyright (c) 2014 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7<link rel="import" href="/tracing/ui/base/table.html">
8
9<polymer-element name="tr-ui-a-stack-frame">
10  <template>
11    <style>
12    :host {
13      display: flex;
14      flex-direction: row;
15      align-items: center;
16    }
17    </style>
18    <tr-ui-b-table id="table"></tr-ui-b-table>
19  </template>
20  <script>
21  'use strict';
22
23  Polymer({
24    ready: function() {
25      this.stackFrame_ = undefined;
26      this.$.table.tableColumns = [];
27      this.$.table.showHeader = true;
28    },
29
30    get stackFrame() {
31      return this.stackFrame_;
32    },
33
34    set stackFrame(stackFrame) {
35      var table = this.$.table;
36
37      this.stackFrame_ = stackFrame;
38      if (stackFrame === undefined) {
39        table.tableColumns = [];
40        table.tableRows = [];
41        table.rebuild();
42        return;
43      }
44
45      var hasName = false;
46      var hasTitle = false;
47
48      table.tableRows = stackFrame.stackTrace;
49      table.tableRows.forEach(function(row) {
50        hasName |= row.name !== undefined;
51        hasTitle |= row.title !== undefined;
52      });
53
54      var cols = [];
55      if (hasName) {
56        cols.push({
57          title: 'Name',
58          value: function(row) { return row.name; }
59        });
60      }
61
62      if (hasTitle) {
63        cols.push({
64          title: 'Title',
65          value: function(row) { return row.title; }
66        });
67      }
68
69      table.tableColumns = cols;
70      table.rebuild();
71    },
72
73    tableForTesting: function() {
74      return this.$.table;
75    }
76  });
77  </script>
78</polymer-element>
79