Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: tracing/tracing/value/ui/related_histogram_set_span.html

Issue 3002973002: Refactor diagnostic spans to share a polymer behavior. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2016 The Chromium Authors. All rights reserved. 3 Copyright 2016 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/ui/analysis/analysis_link.html"> 8 <link rel="import" href="/tracing/ui/analysis/analysis_link.html">
9 <link rel="import" href="/tracing/value/ui/diagnostic_span_behavior.html">
9 10
10 <dom-module id="tr-v-ui-related-histogram-set-span"> 11 <dom-module id="tr-v-ui-related-histogram-set-span">
11 <script> 12 </dom-module>
12 'use strict'; 13
14 <script>
15 'use strict';
16 tr.exportTo('tr.v.ui', function() {
13 Polymer({ 17 Polymer({
14 is: 'tr-v-ui-related-histogram-set-span', 18 is: 'tr-v-ui-related-histogram-set-span',
15 19 behaviors: [tr.v.ui.DIAGNOSTIC_SPAN_BEHAVIOR],
16 ready() {
17 this.diagnostic_ = undefined;
18 },
19
20 get diagnostic() {
21 return this.diagnostic_;
22 },
23
24 set diagnostic(d) {
25 this.diagnostic_ = d;
26 this.updateContents_();
27 },
28 20
29 addLink_(selection, content) { 21 addLink_(selection, content) {
30 const link = document.createElement('tr-ui-a-analysis-link'); 22 const link = document.createElement('tr-ui-a-analysis-link');
31 link.setSelectionAndContent(selection, content); 23 link.setSelectionAndContent(selection, content);
32 Polymer.dom(this).appendChild(link); 24 Polymer.dom(this).appendChild(link);
33 Polymer.dom(this).appendChild(document.createElement('br')); 25 Polymer.dom(this).appendChild(document.createElement('br'));
34 }, 26 },
35 27
36 updateContents_() { 28 updateContents_() {
37 Polymer.dom(this).textContent = ''; 29 Polymer.dom(this).textContent = '';
38 30
39 const histogramNames = new Set(); 31 const histogramNames = new Set();
40 for (const hist of this.diagnostic) { 32 for (const hist of this.diagnostic) {
41 histogramNames.add(hist.name); 33 histogramNames.add(hist.name);
42 } 34 }
43 if (histogramNames.size > 1) { 35 if (histogramNames.size > 1) {
44 this.addLink_(Array.from(histogramNames), 'Select All'); 36 this.addLink_(Array.from(histogramNames), 'Select All');
45 } 37 }
46 38
47 for (const hist of this.diagnostic) { 39 for (const hist of this.diagnostic) {
48 this.addLink_([hist.name], hist.name); 40 this.addLink_([hist.name], hist.name);
49 } 41 }
50 } 42 }
51 }); 43 });
52 </script> 44
53 </dom-module> 45 return {
46 };
47 });
48 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698