| 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 // We can't use the same early return as is present in countElementsAfter du
e | 82 for (const Element* sibling = element->previousElementSibling(); sibling; si
bling = sibling->previousElementSibling()) { |
| 83 // to the order we resolve style; if a new element is inserted into the midd
le, | 83 unsigned index = sibling->childIndex(); |
| 84 // we'd end up using a stale cached childIndex. | 84 if (index) { |
| 85 for (const Element* sibling = element->previousElementSibling(); sibling; si
bling = sibling->previousElementSibling()) | 85 count += index; |
| 86 ++count; | 86 break; |
| 87 } |
| 88 count++; |
| 89 } |
| 87 | 90 |
| 88 return count; | 91 return count; |
| 89 } | 92 } |
| 90 | 93 |
| 91 inline int DOMSiblingTraversalStrategy::countElementsOfTypeBefore(Element* eleme
nt, const QualifiedName& type) const | 94 inline int DOMSiblingTraversalStrategy::countElementsOfTypeBefore(Element* eleme
nt, const QualifiedName& type) const |
| 92 { | 95 { |
| 93 int count = 0; | 96 int count = 0; |
| 94 for (const Element* sibling = element->previousElementSibling(); sibling; si
bling = sibling->previousElementSibling()) { | 97 for (const Element* sibling = element->previousElementSibling(); sibling; si
bling = sibling->previousElementSibling()) { |
| 95 if (sibling->hasTagName(type)) | 98 if (sibling->hasTagName(type)) |
| 96 ++count; | 99 ++count; |
| 97 } | 100 } |
| 98 | 101 |
| 99 return count; | 102 return count; |
| 100 } | 103 } |
| 101 | 104 |
| 102 inline int DOMSiblingTraversalStrategy::countElementsAfter(Element* element) con
st | 105 inline int DOMSiblingTraversalStrategy::countElementsAfter(Element* element) con
st |
| 103 { | 106 { |
| 104 int count = 0; | 107 int count = 0; |
| 105 // We can use an early return here because we resolve style from lastChild t
o | 108 for (const Element* sibling = element->nextElementSibling(); sibling; siblin
g = sibling->nextElementSibling()) |
| 106 // firstChild, so we're guaranteed to not have stale cached childIndices. | |
| 107 for (const Element* sibling = element->nextElementSibling(); sibling; siblin
g = sibling->nextElementSibling()) { | |
| 108 unsigned index = sibling->childIndex(); | |
| 109 if (index) { | |
| 110 count += index; | |
| 111 break; | |
| 112 } | |
| 113 ++count; | 109 ++count; |
| 114 } | |
| 115 | 110 |
| 116 return count; | 111 return count; |
| 117 } | 112 } |
| 118 | 113 |
| 119 inline int DOMSiblingTraversalStrategy::countElementsOfTypeAfter(Element* elemen
t, const QualifiedName& type) const | 114 inline int DOMSiblingTraversalStrategy::countElementsOfTypeAfter(Element* elemen
t, const QualifiedName& type) const |
| 120 { | 115 { |
| 121 int count = 0; | 116 int count = 0; |
| 122 for (const Element* sibling = element->nextElementSibling(); sibling; siblin
g = sibling->nextElementSibling()) { | 117 for (const Element* sibling = element->nextElementSibling(); sibling; siblin
g = sibling->nextElementSibling()) { |
| 123 if (sibling->hasTagName(type)) | 118 if (sibling->hasTagName(type)) |
| 124 ++count; | 119 ++count; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 if (siblings[i] && siblings[i]->isElementNode() && siblings[i]->hasTagNa
me(type)) | 264 if (siblings[i] && siblings[i]->isElementNode() && siblings[i]->hasTagNa
me(type)) |
| 270 return ++count; | 265 return ++count; |
| 271 } | 266 } |
| 272 | 267 |
| 273 return count; | 268 return count; |
| 274 } | 269 } |
| 275 | 270 |
| 276 } | 271 } |
| 277 | 272 |
| 278 #endif | 273 #endif |
| OLD | NEW |