Commit ccc74633 authored by manuk's avatar manuk Committed by Commit Bot

[chrome:omnibox] Use `OutputProperty.text` instead of DOM text when filtering rows.

This allows us to 1) have smarter filtering; e.g. filtering for bookmarked properties with 'is bookmarked' (separate CL) and 2) avoid unnecessarily going through the DOM for something.

Bug: 891303
Change-Id: I336096881f0fcd2e90a621ab2e54853c83e01608
Reviewed-on: https://chromium-review.googlesource.com/c/1357311Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612734}
parent db624ec2
...@@ -562,6 +562,11 @@ cr.define('omnibox_output', function() { ...@@ -562,6 +562,11 @@ cr.define('omnibox_output', function() {
get hasAdditionalProperties() { get hasAdditionalProperties() {
return Object.keys(this.additionalProperties).length > 0; return Object.keys(this.additionalProperties).length > 0;
} }
/** @return !Array<!OutputProperty> */
get allProperties() {
return Object.values(this.properties).concat(this.additionalProperties);
}
} }
/** @abstract */ /** @abstract */
...@@ -767,11 +772,10 @@ cr.define('omnibox_output', function() { ...@@ -767,11 +772,10 @@ cr.define('omnibox_output', function() {
* @return {boolean} * @return {boolean}
*/ */
static filterMatch_(match, filterText) { static filterMatch_(match, filterText) {
const row = match.associatedElement;
const cells = Array.from(row.querySelectorAll('td'));
const regexFilter = Array.from(filterText).join('(.*\\.)?'); const regexFilter = Array.from(filterText).join('(.*\\.)?');
return cells return match.allProperties
.map(cell => FilterDelegate.textToWords_(cell.textContent).join('.')) .map(property => property.text)
.map(text => FilterDelegate.textToWords_(text).join('.'))
.some(text => text.match(regexFilter)); .some(text => text.match(regexFilter));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment