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

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

Issue 2319393002: DevTools: Fix race condition in TextPrompt completions (Closed)
Patch Set: Rename to completionRequestId Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js b/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
index ffd47423e462767910bb2081411566c8cbaf4850..e7882c1ba6505c622a9cd5ad863a4d9d96a1797c 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
@@ -45,6 +45,7 @@ WebInspector.TextPrompt = function(completions, stopCharacters)
this._completionStopCharacters = stopCharacters || " =:[({;,!+-*/&|^<>.";
this._autocompletionTimeout = WebInspector.TextPrompt.DefaultAutocompletionTimeout;
this._title = "";
+ this._completionRequestId = 0;
}
WebInspector.TextPrompt.DefaultAutocompletionTimeout = 250;
@@ -380,7 +381,6 @@ WebInspector.TextPrompt.prototype = {
clearTimeout(this._completeTimeout);
delete this._completeTimeout;
}
- delete this._waitingForCompletions;
if (!this.autoCompleteElement)
return;
@@ -431,8 +431,7 @@ WebInspector.TextPrompt.prototype = {
}
var wordPrefixRange = selectionRange.startContainer.rangeOfWord(selectionRange.startOffset, this._completionStopCharacters, this._element, "backward");
- this._waitingForCompletions = true;
- this._loadCompletions(/** @type {!Element} */ (this._proxyElement), wordPrefixRange, force || false, this._completionsReady.bind(this, selection, wordPrefixRange, !!reverse, !!force));
+ this._loadCompletions(/** @type {!Element} */ (this._proxyElement), wordPrefixRange, force || false, this._completionsReady.bind(this, ++this._completionRequestId, selection, wordPrefixRange, !!reverse, !!force));
},
disableDefaultSuggestionForEmptyInput: function()
@@ -496,6 +495,7 @@ WebInspector.TextPrompt.prototype = {
},
/**
+ * @param {number} completionRequestId
* @param {!Selection} selection
* @param {!Range} originalWordPrefixRange
* @param {boolean} reverse
@@ -503,8 +503,11 @@ WebInspector.TextPrompt.prototype = {
* @param {!Array.<string>} completions
* @param {number=} selectedIndex
*/
- _completionsReady: function(selection, originalWordPrefixRange, reverse, force, completions, selectedIndex)
+ _completionsReady: function(completionRequestId, selection, originalWordPrefixRange, reverse, force, completions, selectedIndex)
{
+ if (this._completionRequestId !== completionRequestId)
+ return;
+
var prefix = originalWordPrefixRange.toString();
// Filter out dupes.
@@ -519,13 +522,11 @@ WebInspector.TextPrompt.prototype = {
annotatedCompletions = this.additionalCompletions(prefix).concat(annotatedCompletions);
}
- if (!this._waitingForCompletions || !annotatedCompletions.length) {
+ if (!annotatedCompletions.length) {
this.clearAutoComplete();
return;
}
- delete this._waitingForCompletions;
-
var selectionRange = selection.getRangeAt(0);
var fullWordRange = this._createRange();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698