Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/HistoryInput.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/ui/HistoryInput.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/HistoryInput.js b/third_party/WebKit/Source/devtools/front_end/ui/HistoryInput.js
index d8ce8ca5363ad42bc4e8b9cfdae98115552aa6aa..750cc0e116eb6cc44c2c8e9772151dac6ca06022 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/HistoryInput.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/HistoryInput.js
@@ -1,73 +1,69 @@
// 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.
-
/**
- * @constructor
- * @extends {HTMLInputElement}
+ * @unrestricted
*/
-WebInspector.HistoryInput = function()
-{
-};
+WebInspector.HistoryInput = class extends HTMLInputElement {
+ constructor() {
+ super();
+ }
-/**
- * @return {!WebInspector.HistoryInput}
- */
-WebInspector.HistoryInput.create = function()
-{
+ /**
+ * @return {!WebInspector.HistoryInput}
+ */
+ static create() {
if (!WebInspector.HistoryInput._constructor)
- WebInspector.HistoryInput._constructor = registerCustomElement("input", "history-input", WebInspector.HistoryInput.prototype);
+ WebInspector.HistoryInput._constructor =
+ registerCustomElement('input', 'history-input', WebInspector.HistoryInput.prototype);
- return /** @type {!WebInspector.HistoryInput} */(new WebInspector.HistoryInput._constructor());
-};
-
-WebInspector.HistoryInput.prototype = {
- createdCallback: function()
- {
- this._history = [""];
- this._historyPosition = 0;
- this.addEventListener("keydown", this._onKeyDown.bind(this), false);
- this.addEventListener("input", this._onInput.bind(this), false);
- },
+ return /** @type {!WebInspector.HistoryInput} */ (new WebInspector.HistoryInput._constructor());
+ }
- /**
- * @param {!Event} event
- */
- _onInput: function(event)
- {
- if (this._history.length === this._historyPosition + 1)
- this._history[this._history.length - 1] = this.value;
- },
+ /**
+ * @override
+ */
+ createdCallback() {
+ this._history = [''];
+ this._historyPosition = 0;
+ this.addEventListener('keydown', this._onKeyDown.bind(this), false);
+ this.addEventListener('input', this._onInput.bind(this), false);
+ }
- /**
- * @param {!Event} event
- */
- _onKeyDown: function(event)
- {
- if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Up.code) {
- this._historyPosition = Math.max(this._historyPosition - 1, 0);
- this.value = this._history[this._historyPosition];
- this.dispatchEvent(new Event("input", {"bubbles": true, "cancelable": true}));
- event.consume(true);
- } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Down.code) {
- this._historyPosition = Math.min(this._historyPosition + 1, this._history.length - 1);
- this.value = this._history[this._historyPosition];
- this.dispatchEvent(new Event("input", {"bubbles": true, "cancelable": true}));
- event.consume(true);
- } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.code) {
- this._saveToHistory();
- }
- },
+ /**
+ * @param {!Event} event
+ */
+ _onInput(event) {
+ if (this._history.length === this._historyPosition + 1)
+ this._history[this._history.length - 1] = this.value;
+ }
- _saveToHistory: function()
- {
- if (this._history.length > 1 && this._history[this._history.length - 2] === this.value)
- return;
- this._history[this._history.length - 1] = this.value;
- this._historyPosition = this._history.length - 1;
- this._history.push("");
- },
+ /**
+ * @param {!Event} event
+ */
+ _onKeyDown(event) {
+ if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Up.code) {
+ this._historyPosition = Math.max(this._historyPosition - 1, 0);
+ this.value = this._history[this._historyPosition];
+ this.dispatchEvent(new Event('input', {'bubbles': true, 'cancelable': true}));
+ event.consume(true);
+ } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Down.code) {
+ this._historyPosition = Math.min(this._historyPosition + 1, this._history.length - 1);
+ this.value = this._history[this._historyPosition];
+ this.dispatchEvent(new Event('input', {'bubbles': true, 'cancelable': true}));
+ event.consume(true);
+ } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.code) {
+ this._saveToHistory();
+ }
+ }
- __proto__: HTMLInputElement.prototype
+ _saveToHistory() {
+ if (this._history.length > 1 && this._history[this._history.length - 2] === this.value)
+ return;
+ this._history[this._history.length - 1] = this.value;
+ this._historyPosition = this._history.length - 1;
+ this._history.push('');
+ }
};
+

Powered by Google App Engine
This is Rietveld 408576698