RESOLVED WONTFIX 42922
[chromium] WebViewClient should have an elementClicked() method
https://bugs.webkit.org/show_bug.cgi?id=42922
Summary [chromium] WebViewClient should have an elementClicked() method
Jay Civelli
Reported 2010-07-23 17:58:26 PDT
In order to factor out the autofill client from WebKit to Chromium, Chromium needs an easy way of knowing an input element has been clicked and whether or not that element had focus before it was clicked. This is so autofill suggestion popups can be shown when an input element is clicked.
Attachments
Initial patch (2.30 KB, patch)
2010-07-23 18:01 PDT, Jay Civelli
no flags
Fixed style. (2.30 KB, patch)
2010-07-23 18:20 PDT, Jay Civelli
no flags
Really fixing style (2.28 KB, patch)
2010-07-25 08:31 PDT, Jay Civelli
fishd: review-
Jay Civelli
Comment 1 2010-07-23 18:01:29 PDT
Created attachment 62480 [details] Initial patch
WebKit Review Bot
Comment 2 2010-07-23 18:02:56 PDT
Attachment 62480 [details] did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1 WebKit/chromium/public/WebViewClient.h:153: One or more unexpected \r (^M) found; better to use only a \n [whitespace/carriage_return] [1] Suppressing further [whitespace/carriage_return] reports for this file. WebKit/chromium/public/WebViewClient.h:153: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] WebKit/chromium/public/WebViewClient.h:154: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] WebKit/chromium/public/WebViewClient.h:155: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 5 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
Jay Civelli
Comment 3 2010-07-23 18:20:32 PDT
Created attachment 62481 [details] Fixed style.
WebKit Review Bot
Comment 4 2010-07-23 18:23:43 PDT
Attachment 62481 [details] did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1 WebKit/chromium/public/WebViewClient.h:153: One or more unexpected \r (^M) found; better to use only a \n [whitespace/carriage_return] [1] Suppressing further [whitespace/carriage_return] reports for this file. Total errors found: 2 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
James Hawkins
Comment 5 2010-07-23 23:27:08 PDT
LGTM, minus style fixes.
Jay Civelli
Comment 6 2010-07-25 08:31:34 PDT
Created attachment 62525 [details] Really fixing style
Darin Fisher (:fishd, Google)
Comment 7 2010-07-25 20:54:53 PDT
Comment on attachment 62525 [details] Really fixing style WebKit/chromium/src/WebViewImpl.cpp:386 + if (!clickedElement.isNull()) { are you sure you want to run this callback right in the middle of the mouseDown handler? could that result in some interesting re-entrancy bugs? suppose the inputElementClicked method did something to change focus. could that be bad? i see the code following this checking focusedWebCoreNode. WebKit/chromium/public/WebViewClient.h:155 + virtual void inputElementClicked(const WebInputElement& element, bool alreadyFocused) { } style-nit: no need for the "element" parameter name since it does not add extra info. WebKit/chromium/public/WebViewClient.h:155 + virtual void inputElementClicked(const WebInputElement& element, bool alreadyFocused) { } this name is a bit confusing. based on the implementation, it seems that this will happen whenever a mousedown event happens to result in the focused node being an <input> element. it does not necessarily mean that the mousedown event was dispatched to an <input> element. couldn't i write an event handler that focused an <input> element during event processing? that would screw up this implementation, right? if you really want to know if a "click" event was dispatched to an <input> element, then I think you need to somehow hook into the defaultEventHandler for the HTMLInputElement. also, there is a difference between the "click" event and the "mousedown" event. i can't tell if that distinction matters to you.
Darin Fisher (:fishd, Google)
Comment 8 2010-07-25 20:59:46 PDT
For reference, the "click" event is defined here: http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-MouseEvent Notice that a "click" corresponds to a mousedown followed by a mouseup. Have you considered just using an event listener?
Jay Civelli
Comment 9 2010-08-02 16:07:35 PDT
@fishd Sorry my patch was wrong. I meant to have clickedElement be the clickedNode, not the focused element. As you suggest, I could probably use an event listener from the Chromium side instead. I could add an event listener for mousedown on the document in render_view.cc I have to use mousedown instead of click because by the time I get notified of the click, the mousedown event already focused the field and I have no way of knowing if the input field was focused before it was clicked (I need to know that so we can have the autofill behavior where clicking a focused input shows the autofill popup). I am not sure there is a reentrency problem in that case, but I can see how some other listeners might change the focus. In that case we probably would not want to notify for autofill purposes. I could post a task so to process the notification and check which element is focused after all listeners have returned (once the stack has unwinded). Do you think it makes sense?
Jay Civelli
Comment 10 2010-11-18 10:36:36 PST
Addressed on the Chromium side.
Note You need to log in before you can comment on or make changes to this bug.