blob: 4118d40e3e5a8d4a061c74cacb7154d7b0b1b71a [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright 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="/tracing/core/scripting_controller.html">
<link rel="import" href="/tracing/extras/tquery/filter.html">
<link rel="import" href="/tracing/extras/tquery/filter_not.html">
<script>
'use strict';
tr.exportTo('tr.e.tquery', function() {
function FilterAnyOf(opt_subExpressions) {
tr.e.tquery.Filter.call(this);
this.subExpressions = opt_subExpressions || [];
};
FilterAnyOf.prototype = {
__proto__: tr.e.tquery.Filter.prototype,
set subExpressions(exprs) {
this.subExpressions_ = [];
for (var i = 0; i < exprs.length; i++) {
this.subExpressions_.push(
tr.e.tquery.Filter.normalizeFilterExpression(exprs[i]));
}
},
get subExpressions() {
return this.subExpressions_;
},
evaluate: function(context) {
if (!this.subExpressions.length)
return true;
for (var i = 0; i < this.subExpressions.length; i++) {
if (this.subExpressions[i].evaluate(context))
return true;
}
return false;
}
};
tr.c.ScriptingObjectRegistry.register(
function() {
var exprs = Array.prototype.slice.call(arguments);
return new FilterAnyOf(exprs);
},
{
name: 'anyOf'
}
);
tr.c.ScriptingObjectRegistry.register(
function() {
var exprs = Array.prototype.slice.call(arguments);
return new tr.e.tquery.FilterNot(new FilterAnyOf(exprs));
},
{
name: 'noneOf'
}
);
return {
FilterAnyOf: FilterAnyOf
};
});
</script>