| 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 30 matching lines...) Expand all Loading... |
| 41 public: | 41 public: |
| 42 bool isFirstChild(Element&) const; | 42 bool isFirstChild(Element&) const; |
| 43 bool isLastChild(Element&) const; | 43 bool isLastChild(Element&) const; |
| 44 bool isFirstOfType(Element&, const QualifiedName&) const; | 44 bool isFirstOfType(Element&, const QualifiedName&) const; |
| 45 bool isLastOfType(Element&, const QualifiedName&) const; | 45 bool isLastOfType(Element&, const QualifiedName&) const; |
| 46 | 46 |
| 47 int countElementsBefore(Element&) const; | 47 int countElementsBefore(Element&) const; |
| 48 int countElementsAfter(Element&) const; | 48 int countElementsAfter(Element&) const; |
| 49 int countElementsOfTypeBefore(Element&, const QualifiedName&) const; | 49 int countElementsOfTypeBefore(Element&, const QualifiedName&) const; |
| 50 int countElementsOfTypeAfter(Element&, const QualifiedName&) const; | 50 int countElementsOfTypeAfter(Element&, const QualifiedName&) const; |
| 51 | |
| 52 private: | |
| 53 class HasTagName { | |
| 54 public: | |
| 55 explicit HasTagName(const QualifiedName& tagName) : m_tagName(tagName) {
} | |
| 56 bool operator() (const Element& element) const { return element.hasTagNa
me(m_tagName); } | |
| 57 private: | |
| 58 const QualifiedName& m_tagName; | |
| 59 }; | |
| 60 }; | 51 }; |
| 61 | 52 |
| 62 inline bool DOMSiblingTraversalStrategy::isFirstChild(Element& element) const | 53 inline bool DOMSiblingTraversalStrategy::isFirstChild(Element& element) const |
| 63 { | 54 { |
| 64 return !ElementTraversal::previousSibling(element); | 55 return !ElementTraversal::previousSibling(element); |
| 65 } | 56 } |
| 66 | 57 |
| 67 inline bool DOMSiblingTraversalStrategy::isLastChild(Element& element) const | 58 inline bool DOMSiblingTraversalStrategy::isLastChild(Element& element) const |
| 68 { | 59 { |
| 69 return !ElementTraversal::nextSibling(element); | 60 return !ElementTraversal::nextSibling(element); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 86 | 77 |
| 87 int count = 0; | 78 int count = 0; |
| 88 for (const Element* sibling = ElementTraversal::previousSibling(element); si
bling; sibling = ElementTraversal::previousSibling(*sibling)) | 79 for (const Element* sibling = ElementTraversal::previousSibling(element); si
bling; sibling = ElementTraversal::previousSibling(*sibling)) |
| 89 count++; | 80 count++; |
| 90 | 81 |
| 91 return count; | 82 return count; |
| 92 } | 83 } |
| 93 | 84 |
| 94 inline int DOMSiblingTraversalStrategy::countElementsOfTypeBefore(Element& eleme
nt, const QualifiedName& type) const | 85 inline int DOMSiblingTraversalStrategy::countElementsOfTypeBefore(Element& eleme
nt, const QualifiedName& type) const |
| 95 { | 86 { |
| 87 if (NthIndexCache* nthIndexCache = element.document().nthIndexCache()) |
| 88 return nthIndexCache->nthChildIndexOfType(element, type) - 1; |
| 96 int count = 0; | 89 int count = 0; |
| 97 for (const Element* sibling = ElementTraversal::previousSibling(element, Has
TagName(type)); sibling; sibling = ElementTraversal::previousSibling(*sibling, H
asTagName(type))) | 90 for (const Element* sibling = ElementTraversal::previousSibling(element, Has
TagName(type)); sibling; sibling = ElementTraversal::previousSibling(*sibling, H
asTagName(type))) |
| 98 ++count; | 91 ++count; |
| 99 return count; | 92 return count; |
| 100 } | 93 } |
| 101 | 94 |
| 102 inline int DOMSiblingTraversalStrategy::countElementsAfter(Element& element) con
st | 95 inline int DOMSiblingTraversalStrategy::countElementsAfter(Element& element) con
st |
| 103 { | 96 { |
| 104 if (NthIndexCache* nthIndexCache = element.document().nthIndexCache()) | 97 if (NthIndexCache* nthIndexCache = element.document().nthIndexCache()) |
| 105 return nthIndexCache->nthLastChildIndex(element) - 1; | 98 return nthIndexCache->nthLastChildIndex(element) - 1; |
| 106 | 99 |
| 107 int count = 0; | 100 int count = 0; |
| 108 for (const Element* sibling = ElementTraversal::nextSibling(element); siblin
g; sibling = ElementTraversal::nextSibling(*sibling)) | 101 for (const Element* sibling = ElementTraversal::nextSibling(element); siblin
g; sibling = ElementTraversal::nextSibling(*sibling)) |
| 109 ++count; | 102 ++count; |
| 110 return count; | 103 return count; |
| 111 } | 104 } |
| 112 | 105 |
| 113 inline int DOMSiblingTraversalStrategy::countElementsOfTypeAfter(Element& elemen
t, const QualifiedName& type) const | 106 inline int DOMSiblingTraversalStrategy::countElementsOfTypeAfter(Element& elemen
t, const QualifiedName& type) const |
| 114 { | 107 { |
| 108 if (NthIndexCache* nthIndexCache = element.document().nthIndexCache()) |
| 109 return nthIndexCache->nthLastChildIndexOfType(element, type) - 1; |
| 110 |
| 115 int count = 0; | 111 int count = 0; |
| 116 for (const Element* sibling = ElementTraversal::nextSibling(element, HasTagN
ame(type)); sibling; sibling = ElementTraversal::nextSibling(*sibling, HasTagNam
e(type))) | 112 for (const Element* sibling = ElementTraversal::nextSibling(element, HasTagN
ame(type)); sibling; sibling = ElementTraversal::nextSibling(*sibling, HasTagNam
e(type))) |
| 117 ++count; | 113 ++count; |
| 118 return count; | 114 return count; |
| 119 } | 115 } |
| 120 | 116 |
| 121 class ShadowDOMSiblingTraversalStrategy final { | 117 class ShadowDOMSiblingTraversalStrategy final { |
| 122 STACK_ALLOCATED(); | 118 STACK_ALLOCATED(); |
| 123 public: | 119 public: |
| 124 ShadowDOMSiblingTraversalStrategy(const WillBeHeapVector<RawPtrWillBeMember<
Node>, 32>& siblings, int nth) | 120 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)) | 234 if (m_siblings[i]->isElementNode() && toElement(m_siblings[i])->hasTagNa
me(type)) |
| 239 return ++count; | 235 return ++count; |
| 240 } | 236 } |
| 241 | 237 |
| 242 return count; | 238 return count; |
| 243 } | 239 } |
| 244 | 240 |
| 245 } | 241 } |
| 246 | 242 |
| 247 #endif | 243 #endif |
| OLD | NEW |