Update To 11.40.268.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="/base/ui/drag_handle.html">
16
17 <script>
18 'use strict';
19
20 tv.exportTo('cc', function() {
21   /*
22    * Displays a LayerTreeHostImpl snapshot in a human readable form.
23    * @constructor
24    */
25   var LayerTreeHostImplSnapshotView = tv.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-change',
40           this.onLayerPickerSelectionChanged_.bind(this));
41
42       this.layerView_ = new cc.LayerView();
43       this.layerView_.addEventListener(
44           'selection-change',
45           this.onLayerViewSelectionChanged_.bind(this));
46       this.dragHandle_ = new tv.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       if (this.selection_ == selection)
88         return;
89       this.selection_ = selection;
90       this.layerPicker_.selection = selection;
91       this.layerView_.selection = selection;
92       tv.dispatchSimpleEvent(this, 'cc-selection-change');
93     },
94
95     onLayerPickerSelectionChanged_: function() {
96       this.selection_ = this.layerPicker_.selection;
97       this.layerView_.selection = this.selection;
98       this.layerView_.layerTreeImpl = this.layerPicker_.layerTreeImpl;
99       this.layerView_.isRenderPassQuads = this.layerPicker_.isRenderPassQuads;
100       this.layerView_.regenerateContent();
101       tv.dispatchSimpleEvent(this, 'cc-selection-change');
102     },
103
104     onLayerViewSelectionChanged_: function() {
105       this.selection_ = this.layerView_.selection;
106       this.layerPicker_.selection = this.selection;
107       tv.dispatchSimpleEvent(this, 'cc-selection-change');
108     },
109
110     get extraHighlightsByLayerId() {
111       return this.layerView_.extraHighlightsByLayerId;
112     },
113
114     set extraHighlightsByLayerId(extraHighlightsByLayerId) {
115       this.layerView_.extraHighlightsByLayerId = extraHighlightsByLayerId;
116     }
117   };
118
119   tracing.analysis.ObjectSnapshotView.register(
120       'cc::LayerTreeHostImpl', LayerTreeHostImplSnapshotView);
121
122   return {
123     LayerTreeHostImplSnapshotView: LayerTreeHostImplSnapshotView
124   };
125 });
126 </script>