| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Nuanti Ltd. | 3 * Copyright (C) 2008 Nuanti Ltd. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "core/editing/FrameSelection.h" | 40 #include "core/editing/FrameSelection.h" |
| 41 #include "core/editing/InputMethodController.h" | 41 #include "core/editing/InputMethodController.h" |
| 42 #include "core/events/Event.h" | 42 #include "core/events/Event.h" |
| 43 #include "core/frame/FrameClient.h" | 43 #include "core/frame/FrameClient.h" |
| 44 #include "core/frame/LocalDOMWindow.h" | 44 #include "core/frame/LocalDOMWindow.h" |
| 45 #include "core/frame/LocalFrame.h" | 45 #include "core/frame/LocalFrame.h" |
| 46 #include "core/frame/LocalFrameView.h" | 46 #include "core/frame/LocalFrameView.h" |
| 47 #include "core/frame/RemoteFrame.h" | 47 #include "core/frame/RemoteFrame.h" |
| 48 #include "core/frame/Settings.h" | 48 #include "core/frame/Settings.h" |
| 49 #include "core/html/HTMLAreaElement.h" | 49 #include "core/html/HTMLAreaElement.h" |
| 50 #include "core/html/HTMLFormElement.h" | |
| 51 #include "core/html/HTMLImageElement.h" | 50 #include "core/html/HTMLImageElement.h" |
| 52 #include "core/html/HTMLPlugInElement.h" | 51 #include "core/html/HTMLPlugInElement.h" |
| 53 #include "core/html/HTMLShadowElement.h" | 52 #include "core/html/HTMLShadowElement.h" |
| 54 #include "core/html/HTMLSlotElement.h" | 53 #include "core/html/HTMLSlotElement.h" |
| 55 #include "core/html/TextControlElement.h" | 54 #include "core/html/TextControlElement.h" |
| 56 #include "core/input/EventHandler.h" | 55 #include "core/input/EventHandler.h" |
| 57 #include "core/layout/HitTestResult.h" | 56 #include "core/layout/HitTestResult.h" |
| 58 #include "core/layout/LayoutObject.h" | |
| 59 #include "core/page/ChromeClient.h" | 57 #include "core/page/ChromeClient.h" |
| 60 #include "core/page/FocusChangedObserver.h" | 58 #include "core/page/FocusChangedObserver.h" |
| 61 #include "core/page/FrameTree.h" | 59 #include "core/page/FrameTree.h" |
| 62 #include "core/page/Page.h" | 60 #include "core/page/Page.h" |
| 63 #include "core/page/SpatialNavigation.h" | 61 #include "core/page/SpatialNavigation.h" |
| 64 | 62 |
| 65 #include <limits> | 63 #include <limits> |
| 66 | 64 |
| 67 namespace blink { | 65 namespace blink { |
| 68 | 66 |
| (...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 } | 1059 } |
| 1062 | 1060 |
| 1063 Element* FocusController::FindFocusableElement(WebFocusType type, | 1061 Element* FocusController::FindFocusableElement(WebFocusType type, |
| 1064 Element& element) { | 1062 Element& element) { |
| 1065 // FIXME: No spacial navigation code yet. | 1063 // FIXME: No spacial navigation code yet. |
| 1066 DCHECK(type == kWebFocusTypeForward || type == kWebFocusTypeBackward); | 1064 DCHECK(type == kWebFocusTypeForward || type == kWebFocusTypeBackward); |
| 1067 ScopedFocusNavigation scope = ScopedFocusNavigation::CreateFor(element); | 1065 ScopedFocusNavigation scope = ScopedFocusNavigation::CreateFor(element); |
| 1068 return FindFocusableElementAcrossFocusScopes(type, scope); | 1066 return FindFocusableElementAcrossFocusScopes(type, scope); |
| 1069 } | 1067 } |
| 1070 | 1068 |
| 1071 Element* FocusController::NextFocusableElementInForm(Element* element, | |
| 1072 WebFocusType focus_type) { | |
| 1073 element->GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); | |
| 1074 if (!element->IsHTMLElement()) | |
| 1075 return nullptr; | |
| 1076 | |
| 1077 if (!element->IsFormControlElement() && | |
| 1078 !ToHTMLElement(element)->isContentEditableForBinding()) | |
| 1079 return nullptr; | |
| 1080 | |
| 1081 HTMLFormElement* form_owner = nullptr; | |
| 1082 if (ToHTMLElement(element)->isContentEditableForBinding()) | |
| 1083 form_owner = Traversal<HTMLFormElement>::FirstAncestor(*element); | |
| 1084 else | |
| 1085 form_owner = ToHTMLFormControlElement(element)->formOwner(); | |
| 1086 | |
| 1087 if (!form_owner) | |
| 1088 return nullptr; | |
| 1089 | |
| 1090 Element* next_element = element; | |
| 1091 for (next_element = FindFocusableElement(focus_type, *next_element); | |
| 1092 next_element; | |
| 1093 next_element = FindFocusableElement(focus_type, *next_element)) { | |
| 1094 if (!next_element->IsHTMLElement()) | |
| 1095 continue; | |
| 1096 if (ToHTMLElement(next_element)->isContentEditableForBinding() && | |
| 1097 next_element->IsDescendantOf(form_owner)) | |
| 1098 return next_element; | |
| 1099 if (!next_element->IsFormControlElement()) | |
| 1100 continue; | |
| 1101 HTMLFormControlElement* form_element = | |
| 1102 ToHTMLFormControlElement(next_element); | |
| 1103 if (form_element->formOwner() != form_owner || | |
| 1104 form_element->IsDisabledOrReadOnly()) | |
| 1105 continue; | |
| 1106 LayoutObject* layout = next_element->GetLayoutObject(); | |
| 1107 if (layout && layout->IsTextControl()) { | |
| 1108 // TODO(ajith.v) Extend it for select elements, radio buttons and check | |
| 1109 // boxes | |
| 1110 return next_element; | |
| 1111 } | |
| 1112 } | |
| 1113 return nullptr; | |
| 1114 } | |
| 1115 | |
| 1116 Element* FocusController::FindFocusableElementInShadowHost( | 1069 Element* FocusController::FindFocusableElementInShadowHost( |
| 1117 const Element& shadow_host) { | 1070 const Element& shadow_host) { |
| 1118 DCHECK(shadow_host.AuthorShadowRoot()); | 1071 DCHECK(shadow_host.AuthorShadowRoot()); |
| 1119 ScopedFocusNavigation scope = | 1072 ScopedFocusNavigation scope = |
| 1120 ScopedFocusNavigation::OwnedByShadowHost(shadow_host); | 1073 ScopedFocusNavigation::OwnedByShadowHost(shadow_host); |
| 1121 return FindFocusableElementAcrossFocusScopes(kWebFocusTypeForward, scope); | 1074 return FindFocusableElementAcrossFocusScopes(kWebFocusTypeForward, scope); |
| 1122 } | 1075 } |
| 1123 | 1076 |
| 1124 static bool RelinquishesEditingFocus(const Element& element) { | 1077 static bool RelinquishesEditingFocus(const Element& element) { |
| 1125 DCHECK(HasEditableStyle(element)); | 1078 DCHECK(HasEditableStyle(element)); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 it->FocusedFrameChanged(); | 1412 it->FocusedFrameChanged(); |
| 1460 } | 1413 } |
| 1461 | 1414 |
| 1462 DEFINE_TRACE(FocusController) { | 1415 DEFINE_TRACE(FocusController) { |
| 1463 visitor->Trace(page_); | 1416 visitor->Trace(page_); |
| 1464 visitor->Trace(focused_frame_); | 1417 visitor->Trace(focused_frame_); |
| 1465 visitor->Trace(focus_changed_observers_); | 1418 visitor->Trace(focus_changed_observers_); |
| 1466 } | 1419 } |
| 1467 | 1420 |
| 1468 } // namespace blink | 1421 } // namespace blink |
| OLD | NEW |