| 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 22 matching lines...) Expand all Loading... |
| 33 #include "wtf/Vector.h" | 33 #include "wtf/Vector.h" |
| 34 #include "wtf/text/AtomicStringHash.h" | 34 #include "wtf/text/AtomicStringHash.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 class CSSSelector; | 38 class CSSSelector; |
| 39 class ContainerNode; | 39 class ContainerNode; |
| 40 class Document; | 40 class Document; |
| 41 class Element; | 41 class Element; |
| 42 class ExceptionState; | 42 class ExceptionState; |
| 43 class StaticNodeList; | 43 template <typename NodeType> class StaticNodeTypeList; |
| 44 typedef StaticNodeTypeList<Element> StaticElementList; |
| 44 | 45 |
| 45 class SelectorDataList { | 46 class SelectorDataList { |
| 46 public: | 47 public: |
| 47 void initialize(const CSSSelectorList&); | 48 void initialize(const CSSSelectorList&); |
| 48 bool matches(Element&) const; | 49 bool matches(Element&) const; |
| 49 PassRefPtrWillBeRawPtr<StaticNodeList> queryAll(ContainerNode& rootNode) con
st; | 50 PassRefPtrWillBeRawPtr<StaticElementList> queryAll(ContainerNode& rootNode)
const; |
| 50 PassRefPtrWillBeRawPtr<Element> queryFirst(ContainerNode& rootNode) const; | 51 PassRefPtrWillBeRawPtr<Element> queryFirst(ContainerNode& rootNode) const; |
| 51 | 52 |
| 52 private: | 53 private: |
| 53 bool canUseFastQuery(const ContainerNode& rootNode) const; | 54 bool canUseFastQuery(const ContainerNode& rootNode) const; |
| 54 bool selectorMatches(const CSSSelector&, Element&, const ContainerNode&) con
st; | 55 bool selectorMatches(const CSSSelector&, Element&, const ContainerNode&) con
st; |
| 55 | 56 |
| 56 template <typename SelectorQueryTrait> | 57 template <typename SelectorQueryTrait> |
| 57 void collectElementsByClassName(ContainerNode& rootNode, const AtomicString&
className, typename SelectorQueryTrait::OutputType&) const; | 58 void collectElementsByClassName(ContainerNode& rootNode, const AtomicString&
className, typename SelectorQueryTrait::OutputType&) const; |
| 58 template <typename SelectorQueryTrait> | 59 template <typename SelectorQueryTrait> |
| 59 void collectElementsByTagName(ContainerNode& rootNode, const QualifiedName&
tagName, typename SelectorQueryTrait::OutputType&) const; | 60 void collectElementsByTagName(ContainerNode& rootNode, const QualifiedName&
tagName, typename SelectorQueryTrait::OutputType&) const; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 81 bool m_crossesTreeBoundary; | 82 bool m_crossesTreeBoundary; |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 class SelectorQuery { | 85 class SelectorQuery { |
| 85 WTF_MAKE_NONCOPYABLE(SelectorQuery); | 86 WTF_MAKE_NONCOPYABLE(SelectorQuery); |
| 86 WTF_MAKE_FAST_ALLOCATED; | 87 WTF_MAKE_FAST_ALLOCATED; |
| 87 public: | 88 public: |
| 88 static PassOwnPtr<SelectorQuery> adopt(CSSSelectorList&); | 89 static PassOwnPtr<SelectorQuery> adopt(CSSSelectorList&); |
| 89 | 90 |
| 90 bool matches(Element&) const; | 91 bool matches(Element&) const; |
| 91 PassRefPtrWillBeRawPtr<StaticNodeList> queryAll(ContainerNode& rootNode) con
st; | 92 PassRefPtrWillBeRawPtr<StaticElementList> queryAll(ContainerNode& rootNode)
const; |
| 92 PassRefPtrWillBeRawPtr<Element> queryFirst(ContainerNode& rootNode) const; | 93 PassRefPtrWillBeRawPtr<Element> queryFirst(ContainerNode& rootNode) const; |
| 93 private: | 94 private: |
| 94 explicit SelectorQuery(CSSSelectorList&); | 95 explicit SelectorQuery(CSSSelectorList&); |
| 95 | 96 |
| 96 SelectorDataList m_selectors; | 97 SelectorDataList m_selectors; |
| 97 CSSSelectorList m_selectorList; | 98 CSSSelectorList m_selectorList; |
| 98 }; | 99 }; |
| 99 | 100 |
| 100 class SelectorQueryCache { | 101 class SelectorQueryCache { |
| 101 WTF_MAKE_FAST_ALLOCATED; | 102 WTF_MAKE_FAST_ALLOCATED; |
| 102 public: | 103 public: |
| 103 SelectorQuery* add(const AtomicString&, const Document&, ExceptionState&); | 104 SelectorQuery* add(const AtomicString&, const Document&, ExceptionState&); |
| 104 void invalidate(); | 105 void invalidate(); |
| 105 | 106 |
| 106 private: | 107 private: |
| 107 HashMap<AtomicString, OwnPtr<SelectorQuery> > m_entries; | 108 HashMap<AtomicString, OwnPtr<SelectorQuery> > m_entries; |
| 108 }; | 109 }; |
| 109 | 110 |
| 110 } | 111 } |
| 111 | 112 |
| 112 #endif | 113 #endif |
| OLD | NEW |