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

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

Issue 2469153003: DevTools: Remove ghost text from FilteredListWidget (Closed)
Patch Set: Exit test on rejected promise 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 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 /** 519 /**
520 * @return {boolean} 520 * @return {boolean}
521 */ 521 */
522 _acceptSuggestionInternal() { 522 _acceptSuggestionInternal() {
523 if (!this._prefixRange) 523 if (!this._prefixRange)
524 return false; 524 return false;
525 525
526 var text = this.text(); 526 var text = this.text();
527 this._element.textContent = text.substring(0, this._prefixRange.startColumn) + this._currentSuggestion + 527 this._element.textContent = text.substring(0, this._prefixRange.startColumn) + this._currentSuggestion +
528 text.substring(this._prefixRange.endColumn); 528 text.substring(this._prefixRange.endColumn);
529 this._setDOMSelection( 529 this.setDOMSelection(
530 this._prefixRange.startColumn + this._currentSuggestion.length, 530 this._prefixRange.startColumn + this._currentSuggestion.length,
531 this._prefixRange.startColumn + this._currentSuggestion.length); 531 this._prefixRange.startColumn + this._currentSuggestion.length);
532 532
533 this.clearAutocomplete(); 533 this.clearAutocomplete();
534 this.dispatchEventToListeners(WebInspector.TextPrompt.Events.ItemAccepted); 534 this.dispatchEventToListeners(WebInspector.TextPrompt.Events.ItemAccepted);
535 535
536 return true; 536 return true;
537 } 537 }
538 538
539 /** 539 /**
540 * @param {number} startColumn 540 * @param {number} startColumn
541 * @param {number} endColumn 541 * @param {number} endColumn
542 */ 542 */
543 _setDOMSelection(startColumn, endColumn) { 543 setDOMSelection(startColumn, endColumn) {
544 this._element.normalize(); 544 this._element.normalize();
545 var node = this._element.childNodes[0]; 545 var node = this._element.childNodes[0];
546 if (!node || node === this._ghostTextElement) 546 if (!node || node === this._ghostTextElement)
547 return; 547 return;
548 var range = this._createRange(); 548 var range = this._createRange();
549 range.setStart(node, startColumn); 549 range.setStart(node, startColumn);
550 range.setEnd(node, endColumn); 550 range.setEnd(node, endColumn);
551 var selection = this._element.getComponentSelection(); 551 var selection = this._element.getComponentSelection();
552 selection.removeAllRanges(); 552 selection.removeAllRanges();
553 selection.addRange(range); 553 selection.addRange(range);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 } 636 }
637 }; 637 };
638 638
639 WebInspector.TextPrompt.DefaultAutocompletionTimeout = 250; 639 WebInspector.TextPrompt.DefaultAutocompletionTimeout = 250;
640 640
641 /** @enum {symbol} */ 641 /** @enum {symbol} */
642 WebInspector.TextPrompt.Events = { 642 WebInspector.TextPrompt.Events = {
643 ItemApplied: Symbol('text-prompt-item-applied'), 643 ItemApplied: Symbol('text-prompt-item-applied'),
644 ItemAccepted: Symbol('text-prompt-item-accepted') 644 ItemAccepted: Symbol('text-prompt-item-accepted')
645 }; 645 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698