Commit 4c1b499d authored by manuk's avatar manuk Committed by Commit Bot

[chrome:omnibox]: Refactoring HTML generation part 1/3, create OutputMatch helper class.

This is the first of 3 CL's to replace the global static helper functions which manipulate the DOM with classes. In this CL, we:

- Replaced the functions createCellForPropertyAndRemoveProperty and addResultTableToOutput with OutputMatch, which is responsible for generating individual HTML rows from individual omnibox matches.

- Moved the data class PresentationInfoRecord and the constants array of PresentationInfoRecord's PROPERTY_OUTPUT_ORDER from omnibox.js to omnibox_output.js as that's where it's now used.

Bug: 891303
Change-Id: If653e16763a3956b0576bf677ede1570626007d7
Reviewed-on: https://chromium-review.googlesource.com/c/1293757
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603225}
parent cd3d77a6
...@@ -23,7 +23,10 @@ ...@@ -23,7 +23,10 @@
.x-mark { .x-mark {
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: contain;
font-size: 0; font-size: 0;
height: 16px;
width: 16px;
} }
.check-mark { .check-mark {
......
This diff is collapsed.
...@@ -2,22 +2,17 @@ ...@@ -2,22 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Helper class to be used as the super class of all Custom Elements in /**
// chrome://omnibox. Constructed with a string id of a <template> element. When * Helper class to be used as the super class of all custom elements in
// this element is added to the DOM, it instantiates its internal DOM from the * chrome://omnibox.
// corresponding <template> element. * @abstract
*/
class OmniboxElement extends HTMLElement { class OmniboxElement extends HTMLElement {
/** @param {string} templateId Template's HTML id attribute */ /** @param {string} templateId */
constructor(templateId) { constructor(templateId) {
super(); super();
/** @type {string} */
this.templateId = templateId;
}
/** @override */
connectedCallback() {
this.attachShadow({mode: 'open'}); this.attachShadow({mode: 'open'});
let template = $(this.templateId).content.cloneNode(true); const template = $(templateId).content.cloneNode(true);
this.shadowRoot.appendChild(template); this.shadowRoot.appendChild(template);
} }
......
...@@ -14,28 +14,29 @@ class OmniboxInputs extends OmniboxElement { ...@@ -14,28 +14,29 @@ class OmniboxInputs extends OmniboxElement {
/** @override */ /** @override */
connectedCallback() { connectedCallback() {
super.connectedCallback(); this.setupElementListeners_();
this.setupElementListeners();
} }
setupElementListeners() { /** @private */
const onQueryInputsChanged = this.onQueryInputsChanged.bind(this); setupElementListeners_() {
const onDisplayInputsChagned = this.onDisplayInputsChagned.bind(this); const onQueryInputsChanged = this.onQueryInputsChanged_.bind(this);
const onDisplayInputsChagned = this.onDisplayInputsChagned_.bind(this);
this.$$('input-text').addEventListener('input', onQueryInputsChanged); this.$$('input-text').addEventListener('input', onQueryInputsChanged);
[ [
this.$$('prevent-inline-autocomplete'), this.$$('prevent-inline-autocomplete'),
this.$$('prefer-keyword'), this.$$('prefer-keyword'),
this.$$('page-classification'), this.$$('page-classification'),
].forEach(element => element.addEventListener('change', onQueryInputsChanged)); ].forEach(elem => elem.addEventListener('change', onQueryInputsChanged));
[ [
this.$$('show-incomplete-results'), this.$$('show-incomplete-results'),
this.$$('show-details'), this.$$('show-details'),
this.$$('show-all-providers'), this.$$('show-all-providers'),
].forEach(element => element.addEventListener('change', onDisplayInputsChagned)); ].forEach(elem => elem.addEventListener('change', onDisplayInputsChagned));
} }
onQueryInputsChanged() { /** @private */
onQueryInputsChanged_() {
this.dispatchEvent(new CustomEvent('query-inputs-changed', { this.dispatchEvent(new CustomEvent('query-inputs-changed', {
detail: { detail: {
inputText: this.$$('input-text').value, inputText: this.$$('input-text').value,
...@@ -47,7 +48,8 @@ class OmniboxInputs extends OmniboxElement { ...@@ -47,7 +48,8 @@ class OmniboxInputs extends OmniboxElement {
})); }));
} }
onDisplayInputsChagned() { /** @private */
onDisplayInputsChagned_() {
this.dispatchEvent(new CustomEvent('display-inputs-changed')); this.dispatchEvent(new CustomEvent('display-inputs-changed'));
} }
} }
......
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