Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 1 | <!-- Copyright (C) 2019 The Android Open Source Project |
| 2 | |
| 3 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | you may not use this file except in compliance with the License. |
| 5 | You may obtain a copy of the License at |
| 6 | |
| 7 | http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | |
| 9 | Unless required by applicable law or agreed to in writing, software |
| 10 | distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | See the License for the specific language governing permissions and |
| 13 | limitations under the License. |
| 14 | --> |
| 15 | <template> |
| 16 | <md-card-content class="container"> |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 17 | <div class="rects" v-if="hasScreenView"> |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 18 | <rects |
| 19 | :bounds="bounds" |
| 20 | :rects="rects" |
| 21 | :highlight="highlight" |
| 22 | @rect-click="onRectClick" |
| 23 | /> |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 24 | </div> |
| 25 | |
| 26 | <div class="hierarchy"> |
| 27 | <flat-card> |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 28 | <md-content |
| 29 | md-tag="md-toolbar" |
| 30 | md-elevation="0" |
| 31 | class="card-toolbar md-transparent md-dense" |
| 32 | > |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 33 | <h2 class="md-title" style="flex: 1;">Hierarchy</h2> |
| 34 | <md-checkbox |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 35 | v-model="showHierarchyDiff" |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 36 | v-if="diffVisualizationAvailable" |
| 37 | > |
| 38 | Show Diff |
| 39 | </md-checkbox> |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 40 | <md-checkbox v-model="store.simplifyNames"> |
| 41 | Simplify names |
| 42 | </md-checkbox> |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 43 | <md-checkbox v-model="store.onlyVisible">Only visible</md-checkbox> |
| 44 | <md-checkbox v-model="store.flattened">Flat</md-checkbox> |
Nataniel Borges | 325b047 | 2021-08-31 15:08:30 +0000 | [diff] [blame] | 45 | <md-checkbox v-if="hasTagsOrErrors" v-model="store.flickerTraceView">Flicker</md-checkbox> |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 46 | <md-field md-inline class="filter"> |
| 47 | <label>Filter...</label> |
Nataniel Borges | 3907154 | 2021-09-22 09:19:41 +0000 | [diff] [blame] | 48 | <md-input |
| 49 | v-model="hierarchyPropertyFilterString" |
| 50 | v-on:focus="updateInputMode(true)" |
| 51 | v-on:blur="updateInputMode(false)" |
| 52 | /> |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 53 | </md-field> |
| 54 | </md-content> |
Pablo Gamito | cc299fc | 2020-08-04 11:30:13 +0100 | [diff] [blame] | 55 | <div class="tree-view-wrapper"> |
| 56 | <tree-view |
| 57 | class="treeview" |
| 58 | :item="tree" |
| 59 | @item-selected="itemSelected" |
| 60 | :selected="hierarchySelected" |
| 61 | :filter="hierarchyFilter" |
| 62 | :flattened="store.flattened" |
Nataniel Borges | 325b047 | 2021-08-31 15:08:30 +0000 | [diff] [blame] | 63 | :onlyVisible="store.onlyVisible" |
| 64 | :flickerTraceView="store.flickerTraceView" |
| 65 | :presentTags="presentTags" |
| 66 | :presentErrors="presentErrors" |
Pablo Gamito | cc299fc | 2020-08-04 11:30:13 +0100 | [diff] [blame] | 67 | :items-clickable="true" |
| 68 | :useGlobalCollapsedState="true" |
| 69 | :simplify-names="store.simplifyNames" |
| 70 | ref="hierarchy" |
| 71 | /> |
| 72 | </div> |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 73 | </flat-card> |
| 74 | </div> |
| 75 | |
| 76 | <div class="properties"> |
| 77 | <flat-card> |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 78 | <md-content |
| 79 | md-tag="md-toolbar" |
| 80 | md-elevation="0" |
| 81 | class="card-toolbar md-transparent md-dense" |
| 82 | > |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 83 | <h2 class="md-title" style="flex: 1">Properties</h2> |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 84 | <div> |
| 85 | <md-checkbox |
| 86 | v-model="displayDefaults" |
| 87 | @change="checkboxChange" |
| 88 | > |
| 89 | Show Defaults |
| 90 | </md-checkbox> |
| 91 | <md-tooltip md-direction="bottom"> |
| 92 | If checked, shows the value of all properties. |
| 93 | Otherwise, hides all properties whose value is |
| 94 | the default for its data type. |
| 95 | </md-tooltip> |
| 96 | </div> |
Pablo Gamito | eac2e92 | 2020-06-02 14:28:19 +0100 | [diff] [blame] | 97 | <md-checkbox |
| 98 | v-model="showPropertiesDiff" |
| 99 | v-if="diffVisualizationAvailable" |
| 100 | > |
| 101 | Show Diff |
| 102 | </md-checkbox> |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 103 | <md-field md-inline class="filter"> |
| 104 | <label>Filter...</label> |
Nataniel Borges | 3907154 | 2021-09-22 09:19:41 +0000 | [diff] [blame] | 105 | <md-input |
| 106 | v-model="propertyFilterString" |
| 107 | v-on:focus="updateInputMode(true)" |
| 108 | v-on:blur="updateInputMode(false)" |
| 109 | /> |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 110 | </md-field> |
| 111 | </md-content> |
Pablo Gamito | cc299fc | 2020-08-04 11:30:13 +0100 | [diff] [blame] | 112 | <div class="properties-content"> |
| 113 | <div v-if="elementSummary" class="element-summary"> |
| 114 | <div v-for="elem in elementSummary" v-bind:key="elem.key"> |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 115 | <!-- eslint-disable-next-line max-len --> |
Pablo Gamito | cc299fc | 2020-08-04 11:30:13 +0100 | [diff] [blame] | 116 | <span class="key">{{ elem.key }}:</span> <span class="value">{{ elem.value }}</span> |
| 117 | </div> |
| 118 | </div> |
| 119 | <div v-if="selectedTree" class="tree-view-wrapper"> |
| 120 | <tree-view |
| 121 | class="treeview" |
| 122 | :item="selectedTree" |
| 123 | :filter="propertyFilter" |
| 124 | :collapseChildren="true" |
Pablo Gamito | cc299fc | 2020-08-04 11:30:13 +0100 | [diff] [blame] | 125 | :elementView="PropertiesTreeElement" |
| 126 | /> |
| 127 | </div> |
| 128 | <div class="no-properties" v-else> |
| 129 | <i class="material-icons none-icon"> |
| 130 | filter_none |
| 131 | </i> |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 132 | <span>No element selected in the hierarchy.</span> |
Pablo Gamito | cc299fc | 2020-08-04 11:30:13 +0100 | [diff] [blame] | 133 | </div> |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 134 | </div> |
| 135 | </flat-card> |
| 136 | </div> |
| 137 | |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 138 | </md-card-content> |
| 139 | </template> |
| 140 | <script> |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 141 | import TreeView from './TreeView.vue'; |
| 142 | import Rects from './Rects.vue'; |
| 143 | import FlatCard from './components/FlatCard.vue'; |
| 144 | import PropertiesTreeElement from './PropertiesTreeElement.vue'; |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 145 | |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 146 | import {ObjectTransformer} from './transform.js'; |
| 147 | import {DiffGenerator, defaultModifiedCheck} from './utils/diff.js'; |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 148 | import {TRACE_TYPES, DUMP_TYPES} from './decode.js'; |
Nataniel Borges | 3907154 | 2021-09-22 09:19:41 +0000 | [diff] [blame] | 149 | import {isPropertyMatch, stableIdCompatibilityFixup} from './utils/utils.js'; |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 150 | import {CompatibleFeatures} from './utils/compatibility.js'; |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 151 | import {getPropertiesForDisplay} from './flickerlib/mixin'; |
| 152 | import ObjectFormatter from './flickerlib/ObjectFormatter'; |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 153 | |
| 154 | function formatProto(obj) { |
Nataniel Borges | c841552 | 2021-04-23 15:05:54 +0200 | [diff] [blame] | 155 | if (obj?.prettyPrint) { |
| 156 | return obj.prettyPrint(); |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 157 | } |
| 158 | } |
| 159 | |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 160 | function findEntryInTree(tree, id) { |
| 161 | if (tree.stableId === id) { |
| 162 | return tree; |
| 163 | } |
| 164 | |
| 165 | if (!tree.children) { |
| 166 | return null; |
| 167 | } |
| 168 | |
| 169 | for (const child of tree.children) { |
| 170 | const foundEntry = findEntryInTree(child, id); |
| 171 | if (foundEntry) { |
| 172 | return foundEntry; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | return null; |
| 177 | } |
| 178 | |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 179 | export default { |
| 180 | name: 'traceview', |
Nataniel Borges | 325b047 | 2021-08-31 15:08:30 +0000 | [diff] [blame] | 181 | props: ['store', 'file', 'summarizer', 'presentTags', 'presentErrors'], |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 182 | data() { |
| 183 | return { |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 184 | propertyFilterString: '', |
| 185 | hierarchyPropertyFilterString: '', |
Pablo Gamito | 4ffa6b8 | 2020-06-10 10:30:33 +0100 | [diff] [blame] | 186 | selectedTree: null, |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 187 | hierarchySelected: null, |
| 188 | lastSelectedStableId: null, |
| 189 | bounds: {}, |
| 190 | rects: [], |
Pablo Gamito | a8eeef8 | 2020-07-13 12:58:00 +0100 | [diff] [blame] | 191 | item: null, |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 192 | tree: null, |
| 193 | highlight: null, |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 194 | showHierarchyDiff: false, |
| 195 | displayDefaults: false, |
Pablo Gamito | cdbcfad | 2020-07-17 10:44:30 +0100 | [diff] [blame] | 196 | showPropertiesDiff: false, |
Pablo Gamito | 06102a2 | 2020-07-23 14:25:24 +0100 | [diff] [blame] | 197 | PropertiesTreeElement, |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 198 | }; |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 199 | }, |
| 200 | methods: { |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 201 | checkboxChange(checked) { |
| 202 | this.itemSelected(this.item); |
| 203 | }, |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 204 | itemSelected(item) { |
| 205 | this.hierarchySelected = item; |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 206 | this.selectedTree = this.getTransformedProperties(item); |
Pablo Gamito | 335b3e1 | 2020-07-17 12:36:18 +0100 | [diff] [blame] | 207 | this.highlight = item.rect; |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 208 | this.lastSelectedStableId = item.stableId; |
| 209 | this.$emit('focus'); |
| 210 | }, |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 211 | getTransformedProperties(item) { |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 212 | ObjectFormatter.displayDefaults = this.displayDefaults; |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 213 | const transformer = new ObjectTransformer( |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 214 | getPropertiesForDisplay(item), |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 215 | item.name, |
| 216 | stableIdCompatibilityFixup(item), |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 217 | ).setOptions({ |
Pablo Gamito | 4c7d95c | 2020-07-03 16:06:40 +0100 | [diff] [blame] | 218 | skip: item.skip, |
| 219 | formatter: formatProto, |
| 220 | }); |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 221 | |
Pablo Gamito | 33d3e86 | 2020-06-16 10:53:05 +0100 | [diff] [blame] | 222 | if (this.showPropertiesDiff && this.diffVisualizationAvailable) { |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 223 | const prevItem = this.getItemFromPrevTree(item); |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 224 | transformer.withDiff(getPropertiesForDisplay(prevItem)); |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | return transformer.transform(); |
| 228 | }, |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 229 | onRectClick(item) { |
| 230 | if (item) { |
| 231 | this.itemSelected(item); |
| 232 | } |
| 233 | }, |
Pablo Gamito | a8eeef8 | 2020-07-13 12:58:00 +0100 | [diff] [blame] | 234 | generateTreeFromItem(item) { |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 235 | if (!this.showHierarchyDiff || !this.diffVisualizationAvailable) { |
Pablo Gamito | a8eeef8 | 2020-07-13 12:58:00 +0100 | [diff] [blame] | 236 | return item; |
Pablo Gamito | e9ed4d5 | 2020-05-25 19:29:34 +0100 | [diff] [blame] | 237 | } |
| 238 | |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 239 | const thisItem = this.item; |
| 240 | const prevItem = this.getDataWithOffset(-1); |
| 241 | return new DiffGenerator(thisItem) |
| 242 | .compareWith(prevItem) |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 243 | .withUniqueNodeId((node) => { |
| 244 | return node.stableId; |
| 245 | }) |
| 246 | .withModifiedCheck(defaultModifiedCheck) |
| 247 | .generateDiffTree(); |
Pablo Gamito | a8eeef8 | 2020-07-13 12:58:00 +0100 | [diff] [blame] | 248 | }, |
| 249 | setData(item) { |
| 250 | this.item = item; |
| 251 | this.tree = this.generateTreeFromItem(item); |
| 252 | |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 253 | const rects = item.rects; // .toArray() |
Nataniel Borges | 5e4ca35 | 2020-10-15 12:22:03 +0200 | [diff] [blame] | 254 | this.rects = [...rects].reverse(); |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 255 | this.bounds = item.bounds; |
| 256 | |
| 257 | this.hierarchySelected = null; |
Pablo Gamito | 4ffa6b8 | 2020-06-10 10:30:33 +0100 | [diff] [blame] | 258 | this.selectedTree = null; |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 259 | this.highlight = null; |
| 260 | |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 261 | function findItem(item, stableId) { |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 262 | if (item.stableId === stableId) { |
| 263 | return item; |
| 264 | } |
| 265 | if (Array.isArray(item.children)) { |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 266 | for (const child of item.children) { |
| 267 | const found = findItem(child, stableId); |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 268 | if (found) { |
| 269 | return found; |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | return null; |
| 274 | } |
| 275 | |
| 276 | if (this.lastSelectedStableId) { |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 277 | const found = findItem(item, this.lastSelectedStableId); |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 278 | if (found) { |
| 279 | this.itemSelected(found); |
| 280 | } |
| 281 | } |
| 282 | }, |
| 283 | arrowUp() { |
| 284 | return this.$refs.hierarchy.selectPrev(); |
| 285 | }, |
| 286 | arrowDown() { |
| 287 | return this.$refs.hierarchy.selectNext(); |
| 288 | }, |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 289 | getDataWithOffset(offset) { |
| 290 | const index = this.file.selectedIndex + offset; |
| 291 | |
| 292 | if (index < 0 || index >= this.file.data.length) { |
| 293 | return null; |
| 294 | } |
| 295 | |
| 296 | return this.file.data[index]; |
| 297 | }, |
| 298 | getItemFromPrevTree(entry) { |
| 299 | if (!this.showPropertiesDiff || !this.hierarchySelected) { |
| 300 | return null; |
| 301 | } |
| 302 | |
| 303 | const id = entry.stableId; |
| 304 | if (!id) { |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 305 | throw new Error('Entry has no stableId...'); |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | const prevTree = this.getDataWithOffset(-1); |
| 309 | if (!prevTree) { |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 310 | console.warn('No previous entry'); |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 311 | return null; |
| 312 | } |
| 313 | |
| 314 | const prevEntry = findEntryInTree(prevTree, id); |
| 315 | if (!prevEntry) { |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 316 | console.warn('Didn\'t exist in last entry'); |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 317 | // TODO: Maybe handle this in some way. |
| 318 | } |
| 319 | |
| 320 | return prevEntry; |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 321 | }, |
Nataniel Borges | 325b047 | 2021-08-31 15:08:30 +0000 | [diff] [blame] | 322 | |
| 323 | /** Performs check for id match between entry and present tags/errors |
| 324 | * must be carried out for every present tag/error |
| 325 | */ |
| 326 | matchItems(flickerItems, entryItem) { |
| 327 | var match = false; |
| 328 | flickerItems.forEach(flickerItem => { |
Nataniel Borges | 3907154 | 2021-09-22 09:19:41 +0000 | [diff] [blame] | 329 | if (isPropertyMatch(flickerItem, entryItem)) match = true; |
Nataniel Borges | 325b047 | 2021-08-31 15:08:30 +0000 | [diff] [blame] | 330 | }); |
| 331 | return match; |
| 332 | }, |
| 333 | /** Returns check for id match between entry and present tags/errors */ |
| 334 | isEntryTagMatch(entryItem) { |
| 335 | return this.matchItems(this.presentTags, entryItem) || this.matchItems(this.presentErrors, entryItem); |
| 336 | }, |
Nataniel Borges | 3907154 | 2021-09-22 09:19:41 +0000 | [diff] [blame] | 337 | |
| 338 | /** determines whether left/right arrow keys should move cursor in input field */ |
| 339 | updateInputMode(isInputMode) { |
| 340 | this.store.isInputMode = isInputMode; |
| 341 | }, |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 342 | }, |
| 343 | created() { |
Pablo Gamito | f25221c | 2020-08-06 18:26:42 +0100 | [diff] [blame] | 344 | this.setData(this.file.data[this.file.selectedIndex ?? 0]); |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 345 | }, |
Nataniel Borges | 325b047 | 2021-08-31 15:08:30 +0000 | [diff] [blame] | 346 | destroyed() { |
| 347 | this.store.flickerTraceView = false; |
| 348 | }, |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 349 | watch: { |
| 350 | selectedIndex() { |
Pablo Gamito | f25221c | 2020-08-06 18:26:42 +0100 | [diff] [blame] | 351 | this.setData(this.file.data[this.file.selectedIndex ?? 0]); |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 352 | }, |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 353 | showHierarchyDiff() { |
Pablo Gamito | a8eeef8 | 2020-07-13 12:58:00 +0100 | [diff] [blame] | 354 | this.tree = this.generateTreeFromItem(this.item); |
| 355 | }, |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 356 | showPropertiesDiff() { |
| 357 | if (this.hierarchySelected) { |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 358 | this.selectedTree = |
| 359 | this.getTransformedProperties(this.hierarchySelected); |
Pablo Gamito | aa2c133 | 2020-05-20 16:50:15 +0100 | [diff] [blame] | 360 | } |
Pablo Gamito | a8eeef8 | 2020-07-13 12:58:00 +0100 | [diff] [blame] | 361 | }, |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 362 | }, |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 363 | computed: { |
Pablo Gamito | eac2e92 | 2020-06-02 14:28:19 +0100 | [diff] [blame] | 364 | diffVisualizationAvailable() { |
| 365 | return CompatibleFeatures.DiffVisualization && ( |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 366 | this.file.type == TRACE_TYPES.WINDOW_MANAGER || |
Pablo Gamito | f25221c | 2020-08-06 18:26:42 +0100 | [diff] [blame] | 367 | this.file.type == TRACE_TYPES.SURFACE_FLINGER |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 368 | ); |
Pablo Gamito | eac2e92 | 2020-06-02 14:28:19 +0100 | [diff] [blame] | 369 | }, |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 370 | selectedIndex() { |
| 371 | return this.file.selectedIndex; |
| 372 | }, |
| 373 | hierarchyFilter() { |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 374 | const hierarchyPropertyFilter = |
| 375 | getFilter(this.hierarchyPropertyFilterString); |
Nataniel Borges | 325b047 | 2021-08-31 15:08:30 +0000 | [diff] [blame] | 376 | var fil = this.store.onlyVisible ? (c) => { |
Nataniel Borges | f230a13 | 2021-07-28 07:13:45 +0000 | [diff] [blame] | 377 | return c.isVisible && hierarchyPropertyFilter(c); |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 378 | } : hierarchyPropertyFilter; |
Nataniel Borges | 325b047 | 2021-08-31 15:08:30 +0000 | [diff] [blame] | 379 | return this.store.flickerTraceView ? (c) => { |
| 380 | return this.isEntryTagMatch(c); |
| 381 | } : fil; |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 382 | }, |
| 383 | propertyFilter() { |
Vishnu Nair | c778b9b | 2020-03-27 15:32:29 -0700 | [diff] [blame] | 384 | return getFilter(this.propertyFilterString); |
Adam Pardyl | f1af74f | 2019-09-16 12:18:15 +0200 | [diff] [blame] | 385 | }, |
| 386 | hasScreenView() { |
Pablo Gamito | f25221c | 2020-08-06 18:26:42 +0100 | [diff] [blame] | 387 | return this.file.type == TRACE_TYPES.WINDOW_MANAGER || |
| 388 | this.file.type == TRACE_TYPES.SURFACE_FLINGER || |
| 389 | this.file.type == DUMP_TYPES.WINDOW_MANAGER || |
| 390 | this.file.type == DUMP_TYPES.SURFACE_FLINGER; |
Adam Pardyl | f1af74f | 2019-09-16 12:18:15 +0200 | [diff] [blame] | 391 | }, |
Pablo Gamito | cc299fc | 2020-08-04 11:30:13 +0100 | [diff] [blame] | 392 | elementSummary() { |
| 393 | if (!this.hierarchySelected || !this.summarizer) { |
| 394 | return null; |
| 395 | } |
| 396 | |
Pablo Gamito | 6fe0827 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 397 | const summary = this.summarizer(this.hierarchySelected); |
| 398 | |
| 399 | if (summary?.length === 0) { |
| 400 | return null; |
| 401 | } |
| 402 | |
| 403 | return summary; |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 404 | }, |
Nataniel Borges | 325b047 | 2021-08-31 15:08:30 +0000 | [diff] [blame] | 405 | hasTagsOrErrors() { |
| 406 | return this.presentTags.length > 0 || this.presentErrors.length > 0; |
| 407 | }, |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 408 | }, |
| 409 | components: { |
| 410 | 'tree-view': TreeView, |
| 411 | 'rects': Rects, |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 412 | 'flat-card': FlatCard, |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 413 | }, |
| 414 | }; |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 415 | |
Vishnu Nair | c778b9b | 2020-03-27 15:32:29 -0700 | [diff] [blame] | 416 | function getFilter(filterString) { |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 417 | const filterStrings = filterString.split(','); |
| 418 | const positive = []; |
| 419 | const negative = []; |
Vishnu Nair | c778b9b | 2020-03-27 15:32:29 -0700 | [diff] [blame] | 420 | filterStrings.forEach((f) => { |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 421 | if (f.startsWith('!')) { |
| 422 | const str = f.substring(1); |
Vishnu Nair | c778b9b | 2020-03-27 15:32:29 -0700 | [diff] [blame] | 423 | negative.push((s) => s.indexOf(str) === -1); |
| 424 | } else { |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 425 | const str = f; |
Vishnu Nair | c778b9b | 2020-03-27 15:32:29 -0700 | [diff] [blame] | 426 | positive.push((s) => s.indexOf(str) !== -1); |
| 427 | } |
| 428 | }); |
Pablo Gamito | 246e602 | 2020-09-17 12:50:45 +0200 | [diff] [blame] | 429 | const filter = (item) => { |
| 430 | const apply = (f) => f(String(item.name)); |
Vishnu Nair | c778b9b | 2020-03-27 15:32:29 -0700 | [diff] [blame] | 431 | return (positive.length === 0 || positive.some(apply)) && |
| 432 | (negative.length === 0 || negative.every(apply)); |
| 433 | }; |
| 434 | return filter; |
| 435 | } |
| 436 | |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 437 | </script> |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 438 | <style scoped> |
| 439 | .container { |
| 440 | display: flex; |
| 441 | flex-wrap: wrap; |
| 442 | } |
| 443 | |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 444 | .rects { |
| 445 | flex: none; |
| 446 | margin: 8px; |
| 447 | } |
| 448 | |
| 449 | .hierarchy, |
| 450 | .properties { |
| 451 | flex: 1; |
| 452 | margin: 8px; |
| 453 | min-width: 400px; |
Pablo Gamito | cc299fc | 2020-08-04 11:30:13 +0100 | [diff] [blame] | 454 | min-height: 50rem; |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 455 | } |
| 456 | |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 457 | .rects, |
| 458 | .hierarchy, |
| 459 | .properties { |
| 460 | padding: 5px; |
| 461 | } |
| 462 | |
| 463 | .flat-card { |
Pablo Gamito | cc299fc | 2020-08-04 11:30:13 +0100 | [diff] [blame] | 464 | display: flex; |
| 465 | flex-direction: column; |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 466 | height: 100%; |
| 467 | } |
| 468 | |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 469 | .hierarchy>.tree-view, |
| 470 | .properties>.tree-view { |
| 471 | margin: 16px; |
| 472 | } |
| 473 | |
Pablo Gamito | cc299fc | 2020-08-04 11:30:13 +0100 | [diff] [blame] | 474 | .treeview { |
Adam Pardyl | 41a5e82 | 2019-08-06 17:30:37 +0200 | [diff] [blame] | 475 | overflow: auto; |
Alec Mouri | c3457a0 | 2020-03-11 18:29:55 -0700 | [diff] [blame] | 476 | white-space: pre-line; |
| 477 | } |
| 478 | |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 479 | .no-properties { |
| 480 | display: flex; |
Pablo Gamito | cc299fc | 2020-08-04 11:30:13 +0100 | [diff] [blame] | 481 | flex: 1; |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 482 | flex-direction: column; |
| 483 | align-self: center; |
| 484 | align-items: center; |
| 485 | justify-content: center; |
Pablo Gamito | 050e20b | 2020-07-01 16:41:56 +0100 | [diff] [blame] | 486 | padding: 50px 25px; |
| 487 | } |
| 488 | |
| 489 | .no-properties .none-icon { |
| 490 | font-size: 35px; |
| 491 | margin-bottom: 10px; |
| 492 | } |
| 493 | |
| 494 | .no-properties span { |
| 495 | font-weight: 100; |
| 496 | } |
| 497 | |
| 498 | .filter { |
| 499 | width: auto; |
| 500 | } |
| 501 | |
Pablo Gamito | cc299fc | 2020-08-04 11:30:13 +0100 | [diff] [blame] | 502 | .element-summary { |
| 503 | padding: 1rem; |
| 504 | border-bottom: thin solid rgba(0,0,0,.12); |
| 505 | } |
| 506 | |
| 507 | .element-summary .key { |
| 508 | font-weight: 500; |
| 509 | } |
| 510 | |
| 511 | .element-summary .value { |
| 512 | color: rgba(0, 0, 0, 0.75); |
| 513 | } |
| 514 | |
| 515 | .properties-content { |
| 516 | display: flex; |
| 517 | flex-direction: column; |
| 518 | flex: 1; |
| 519 | } |
| 520 | |
| 521 | .tree-view-wrapper { |
| 522 | display: flex; |
| 523 | flex-direction: column; |
| 524 | flex: 1; |
| 525 | } |
| 526 | |
| 527 | .treeview { |
| 528 | flex: 1 0 0; |
| 529 | } |
Adam Pardyl | 367cc8c | 2019-07-16 12:20:13 +0200 | [diff] [blame] | 530 | </style> |