1<!DOCTYPE html> 2<!-- 3Copyright 2015 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="import" href="/tracing/base/base.html"> 9 10<!-- 11@fileoverview Analysis view stacked pane. See the stacked pane view element 12(tr-ui-a-stacked-pane-view) documentation for more details. 13--> 14<polymer-element name="tr-ui-a-stacked-pane"> 15 <script> 16 'use strict'; 17 18 Polymer({ 19 rebuild: function() { 20 /** 21 * Rebuild the pane if necessary. 22 * 23 * This method is not intended to be overriden by subclasses. Please 24 * override scheduleRebuildPane_() instead. 25 */ 26 if (!this.paneDirty_) { 27 // Avoid rebuilding unnecessarily as it breaks things like table 28 // selection. 29 return; 30 } 31 32 this.paneDirty_ = false; 33 this.rebuildPane_(); 34 }, 35 36 /** 37 * Mark the UI state of the pane as dirty and schedule a rebuild. 38 * 39 * This method is intended to be called by subclasses. 40 */ 41 scheduleRebuildPane_: function() { 42 if (this.paneDirty_) 43 return; 44 this.paneDirty_ = true; 45 setTimeout(this.rebuild.bind(this), 0); 46 }, 47 48 /** 49 * Called when the pane is dirty and a rebuild is triggered. 50 * 51 * This method is intended to be overriden by subclasses (instead of 52 * directly overriding rebuild()). 53 */ 54 rebuildPane_: function() { 55 }, 56 57 /** 58 * Request changing the child pane of this pane in the associated stacked 59 * pane view. If the assigned builder is undefined, request removing the 60 * current child pane. 61 * 62 * Note that setting this property before appended() is called will have no 63 * effect (as there will be no listener attached to the pane). 64 * 65 * This method is intended to be called by subclasses. 66 */ 67 set childPaneBuilder(childPaneBuilder) { 68 this.childPaneBuilder_ = childPaneBuilder; 69 this.dispatchEvent(new tr.b.Event('request-child-pane-change')); 70 }, 71 72 get childPaneBuilder() { 73 return this.childPaneBuilder_; 74 }, 75 76 /** 77 * Called right after the pane is appended to a pane view. 78 * 79 * This method triggers an immediate rebuild by default (if necessary). 80 * Subclasses are free to change this behavior (e.g. if a pane has lots of 81 * data to display, it might decide to defer rebuilding in order not to 82 * cause jank). 83 */ 84 appended: function() { 85 this.rebuild(); 86 } 87 }); 88 </script> 89</polymer-element> 90