Bug 200997 - SVG element should not become focusable when focus and key event listeners are added
Summary: SVG element should not become focusable when focus and key event listeners ar...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords: InRadar
: 140024 (view as bug list)
Depends on:
Blocks: 199606
  Show dependency treegraph
 
Reported: 2019-08-21 14:01 PDT by Ryosuke Niwa
Modified: 2022-07-15 22:27 PDT (History)
11 users (show)

See Also:


Attachments
Patch (12.71 KB, patch)
2019-08-21 16:15 PDT, Ryosuke Niwa
sabouhallawa: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2019-08-21 14:01:10 PDT
SVGElement::isMouseFocusable() has bizarre code which checks the presence of keydown, keyup, keypress, focusin, focusout, focus, and blur event listeners.

We shouldn't make an element focusable just because it has a bunch of event listeners.
Comment 1 Ryosuke Niwa 2019-08-21 16:15:18 PDT
Created attachment 376945 [details]
Patch
Comment 2 Said Abou-Hallawa 2019-08-21 17:21:38 PDT
Comment on attachment 376945 [details]
Patch

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

> Source/WebCore/svg/SVGAElement.cpp:162
>      if (hasEditableStyle())
>          return SVGGraphicsElement::supportsFocus();

How can this element be editable?

> LayoutTests/svg/custom/tabindex-order.html:66
> +    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

I think you do not have to add these namespaces in html. The xlink namespaces is removed in SVG2 beside it is not used in this test.

> LayoutTests/svg/custom/tabindex-order.html:68
> +        <rect class="tab" id="rect without tabindex is not focusable" width="1" height="1"/>

I am not sure why the id's contains white spaces. I see they are not referenced but they look weird to me. You may use comment element <!-- --> instead.
Comment 3 Ryosuke Niwa 2019-08-21 17:29:04 PDT
(In reply to Said Abou-Hallawa from comment #2)
> Comment on attachment 376945 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=376945&action=review
> 
> > Source/WebCore/svg/SVGAElement.cpp:162
> >      if (hasEditableStyle())
> >          return SVGGraphicsElement::supportsFocus();
> 
> How can this element be editable?

You can put contenteditble attribute anywhere, or put the entire document into design mode by document.designMode = 'on'.

> > LayoutTests/svg/custom/tabindex-order.html:66
> > +    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
> 
> I think you do not have to add these namespaces in html. The xlink
> namespaces is removed in SVG2 beside it is not used in this test.

Yeah, I added for some testing. Removed.

> > LayoutTests/svg/custom/tabindex-order.html:68
> > +        <rect class="tab" id="rect without tabindex is not focusable" width="1" height="1"/>
> 
> I am not sure why the id's contains white spaces. I see they are not
> referenced but they look weird to me. You may use comment element <!-- -->
> instead.

Well, these IDs are like that because if they ever get focused, it would show up in the test result. The rest of the test uses that convention so I'd keep that for now.
Comment 4 Ryosuke Niwa 2019-08-21 17:29:22 PDT
Thanks for the review!
Comment 5 Ryosuke Niwa 2019-08-21 17:34:50 PDT
Committed r248983: <https://trac.webkit.org/changeset/248983>
Comment 6 Radar WebKit Bug Importer 2019-08-21 17:35:17 PDT
<rdar://problem/54579978>
Comment 7 Ryosuke Niwa 2022-07-15 22:27:30 PDT
*** Bug 140024 has been marked as a duplicate of this bug. ***