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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 for (const Element* sibling = element->nextElementSibling(); sibling; siblin g = sibling->nextElementSibling()) { | 72 for (const Element* sibling = element->nextElementSibling(); sibling; siblin g = sibling->nextElementSibling()) { |
73 if (sibling->hasTagName(type)) | 73 if (sibling->hasTagName(type)) |
74 return false; | 74 return false; |
75 } | 75 } |
76 return true; | 76 return true; |
77 } | 77 } |
78 | 78 |
79 inline int DOMSiblingTraversalStrategy::countElementsBefore(Element* element) co nst | 79 inline int DOMSiblingTraversalStrategy::countElementsBefore(Element* element) co nst |
80 { | 80 { |
81 int count = 0; | 81 int count = 0; |
82 for (const Element* sibling = element->previousElementSibling(); sibling; si bling = sibling->previousElementSibling()) { | 82 for (const Element* sibling = element->previousElementSibling(); sibling; si bling = sibling->previousElementSibling()) |
83 unsigned index = sibling->childIndex(); | 83 ++count; |
84 if (index) { | |
85 count += index; | |
86 break; | |
87 } | |
88 count++; | |
89 } | |
90 | 84 |
91 return count; | 85 return count; |
92 } | 86 } |
93 | 87 |
94 inline int DOMSiblingTraversalStrategy::countElementsOfTypeBefore(Element* eleme nt, const QualifiedName& type) const | 88 inline int DOMSiblingTraversalStrategy::countElementsOfTypeBefore(Element* eleme nt, const QualifiedName& type) const |
95 { | 89 { |
96 int count = 0; | 90 int count = 0; |
97 for (const Element* sibling = element->previousElementSibling(); sibling; si bling = sibling->previousElementSibling()) { | 91 for (const Element* sibling = element->previousElementSibling(); sibling; si bling = sibling->previousElementSibling()) { |
98 if (sibling->hasTagName(type)) | 92 if (sibling->hasTagName(type)) |
99 ++count; | 93 ++count; |
100 } | 94 } |
101 | 95 |
102 return count; | 96 return count; |
103 } | 97 } |
104 | 98 |
105 inline int DOMSiblingTraversalStrategy::countElementsAfter(Element* element) con st | 99 inline int DOMSiblingTraversalStrategy::countElementsAfter(Element* element) con st |
106 { | 100 { |
107 int count = 0; | 101 int count = 0; |
108 for (const Element* sibling = element->nextElementSibling(); sibling; siblin g = sibling->nextElementSibling()) | 102 for (const Element* sibling = element->nextElementSibling(); sibling; siblin g = sibling->nextElementSibling()) { |
103 unsigned index = sibling->childIndex(); | |
ojan
2013/05/31 18:05:07
I think this deserves a comment. Specifically, tha
| |
104 if (index) { | |
105 count += index; | |
106 break; | |
107 } | |
109 ++count; | 108 ++count; |
109 } | |
110 | 110 |
111 return count; | 111 return count; |
112 } | 112 } |
113 | 113 |
114 inline int DOMSiblingTraversalStrategy::countElementsOfTypeAfter(Element* elemen t, const QualifiedName& type) const | 114 inline int DOMSiblingTraversalStrategy::countElementsOfTypeAfter(Element* elemen t, const QualifiedName& type) const |
115 { | 115 { |
116 int count = 0; | 116 int count = 0; |
117 for (const Element* sibling = element->nextElementSibling(); sibling; siblin g = sibling->nextElementSibling()) { | 117 for (const Element* sibling = element->nextElementSibling(); sibling; siblin g = sibling->nextElementSibling()) { |
118 if (sibling->hasTagName(type)) | 118 if (sibling->hasTagName(type)) |
119 ++count; | 119 ++count; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 if (siblings[i] && siblings[i]->isElementNode() && siblings[i]->hasTagNa me(type)) | 264 if (siblings[i] && siblings[i]->isElementNode() && siblings[i]->hasTagNa me(type)) |
265 return ++count; | 265 return ++count; |
266 } | 266 } |
267 | 267 |
268 return count; | 268 return count; |
269 } | 269 } |
270 | 270 |
271 } | 271 } |
272 | 272 |
273 #endif | 273 #endif |
OLD | NEW |