Moving focus by tab could erroneously focus a non-focusable shadow host
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 May 2016 22:42:23 +0000 (22:42 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 May 2016 22:42:23 +0000 (22:42 +0000)
commitb83424d1cef2083b9d9e3e6f3fe0609848781200
treef72f0d33fe5c11551321af485b55c151723d6573
parentc6a161dedf24df3b8df2d55cd7f7c8e71b98c0bf
Moving focus by tab could erroneously focus a non-focusable shadow host
https://bugs.webkit.org/show_bug.cgi?id=157585

Reviewed by Antti Koivisto.

Source/WebCore:

The bug was caused by findFocusableElementDescendingDownIntoFrameDocument erroneously returning a shadow host
that contains a focusable element instead of traversing it through to find a focusable element within. Fixed
the bug calling findFocusableElementWithinScope which traverses shadow trees to find a focusable element unlike
findFocusableElementOrScopeOwner which returns a focusable element or a shadow host.

Also done some refactoring for clarity.

Test: fast/shadow-dom/focus-on-iframe.html

* page/FocusController.cpp:
(WebCore::FocusController::findFocusableElementDescendingDownIntoFrameDocument): See above.

(WebCore::FocusController::findFocusableElementAcrossFocusScope): Declare outerScope as late as possible.
(WebCore::nextElementWithGreaterTabIndex): Merged if conditions for clarity.
(WebCore::previousElementWithLowerTabIndex): Removed the check for isNonFocusableShadowHost since
isFocusableOrHasShadowTreeWithoutCustomFocusLogic returns true whenever isNonFocusableShadowHost returns true.

LayoutTests:

Added a regression test for moving focus across iframes.

Also expanded negative-tabindex-on-shadow-host.html to cover reverse traversal.

* fast/shadow-dom/focus-on-iframe-expected.txt: Added.
* fast/shadow-dom/focus-on-iframe.html: Added.
* fast/shadow-dom/negative-tabindex-on-shadow-host-expected.txt:
* fast/shadow-dom/negative-tabindex-on-shadow-host.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@200712 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/shadow-dom/focus-on-iframe-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/focus-on-iframe.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/negative-tabindex-on-shadow-host-expected.txt
LayoutTests/fast/shadow-dom/negative-tabindex-on-shadow-host.html
Source/WebCore/ChangeLog
Source/WebCore/page/FocusController.cpp