diff options
Diffstat (limited to 'chromium/third_party/catapult/tracing/tracing/ui/analysis/rebuildable_behavior.html')
-rw-r--r-- | chromium/third_party/catapult/tracing/tracing/ui/analysis/rebuildable_behavior.html | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/chromium/third_party/catapult/tracing/tracing/ui/analysis/rebuildable_behavior.html b/chromium/third_party/catapult/tracing/tracing/ui/analysis/rebuildable_behavior.html new file mode 100644 index 00000000000..65cf075a003 --- /dev/null +++ b/chromium/third_party/catapult/tracing/tracing/ui/analysis/rebuildable_behavior.html @@ -0,0 +1,59 @@ +<!DOCTYPE html> +<!-- +Copyright 2016 The Chromium Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> + +<link rel="import" href="/tracing/base/raf.html"> + +<script> +'use strict'; + +tr.exportTo('tr.ui.analysis', function() { + + var RebuildableBehavior = { + rebuild: function() { + /** + * Rebuild the pane if necessary. + * + * This method is not intended to be overriden by subclasses. Please + * override scheduleRebuild_() instead. + */ + if (!this.paneDirty_) { + // Avoid rebuilding unnecessarily as it breaks things like table + // selection. + return; + } + + this.paneDirty_ = false; + this.onRebuild_(); + }, + + /** + * Mark the UI state of the pane as dirty and schedule a rebuild. + * + * This method is intended to be called by subclasses. + */ + scheduleRebuild_: function() { + if (this.paneDirty_) + return; + this.paneDirty_ = true; + tr.b.requestAnimationFrame(this.rebuild.bind(this)); + }, + + /** + * Called when the pane is dirty and a rebuild is triggered. + * + * This method is intended to be overriden by subclasses (instead of + * directly overriding rebuild()). + */ + onRebuild_: function() { + } + }; + + return { + RebuildableBehavior: RebuildableBehavior + }; +}); +</script> |