blob: 7eeff9715a90a1dfe5018ba6e91fa24aebf3c084 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2015 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="/core/trace_model/selection_state.html">
<script>
'use strict';
/**
* @fileoverview Provides the SelectableItem class.
*/
tv.exportTo('tv.c.trace_model', function() {
var SelectionState = tv.c.trace_model.SelectionState;
/**
* A SelectableItem is the abstract base class for any non-container data that
* has an associated model item in the trace model (possibly itself).
*
* Subclasses must provide a selectionState property (or getter).
*
* @constructor
*/
function SelectableItem(modelItem) {
this.modelItem_ = modelItem;
}
SelectableItem.prototype = {
get modelItem() {
return this.modelItem_;
},
get selected() {
return this.selectionState === SelectionState.SELECTED;
},
addToSelection: function(selection) {
var modelItem = this.modelItem_;
if (!modelItem)
return;
selection.push(modelItem);
},
addToTrackMap: function(eventToTrackMap, track) {
var modelItem = this.modelItem_;
if (!modelItem)
return;
eventToTrackMap.addEvent(modelItem, track);
}
};
return {
SelectableItem: SelectableItem
};
});
</script>