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 10 matching lines...) Expand all Loading... |
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #ifndef SelectorQuery_h | 27 #ifndef SelectorQuery_h |
28 #define SelectorQuery_h | 28 #define SelectorQuery_h |
29 | 29 |
30 #include "core/css/CSSSelectorList.h" | 30 #include "core/css/CSSSelectorList.h" |
| 31 #include "platform/heap/Handle.h" |
31 #include "wtf/HashMap.h" | 32 #include "wtf/HashMap.h" |
32 #include "wtf/Vector.h" | 33 #include "wtf/Vector.h" |
33 #include "wtf/text/AtomicStringHash.h" | 34 #include "wtf/text/AtomicStringHash.h" |
34 | 35 |
35 namespace WebCore { | 36 namespace WebCore { |
36 | 37 |
37 class CSSSelector; | 38 class CSSSelector; |
38 class ContainerNode; | 39 class ContainerNode; |
39 class Document; | 40 class Document; |
40 class Element; | 41 class Element; |
41 class ExceptionState; | 42 class ExceptionState; |
42 class Node; | 43 class Node; |
43 class NodeList; | 44 class NodeList; |
44 class SimpleNodeList; | 45 class SimpleNodeList; |
45 class SpaceSplitString; | 46 class SpaceSplitString; |
46 | 47 |
47 class SelectorDataList { | 48 class SelectorDataList { |
48 public: | 49 public: |
49 void initialize(const CSSSelectorList&); | 50 void initialize(const CSSSelectorList&); |
50 bool matches(Element&) const; | 51 bool matches(Element&) const; |
51 PassRefPtr<NodeList> queryAll(ContainerNode& rootNode) const; | 52 PassRefPtrWillBeRawPtr<NodeList> queryAll(ContainerNode& rootNode) const; |
52 PassRefPtr<Element> queryFirst(ContainerNode& rootNode) const; | 53 PassRefPtr<Element> queryFirst(ContainerNode& rootNode) const; |
53 | 54 |
54 private: | 55 private: |
55 bool canUseFastQuery(const ContainerNode& rootNode) const; | 56 bool canUseFastQuery(const ContainerNode& rootNode) const; |
56 bool selectorMatches(const CSSSelector&, Element&, const ContainerNode&) con
st; | 57 bool selectorMatches(const CSSSelector&, Element&, const ContainerNode&) con
st; |
57 | 58 |
58 template <typename SelectorQueryTrait> | 59 template <typename SelectorQueryTrait> |
59 void collectElementsByClassName(ContainerNode& rootNode, const AtomicString&
className, typename SelectorQueryTrait::OutputType&) const; | 60 void collectElementsByClassName(ContainerNode& rootNode, const AtomicString&
className, typename SelectorQueryTrait::OutputType&) const; |
60 template <typename SelectorQueryTrait> | 61 template <typename SelectorQueryTrait> |
61 void collectElementsByTagName(ContainerNode& rootNode, const QualifiedName&
tagName, typename SelectorQueryTrait::OutputType&) const; | 62 void collectElementsByTagName(ContainerNode& rootNode, const QualifiedName&
tagName, typename SelectorQueryTrait::OutputType&) const; |
(...skipping 20 matching lines...) Expand all Loading... |
82 Vector<const CSSSelector*> m_selectors; | 83 Vector<const CSSSelector*> m_selectors; |
83 bool m_crossesTreeBoundary; | 84 bool m_crossesTreeBoundary; |
84 }; | 85 }; |
85 | 86 |
86 class SelectorQuery { | 87 class SelectorQuery { |
87 WTF_MAKE_NONCOPYABLE(SelectorQuery); | 88 WTF_MAKE_NONCOPYABLE(SelectorQuery); |
88 WTF_MAKE_FAST_ALLOCATED; | 89 WTF_MAKE_FAST_ALLOCATED; |
89 public: | 90 public: |
90 explicit SelectorQuery(const CSSSelectorList&); | 91 explicit SelectorQuery(const CSSSelectorList&); |
91 bool matches(Element&) const; | 92 bool matches(Element&) const; |
92 PassRefPtr<NodeList> queryAll(ContainerNode& rootNode) const; | 93 PassRefPtrWillBeRawPtr<NodeList> queryAll(ContainerNode& rootNode) const; |
93 PassRefPtr<Element> queryFirst(ContainerNode& rootNode) const; | 94 PassRefPtr<Element> queryFirst(ContainerNode& rootNode) const; |
94 private: | 95 private: |
95 SelectorDataList m_selectors; | 96 SelectorDataList m_selectors; |
96 CSSSelectorList m_selectorList; | 97 CSSSelectorList m_selectorList; |
97 }; | 98 }; |
98 | 99 |
99 class SelectorQueryCache { | 100 class SelectorQueryCache { |
100 WTF_MAKE_FAST_ALLOCATED; | 101 WTF_MAKE_FAST_ALLOCATED; |
101 public: | 102 public: |
102 SelectorQuery* add(const AtomicString&, const Document&, ExceptionState&); | 103 SelectorQuery* add(const AtomicString&, const Document&, ExceptionState&); |
103 void invalidate(); | 104 void invalidate(); |
104 | 105 |
105 private: | 106 private: |
106 HashMap<AtomicString, OwnPtr<SelectorQuery> > m_entries; | 107 HashMap<AtomicString, OwnPtr<SelectorQuery> > m_entries; |
107 }; | 108 }; |
108 | 109 |
109 } | 110 } |
110 | 111 |
111 #endif | 112 #endif |
OLD | NEW |