Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / cc / layer_tree_host_impl_view.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="/cc/layer_tree_host_impl_view.css">
9
10 <link rel="import" href="/cc/layer_tree_host_impl.html">
11 <link rel="import" href="/cc/layer_picker.html">
12 <link rel="import" href="/cc/layer_view.html">
13 <link rel="import" href="/cc/tile.html">
14 <link rel="import" href="/tracing/analysis/object_snapshot_view.html">
15 <link rel="import" href="/tvcm/ui/drag_handle.html">
16
17 <script>
18 'use strict';
19
20 tvcm.exportTo('cc', function() {
21   /*
22    * Displays a LayerTreeHostImpl snapshot in a human readable form.
23    * @constructor
24    */
25   var LayerTreeHostImplSnapshotView = tvcm.ui.define(
26       'layer-tree-host-impl-snapshot-view',
27       tracing.analysis.ObjectSnapshotView);
28
29   LayerTreeHostImplSnapshotView.prototype = {
30     __proto__: tracing.analysis.ObjectSnapshotView.prototype,
31
32     decorate: function() {
33       this.classList.add('lthi-s-view');
34
35       this.selection_ = undefined;
36
37       this.layerPicker_ = new cc.LayerPicker();
38       this.layerPicker_.addEventListener(
39           'selection-changed',
40           this.onLayerPickerSelectionChanged_.bind(this));
41
42       this.layerView_ = new cc.LayerView();
43       this.layerView_.addEventListener(
44           'selection-changed',
45           this.onLayerViewSelectionChanged_.bind(this));
46       this.dragHandle_ = new tvcm.ui.DragHandle();
47       this.dragHandle_.horizontal = false;
48       this.dragHandle_.target = this.layerView_;
49
50       this.appendChild(this.layerPicker_);
51       this.appendChild(this.dragHandle_);
52       this.appendChild(this.layerView_);
53
54       // Make sure we have the current values from layerView_ and layerPicker_,
55       // since those might have been created before we added the listener.
56       this.onLayerViewSelectionChanged_();
57       this.onLayerPickerSelectionChanged_();
58
59     },
60
61     get objectSnapshot() {
62       return this.objectSnapshot_;
63     },
64
65     set objectSnapshot(objectSnapshot) {
66       this.objectSnapshot_ = objectSnapshot;
67
68       var lthi = this.objectSnapshot;
69       var layerTreeImpl;
70       if (lthi)
71         layerTreeImpl = lthi.getTree(this.layerPicker_.whichTree);
72
73       this.layerPicker_.lthiSnapshot = lthi;
74       this.layerView_.layerTreeImpl = layerTreeImpl;
75       this.layerView_.regenerateContent();
76
77       if (!this.selection_)
78         return;
79       this.selection = this.selection_.findEquivalent(lthi);
80     },
81
82     get selection() {
83       return this.selection_;
84     },
85
86     set selection(selection) {
87       this.selection_ = selection;
88       this.layerPicker_.selection = selection;
89       this.layerView_.selection = selection;
90     },
91
92     onLayerPickerSelectionChanged_: function() {
93       this.selection_ = this.layerPicker_.selection;
94       this.layerView_.selection = this.selection;
95       this.layerView_.layerTreeImpl = this.layerPicker_.layerTreeImpl;
96       this.layerView_.isRenderPassQuads = this.layerPicker_.isRenderPassQuads;
97       this.layerView_.regenerateContent();
98     },
99
100     onLayerViewSelectionChanged_: function() {
101       this.selection_ = this.layerView_.selection;
102       this.layerPicker_.selection = this.selection;
103     }
104
105   };
106
107   tracing.analysis.ObjectSnapshotView.register(
108       'cc::LayerTreeHostImpl', LayerTreeHostImplSnapshotView);
109
110   return {
111     LayerTreeHostImplSnapshotView: LayerTreeHostImplSnapshotView
112   };
113 });
114 </script>