OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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/base/settings.html"> | 8 <link rel="import" href="/tracing/base/settings.html"> |
9 <link rel="import" href="/tracing/base/utils.html"> | 9 <link rel="import" href="/tracing/base/utils.html"> |
10 <link rel="import" href="/tracing/core/scripting_controller.html"> | 10 <link rel="import" href="/tracing/core/scripting_controller.html"> |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 <script> | 137 <script> |
138 'use strict'; | 138 'use strict'; |
139 | 139 |
140 Polymer({ | 140 Polymer({ |
141 is: 'tr-ui-timeline-view', | 141 is: 'tr-ui-timeline-view', |
142 | 142 |
143 attached: function() { | 143 attached: function() { |
144 this.async(function() { | 144 this.async(function() { |
145 this.trackViewContainer_ = Polymer.dom(this).querySelector( | 145 this.trackViewContainer_ = Polymer.dom(this).querySelector( |
146 '#track_view_container'); | 146 '#track_view_container'); |
147 if (!this.trackViewContainer_) | 147 if (!this.trackViewContainer_) { |
148 console.error('missing trackviewContainer'); | 148 console.error('missing trackviewContainer'); |
| 149 } |
| 150 if (this.model_) { |
| 151 this.updateContents_(); |
| 152 } |
149 }); | 153 }); |
150 }, | 154 }, |
151 | 155 |
152 ready: function() { | 156 ready: function() { |
153 this.tabIndex = 0; // Let the timeline able to receive key events. | 157 this.tabIndex = 0; // Let the timeline able to receive key events. |
154 | 158 |
155 this.titleEl_ = this.$.title; | 159 this.titleEl_ = this.$.title; |
156 this.leftControlsEl_ = this.$.left_controls; | 160 this.leftControlsEl_ = this.$.left_controls; |
157 this.rightControlsEl_ = this.$.right_controls; | 161 this.rightControlsEl_ = this.$.right_controls; |
158 this.collapsingControlsEl_ = this.$.collapsing_controls; | 162 this.collapsingControlsEl_ = this.$.collapsing_controls; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 if (text === undefined) { | 361 if (text === undefined) { |
358 Polymer.dom(this.titleEl_).textContent = ''; | 362 Polymer.dom(this.titleEl_).textContent = ''; |
359 this.titleEl_.hidden = true; | 363 this.titleEl_.hidden = true; |
360 return; | 364 return; |
361 } | 365 } |
362 this.titleEl_.hidden = false; | 366 this.titleEl_.hidden = false; |
363 Polymer.dom(this.titleEl_).textContent = text; | 367 Polymer.dom(this.titleEl_).textContent = text; |
364 }, | 368 }, |
365 | 369 |
366 get model() { | 370 get model() { |
367 if (this.trackView_) | 371 return this.model_; |
368 return this.trackView_.model; | |
369 return undefined; | |
370 }, | 372 }, |
371 | 373 |
372 set model(model) { | 374 set model(model) { |
373 var modelInstanceChanged = model !== this.model; | 375 this.model_ = model; |
374 var modelValid = model && !model.bounds.isEmpty; | 376 if (this.isAttached) this.updateContents_(); |
| 377 }, |
| 378 |
| 379 updateContents_: function() { |
| 380 var modelInstanceChanged = (this.trackViewModel_ === undefined) || |
| 381 (this.model !== this.trackViewModel_.model); |
| 382 var modelValid = this.model && !this.model.bounds.isEmpty; |
375 | 383 |
376 var importWarningsEl = Polymer.dom(this.root).querySelector( | 384 var importWarningsEl = Polymer.dom(this.root).querySelector( |
377 '#import-warnings'); | 385 '#import-warnings'); |
378 Polymer.dom(importWarningsEl).textContent = ''; | 386 Polymer.dom(importWarningsEl).textContent = ''; |
379 | 387 |
380 // Remove old trackView if the model has completely changed. | 388 // Remove old trackView if the model has completely changed. |
381 if (modelInstanceChanged) { | 389 if (modelInstanceChanged) { |
382 if (this.railScoreSpan_) | 390 if (this.railScoreSpan_) |
383 this.railScoreSpan_.model = undefined; | 391 this.railScoreSpan_.model = undefined; |
384 Polymer.dom(this.trackViewContainer_).textContent = ''; | 392 Polymer.dom(this.trackViewContainer_).textContent = ''; |
(...skipping 14 matching lines...) Expand all Loading... |
399 | 407 |
400 this.trackView.brushingStateController = this.brushingStateController_; | 408 this.trackView.brushingStateController = this.brushingStateController_; |
401 | 409 |
402 Polymer.dom(this.trackViewContainer_).appendChild(this.trackView_); | 410 Polymer.dom(this.trackViewContainer_).appendChild(this.trackView_); |
403 this.trackView_.viewport.addEventListener( | 411 this.trackView_.viewport.addEventListener( |
404 'change', this.onViewportChanged_); | 412 'change', this.onViewportChanged_); |
405 } | 413 } |
406 | 414 |
407 // Set the model. | 415 // Set the model. |
408 if (modelValid) { | 416 if (modelValid) { |
409 this.trackView_.model = model; | 417 this.trackView_.model = this.model; |
410 this.trackView_.viewport.showFlowEvents = this.showFlowEvents; | 418 this.trackView_.viewport.showFlowEvents = this.showFlowEvents; |
411 this.trackView_.viewport.highlightVSync = this.highlightVSync; | 419 this.trackView_.viewport.highlightVSync = this.highlightVSync; |
412 if (this.railScoreSpan_) | 420 if (this.railScoreSpan_) { |
413 this.railScoreSpan_.model = model; | 421 this.railScoreSpan_.model = this.model; |
414 | 422 } |
415 this.$.display_unit.preferredTimeDisplayMode = model.intrinsicTimeUnit; | 423 this.$.display_unit.preferredTimeDisplayMode = |
| 424 this.model.intrinsicTimeUnit; |
416 } | 425 } |
417 | 426 |
418 if (model) { | 427 if (this.model) { |
419 model.importWarningsThatShouldBeShownToUser.forEach( | 428 this.model.importWarningsThatShouldBeShownToUser.forEach( |
420 function(importWarning) { | 429 function(importWarning) { |
421 importWarningsEl.addMessage( | 430 importWarningsEl.addMessage( |
422 'Import Warning: ' + importWarning.type + ': ' + | 431 'Import Warning: ' + importWarning.type + ': ' + |
423 importWarning.message); | 432 importWarning.message); |
424 }, this); | 433 }, this); |
425 } | 434 } |
426 | 435 |
427 // Do things that are selection specific | 436 // Do things that are selection specific |
428 if (modelInstanceChanged) { | 437 if (modelInstanceChanged) { |
429 this.updateMetadataButtonVisibility_(); | 438 this.updateMetadataButtonVisibility_(); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 toggleHighlightVSync_: function() { | 541 toggleHighlightVSync_: function() { |
533 this.highlightVSyncCheckbox_.checked = | 542 this.highlightVSyncCheckbox_.checked = |
534 !this.highlightVSyncCheckbox_.checked; | 543 !this.highlightVSyncCheckbox_.checked; |
535 }, | 544 }, |
536 | 545 |
537 setFindCtlText: function(string) { | 546 setFindCtlText: function(string) { |
538 this.findCtl_.setText(string); | 547 this.findCtl_.setText(string); |
539 } | 548 } |
540 }); | 549 }); |
541 </script> | 550 </script> |
OLD | NEW |