| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {HTMLInputElement} | 7 * @extends {HTMLInputElement} |
| 8 */ | 8 */ |
| 9 WebInspector.HistoryInput = function() | 9 WebInspector.HistoryInput = function() |
| 10 { | 10 { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 }, | 40 }, |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * @param {!Event} event | 43 * @param {!Event} event |
| 44 */ | 44 */ |
| 45 _onKeyDown: function(event) | 45 _onKeyDown: function(event) |
| 46 { | 46 { |
| 47 if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Up.code) { | 47 if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Up.code) { |
| 48 this._historyPosition = Math.max(this._historyPosition - 1, 0); | 48 this._historyPosition = Math.max(this._historyPosition - 1, 0); |
| 49 this.value = this._history[this._historyPosition]; | 49 this.value = this._history[this._historyPosition]; |
| 50 this.dispatchEvent(createEvent("input", true, true)); | 50 this.dispatchEvent(new Event("input", {"bubbles": true, "cancelable"
: true})); |
| 51 event.consume(true); | 51 event.consume(true); |
| 52 } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Down.cod
e) { | 52 } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Down.cod
e) { |
| 53 this._historyPosition = Math.min(this._historyPosition + 1, this._hi
story.length - 1); | 53 this._historyPosition = Math.min(this._historyPosition + 1, this._hi
story.length - 1); |
| 54 this.value = this._history[this._historyPosition]; | 54 this.value = this._history[this._historyPosition]; |
| 55 this.dispatchEvent(createEvent("input", true, true)); | 55 this.dispatchEvent(new Event("input", {"bubbles": true, "cancelable"
: true})); |
| 56 event.consume(true); | 56 event.consume(true); |
| 57 } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.co
de) { | 57 } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.co
de) { |
| 58 this._saveToHistory(); | 58 this._saveToHistory(); |
| 59 } | 59 } |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 _saveToHistory: function() | 62 _saveToHistory: function() |
| 63 { | 63 { |
| 64 if (this._history.length > 1 && this._history[this._history.length - 2]
=== this.value) | 64 if (this._history.length > 1 && this._history[this._history.length - 2]
=== this.value) |
| 65 return; | 65 return; |
| 66 this._history[this._history.length - 1] = this.value; | 66 this._history[this._history.length - 1] = this.value; |
| 67 this._historyPosition = this._history.length - 1; | 67 this._historyPosition = this._history.length - 1; |
| 68 this._history.push(""); | 68 this._history.push(""); |
| 69 }, | 69 }, |
| 70 | 70 |
| 71 __proto__: HTMLInputElement.prototype | 71 __proto__: HTMLInputElement.prototype |
| 72 } | 72 } |
| 73 | 73 |
| OLD | NEW |