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 2aeabe8ca422443303126e1ebd70b72187553b8c..74430c5d4711e842f5d45129d908d21273108875 100644 |
| --- a/third_party/WebKit/Source/core/page/FocusController.cpp |
| +++ b/third_party/WebKit/Source/core/page/FocusController.cpp |
| @@ -47,6 +47,7 @@ |
| #include "core/frame/RemoteFrame.h" |
| #include "core/frame/Settings.h" |
| #include "core/html/HTMLAreaElement.h" |
| +#include "core/html/HTMLFormElement.h" |
| #include "core/html/HTMLImageElement.h" |
| #include "core/html/HTMLPlugInElement.h" |
| #include "core/html/HTMLShadowElement.h" |
| @@ -54,6 +55,7 @@ |
| #include "core/html/TextControlElement.h" |
| #include "core/input/EventHandler.h" |
| #include "core/layout/HitTestResult.h" |
| +#include "core/layout/LayoutObject.h" |
| #include "core/page/ChromeClient.h" |
| #include "core/page/FocusChangedObserver.h" |
| #include "core/page/FrameTree.h" |
| @@ -1066,6 +1068,48 @@ Element* FocusController::FindFocusableElement(WebFocusType type, |
| return FindFocusableElementAcrossFocusScopes(type, scope); |
| } |
| +Element* FocusController::NextFocusableElementInForm(Element* element, |
| + WebFocusType focus_type) { |
|
Changwan Ryu
2017/06/09 19:34:30
could you try adding
element->GetDocument().Update
AKVT
2017/06/10 03:37:56
I had tried to call NeedsLayoutTreeUpdateForNode e
AKVT
2017/06/12 12:21:24
Done. Thank you.
|
| + if (!element->IsHTMLElement()) |
| + return nullptr; |
| + |
| + if (!element->IsFormControlElement() && |
| + !ToHTMLElement(element)->isContentEditableForBinding()) |
| + return nullptr; |
| + |
| + HTMLFormElement* form_owner = nullptr; |
| + if (ToHTMLElement(element)->isContentEditableForBinding()) |
| + form_owner = Traversal<HTMLFormElement>::FirstAncestor(*element); |
| + else |
| + form_owner = ToHTMLFormControlElement(element)->formOwner(); |
| + |
| + if (!form_owner) |
| + return nullptr; |
| + |
| + Element* next_element = element; |
| + for (next_element = FindFocusableElement(focus_type, *next_element); |
| + next_element; |
| + next_element = FindFocusableElement(focus_type, *next_element)) { |
| + if (ToHTMLElement(next_element)->isContentEditableForBinding() && |
| + next_element->IsDescendantOf(form_owner)) |
| + return next_element; |
| + if (!next_element->IsFormControlElement()) |
| + continue; |
| + HTMLFormControlElement* form_element = |
| + ToHTMLFormControlElement(next_element); |
| + if (form_element->formOwner() != form_owner || |
| + form_element->IsDisabledOrReadOnly()) |
| + continue; |
| + LayoutObject* layout = next_element->GetLayoutObject(); |
| + if (layout && layout->IsTextControl()) { |
| + // TODO(ajith.v) Extend it for select elements, radio buttons and check |
| + // boxes |
| + return next_element; |
| + } |
| + } |
| + return nullptr; |
| +} |
| + |
| Element* FocusController::FindFocusableElementInShadowHost( |
| const Element& shadow_host) { |
| DCHECK(shadow_host.AuthorShadowRoot()); |