| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 { | 108 { |
| 109 int count = 0; | 109 int count = 0; |
| 110 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)) { |
| 111 if (sibling->hasTagName(type)) | 111 if (sibling->hasTagName(type)) |
| 112 ++count; | 112 ++count; |
| 113 } | 113 } |
| 114 | 114 |
| 115 return count; | 115 return count; |
| 116 } | 116 } |
| 117 | 117 |
| 118 struct ShadowDOMSiblingTraversalStrategy { | 118 class ShadowDOMSiblingTraversalStrategy FINAL { |
| 119 ShadowDOMSiblingTraversalStrategy(const Vector<Node*, 32>& siblings, int nth
) | 119 STACK_ALLOCATED(); |
| 120 public: |
| 121 ShadowDOMSiblingTraversalStrategy(const WillBeHeapVector<RawPtrWillBeMember<
Node>, 32>& siblings, int nth) |
| 120 : m_siblings(siblings) | 122 : m_siblings(siblings) |
| 121 , m_nth(nth) | 123 , m_nth(nth) |
| 122 { | 124 { |
| 123 } | 125 } |
| 124 | 126 |
| 125 bool isFirstChild(Element&) const; | 127 bool isFirstChild(Element&) const; |
| 126 bool isLastChild(Element&) const; | 128 bool isLastChild(Element&) const; |
| 127 bool isFirstOfType(Element&, const QualifiedName&) const; | 129 bool isFirstOfType(Element&, const QualifiedName&) const; |
| 128 bool isLastOfType(Element&, const QualifiedName&) const; | 130 bool isLastOfType(Element&, const QualifiedName&) const; |
| 129 | 131 |
| 130 int countElementsBefore(Element&) const; | 132 int countElementsBefore(Element&) const; |
| 131 int countElementsAfter(Element&) const; | 133 int countElementsAfter(Element&) const; |
| 132 int countElementsOfTypeBefore(Element&, const QualifiedName&) const; | 134 int countElementsOfTypeBefore(Element&, const QualifiedName&) const; |
| 133 int countElementsOfTypeAfter(Element&, const QualifiedName&) const; | 135 int countElementsOfTypeAfter(Element&, const QualifiedName&) const; |
| 134 | 136 |
| 135 private: | 137 private: |
| 136 const Vector<Node*, 32>& m_siblings; | 138 const WillBeHeapVector<RawPtrWillBeMember<Node>, 32>& m_siblings; |
| 137 int m_nth; | 139 int m_nth; |
| 138 }; | 140 }; |
| 139 | 141 |
| 140 inline bool ShadowDOMSiblingTraversalStrategy::isFirstChild(Element& element) co
nst | 142 inline bool ShadowDOMSiblingTraversalStrategy::isFirstChild(Element& element) co
nst |
| 141 { | 143 { |
| 142 ASSERT(element == toElement(m_siblings[m_nth])); | 144 ASSERT(element == toElement(m_siblings[m_nth])); |
| 143 | 145 |
| 144 for (int i = m_nth - 1; i >= 0; --i) { | 146 for (int i = m_nth - 1; i >= 0; --i) { |
| 145 if (m_siblings[i]->isElementNode()) | 147 if (m_siblings[i]->isElementNode()) |
| 146 return false; | 148 return false; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 if (m_siblings[i]->hasTagName(type)) | 235 if (m_siblings[i]->hasTagName(type)) |
| 234 return ++count; | 236 return ++count; |
| 235 } | 237 } |
| 236 | 238 |
| 237 return count; | 239 return count; |
| 238 } | 240 } |
| 239 | 241 |
| 240 } | 242 } |
| 241 | 243 |
| 242 #endif | 244 #endif |
| OLD | NEW |