Bug 73900 - Web Inspector: [TextPrompt] Autocomplete improperly determines user input
Summary: Web Inspector: [TextPrompt] Autocomplete improperly determines user input
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Alexander Pavlov (apavlov)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-06 03:06 PST by Alexander Pavlov (apavlov)
Modified: 2011-12-08 02:36 PST (History)
10 users (show)

See Also:


Attachments
Patch (4.47 KB, patch)
2011-12-06 03:12 PST, Alexander Pavlov (apavlov)
no flags Details | Formatted Diff | Diff
[PATCH] Comments addressed (4.50 KB, patch)
2011-12-06 04:13 PST, Alexander Pavlov (apavlov)
yurys: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Pavlov (apavlov) 2011-12-06 03:06:09 PST
The underlying cause is that a handler invoked as setTimeout(.., 0) from keydown handler gets run BEFORE the keypress and textInput events are dispatched, presumably due to some weird change in WebKit.

Upstreaming http://code.google.com/p/chromium/issues/detail?id=106224
Comment 1 Alexander Pavlov (apavlov) 2011-12-06 03:12:58 PST
Created attachment 118015 [details]
Patch
Comment 2 Yury Semikhatsky 2011-12-06 03:59:59 PST
Comment on attachment 118015 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=118015&action=review

> Source/WebCore/ChangeLog:5
> +

Please describe the fix here.

> Source/WebCore/inspector/front-end/TextPrompt.js:346
> +        var immediately = this.isSuggestBoxVisible() || this._autocompleteRequestForced;

Could you extract this code into a separate method and call it directly where you pass actuateNow=true. This way you could get rid of actuateNow parameter.
Comment 3 Alexander Pavlov (apavlov) 2011-12-06 04:13:24 PST
Created attachment 118022 [details]
[PATCH] Comments addressed
Comment 4 Alexander Pavlov (apavlov) 2011-12-06 04:55:15 PST
A small investigation has shown that the sequence of keydown, keypress, textInput (a.k.a input) events is NOT dispatched synchronously. For one, in Chromium the "keydown" event arrives into Source/WebKit/chromium/src/WebViewImpl.cpp (handleInputEvent) as WebInputEvent::[Raw]KeyDown over IPC, while the "keypress" event arrives into the same method in a DIFFERENT IPC message as WebInputEvent::Char. Obviously, anything can happen between these two invocations of handleInputEvent(), including a triggering of a DOM timer (setTimeout). Hence, the correct solution seems to be the autocompletion of user input in the "input" event handler, which has been implemented in the suggested patch.
Comment 5 Yury Semikhatsky 2011-12-06 05:16:38 PST
Comment on attachment 118022 [details]
[PATCH] Comments addressed

View in context: https://bugs.webkit.org/attachment.cgi?id=118022&action=review

> Source/WebCore/inspector/front-end/TextPrompt.js:329
> +        this._autocompleteRequestForced = force || false;

Please rename _autocompleteRequestForced to something more appropriate that would reflect that it can have one of three states.

> Source/WebCore/inspector/front-end/TextPrompt.js:330
> +        return;

Remove this line.
Comment 6 Alexander Pavlov (apavlov) 2011-12-06 05:20:50 PST
(In reply to comment #5)
> (From update of attachment 118022 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=118022&action=review
> 
> > Source/WebCore/inspector/front-end/TextPrompt.js:329
> > +        this._autocompleteRequestForced = force || false;
> 
> Please rename _autocompleteRequestForced to something more appropriate that would reflect that it can have one of three states.

Renamed to _autocompleteRequestState.

> > Source/WebCore/inspector/front-end/TextPrompt.js:330
> > +        return;
> 
> Remove this line.

Done.
Comment 7 Alexander Pavlov (apavlov) 2011-12-08 02:36:26 PST
This issue has been determined to be a Chromium-specific regression, so the workaround patch should not be landed.