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 27 matching lines...) Expand all Loading... |
38 class Element; | 38 class Element; |
39 class ExceptionState; | 39 class ExceptionState; |
40 class Node; | 40 class Node; |
41 class NodeList; | 41 class NodeList; |
42 class SimpleNodeList; | 42 class SimpleNodeList; |
43 class SpaceSplitString; | 43 class SpaceSplitString; |
44 | 44 |
45 class SelectorDataList { | 45 class SelectorDataList { |
46 public: | 46 public: |
47 void initialize(const CSSSelectorList&); | 47 void initialize(const CSSSelectorList&); |
48 bool matches(Element*) const; | 48 bool matches(Element&) const; |
49 PassRefPtr<NodeList> queryAll(Node* rootNode) const; | 49 PassRefPtr<NodeList> queryAll(Node& rootNode) const; |
50 PassRefPtr<Element> queryFirst(Node* rootNode) const; | 50 PassRefPtr<Element> queryFirst(Node& rootNode) const; |
51 | 51 |
52 private: | 52 private: |
53 struct SelectorData { | 53 struct SelectorData { |
54 SelectorData(const CSSSelector* selector, bool isFastCheckable) : select
or(selector), isFastCheckable(isFastCheckable) { } | 54 SelectorData(const CSSSelector* selector, bool isFastCheckable) : select
or(selector), isFastCheckable(isFastCheckable) { } |
55 const CSSSelector* selector; | 55 const CSSSelector* selector; |
56 bool isFastCheckable; | 56 bool isFastCheckable; |
57 }; | 57 }; |
58 | 58 |
59 bool canUseFastQuery(Node* rootNode) const; | 59 bool canUseFastQuery(const Node& rootNode) const; |
60 bool selectorMatches(const SelectorData&, Element*, const Node*) const; | 60 bool selectorMatches(const SelectorData&, Element&, const Node&) const; |
61 void collectElementsByClassName(Node* rootNode, const AtomicString& classNam
e, Vector<RefPtr<Node> >&) const; | 61 void collectElementsByClassName(Node& rootNode, const AtomicString& classNam
e, Vector<RefPtr<Node> >&) const; |
62 Element* findElementByClassName(Node* rootNode, const AtomicString& classNam
e) const; | 62 Element* findElementByClassName(Node& rootNode, const AtomicString& classNam
e) const; |
63 void collectElementsByTagName(Node* rootNode, const QualifiedName& tagName,
Vector<RefPtr<Node> >&) const; | 63 void collectElementsByTagName(Node& rootNode, const QualifiedName& tagName,
Vector<RefPtr<Node> >&) const; |
64 Element* findElementByTagName(Node* rootNode, const QualifiedName& tagName)
const; | 64 Element* findElementByTagName(Node& rootNode, const QualifiedName& tagName)
const; |
65 PassOwnPtr<SimpleNodeList> findTraverseRoots(Node* rootNode, bool& matchTrav
erseRoots) const; | 65 PassOwnPtr<SimpleNodeList> findTraverseRoots(Node* rootNode, bool& matchTrav
erseRoots) const; |
66 void executeSlowQueryAll(Node* rootNode, Vector<RefPtr<Node> >& matchedEleme
nts) const; | 66 void executeSlowQueryAll(Node& rootNode, Vector<RefPtr<Node> >& matchedEleme
nts) const; |
67 void executeQueryAll(Node* rootNode, Vector<RefPtr<Node> >& matchedElements)
const; | 67 void executeQueryAll(Node& rootNode, Vector<RefPtr<Node> >& matchedElements)
const; |
68 Node* findTraverseRoot(Node* rootNode, bool& matchTraverseRoot) const; | 68 Node* findTraverseRoot(Node& rootNode, bool& matchTraverseRoot) const; |
69 Element* executeSlowQueryFirst(Node* rootNode) const; | 69 Element* executeSlowQueryFirst(Node& rootNode) const; |
70 Element* executeQueryFirst(Node* rootNode) const; | 70 Element* executeQueryFirst(Node& rootNode) const; |
71 | 71 |
72 Vector<SelectorData> m_selectors; | 72 Vector<SelectorData> m_selectors; |
73 }; | 73 }; |
74 | 74 |
75 class SelectorQuery { | 75 class SelectorQuery { |
76 WTF_MAKE_NONCOPYABLE(SelectorQuery); | 76 WTF_MAKE_NONCOPYABLE(SelectorQuery); |
77 WTF_MAKE_FAST_ALLOCATED; | 77 WTF_MAKE_FAST_ALLOCATED; |
78 public: | 78 public: |
79 explicit SelectorQuery(const CSSSelectorList&); | 79 explicit SelectorQuery(const CSSSelectorList&); |
80 bool matches(Element*) const; | 80 bool matches(Element&) const; |
81 PassRefPtr<NodeList> queryAll(Node* rootNode) const; | 81 PassRefPtr<NodeList> queryAll(Node& rootNode) const; |
82 PassRefPtr<Element> queryFirst(Node* rootNode) const; | 82 PassRefPtr<Element> queryFirst(Node& rootNode) const; |
83 private: | 83 private: |
84 SelectorDataList m_selectors; | 84 SelectorDataList m_selectors; |
85 CSSSelectorList m_selectorList; | 85 CSSSelectorList m_selectorList; |
86 }; | 86 }; |
87 | 87 |
88 class SelectorQueryCache { | 88 class SelectorQueryCache { |
89 WTF_MAKE_FAST_ALLOCATED; | 89 WTF_MAKE_FAST_ALLOCATED; |
90 public: | 90 public: |
91 SelectorQuery* add(const AtomicString&, const Document&, ExceptionState&); | 91 SelectorQuery* add(const AtomicString&, const Document&, ExceptionState&); |
92 void invalidate(); | 92 void invalidate(); |
93 | 93 |
94 private: | 94 private: |
95 HashMap<AtomicString, OwnPtr<SelectorQuery> > m_entries; | 95 HashMap<AtomicString, OwnPtr<SelectorQuery> > m_entries; |
96 }; | 96 }; |
97 | 97 |
98 } | 98 } |
99 | 99 |
100 #endif | 100 #endif |
OLD | NEW |