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 6147f5c5b9e8805b36d5d7b16b1a930762242497..0360710898773682253e213829c74c1c6a173c5a 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,45 @@ Element* FocusController::FindFocusableElement(WebFocusType type, |
| return FindFocusableElementAcrossFocusScopes(type, scope); |
| } |
| +Element* FocusController::NextFocusableElementInForm(Element* element, |
| + WebFocusType focus_type) { |
| + 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 element, Radio button and Check |
|
tkent
2017/05/14 23:24:58
Select -> select
Radio -> radio
Check boxes -> che
AKVT
2017/05/15 06:40:42
Done.
|
| + // boxes |
| + return next_element; |
| + } |
| + } |
| + return nullptr; |
| +} |
| + |
| Element* FocusController::FindFocusableElementInShadowHost( |
| const Element& shadow_host) { |
| DCHECK(shadow_host.AuthorShadowRoot()); |