Bug 118043 - Mouse press should focus on any types of form controls
Summary: Mouse press should focus on any types of form controls
Status: RESOLVED DUPLICATE of bug 22261
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: BlinkMergeCandidate
Depends on:
Blocks:
 
Reported: 2013-06-26 00:02 PDT by Ryosuke Niwa
Modified: 2021-05-17 02:52 PDT (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2013-06-26 00:02:12 PDT
Consider merging https://chromium.googlesource.com/chromium/blink/+/b9834f34667cd0a4bee67fe702a915950dfb839a

* Background
In WebKit, form controls except text fields and <select> are not
mouse-focusable. This behavior is based on Cocoa native controls.
Though Firefox on Mac behaves same as WebKit, IE, Firefox (non-Mac),
and Opera(Presto) set focus by mouse press.

The WebKit behavior is not Web-compatible.

* Behavior change
We change the behavior so that mouse press sets focus to form controls
to improve web compatibility. However, We haven't set focus until now and
this behavior change might make existing users uncomfortable with focus
rings which appear on click. So, we don't draw focus rings if a form control
was focused by mouse press.

* Implementation
The main part of this CL is to remove HTMLFormControlElement::isMouseFocusable.
It means we use Node::isMouseFocusable, which is just isFocusable. We
can remove many isMouseFocusable implementations of
HTMLFormControlElement subclasses.

We change the followings to hide focus rings on mouse-focus:
 - Introduce FocusDirectionMouse so that form control can distinguish
   mouse focus from others.
 - HTMLFormControlElement has m_wasFocusedByMouse flag. It is cleared
   when a keydown event is delivered.
 - Introduce HTMLFormControlElement::shouldShowFocusRingOnMouseFocus,
    which represents differences between button controls and text/select
    controls.
 - RenderTheme, RenderObject, RenderInline don't draw focus rings if
    conditions match.

We introduced Node::willCallDefaultEventHandler to re-show focus rings
after keyboard operations.

Test changes:
 - Add many tests for new behavior.
 - Remove fast/events/click-focus-control.html because now it is covered
   by existing and new tests.
 - Need rebaseline for afast/repaint/slider-thumb-float.html. We show
    a focus ring for a control without -webkit-appearance.
Comment 2 Alexey Proskuryakov 2013-08-13 09:56:23 PDT
I’m pretty sure we have something to dupe this to.
Comment 4 Alexey Proskuryakov 2013-08-30 11:38:18 PDT
> I’m pretty sure we have something to dupe this to.

And that something likely has a long discussion about why this is not desirable.
Comment 5 Ryosuke Niwa 2013-11-07 01:12:26 PST
Another regression fix: http://src.chromium.org/viewvc/blink?revision=153039&view=revision
Comment 7 Kent Tamura 2013-11-07 14:25:44 PST
(In reply to comment #6)
> (In reply to comment #5)
> I mean https://chromium.googlesource.com/chromium/blink/+/ae238642883fd96e5ad4fa019ea13187dab4f5ae

I recommend to merge Blink r159400 regardless of this bug. Blink r159400 is a general improvement of LABEL processing.
Comment 8 Patrick H. Lauke 2020-08-02 11:33:11 PDT
Coming in late as this caught me by complete surprise today ... that clicking with a mouse on a <button> does not set focus/fire the focus event on the <button>. This feels...extremely broken and unexpected.

I understand the rationale may be to "avoid visual clutter" (per https://bugs.webkit.org/show_bug.cgi?id=26856) but this sounds like an odd reason to break a fairly basic assumption on events/behavior.

Also, this is likely a dupe of https://bugs.webkit.org/show_bug.cgi?id=26856 ?
Comment 9 Patrick H. Lauke 2020-08-02 12:08:17 PDT
and probably related too https://bugs.webkit.org/show_bug.cgi?id=112968
Comment 10 Patrick H. Lauke 2020-08-02 12:11:17 PDT
and https://bugs.webkit.org/show_bug.cgi?id=92029 (sorry for flood of comments, but only unearthed these just now, as it seems to be a long-standing decision not to focus things)
Comment 11 Sam Sneddon [:gsnedders] 2021-05-17 02:52:07 PDT
(In reply to Patrick H. Lauke from comment #8)
> Coming in late as this caught me by complete surprise today ... that
> clicking with a mouse on a <button> does not set focus/fire the focus event
> on the <button>. This feels...extremely broken and unexpected.
> 
> I understand the rationale may be to "avoid visual clutter" (per
> https://bugs.webkit.org/show_bug.cgi?id=26856) but this sounds like an odd
> reason to break a fairly basic assumption on events/behavior.

FWIW, I wouldn't take the opinion of a former Chrome engineer over a decade ago to have any bearing on WebKit today.

As discussed in bug 22261, Safari follows the macOS setting that controls whether non-text inputs are focusable, so that behaviour is similar between native apps and the web.

But yes, let's close this as a dupe.

*** This bug has been marked as a duplicate of bug 22261 ***