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

Side by Side Diff: third_party/WebKit/Source/core/dom/shadow/SlotScopedTraversal.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/shadow/SlotScopedTraversal.h" 5 #include "core/dom/shadow/SlotScopedTraversal.h"
6 6
7 #include "core/dom/Element.h" 7 #include "core/dom/Element.h"
8 #include "core/dom/ElementTraversal.h" 8 #include "core/dom/ElementTraversal.h"
9 #include "core/html/HTMLSlotElement.h" 9 #include "core/html/HTMLSlotElement.h"
10 10
(...skipping 27 matching lines...) Expand all
38 if (Element* next = ElementTraversal::next(current, &current)) 38 if (Element* next = ElementTraversal::next(current, &current))
39 return next; 39 return next;
40 } else { 40 } else {
41 // If current is in assigned scope, find an assigned ancestor. 41 // If current is in assigned scope, find an assigned ancestor.
42 ASSERT(nearestAncestorAssignedToSlot); 42 ASSERT(nearestAncestorAssignedToSlot);
43 if (Element* next = ElementTraversal::next(current, nearestAncestorAssig nedToSlot)) 43 if (Element* next = ElementTraversal::next(current, nearestAncestorAssig nedToSlot))
44 return next; 44 return next;
45 slot = nearestAncestorAssignedToSlot->assignedSlot(); 45 slot = nearestAncestorAssignedToSlot->assignedSlot();
46 ASSERT(slot); 46 ASSERT(slot);
47 } 47 }
48 WillBeHeapVector<RefPtrWillBeMember<Node>> assignedNodes = slot->getAssigned Nodes(); 48 HeapVector<Member<Node>> assignedNodes = slot->getAssignedNodes();
49 size_t currentIndex = assignedNodes.find(*nearestAncestorAssignedToSlot); 49 size_t currentIndex = assignedNodes.find(*nearestAncestorAssignedToSlot);
50 ASSERT(currentIndex != kNotFound); 50 ASSERT(currentIndex != kNotFound);
51 for (++currentIndex; currentIndex < assignedNodes.size(); ++currentIndex) { 51 for (++currentIndex; currentIndex < assignedNodes.size(); ++currentIndex) {
52 if (assignedNodes[currentIndex]->isElementNode()) 52 if (assignedNodes[currentIndex]->isElementNode())
53 return toElement(assignedNodes[currentIndex]); 53 return toElement(assignedNodes[currentIndex]);
54 } 54 }
55 return nullptr; 55 return nullptr;
56 } 56 }
57 57
58 Element* SlotScopedTraversal::previous(const Element& current) 58 Element* SlotScopedTraversal::previous(const Element& current)
59 { 59 {
60 Element* nearestAncestorAssignedToSlot = SlotScopedTraversal::nearestAncesto rAssignedToSlot(current); 60 Element* nearestAncestorAssignedToSlot = SlotScopedTraversal::nearestAncesto rAssignedToSlot(current);
61 ASSERT(nearestAncestorAssignedToSlot); 61 ASSERT(nearestAncestorAssignedToSlot);
62 // NodeTraversal within nearestAncestorAssignedToSlot 62 // NodeTraversal within nearestAncestorAssignedToSlot
63 if (Element* previous = ElementTraversal::previous(current, nearestAncestorA ssignedToSlot)) 63 if (Element* previous = ElementTraversal::previous(current, nearestAncestorA ssignedToSlot))
64 return previous; 64 return previous;
65 // If null, jump to previous assigned node's descendant 65 // If null, jump to previous assigned node's descendant
66 const WillBeHeapVector<RefPtrWillBeMember<Node>> assignedNodes = nearestAnce storAssignedToSlot->assignedSlot()->getAssignedNodes(); 66 const HeapVector<Member<Node>> assignedNodes = nearestAncestorAssignedToSlot ->assignedSlot()->getAssignedNodes();
67 size_t currentIndex = assignedNodes.reverseFind(*nearestAncestorAssignedToSl ot); 67 size_t currentIndex = assignedNodes.reverseFind(*nearestAncestorAssignedToSl ot);
68 ASSERT(currentIndex != kNotFound); 68 ASSERT(currentIndex != kNotFound);
69 for (; currentIndex > 0; --currentIndex) { 69 for (; currentIndex > 0; --currentIndex) {
70 const RefPtrWillBeMember<Node> assignedPrevious = assignedNodes[currentI ndex - 1]; 70 const Member<Node> assignedPrevious = assignedNodes[currentIndex - 1];
71 if (assignedPrevious->isElementNode()) { 71 if (assignedPrevious->isElementNode()) {
72 if (Element* last = ElementTraversal::lastWithin(*toElement(assigned Previous))) 72 if (Element* last = ElementTraversal::lastWithin(*toElement(assigned Previous)))
73 return last; 73 return last;
74 return toElement(assignedPrevious); 74 return toElement(assignedPrevious);
75 } 75 }
76 } 76 }
77 return nullptr; 77 return nullptr;
78 } 78 }
79 79
80 bool SlotScopedTraversal::isSlotScoped(const Element& current) 80 bool SlotScopedTraversal::isSlotScoped(const Element& current)
81 { 81 {
82 return SlotScopedTraversal::nearestAncestorAssignedToSlot(current); 82 return SlotScopedTraversal::nearestAncestorAssignedToSlot(current);
83 } 83 }
84 84
85 } // namespace blink 85 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/shadow/SlotAssignment.cpp ('k') | third_party/WebKit/Source/core/editing/CaretBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698