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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/console/ConsolePrompt.js

Issue 2565113002: DevTools: update console viewport scroll when prompt is resized (Closed)
Patch Set: yay Created 3 years, 9 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 Console.ConsolePrompt = class extends UI.Widget { 7 Console.ConsolePrompt = class extends UI.Widget {
8 constructor() { 8 constructor() {
9 super(); 9 super();
10 this._addCompletionsFromHistory = true; 10 this._addCompletionsFromHistory = true;
(...skipping 14 matching lines...) Expand all
25 this._editor = 25 this._editor =
26 factory.createEditor({lineNumbers: false, lineWrapping: true, mimeType : 'javascript', autoHeight: true}); 26 factory.createEditor({lineNumbers: false, lineWrapping: true, mimeType : 'javascript', autoHeight: true});
27 27
28 this._editor.configureAutocomplete({ 28 this._editor.configureAutocomplete({
29 substituteRangeCallback: this._substituteRange.bind(this), 29 substituteRangeCallback: this._substituteRange.bind(this),
30 suggestionsCallback: this._wordsWithQuery.bind(this), 30 suggestionsCallback: this._wordsWithQuery.bind(this),
31 captureEnter: true 31 captureEnter: true
32 }); 32 });
33 this._editor.widget().element.addEventListener('keydown', this._editorKeyD own.bind(this), true); 33 this._editor.widget().element.addEventListener('keydown', this._editorKeyD own.bind(this), true);
34 this._editor.widget().show(this.element); 34 this._editor.widget().show(this.element);
35 this._editor.widget().on(UI.TextEditor.TextChangedEvent, this._onTextChang ed, this);
pfeldman 2017/03/24 22:28:33 You don't know that the widget is editor, this cal
luoe 2017/03/28 17:40:41 einbinder@, wdyt about adding a text changed handl
luoe 2017/03/31 02:18:08 Done, Updated TextEditor to extend Common.EventTar
35 36
36 this.setText(this._initialText); 37 this.setText(this._initialText);
37 delete this._initialText; 38 delete this._initialText;
38 if (this.hasFocus()) 39 if (this.hasFocus())
39 this.focus(); 40 this.focus();
40 this.element.tabIndex = -1; 41 this.element.tabIndex = -1;
41 42
42 this._editorSetForTest(); 43 this._editorSetForTest();
43 } 44 }
44 } 45 }
45 46
47 _onTextChanged() {
48 this.emit(new Console.ConsolePrompt.TextChangedEvent());
49 }
50
46 /** 51 /**
47 * @return {!Console.ConsoleHistoryManager} 52 * @return {!Console.ConsoleHistoryManager}
48 */ 53 */
49 history() { 54 history() {
50 return this._history; 55 return this._history;
51 } 56 }
52 57
53 clearAutocomplete() { 58 clearAutocomplete() {
54 if (this._editor) 59 if (this._editor)
55 this._editor.clearAutocomplete(); 60 this._editor.clearAutocomplete();
(...skipping 12 matching lines...) Expand all
68 } 73 }
69 74
70 /** 75 /**
71 * @param {string} text 76 * @param {string} text
72 */ 77 */
73 setText(text) { 78 setText(text) {
74 if (this._editor) 79 if (this._editor)
75 this._editor.setText(text); 80 this._editor.setText(text);
76 else 81 else
77 this._initialText = text; 82 this._initialText = text;
83 this.emit(new Console.ConsolePrompt.TextChangedEvent());
78 } 84 }
79 85
80 /** 86 /**
81 * @return {string} 87 * @return {string}
82 */ 88 */
83 text() { 89 text() {
84 return this._editor ? this._editor.text() : this._initialText; 90 return this._editor ? this._editor.text() : this._initialText;
85 } 91 }
86 92
87 /** 93 /**
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 136
131 if (newText === undefined) 137 if (newText === undefined)
132 return; 138 return;
133 keyboardEvent.consume(true); 139 keyboardEvent.consume(true);
134 this.setText(newText); 140 this.setText(newText);
135 141
136 if (isPrevious) 142 if (isPrevious)
137 this._editor.setSelection(Common.TextRange.createFromLocation(0, Infinity) ); 143 this._editor.setSelection(Common.TextRange.createFromLocation(0, Infinity) );
138 else 144 else
139 this.moveCaretToEndOfPrompt(); 145 this.moveCaretToEndOfPrompt();
140 this.setMinimumSize(0, this._editor.widget().element.offsetHeight);
141 } 146 }
142 147
143 /** 148 /**
144 * @param {!KeyboardEvent} event 149 * @param {!KeyboardEvent} event
145 */ 150 */
146 _enterKeyPressed(event) { 151 _enterKeyPressed(event) {
147 if (event.altKey || event.ctrlKey || event.shiftKey) 152 if (event.altKey || event.ctrlKey || event.shiftKey)
148 return; 153 return;
149 154
150 event.consume(true); 155 event.consume(true);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 return this._currentHistoryItem(); 366 return this._currentHistoryItem();
362 } 367 }
363 368
364 /** 369 /**
365 * @return {string|undefined} 370 * @return {string|undefined}
366 */ 371 */
367 _currentHistoryItem() { 372 _currentHistoryItem() {
368 return this._data[this._data.length - this._historyOffset]; 373 return this._data[this._data.length - this._historyOffset];
369 } 374 }
370 }; 375 };
376
377 /** @implements {Common.Emittable} */
378 Console.ConsolePrompt.TextChangedEvent = class {};
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698