Chris Craik | b2cbf15 | 2015-07-28 16:26:29 -0700 | [diff] [blame^] | 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="import" href="/ui/analysis/analysis_sub_view.html"> |
| 9 | <link rel="import" href="/ui/analysis/multi_event_sub_view.html"> |
| 10 | <link rel="import" href="/ui/analysis/related_events.html"> |
| 11 | |
| 12 | <polymer-element name="tr-ui-a-multi-thread-slice-sub-view" |
| 13 | extends="tr-ui-a-sub-view"> |
| 14 | <template> |
| 15 | <style> |
| 16 | :host { |
| 17 | display: flex; |
| 18 | } |
| 19 | #content { |
| 20 | display: flex; |
| 21 | flex: 1 1 auto; |
| 22 | } |
| 23 | #content > tr-ui-a-related-events { |
| 24 | margin-left: 8px; |
| 25 | flex: 0 1 200px; |
| 26 | } |
| 27 | </style> |
| 28 | <div id="content"></div> |
| 29 | </template> |
| 30 | |
| 31 | <script> |
| 32 | 'use strict'; |
| 33 | |
| 34 | Polymer({ |
| 35 | created: function() { |
| 36 | this.selection_ = undefined; |
| 37 | }, |
| 38 | |
| 39 | get selection() { |
| 40 | return this.selection_; |
| 41 | }, |
| 42 | |
| 43 | set selection(selection) { |
| 44 | this.selection_ = selection; |
| 45 | |
| 46 | // TODO(nduca): This is a gross hack for cc Frame Viewer, but its only |
| 47 | // the frame viewer that needs this feature, so ~shrug~. |
| 48 | // We check for its presence so that we do not have a hard dependency |
| 49 | // on frame viewer. |
| 50 | if (tr.isExported('tr.ui.e.chrome.cc.RasterTaskSelection')) { |
| 51 | if (tr.ui.e.chrome.cc.RasterTaskSelection.supports(selection)) { |
| 52 | var ltvSelection = new tr.ui.e.chrome.cc.RasterTaskSelection( |
| 53 | selection); |
| 54 | |
| 55 | var ltv = new tr.ui.e.chrome.cc.LayerTreeHostImplSnapshotView(); |
| 56 | ltv.objectSnapshot = ltvSelection.containingSnapshot; |
| 57 | ltv.selection = ltvSelection; |
| 58 | ltv.extraHighlightsByLayerId = ltvSelection.extraHighlightsByLayerId; |
| 59 | |
| 60 | this.$.content.textContent = ''; |
| 61 | this.$.content.appendChild(ltv); |
| 62 | |
| 63 | this.requiresTallView_ = true; |
| 64 | return; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | this.$.content.textContent = ''; |
| 69 | |
| 70 | var mesv = document.createElement('tr-ui-a-multi-event-sub-view'); |
| 71 | mesv.selection = selection; |
| 72 | this.$.content.appendChild(mesv); |
| 73 | |
| 74 | var relatedEvents = document.createElement('tr-ui-a-related-events'); |
| 75 | relatedEvents.setRelatedEvents(selection); |
| 76 | |
| 77 | if (relatedEvents.hasRelatedEvents()) { |
| 78 | this.$.content.appendChild(relatedEvents); |
| 79 | } |
| 80 | }, |
| 81 | |
| 82 | get requiresTallView() { |
| 83 | if (this.$.content.children.length === 0) |
| 84 | return false; |
| 85 | var childTagName = this.$.content.children[0].tagName; |
| 86 | if (childTagName === 'TR-UI-A-MULTI-EVENT-SUB-VIEW') |
| 87 | return false; |
| 88 | |
| 89 | // Using raster task view. |
| 90 | return true; |
| 91 | } |
| 92 | }); |
| 93 | </script> |
| 94 | </polymer-element> |