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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 static ScopedFocusNavigation ownedByShadowInsertionPoint(HTMLShadowElement&)
; | 88 static ScopedFocusNavigation ownedByShadowInsertionPoint(HTMLShadowElement&)
; |
89 static ScopedFocusNavigation ownedByHTMLSlotElement(const HTMLSlotElement&); | 89 static ScopedFocusNavigation ownedByHTMLSlotElement(const HTMLSlotElement&); |
90 static ScopedFocusNavigation ownedByIFrame(const HTMLFrameOwnerElement&); | 90 static ScopedFocusNavigation ownedByIFrame(const HTMLFrameOwnerElement&); |
91 static HTMLSlotElement* findFallbackScopeOwnerSlot(const Element&); | 91 static HTMLSlotElement* findFallbackScopeOwnerSlot(const Element&); |
92 static bool isSlotFallbackScoped(const Element&); | 92 static bool isSlotFallbackScoped(const Element&); |
93 static bool isSlotFallbackScopedForThisSlot(const HTMLSlotElement&, const El
ement&); | 93 static bool isSlotFallbackScopedForThisSlot(const HTMLSlotElement&, const El
ement&); |
94 | 94 |
95 private: | 95 private: |
96 ScopedFocusNavigation(TreeScope&, const Element*); | 96 ScopedFocusNavigation(TreeScope&, const Element*); |
97 ScopedFocusNavigation(HTMLSlotElement&, const Element*); | 97 ScopedFocusNavigation(HTMLSlotElement&, const Element*); |
98 RawPtrWillBeMember<ContainerNode> m_rootNode; | 98 Member<ContainerNode> m_rootNode; |
99 RawPtrWillBeMember<HTMLSlotElement> m_rootSlot; | 99 Member<HTMLSlotElement> m_rootSlot; |
100 RawPtrWillBeMember<Element> m_current; | 100 Member<Element> m_current; |
101 bool m_slotFallbackTraversal; | 101 bool m_slotFallbackTraversal; |
102 }; | 102 }; |
103 | 103 |
104 ScopedFocusNavigation::ScopedFocusNavigation(TreeScope& treeScope, const Element
* current) | 104 ScopedFocusNavigation::ScopedFocusNavigation(TreeScope& treeScope, const Element
* current) |
105 : m_rootNode(treeScope.rootNode()) | 105 : m_rootNode(treeScope.rootNode()) |
106 , m_rootSlot(nullptr) | 106 , m_rootSlot(nullptr) |
107 , m_current(const_cast<Element*>(current)) | 107 , m_current(const_cast<Element*>(current)) |
108 { | 108 { |
109 } | 109 } |
110 | 110 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 m_current = ElementTraversal::previous(*m_current); | 161 m_current = ElementTraversal::previous(*m_current); |
162 while (m_current && (SlotScopedTraversal::isSlotScoped(*m_current) || Sc
opedFocusNavigation::isSlotFallbackScoped(*m_current))) | 162 while (m_current && (SlotScopedTraversal::isSlotScoped(*m_current) || Sc
opedFocusNavigation::isSlotFallbackScoped(*m_current))) |
163 m_current = ElementTraversal::previous(*m_current); | 163 m_current = ElementTraversal::previous(*m_current); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 void ScopedFocusNavigation::moveToFirst() | 167 void ScopedFocusNavigation::moveToFirst() |
168 { | 168 { |
169 if (m_rootSlot) { | 169 if (m_rootSlot) { |
170 if (!m_slotFallbackTraversal) { | 170 if (!m_slotFallbackTraversal) { |
171 WillBeHeapVector<RefPtrWillBeMember<Node>> assignedNodes = m_rootSlo
t->getAssignedNodes(); | 171 HeapVector<Member<Node>> assignedNodes = m_rootSlot->getAssignedNode
s(); |
172 for (auto assignedNode : assignedNodes) { | 172 for (auto assignedNode : assignedNodes) { |
173 if (assignedNode->isElementNode()) { | 173 if (assignedNode->isElementNode()) { |
174 m_current = toElement(assignedNode); | 174 m_current = toElement(assignedNode); |
175 break; | 175 break; |
176 } | 176 } |
177 } | 177 } |
178 } else { | 178 } else { |
179 Element* first = ElementTraversal::firstChild(*m_rootSlot); | 179 Element* first = ElementTraversal::firstChild(*m_rootSlot); |
180 while (first && !ScopedFocusNavigation::isSlotFallbackScopedForThisS
lot(*m_rootSlot, *first)) | 180 while (first && !ScopedFocusNavigation::isSlotFallbackScopedForThisS
lot(*m_rootSlot, *first)) |
181 first = ElementTraversal::next(*first, m_rootSlot); | 181 first = ElementTraversal::next(*first, m_rootSlot); |
182 m_current = first; | 182 m_current = first; |
183 } | 183 } |
184 } else { | 184 } else { |
185 Element* first = m_rootNode->isElementNode() ? &toElement(*m_rootNode) :
ElementTraversal::next(*m_rootNode); | 185 Element* first = m_rootNode->isElementNode() ? &toElement(*m_rootNode) :
ElementTraversal::next(*m_rootNode); |
186 while (first && (SlotScopedTraversal::isSlotScoped(*first) || ScopedFocu
sNavigation::isSlotFallbackScoped(*first))) | 186 while (first && (SlotScopedTraversal::isSlotScoped(*first) || ScopedFocu
sNavigation::isSlotFallbackScoped(*first))) |
187 first = ElementTraversal::next(*first, m_rootNode); | 187 first = ElementTraversal::next(*first, m_rootNode); |
188 m_current = first; | 188 m_current = first; |
189 } | 189 } |
190 | 190 |
191 } | 191 } |
192 | 192 |
193 void ScopedFocusNavigation::moveToLast() | 193 void ScopedFocusNavigation::moveToLast() |
194 { | 194 { |
195 if (m_rootSlot) { | 195 if (m_rootSlot) { |
196 if (!m_slotFallbackTraversal) { | 196 if (!m_slotFallbackTraversal) { |
197 WillBeHeapVector<RefPtrWillBeMember<Node>> assignedNodes = m_rootSlo
t->getAssignedNodes(); | 197 HeapVector<Member<Node>> assignedNodes = m_rootSlot->getAssignedNode
s(); |
198 for (auto assignedNode = assignedNodes.rbegin(); assignedNode != ass
ignedNodes.rend(); ++assignedNode) { | 198 for (auto assignedNode = assignedNodes.rbegin(); assignedNode != ass
ignedNodes.rend(); ++assignedNode) { |
199 if ((*assignedNode)->isElementNode()) { | 199 if ((*assignedNode)->isElementNode()) { |
200 m_current = ElementTraversal::lastWithinOrSelf(*toElement(*a
ssignedNode)); | 200 m_current = ElementTraversal::lastWithinOrSelf(*toElement(*a
ssignedNode)); |
201 break; | 201 break; |
202 } | 202 } |
203 } | 203 } |
204 } else { | 204 } else { |
205 Element* last = ElementTraversal::lastWithin(*m_rootSlot); | 205 Element* last = ElementTraversal::lastWithin(*m_rootSlot); |
206 while (last && !ScopedFocusNavigation::isSlotFallbackScopedForThisSl
ot(*m_rootSlot, *last)) | 206 while (last && !ScopedFocusNavigation::isSlotFallbackScopedForThisSl
ot(*m_rootSlot, *last)) |
207 last = ElementTraversal::previous(*last, m_rootSlot); | 207 last = ElementTraversal::previous(*last, m_rootSlot); |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 current = document->sequentialFocusNavigationStartingPoint(type); | 916 current = document->sequentialFocusNavigationStartingPoint(type); |
917 | 917 |
918 // FIXME: Not quite correct when it comes to focus transitions leaving/enter
ing the WebView itself | 918 // FIXME: Not quite correct when it comes to focus transitions leaving/enter
ing the WebView itself |
919 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEn
abled(); | 919 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEn
abled(); |
920 | 920 |
921 if (caretBrowsing && !current) | 921 if (caretBrowsing && !current) |
922 current = adjustToElement(frame->selection().start().anchorNode(), type)
; | 922 current = adjustToElement(frame->selection().start().anchorNode(), type)
; |
923 | 923 |
924 document->updateLayoutIgnorePendingStylesheets(); | 924 document->updateLayoutIgnorePendingStylesheets(); |
925 ScopedFocusNavigation scope = current ? ScopedFocusNavigation::createFor(*cu
rrent) : ScopedFocusNavigation::createForDocument(*document); | 925 ScopedFocusNavigation scope = current ? ScopedFocusNavigation::createFor(*cu
rrent) : ScopedFocusNavigation::createForDocument(*document); |
926 RefPtrWillBeRawPtr<Element> element = findFocusableElementAcrossFocusScopes(
type, scope); | 926 RawPtr<Element> element = findFocusableElementAcrossFocusScopes(type, scope)
; |
927 if (!element) { | 927 if (!element) { |
928 // If there's a RemoteFrame on the ancestor chain, we need to continue | 928 // If there's a RemoteFrame on the ancestor chain, we need to continue |
929 // searching for focusable elements there. | 929 // searching for focusable elements there. |
930 if (frame->localFrameRoot() != frame->tree().top()) { | 930 if (frame->localFrameRoot() != frame->tree().top()) { |
931 document->clearFocusedElement(); | 931 document->clearFocusedElement(); |
932 document->setSequentialFocusNavigationStartingPoint(nullptr); | 932 document->setSequentialFocusNavigationStartingPoint(nullptr); |
933 toRemoteFrame(frame->localFrameRoot()->tree().parent())->advanceFocu
s(type, frame->localFrameRoot()); | 933 toRemoteFrame(frame->localFrameRoot()->tree().parent())->advanceFocu
s(type, frame->localFrameRoot()); |
934 return true; | 934 return true; |
935 } | 935 } |
936 | 936 |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 return consumed; | 1309 return consumed; |
1310 } | 1310 } |
1311 | 1311 |
1312 DEFINE_TRACE(FocusController) | 1312 DEFINE_TRACE(FocusController) |
1313 { | 1313 { |
1314 visitor->trace(m_page); | 1314 visitor->trace(m_page); |
1315 visitor->trace(m_focusedFrame); | 1315 visitor->trace(m_focusedFrame); |
1316 } | 1316 } |
1317 | 1317 |
1318 } // namespace blink | 1318 } // namespace blink |
OLD | NEW |