OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 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 | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. 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 ALWAYS_INLINE static void appendElement(OutputType& output, Node& element) | 56 ALWAYS_INLINE static void appendElement(OutputType& output, Node& element) |
57 { | 57 { |
58 output.append(&element); | 58 output.append(&element); |
59 } | 59 } |
60 }; | 60 }; |
61 | 61 |
62 enum ClassElementListBehavior { AllElements, OnlyRoots }; | 62 enum ClassElementListBehavior { AllElements, OnlyRoots }; |
63 | 63 |
64 template <ClassElementListBehavior onlyRoots> | 64 template <ClassElementListBehavior onlyRoots> |
65 class ClassElementList { | 65 class ClassElementList { |
| 66 STACK_ALLOCATED(); |
66 public: | 67 public: |
67 ClassElementList(ContainerNode& rootNode, const AtomicString& className) | 68 ClassElementList(ContainerNode& rootNode, const AtomicString& className) |
68 : m_className(className) | 69 : m_className(className) |
69 , m_rootNode(rootNode) | 70 , m_rootNode(&rootNode) |
70 , m_currentElement(nextInternal(ElementTraversal::firstWithin(rootNode))
) { } | 71 , m_currentElement(nextInternal(ElementTraversal::firstWithin(rootNode))
) { } |
71 | 72 |
72 bool isEmpty() const { return !m_currentElement; } | 73 bool isEmpty() const { return !m_currentElement; } |
73 | 74 |
74 Element* next() | 75 Element* next() |
75 { | 76 { |
76 Element* current = m_currentElement; | 77 Element* current = m_currentElement; |
77 ASSERT(current); | 78 ASSERT(current); |
78 if (onlyRoots) | 79 if (onlyRoots) |
79 m_currentElement = nextInternal(ElementTraversal::nextSkippingChildr
en(*m_currentElement, &m_rootNode)); | 80 m_currentElement = nextInternal(ElementTraversal::nextSkippingChildr
en(*m_currentElement, m_rootNode)); |
80 else | 81 else |
81 m_currentElement = nextInternal(ElementTraversal::next(*m_currentEle
ment, &m_rootNode)); | 82 m_currentElement = nextInternal(ElementTraversal::next(*m_currentEle
ment, m_rootNode)); |
82 return current; | 83 return current; |
83 } | 84 } |
84 | 85 |
85 private: | 86 private: |
86 Element* nextInternal(Element* element) | 87 Element* nextInternal(Element* element) |
87 { | 88 { |
88 for (; element; element = ElementTraversal::next(*element, &m_rootNode))
{ | 89 for (; element; element = ElementTraversal::next(*element, m_rootNode))
{ |
89 if (element->hasClass() && element->classNames().contains(m_classNam
e)) | 90 if (element->hasClass() && element->classNames().contains(m_classNam
e)) |
90 return element; | 91 return element; |
91 } | 92 } |
92 return 0; | 93 return 0; |
93 } | 94 } |
94 | 95 |
95 const AtomicString& m_className; | 96 const AtomicString& m_className; |
96 ContainerNode& m_rootNode; | 97 RawPtrWillBeMember<ContainerNode> m_rootNode; |
97 Element* m_currentElement; | 98 RawPtrWillBeMember<Element> m_currentElement; |
98 }; | 99 }; |
99 | 100 |
100 void SelectorDataList::initialize(const CSSSelectorList& selectorList) | 101 void SelectorDataList::initialize(const CSSSelectorList& selectorList) |
101 { | 102 { |
102 ASSERT(m_selectors.isEmpty()); | 103 ASSERT(m_selectors.isEmpty()); |
103 | 104 |
104 unsigned selectorCount = 0; | 105 unsigned selectorCount = 0; |
105 for (const CSSSelector* selector = selectorList.first(); selector; selector
= CSSSelectorList::next(*selector)) | 106 for (const CSSSelector* selector = selectorList.first(); selector; selector
= CSSSelectorList::next(*selector)) |
106 selectorCount++; | 107 selectorCount++; |
107 | 108 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 m_entries.add(selectors, selectorQuery.release()); | 516 m_entries.add(selectors, selectorQuery.release()); |
516 return rawSelectorQuery; | 517 return rawSelectorQuery; |
517 } | 518 } |
518 | 519 |
519 void SelectorQueryCache::invalidate() | 520 void SelectorQueryCache::invalidate() |
520 { | 521 { |
521 m_entries.clear(); | 522 m_entries.clear(); |
522 } | 523 } |
523 | 524 |
524 } | 525 } |
OLD | NEW |