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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js

Issue 2545983002: DevTools: Use TextPrompt for FilterBar instead of input element (Closed)
Patch Set: Use textWithCurrentSuggestion Created 4 years 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 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 /** 190 /**
191 * @param {string} title 191 * @param {string} title
192 */ 192 */
193 setTitle(title) { 193 setTitle(title) {
194 this._title = title; 194 this._title = title;
195 if (this._proxyElement) 195 if (this._proxyElement)
196 this._proxyElement.title = title; 196 this._proxyElement.title = title;
197 } 197 }
198 198
199 /**
200 * @param {string} placeholder
201 */
202 setPlaceholder(placeholder) {
203 this._element.setAttribute('data-placeholder', placeholder);
204 }
205
199 _removeFromElement() { 206 _removeFromElement() {
200 this.clearAutocomplete(); 207 this.clearAutocomplete();
201 this._element.removeEventListener('keydown', this._boundOnKeyDown, false); 208 this._element.removeEventListener('keydown', this._boundOnKeyDown, false);
202 this._element.removeEventListener('input', this._boundOnInput, false); 209 this._element.removeEventListener('input', this._boundOnInput, false);
203 this._element.removeEventListener('selectstart', this._boundClearAutocomplet e, false); 210 this._element.removeEventListener('selectstart', this._boundClearAutocomplet e, false);
204 this._element.removeEventListener('blur', this._boundClearAutocomplete, fals e); 211 this._element.removeEventListener('blur', this._boundClearAutocomplete, fals e);
205 this._element.ownerDocument.defaultView.removeEventListener('resize', this._ boundClearAutocomplete, false); 212 this._element.ownerDocument.defaultView.removeEventListener('resize', this._ boundClearAutocomplete, false);
206 if (this._isEditing) 213 if (this._isEditing)
207 this._stopEditing(); 214 this._stopEditing();
208 if (this._suggestBox) 215 if (this._suggestBox)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 var result = false; 317 var result = false;
311 if (this._isSuggestBoxVisible()) 318 if (this._isSuggestBoxVisible())
312 result = this._suggestBox.acceptSuggestion(); 319 result = this._suggestBox.acceptSuggestion();
313 if (!result) 320 if (!result)
314 result = this._acceptSuggestionInternal(); 321 result = this._acceptSuggestionInternal();
315 322
316 return result; 323 return result;
317 } 324 }
318 325
319 clearAutocomplete() { 326 clearAutocomplete() {
327 var beforeText = this.textWithCurrentSuggestion();
328
320 if (this._isSuggestBoxVisible()) 329 if (this._isSuggestBoxVisible())
321 this._suggestBox.hide(); 330 this._suggestBox.hide();
322 this._clearAutocompleteTimeout(); 331 this._clearAutocompleteTimeout();
323 this._queryRange = null; 332 this._queryRange = null;
324 this._refreshGhostText(); 333 this._refreshGhostText();
334
335 if (beforeText !== this.textWithCurrentSuggestion())
336 this.dispatchEventToListeners(UI.TextPrompt.Events.ItemApplied);
325 } 337 }
326 338
327 _refreshGhostText() { 339 _refreshGhostText() {
328 if (this._queryRange && this._isCaretAtEndOfPrompt() && 340 if (this._queryRange && this._isCaretAtEndOfPrompt() &&
329 this._currentSuggestion.startsWith(this.text().substring(this._queryRang e.startColumn))) { 341 this._currentSuggestion.startsWith(this.text().substring(this._queryRang e.startColumn))) {
330 this._ghostTextElement.textContent = 342 this._ghostTextElement.textContent =
331 this._currentSuggestion.substring(this._queryRange.endColumn - this._q ueryRange.startColumn); 343 this._currentSuggestion.substring(this._queryRange.endColumn - this._q ueryRange.startColumn);
332 this._element.appendChild(this._ghostTextElement); 344 this._element.appendChild(this._ghostTextElement);
333 } else { 345 } else {
334 this._ghostTextElement.remove(); 346 this._ghostTextElement.remove();
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 } 635 }
624 }; 636 };
625 637
626 UI.TextPrompt.DefaultAutocompletionTimeout = 250; 638 UI.TextPrompt.DefaultAutocompletionTimeout = 250;
627 639
628 /** @enum {symbol} */ 640 /** @enum {symbol} */
629 UI.TextPrompt.Events = { 641 UI.TextPrompt.Events = {
630 ItemApplied: Symbol('text-prompt-item-applied'), 642 ItemApplied: Symbol('text-prompt-item-applied'),
631 ItemAccepted: Symbol('text-prompt-item-accepted') 643 ItemAccepted: Symbol('text-prompt-item-accepted')
632 }; 644 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698