Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: third_party/WebKit/Source/core/page/FocusController.cpp

Issue 2432293002: Fix focus navigation for nested slot case (Closed)
Patch Set: More references Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/shadow/SlotScopedTraversalTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 while (m_current && 164 while (m_current &&
165 (SlotScopedTraversal::isSlotScoped(*m_current) || 165 (SlotScopedTraversal::isSlotScoped(*m_current) ||
166 ScopedFocusNavigation::isSlotFallbackScoped(*m_current))) 166 ScopedFocusNavigation::isSlotFallbackScoped(*m_current)))
167 m_current = ElementTraversal::previous(*m_current); 167 m_current = ElementTraversal::previous(*m_current);
168 } 168 }
169 } 169 }
170 170
171 void ScopedFocusNavigation::moveToFirst() { 171 void ScopedFocusNavigation::moveToFirst() {
172 if (m_rootSlot) { 172 if (m_rootSlot) {
173 if (!m_slotFallbackTraversal) { 173 if (!m_slotFallbackTraversal) {
174 HeapVector<Member<Node>> assignedNodes = m_rootSlot->assignedNodes(); 174 m_current = SlotScopedTraversal::firstAssignedToSlot(*m_rootSlot);
175 for (auto assignedNode : assignedNodes) {
176 if (assignedNode->isElementNode()) {
177 m_current = toElement(assignedNode);
178 break;
179 }
180 }
181 } else { 175 } else {
182 Element* first = ElementTraversal::firstChild(*m_rootSlot); 176 Element* first = ElementTraversal::firstChild(*m_rootSlot);
183 while (first && 177 while (first &&
184 !ScopedFocusNavigation::isSlotFallbackScopedForThisSlot( 178 !ScopedFocusNavigation::isSlotFallbackScopedForThisSlot(
185 *m_rootSlot, *first)) 179 *m_rootSlot, *first))
186 first = ElementTraversal::next(*first, m_rootSlot); 180 first = ElementTraversal::next(*first, m_rootSlot);
187 m_current = first; 181 m_current = first;
188 } 182 }
189 } else { 183 } else {
190 Element* first = m_rootNode->isElementNode() 184 Element* first = m_rootNode->isElementNode()
191 ? &toElement(*m_rootNode) 185 ? &toElement(*m_rootNode)
192 : ElementTraversal::next(*m_rootNode); 186 : ElementTraversal::next(*m_rootNode);
193 while (first && (SlotScopedTraversal::isSlotScoped(*first) || 187 while (first && (SlotScopedTraversal::isSlotScoped(*first) ||
194 ScopedFocusNavigation::isSlotFallbackScoped(*first))) 188 ScopedFocusNavigation::isSlotFallbackScoped(*first)))
195 first = ElementTraversal::next(*first, m_rootNode); 189 first = ElementTraversal::next(*first, m_rootNode);
196 m_current = first; 190 m_current = first;
197 } 191 }
198 } 192 }
199 193
200 void ScopedFocusNavigation::moveToLast() { 194 void ScopedFocusNavigation::moveToLast() {
201 if (m_rootSlot) { 195 if (m_rootSlot) {
202 if (!m_slotFallbackTraversal) { 196 if (!m_slotFallbackTraversal) {
203 HeapVector<Member<Node>> assignedNodes = m_rootSlot->assignedNodes(); 197 m_current = SlotScopedTraversal::lastAssignedToSlot(*m_rootSlot);
204 for (auto assignedNode = assignedNodes.rbegin();
205 assignedNode != assignedNodes.rend(); ++assignedNode) {
206 if ((*assignedNode)->isElementNode()) {
207 m_current =
208 ElementTraversal::lastWithinOrSelf(*toElement(*assignedNode));
209 break;
210 }
211 }
212 } else { 198 } else {
213 Element* last = ElementTraversal::lastWithin(*m_rootSlot); 199 Element* last = ElementTraversal::lastWithin(*m_rootSlot);
214 while (last && 200 while (last &&
215 !ScopedFocusNavigation::isSlotFallbackScopedForThisSlot( 201 !ScopedFocusNavigation::isSlotFallbackScopedForThisSlot(
216 *m_rootSlot, *last)) 202 *m_rootSlot, *last))
217 last = ElementTraversal::previous(*last, m_rootSlot); 203 last = ElementTraversal::previous(*last, m_rootSlot);
218 m_current = last; 204 m_current = last;
219 } 205 }
220 } else { 206 } else {
221 Element* last = ElementTraversal::lastWithin(*m_rootNode); 207 Element* last = ElementTraversal::lastWithin(*m_rootNode);
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 1411
1426 return consumed; 1412 return consumed;
1427 } 1413 }
1428 1414
1429 DEFINE_TRACE(FocusController) { 1415 DEFINE_TRACE(FocusController) {
1430 visitor->trace(m_page); 1416 visitor->trace(m_page);
1431 visitor->trace(m_focusedFrame); 1417 visitor->trace(m_focusedFrame);
1432 } 1418 }
1433 1419
1434 } // namespace blink 1420 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/shadow/SlotScopedTraversalTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698