OLD | NEW |
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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 * @param {boolean=} force | 350 * @param {boolean=} force |
351 */ | 351 */ |
352 autoCompleteSoon: function(force) | 352 autoCompleteSoon: function(force) |
353 { | 353 { |
354 var immediately = this.isSuggestBoxVisible() || force; | 354 var immediately = this.isSuggestBoxVisible() || force; |
355 if (!this._completeTimeout) | 355 if (!this._completeTimeout) |
356 this._completeTimeout = setTimeout(this.complete.bind(this, force),
immediately ? 0 : 250); | 356 this._completeTimeout = setTimeout(this.complete.bind(this, force),
immediately ? 0 : 250); |
357 }, | 357 }, |
358 | 358 |
359 /** | 359 /** |
| 360 * @param {boolean=} force |
360 * @param {boolean=} reverse | 361 * @param {boolean=} reverse |
361 */ | 362 */ |
362 complete: function(force, reverse) | 363 complete: function(force, reverse) |
363 { | 364 { |
364 this.clearAutoComplete(true); | 365 this.clearAutoComplete(true); |
365 var selection = window.getSelection(); | 366 var selection = window.getSelection(); |
366 if (!selection.rangeCount) | 367 if (!selection.rangeCount) |
367 return; | 368 return; |
368 | 369 |
369 var selectionRange = selection.getRangeAt(0); | 370 var selectionRange = selection.getRangeAt(0); |
370 var shouldExit; | 371 var shouldExit; |
371 | 372 |
372 if (!force && !this.isCaretAtEndOfPrompt() && !this.isSuggestBoxVisible(
)) | 373 if (!force && !this.isCaretAtEndOfPrompt() && !this.isSuggestBoxVisible(
)) |
373 shouldExit = true; | 374 shouldExit = true; |
374 else if (!selection.isCollapsed) | 375 else if (!selection.isCollapsed) |
375 shouldExit = true; | 376 shouldExit = true; |
376 else if (!force) { | 377 else if (!force) { |
377 // BUG72018: Do not show suggest box if caret is followed by a non-s
top character. | 378 // BUG72018: Do not show suggest box if caret is followed by a non-s
top character. |
378 var wordSuffixRange = selectionRange.startContainer.rangeOfWord(sele
ctionRange.endOffset, this._completionStopCharacters, this._element, "forward"); | 379 var wordSuffixRange = selectionRange.startContainer.rangeOfWord(sele
ctionRange.endOffset, this._completionStopCharacters, this._element, "forward"); |
379 if (wordSuffixRange.toString().length) | 380 if (wordSuffixRange.toString().length) |
380 shouldExit = true; | 381 shouldExit = true; |
381 } | 382 } |
382 if (shouldExit) { | 383 if (shouldExit) { |
383 this.hideSuggestBox(); | 384 this.hideSuggestBox(); |
384 return; | 385 return; |
385 } | 386 } |
386 | 387 |
387 var wordPrefixRange = selectionRange.startContainer.rangeOfWord(selectio
nRange.startOffset, this._completionStopCharacters, this._element, "backward"); | 388 var wordPrefixRange = selectionRange.startContainer.rangeOfWord(selectio
nRange.startOffset, this._completionStopCharacters, this._element, "backward"); |
388 this._waitingForCompletions = true; | 389 this._waitingForCompletions = true; |
389 this._loadCompletions(this.proxyElement, wordPrefixRange, force, this._c
ompletionsReady.bind(this, selection, wordPrefixRange, !!reverse)); | 390 this._loadCompletions(this.proxyElement, wordPrefixRange, force || false
, this._completionsReady.bind(this, selection, wordPrefixRange, !!reverse)); |
390 }, | 391 }, |
391 | 392 |
392 disableDefaultSuggestionForEmptyInput: function() | 393 disableDefaultSuggestionForEmptyInput: function() |
393 { | 394 { |
394 this._disableDefaultSuggestionForEmptyInput = true; | 395 this._disableDefaultSuggestionForEmptyInput = true; |
395 }, | 396 }, |
396 | 397 |
397 /** | 398 /** |
398 * @param {!Selection} selection | 399 * @param {!Selection} selection |
399 * @param {!Range} textRange | 400 * @param {!Range} textRange |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 | 899 |
899 return; | 900 return; |
900 } | 901 } |
901 | 902 |
902 WebInspector.TextPrompt.prototype.onKeyDown.apply(this, arguments); | 903 WebInspector.TextPrompt.prototype.onKeyDown.apply(this, arguments); |
903 }, | 904 }, |
904 | 905 |
905 __proto__: WebInspector.TextPrompt.prototype | 906 __proto__: WebInspector.TextPrompt.prototype |
906 } | 907 } |
907 | 908 |
OLD | NEW |