Chromium Code Reviews| Index: third_party/WebKit/Source/core/page/FocusController.cpp |
| diff --git a/third_party/WebKit/Source/core/page/FocusController.cpp b/third_party/WebKit/Source/core/page/FocusController.cpp |
| index 383f1623b0b046285b32c9e0537673b3ddb79e4d..2aba7a05069f65455ba69d08b4fa4b31b013de14 100644 |
| --- a/third_party/WebKit/Source/core/page/FocusController.cpp |
| +++ b/third_party/WebKit/Source/core/page/FocusController.cpp |
| @@ -933,7 +933,11 @@ bool FocusController::advanceFocusAcrossFrames( |
| start = toHTMLFrameOwnerElement(from->owner()); |
| } |
| - return advanceFocusInDocumentOrder(to, start, type, false, |
| + // If we're coming from a parent frame, we need to restart from the first or |
| + // last focusable element. |
| + bool initialFocus = to->tree().parent() == from; |
| + |
| + return advanceFocusInDocumentOrder(to, start, type, initialFocus, |
| sourceCapabilities); |
| } |
| @@ -999,6 +1003,8 @@ bool FocusController::advanceFocusInDocumentOrder( |
| if (element == document->focusedElement()) { |
| // Focus wrapped around to the same element. |
| + setFocusedFrame(document->frame()); |
| + dispatchFocusEvent(*document, *element); |
|
alexmos
2017/04/05 00:21:13
Sanity check: could this have any side effects (li
avallee
2017/04/05 15:13:00
It could mean an extra focus event, but I don't kn
alexmos
2017/04/05 18:08:33
Acknowledged.
|
| return true; |
| } |
| @@ -1012,7 +1018,6 @@ bool FocusController::advanceFocusInDocumentOrder( |
| return false; |
| document->clearFocusedElement(); |
| - setFocusedFrame(owner->contentFrame()); |
| // If contentFrame is remote, continue the search for focusable |
| // elements in that frame's process. |
|
alexmos
2017/04/05 00:21:13
Might be worth also mentioning that contentFrame w
avallee
2017/04/05 15:13:00
Yes, it would either be set up above where your ot
|
| @@ -1020,6 +1025,8 @@ bool FocusController::advanceFocusInDocumentOrder( |
| // contentFrame, hence the need to null-check it again. |
| if (owner->contentFrame() && owner->contentFrame()->isRemoteFrame()) |
| toRemoteFrame(owner->contentFrame())->advanceFocus(type, frame); |
| + else |
| + setFocusedFrame(owner->contentFrame()); |
| return true; |
| } |