| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2014 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 if (cachedNode()) | 56 if (cachedNode()) |
| 57 return !cachedNodeIndex() && !nodeAt(collection, 1); | 57 return !cachedNodeIndex() && !nodeAt(collection, 1); |
| 58 return nodeAt(collection, 0) && !nodeAt(collection, 1); | 58 return nodeAt(collection, 0) && !nodeAt(collection, 1); |
| 59 } | 59 } |
| 60 | 60 |
| 61 unsigned nodeCount(const Collection&); | 61 unsigned nodeCount(const Collection&); |
| 62 NodeType* nodeAt(const Collection&, unsigned index); | 62 NodeType* nodeAt(const Collection&, unsigned index); |
| 63 | 63 |
| 64 void invalidate(); | 64 void invalidate(); |
| 65 | 65 |
| 66 ALWAYS_INLINE void setCachedNode(NodeType* node, unsigned index) | |
| 67 { | |
| 68 ASSERT(node); | |
| 69 m_currentNode = node; | |
| 70 m_cachedNodeIndex = index; | |
| 71 } | |
| 72 | |
| 73 private: | 66 private: |
| 74 NodeType* nodeBeforeOrAfterCachedNode(const Collection&, unsigned index, con
st ContainerNode& root); | 67 NodeType* nodeBeforeOrAfterCachedNode(const Collection&, unsigned index, con
st ContainerNode& root); |
| 75 bool isLastNodeCloserThanLastOrCachedNode(unsigned index) const; | 68 bool isLastNodeCloserThanLastOrCachedNode(unsigned index) const; |
| 76 bool isFirstNodeCloserThanCachedNode(unsigned index) const; | 69 bool isFirstNodeCloserThanCachedNode(unsigned index) const; |
| 77 | 70 |
| 78 ALWAYS_INLINE NodeType* cachedNode() const { return m_currentNode; } | 71 ALWAYS_INLINE NodeType* cachedNode() const { return m_currentNode; } |
| 79 ALWAYS_INLINE unsigned cachedNodeIndex() const { ASSERT(cachedNode()); retur
n m_cachedNodeIndex; } | 72 ALWAYS_INLINE unsigned cachedNodeIndex() const { ASSERT(cachedNode()); retur
n m_cachedNodeIndex; } |
| 73 ALWAYS_INLINE void setCachedNode(NodeType* node, unsigned index) |
| 74 { |
| 75 ASSERT(node); |
| 76 m_currentNode = node; |
| 77 m_cachedNodeIndex = index; |
| 78 } |
| 80 | 79 |
| 81 ALWAYS_INLINE bool isCachedNodeCountValid() const { return m_isLengthCacheVa
lid; } | 80 ALWAYS_INLINE bool isCachedNodeCountValid() const { return m_isLengthCacheVa
lid; } |
| 82 ALWAYS_INLINE unsigned cachedNodeCount() const { return m_cachedNodeCount; } | 81 ALWAYS_INLINE unsigned cachedNodeCount() const { return m_cachedNodeCount; } |
| 83 ALWAYS_INLINE void setCachedNodeCount(unsigned length) | 82 ALWAYS_INLINE void setCachedNodeCount(unsigned length) |
| 84 { | 83 { |
| 85 m_cachedNodeCount = length; | 84 m_cachedNodeCount = length; |
| 86 m_isLengthCacheValid = true; | 85 m_isLengthCacheValid = true; |
| 87 } | 86 } |
| 88 | 87 |
| 89 NodeType* m_currentNode; | 88 NodeType* m_currentNode; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 if (cachedNodeIndex() < index) | 198 if (cachedNodeIndex() < index) |
| 200 return false; | 199 return false; |
| 201 | 200 |
| 202 unsigned distanceFromCachedNode = cachedNodeIndex() - index; | 201 unsigned distanceFromCachedNode = cachedNodeIndex() - index; |
| 203 return index < distanceFromCachedNode; | 202 return index < distanceFromCachedNode; |
| 204 } | 203 } |
| 205 | 204 |
| 206 } // namespace WebCore | 205 } // namespace WebCore |
| 207 | 206 |
| 208 #endif // CollectionIndexCache_h | 207 #endif // CollectionIndexCache_h |
| OLD | NEW |