Bug 37961

Summary: Add a way for Widget to know about focus loss
Product: WebKit Reporter: Stuart Morgan <stuartmorgan>
Component: WebCore Misc.Assignee: Stuart Morgan <stuartmorgan>
Status: RESOLVED FIXED    
Severity: Normal CC: amohr, commit-queue, fishd, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Adds blur() to Widget
none
Adds blur() to Widget
none
Adds boolean argument to setFocus none

Stuart Morgan
Reported 2010-04-21 17:20:42 PDT
Currently, Widget has a setFocus() method to tell it that it has received focus, but no way of finding out that it has lost focus. This makes it impossible to correctly implemented focus for windowless plugins that don't have a corresponding native OS view--which Chromium on the Mac, at least, does not (and there are indications in the code that Mac Safari is, or at least once was) exploring the possibility of doing this.
Attachments
Adds blur() to Widget (8.55 KB, patch)
2010-04-21 17:30 PDT, Stuart Morgan
no flags
Adds blur() to Widget (9.07 KB, patch)
2010-04-22 10:02 PDT, Stuart Morgan
no flags
Adds boolean argument to setFocus (17.31 KB, patch)
2010-05-05 08:46 PDT, Stuart Morgan
no flags
Stuart Morgan
Comment 1 2010-04-21 17:30:59 PDT
Created attachment 54008 [details] Adds blur() to Widget This adds blur() to Widget, along with an empty implementation on all platforms, and causes it to be called the same way setFocus() is currently called. Also adds the plumbing to connect blur() to the appropriate plugin method in Chromium (currently a no-op, but necessary for later non-WebKit Chromium changes). No actual behavior changes should result from this patch. It will be up to platforms to start using this new method as they need it.
WebKit Review Bot
Comment 2 2010-04-21 17:35:41 PDT
Attachment 54008 [details] did not pass style-queue: Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1 WebCore/dom/Document.cpp:2873: Declaration has space between type name and * in Widget *blurWidget [whitespace/declaration] [3] Total errors found: 1 in 16 files If any of these errors are false positives, please file a bug against check-webkit-style.
Stuart Morgan
Comment 3 2010-04-22 10:02:15 PDT
Created attachment 54069 [details] Adds blur() to Widget Fixes style issue (in both the new code and the code it was based on)
Darin Fisher (:fishd, Google)
Comment 4 2010-05-03 09:39:06 PDT
Comment on attachment 54069 [details] Adds blur() to Widget WebCore/platform/Widget.h:155 + virtual void setFocus(); how about just passing a 'bool focused' to setFocus?
Stuart Morgan
Comment 5 2010-05-03 09:47:46 PDT
The only reason is that it would be a much more invasive change. I would have to find and change the existing implementation of setFocus in every descendent of Widget in every port, which would touch a lot more files and actually change existing logic. The chance of a build break or regression would be much higher. Since there didn't seem to be an obvious preference for bool-argument setters in other cases (e.g., Widget has show() and hide() rather than setVisible(bool)), I opted for the simpler change. I can do it the other way if people feel strongly.
Darin Fisher (:fishd, Google)
Comment 6 2010-05-04 14:19:38 PDT
It just struck me that 'setFocus' and 'blur' do not read like opposites. Maybe the new method should be named setBlur? That reads a bit funny though.
Stuart Morgan
Comment 7 2010-05-05 08:46:28 PDT
Created attachment 55128 [details] Adds boolean argument to setFocus I can't come up with a better name, so I gave the setFocus(bool) approach a shot. The QT code unfortunately has a setFocus() call as well, but that was the only other one, so finding the right things to change wasn't as bad as I feared.
WebKit Commit Bot
Comment 8 2010-05-05 09:22:21 PDT
Comment on attachment 55128 [details] Adds boolean argument to setFocus Clearing flags on attachment: 55128 Committed r58821: <http://trac.webkit.org/changeset/58821>
WebKit Commit Bot
Comment 9 2010-05-05 09:22:27 PDT
All reviewed patches have been landed. Closing bug.
Alexander Mohr
Comment 10 2011-03-09 10:35:12 PST
*** Bug 32836 has been marked as a duplicate of this bug. ***
Note You need to log in before you can comment on or make changes to this bug.