OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 public: | 42 public: |
43 virtual ~SimpleNodeList() { } | 43 virtual ~SimpleNodeList() { } |
44 virtual bool isEmpty() const = 0; | 44 virtual bool isEmpty() const = 0; |
45 virtual Node* next() = 0; | 45 virtual Node* next() = 0; |
46 }; | 46 }; |
47 | 47 |
48 class SingleNodeList FINAL : public SimpleNodeList { | 48 class SingleNodeList FINAL : public SimpleNodeList { |
49 public: | 49 public: |
50 explicit SingleNodeList(Node* rootNode) : m_currentNode(rootNode) { } | 50 explicit SingleNodeList(Node* rootNode) : m_currentNode(rootNode) { } |
51 | 51 |
52 bool isEmpty() const OVERRIDE { return !m_currentNode; } | 52 virtual bool isEmpty() const OVERRIDE { return !m_currentNode; } |
53 | 53 |
54 Node* next() OVERRIDE | 54 virtual Node* next() OVERRIDE |
55 { | 55 { |
56 Node* current = m_currentNode; | 56 Node* current = m_currentNode; |
57 m_currentNode = 0; | 57 m_currentNode = 0; |
58 return current; | 58 return current; |
59 } | 59 } |
60 | 60 |
61 private: | 61 private: |
62 Node* m_currentNode; | 62 Node* m_currentNode; |
63 }; | 63 }; |
64 | 64 |
65 class ClassRootNodeList FINAL : public SimpleNodeList { | 65 class ClassRootNodeList FINAL : public SimpleNodeList { |
66 public: | 66 public: |
67 ClassRootNodeList(Node& rootNode, const AtomicString& className) | 67 ClassRootNodeList(Node& rootNode, const AtomicString& className) |
68 : m_className(className) | 68 : m_className(className) |
69 , m_rootNode(rootNode) | 69 , m_rootNode(rootNode) |
70 , m_currentElement(nextInternal(ElementTraversal::firstWithin(m_rootNode
))) { } | 70 , m_currentElement(nextInternal(ElementTraversal::firstWithin(m_rootNode
))) { } |
71 | 71 |
72 bool isEmpty() const OVERRIDE { return !m_currentElement; } | 72 virtual bool isEmpty() const OVERRIDE { return !m_currentElement; } |
73 | 73 |
74 Node* next() OVERRIDE | 74 virtual Node* next() OVERRIDE |
75 { | 75 { |
76 Node* current = m_currentElement; | 76 Node* current = m_currentElement; |
77 ASSERT(current); | 77 ASSERT(current); |
78 m_currentElement = nextInternal(ElementTraversal::nextSkippingChildren(*
m_currentElement, &m_rootNode)); | 78 m_currentElement = nextInternal(ElementTraversal::nextSkippingChildren(*
m_currentElement, &m_rootNode)); |
79 return current; | 79 return current; |
80 } | 80 } |
81 | 81 |
82 private: | 82 private: |
83 Element* nextInternal(Element* element) | 83 Element* nextInternal(Element* element) |
84 { | 84 { |
85 for (; element; element = ElementTraversal::next(*element, &m_rootNode))
{ | 85 for (; element; element = ElementTraversal::next(*element, &m_rootNode))
{ |
86 if (element->hasClass() && element->classNames().contains(m_classNam
e)) | 86 if (element->hasClass() && element->classNames().contains(m_classNam
e)) |
87 return element; | 87 return element; |
88 } | 88 } |
89 return 0; | 89 return 0; |
90 } | 90 } |
91 | 91 |
92 const AtomicString& m_className; | 92 const AtomicString& m_className; |
93 Node& m_rootNode; | 93 Node& m_rootNode; |
94 Element* m_currentElement; | 94 Element* m_currentElement; |
95 }; | 95 }; |
96 | 96 |
97 class ClassElementList FINAL : public SimpleNodeList { | 97 class ClassElementList FINAL : public SimpleNodeList { |
98 public: | 98 public: |
99 ClassElementList(Node& rootNode, const AtomicString& className) | 99 ClassElementList(Node& rootNode, const AtomicString& className) |
100 : m_className(className) | 100 : m_className(className) |
101 , m_rootNode(rootNode) | 101 , m_rootNode(rootNode) |
102 , m_currentElement(nextInternal(ElementTraversal::firstWithin(rootNode))
) { } | 102 , m_currentElement(nextInternal(ElementTraversal::firstWithin(rootNode))
) { } |
103 | 103 |
104 bool isEmpty() const OVERRIDE { return !m_currentElement; } | 104 virtual bool isEmpty() const OVERRIDE { return !m_currentElement; } |
105 | 105 |
106 Node* next() OVERRIDE | 106 virtual Node* next() OVERRIDE |
107 { | 107 { |
108 Node* current = m_currentElement; | 108 Node* current = m_currentElement; |
109 ASSERT(current); | 109 ASSERT(current); |
110 m_currentElement = nextInternal(ElementTraversal::next(*m_currentElement
, &m_rootNode)); | 110 m_currentElement = nextInternal(ElementTraversal::next(*m_currentElement
, &m_rootNode)); |
111 return current; | 111 return current; |
112 } | 112 } |
113 | 113 |
114 private: | 114 private: |
115 Element* nextInternal(Element* element) | 115 Element* nextInternal(Element* element) |
116 { | 116 { |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 m_entries.add(selectors, selectorQuery.release()); | 559 m_entries.add(selectors, selectorQuery.release()); |
560 return rawSelectorQuery; | 560 return rawSelectorQuery; |
561 } | 561 } |
562 | 562 |
563 void SelectorQueryCache::invalidate() | 563 void SelectorQueryCache::invalidate() |
564 { | 564 { |
565 m_entries.clear(); | 565 m_entries.clear(); |
566 } | 566 } |
567 | 567 |
568 } | 568 } |
OLD | NEW |