blob: 4497acc80b96107c90dcb0f468f12cf0d81b6a5a [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2013 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/core/analysis/analysis_link.html">
<link rel="import" href="/core/analysis/analysis_sub_view.html">
<link rel="import" href="/core/analysis/generic_object_view.html">
<link rel="import" href="/core/analysis/object_instance_view.html">
<link rel="import" href="/core/analysis/object_snapshot_view.html">
<link rel="import" href="/core/analysis/single_event_sub_view.html">
<link rel="import" href="/base/units/util.html">
<polymer-element name="tr-c-a-single-object-snapshot-sub-view"
extends="tr-c-a-sub-view">
<template>
<style>
#args {
white-space: pre;
}
:host {
overflow: auto;
display: flex;
}
* {
-webkit-user-select: text;
}
.title {
border-bottom: 1px solid rgb(128, 128, 128);
font-size: 110%;
font-weight: bold;
}
td, th {
font-family: monospace;
vertical-align: top;
}
</style>
<content></content>
</template>
<script>
'use strict';
Polymer({
created: function() {
this.currentSelection_ = undefined;
},
get requiresTallView() {
if (this.children.length === 0)
return false;
if (this.children[0] instanceof tr.c.analysis.ObjectSnapshotView)
return this.children[0].requiresTallView;
},
get selection() {
return this.currentSelection_;
},
set selection(selection) {
if (selection.length !== 1)
throw new Error('Only supports single item selections');
if (!(selection[0] instanceof tr.model.ObjectSnapshot))
throw new Error('Only supports object instances');
this.textContent = '';
this.currentSelection_ = selection;
var snapshot = selection[0];
var typeInfo = tr.c.analysis.ObjectSnapshotView.getTypeInfo(
snapshot.objectInstance.category, snapshot.objectInstance.typeName);
if (typeInfo) {
var customView = new typeInfo.constructor();
this.appendChild(customView);
customView.modelEvent = snapshot;
} else {
this.appendGenericAnalysis_(snapshot);
}
},
appendGenericAnalysis_: function(snapshot) {
var instance = snapshot.objectInstance;
var html = '';
html += '<div class="title">Snapshot of <a id="instance-link"></a> @ ' +
tr.b.units.tsString(snapshot.ts) + '</div>\n';
html += '<table>';
html += '<tr>';
html += '<tr><td>args:</td><td id="args"></td></tr>\n';
html += '</table>';
this.innerHTML = html;
var instanceLinkEl = document.createElement('tr-c-a-analysis-link');
instanceLinkEl.selection = new tr.c.Selection(instance);
// TODO(nduca): tr.ui.decoreate doesn't work when subclassed. So,
// replace the template element.
var tmp = this.querySelector('#instance-link');
tmp.parentElement.replaceChild(instanceLinkEl, tmp);
var argsEl = this.querySelector('#args');
argsEl.textContent = '';
var objectView =
document.createElement('tr-c-a-generic-object-view');
objectView.object = snapshot.args;
argsEl.appendChild(objectView);
}
});
</script>
</polymer-element>