OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 int count = 0; | 87 int count = 0; |
88 for (const Element* sibling = ElementTraversal::previousSibling(element); si
bling; sibling = ElementTraversal::previousSibling(*sibling)) | 88 for (const Element* sibling = ElementTraversal::previousSibling(element); si
bling; sibling = ElementTraversal::previousSibling(*sibling)) |
89 count++; | 89 count++; |
90 | 90 |
91 return count; | 91 return count; |
92 } | 92 } |
93 | 93 |
94 inline int DOMSiblingTraversalStrategy::countElementsOfTypeBefore(Element& eleme
nt, const QualifiedName& type) const | 94 inline int DOMSiblingTraversalStrategy::countElementsOfTypeBefore(Element& eleme
nt, const QualifiedName& type) const |
95 { | 95 { |
| 96 if (NthIndexCache* nthIndexCache = element.document().nthIndexCache()) |
| 97 return nthIndexCache->nthChildIndexOfType(element, type) - 1; |
96 int count = 0; | 98 int count = 0; |
97 for (const Element* sibling = ElementTraversal::previousSibling(element, Has
TagName(type)); sibling; sibling = ElementTraversal::previousSibling(*sibling, H
asTagName(type))) | 99 for (const Element* sibling = ElementTraversal::previousSibling(element, Has
TagName(type)); sibling; sibling = ElementTraversal::previousSibling(*sibling, H
asTagName(type))) |
98 ++count; | 100 ++count; |
99 return count; | 101 return count; |
100 } | 102 } |
101 | 103 |
102 inline int DOMSiblingTraversalStrategy::countElementsAfter(Element& element) con
st | 104 inline int DOMSiblingTraversalStrategy::countElementsAfter(Element& element) con
st |
103 { | 105 { |
104 if (NthIndexCache* nthIndexCache = element.document().nthIndexCache()) | 106 if (NthIndexCache* nthIndexCache = element.document().nthIndexCache()) |
105 return nthIndexCache->nthLastChildIndex(element) - 1; | 107 return nthIndexCache->nthLastChildIndex(element) - 1; |
106 | 108 |
107 int count = 0; | 109 int count = 0; |
108 for (const Element* sibling = ElementTraversal::nextSibling(element); siblin
g; sibling = ElementTraversal::nextSibling(*sibling)) | 110 for (const Element* sibling = ElementTraversal::nextSibling(element); siblin
g; sibling = ElementTraversal::nextSibling(*sibling)) |
109 ++count; | 111 ++count; |
110 return count; | 112 return count; |
111 } | 113 } |
112 | 114 |
113 inline int DOMSiblingTraversalStrategy::countElementsOfTypeAfter(Element& elemen
t, const QualifiedName& type) const | 115 inline int DOMSiblingTraversalStrategy::countElementsOfTypeAfter(Element& elemen
t, const QualifiedName& type) const |
114 { | 116 { |
| 117 if (NthIndexCache* nthIndexCache = element.document().nthIndexCache()) |
| 118 return nthIndexCache->nthLastChildIndexOfType(element, type) - 1; |
| 119 |
115 int count = 0; | 120 int count = 0; |
116 for (const Element* sibling = ElementTraversal::nextSibling(element, HasTagN
ame(type)); sibling; sibling = ElementTraversal::nextSibling(*sibling, HasTagNam
e(type))) | 121 for (const Element* sibling = ElementTraversal::nextSibling(element, HasTagN
ame(type)); sibling; sibling = ElementTraversal::nextSibling(*sibling, HasTagNam
e(type))) |
117 ++count; | 122 ++count; |
118 return count; | 123 return count; |
119 } | 124 } |
120 | 125 |
121 class ShadowDOMSiblingTraversalStrategy final { | 126 class ShadowDOMSiblingTraversalStrategy final { |
122 STACK_ALLOCATED(); | 127 STACK_ALLOCATED(); |
123 public: | 128 public: |
124 ShadowDOMSiblingTraversalStrategy(const WillBeHeapVector<RawPtrWillBeMember<
Node>, 32>& siblings, int nth) | 129 ShadowDOMSiblingTraversalStrategy(const WillBeHeapVector<RawPtrWillBeMember<
Node>, 32>& siblings, int nth) |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 if (m_siblings[i]->isElementNode() && toElement(m_siblings[i])->hasTagNa
me(type)) | 243 if (m_siblings[i]->isElementNode() && toElement(m_siblings[i])->hasTagNa
me(type)) |
239 return ++count; | 244 return ++count; |
240 } | 245 } |
241 | 246 |
242 return count; | 247 return count; |
243 } | 248 } |
244 | 249 |
245 } | 250 } |
246 | 251 |
247 #endif | 252 #endif |
OLD | NEW |