OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 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 * | 4 * |
4 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
6 * are met: | 7 * are met: |
7 * | 8 * |
8 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
11 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 52 |
52 private: | 53 private: |
53 struct SelectorData { | 54 struct SelectorData { |
54 SelectorData(const CSSSelector* selector, bool isFastCheckable) : select
or(selector), isFastCheckable(isFastCheckable) { } | 55 SelectorData(const CSSSelector* selector, bool isFastCheckable) : select
or(selector), isFastCheckable(isFastCheckable) { } |
55 const CSSSelector* selector; | 56 const CSSSelector* selector; |
56 bool isFastCheckable; | 57 bool isFastCheckable; |
57 }; | 58 }; |
58 | 59 |
59 bool canUseFastQuery(const Node& rootNode) const; | 60 bool canUseFastQuery(const Node& rootNode) const; |
60 bool selectorMatches(const SelectorData&, Element&, const Node&) const; | 61 bool selectorMatches(const SelectorData&, Element&, const Node&) const; |
61 void collectElementsByClassName(Node& rootNode, const AtomicString& classNam
e, Vector<RefPtr<Node> >&) const; | 62 |
62 Element* findElementByClassName(Node& rootNode, const AtomicString& classNam
e) const; | 63 template <typename SelectorQueryTrait> |
63 void collectElementsByTagName(Node& rootNode, const QualifiedName& tagName,
Vector<RefPtr<Node> >&) const; | 64 void collectElementsByClassName(Node& rootNode, const AtomicString& classNam
e, typename SelectorQueryTrait::OutputType&) const; |
64 Element* findElementByTagName(Node& rootNode, const QualifiedName& tagName)
const; | 65 template <typename SelectorQueryTrait> |
65 PassOwnPtr<SimpleNodeList> findTraverseRoots(Node& rootNode, bool& matchTrav
erseRoots) const; | 66 void collectElementsByTagName(Node& rootNode, const QualifiedName& tagName,
typename SelectorQueryTrait::OutputType&) const; |
66 void executeSlowQueryAll(Node& rootNode, Vector<RefPtr<Node> >& matchedEleme
nts) const; | 67 |
67 void executeQueryAll(Node& rootNode, Vector<RefPtr<Node> >& matchedElements)
const; | 68 template <typename SelectorQueryTrait> |
68 Node* findTraverseRoot(Node& rootNode, bool& matchTraverseRoot) const; | 69 void findTraverseRootsAndExecute(Node& rootNode, typename SelectorQueryTrait
::OutputType&) const; |
69 Element* executeSlowQueryFirst(Node& rootNode) const; | 70 |
70 Element* executeQueryFirst(Node& rootNode) const; | 71 enum MatchTraverseRootState { DoesNotMatchTraverseRoots, MatchesTraverseRoot
s }; |
| 72 template <typename SelectorQueryTrait> |
| 73 void executeForTraverseRoot(const SelectorData&, Node* traverseRoot, MatchTr
averseRootState, Node& rootNode, typename SelectorQueryTrait::OutputType&) const
; |
| 74 template <typename SelectorQueryTrait, typename SimpleNodeListType> |
| 75 void executeForTraverseRoots(const SelectorData&, SimpleNodeListType& traver
seRoots, MatchTraverseRootState, Node& rootNode, typename SelectorQueryTrait::Ou
tputType&) const; |
| 76 |
| 77 template <typename SelectorQueryTrait> |
| 78 void executeSlow(Node& rootNode, typename SelectorQueryTrait::OutputType&) c
onst; |
| 79 template <typename SelectorQueryTrait> |
| 80 void execute(Node& rootNode, typename SelectorQueryTrait::OutputType&) const
; |
71 const CSSSelector* selectorForIdLookup(const CSSSelector*) const; | 81 const CSSSelector* selectorForIdLookup(const CSSSelector*) const; |
72 | 82 |
73 Vector<SelectorData> m_selectors; | 83 Vector<SelectorData> m_selectors; |
74 }; | 84 }; |
75 | 85 |
76 class SelectorQuery { | 86 class SelectorQuery { |
77 WTF_MAKE_NONCOPYABLE(SelectorQuery); | 87 WTF_MAKE_NONCOPYABLE(SelectorQuery); |
78 WTF_MAKE_FAST_ALLOCATED; | 88 WTF_MAKE_FAST_ALLOCATED; |
79 public: | 89 public: |
80 explicit SelectorQuery(const CSSSelectorList&); | 90 explicit SelectorQuery(const CSSSelectorList&); |
(...skipping 11 matching lines...) Expand all Loading... |
92 SelectorQuery* add(const AtomicString&, const Document&, ExceptionState&); | 102 SelectorQuery* add(const AtomicString&, const Document&, ExceptionState&); |
93 void invalidate(); | 103 void invalidate(); |
94 | 104 |
95 private: | 105 private: |
96 HashMap<AtomicString, OwnPtr<SelectorQuery> > m_entries; | 106 HashMap<AtomicString, OwnPtr<SelectorQuery> > m_entries; |
97 }; | 107 }; |
98 | 108 |
99 } | 109 } |
100 | 110 |
101 #endif | 111 #endif |
OLD | NEW |