WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
119727
Do not dispatch 'focus' or 'blur' event twice when window active state is changed
https://bugs.webkit.org/show_bug.cgi?id=119727
Summary
Do not dispatch 'focus' or 'blur' event twice when window active state is cha...
Ryosuke Niwa
Reported
2013-08-12 21:10:52 PDT
* Bug On Windows, 'focus' event for the window object or a focused element is dispatched twice when the browser tab gets active, and 'blue' evnet is dispatched twice when the browser tab gets inactive. On OSX, 'blur' evnet is dispatched twice when the browser tab gets inactive. On Android, we don't have this bug. * Root cause Focus/blue event is dispatched in dispatchEventsOnWindowAndFocusedNode in these cases. FocusController::setFocused(bool) calls it, and FocusController::setActive(bool) also calls it if setFocused(true) was already called. On Windows, these functions are called in the following sequence: Activation: WebView::setFocus(true) FocusController::setFocused(true) FocusController::setActive(true) WebView::setIsActive(true) Inactivation: WebView::setIsActive(false) FocusController::setActive(false) WebView::setFocus(false) FocusController::setFocused(false) On OSX, these functions are called in the following sequence: Activation: WebView::setIsActive(true) FocusController::setActive(true) WebView::setFocus(true) FocusController::setFocused(true) FocusController::setActive(true) Inactivation: WebView::setIsActive(false) FocusController::setActive(false) WebView::setFocus(false) FocusController::setFocused(false); On Android, these functions are called in the following sequence: Activation: WebView::setFocus(true) FocusController::setFocused(true) FocusController::setActive(true) Inactivation: WebView::setFocus(false) FocusController::setFocused(false); * Fix We don't need to call dispatchEventsOnWindowAndFocusedNode in setActive() because we don't make a window focused state true when the window is inactive.
Attachments
Add attachment
proposed patch, testcase, etc.
Kent Tamura
Comment 1
2013-08-13 18:40:42 PDT
AFAIK, Apple Mac port doesn't have this issue. Test page:
http://jsfiddle.net/FbzNA/
Ryosuke Niwa
Comment 2
2013-08-13 19:41:01 PDT
(In reply to
comment #1
)
> AFAIK, Apple Mac port doesn't have this issue. > > Test page:
http://jsfiddle.net/FbzNA/
Thanks for the info! We should probably add a test though.
Ahmad Saleem
Comment 3
2022-09-20 04:45:22 PDT
(In reply to Ryosuke Niwa from
comment #2
)
> (In reply to
comment #1
) > > AFAIK, Apple Mac port doesn't have this issue. > > > > Test page:
http://jsfiddle.net/FbzNA/
> > Thanks for the info! We should probably add a test though.
This commit does not have any test -
https://src.chromium.org/viewvc/blink?view=revision&revision=155558
Do we require this at this point? Thanks!
Ahmad Saleem
Comment 4
2022-09-29 14:36:52 PDT
(In reply to Ahmad Saleem from
comment #3
)
> (In reply to Ryosuke Niwa from
comment #2
) > > (In reply to
comment #1
) > > > AFAIK, Apple Mac port doesn't have this issue. > > > > > > Test page:
http://jsfiddle.net/FbzNA/
> > > > Thanks for the info! We should probably add a test though. > > This commit does not have any test - >
https://src.chromium.org/viewvc/blink?view=revision&revision=155558
> > Do we require this at this point? Thanks!
It seems to be reproducible in macOS 12.6 using testcase mentioned on
Comment 01
: *** Safari 16 *** Thu Sep 29 2022 22:34:59 GMT+0100 (British Summer Time): window focus Thu Sep 29 2022 22:35:01 GMT+0100 (British Summer Time): window blur Thu Sep 29 2022 22:35:02 GMT+0100 (British Summer Time): window focus Thu Sep 29 2022 22:35:02 GMT+0100 (British Summer Time): window focus ^ When you activate JSFiddle result window and then you switch to other tab and come back *** Chrome Canary 108 *** Thu Sep 29 2022 22:35:43 GMT+0100 (British Summer Time): window focus Thu Sep 29 2022 22:35:45 GMT+0100 (British Summer Time): window blur Thu Sep 29 2022 22:35:45 GMT+0100 (British Summer Time): window focus *** Firefox Nightly 107 *** Thu Sep 29 2022 22:36:17 GMT+0100 (British Summer Time): window focus Thu Sep 29 2022 22:36:18 GMT+0100 (British Summer Time): window blur Thu Sep 29 2022 22:36:19 GMT+0100 (British Summer Time): window focus ______ As can be seen "Safari" show "window focus" twice when activating tab again.
Ahmad Saleem
Comment 5
2022-09-29 14:44:29 PDT
I tried to land this in following:
https://github.com/WebKit/WebKit/pull/4808
but it didn't compile and give quite a few errors, which I am not able to resolve. So appreciate if someone else can try. Thanks!
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug