blob: e15614fce86c1460c9f3c2db5c0ca59b424f2534 [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="/core/scripting_controller.html">
<link rel="import" href="/extras/tquery/filter.html">
<script>
'use strict';
tr.exportTo('tr.e.tquery', function() {
function FilterIsTopLevel(opt_subExpression) {
this.subExpression = opt_subExpression;
}
FilterIsTopLevel.prototype = {
__proto__: tr.e.tquery.Filter.prototype,
set subExpression(expr) {
this.subExpression_ = tr.e.tquery.Filter.normalizeFilterExpression(expr);
},
get subExpression() {
return this.subExpression_;
},
evaluate: function(context) {
if (context.ancestors.length > 0)
return false;
if (!this.subExpression)
return true;
return this.subExpression.evaluate(context);
}
};
tr.c.ScriptingObjectRegistry.register(
function(subExpression) {
return new FilterIsTopLevel(subExpression);
},
{
name: 'isTopLevel'
}
);
return {
FilterIsTopLevel: FilterIsTopLevel
};
});
</script>