| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // the last query. Always reset between queries. This system is disabled in | 77 // the last query. Always reset between queries. This system is disabled in |
| 78 // non DCHECK builds to avoid the overhead on the query process. | 78 // non DCHECK builds to avoid the overhead on the query process. |
| 79 static QueryStats LastQueryStats(); | 79 static QueryStats LastQueryStats(); |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 explicit SelectorQuery(CSSSelectorList); | 82 explicit SelectorQuery(CSSSelectorList); |
| 83 | 83 |
| 84 bool CanUseFastQuery(const ContainerNode& root_node) const; | 84 bool CanUseFastQuery(const ContainerNode& root_node) const; |
| 85 | 85 |
| 86 template <typename SelectorQueryTrait> | 86 template <typename SelectorQueryTrait> |
| 87 void ExecuteWithId(ContainerNode& root_node, |
| 88 typename SelectorQueryTrait::OutputType&) const; |
| 89 template <typename SelectorQueryTrait> |
| 87 void FindTraverseRootsAndExecute( | 90 void FindTraverseRootsAndExecute( |
| 88 ContainerNode& root_node, | 91 ContainerNode& root_node, |
| 89 typename SelectorQueryTrait::OutputType&) const; | 92 typename SelectorQueryTrait::OutputType&) const; |
| 90 template <typename SelectorQueryTrait> | 93 template <typename SelectorQueryTrait> |
| 91 void ExecuteForTraverseRoot(ContainerNode& traverse_root, | 94 void ExecuteForTraverseRoot(ContainerNode& traverse_root, |
| 92 ContainerNode& root_node, | 95 ContainerNode& root_node, |
| 93 typename SelectorQueryTrait::OutputType&) const; | 96 typename SelectorQueryTrait::OutputType&) const; |
| 94 template <typename SelectorQueryTrait> | 97 template <typename SelectorQueryTrait> |
| 95 void ExecuteSlow(ContainerNode& root_node, | 98 void ExecuteSlow(ContainerNode& root_node, |
| 96 typename SelectorQueryTrait::OutputType&) const; | 99 typename SelectorQueryTrait::OutputType&) const; |
| 97 template <typename SelectorQueryTrait> | 100 template <typename SelectorQueryTrait> |
| 98 void ExecuteSlowTraversingShadowTree( | 101 void ExecuteSlowTraversingShadowTree( |
| 99 ContainerNode& root_node, | 102 ContainerNode& root_node, |
| 100 typename SelectorQueryTrait::OutputType&) const; | 103 typename SelectorQueryTrait::OutputType&) const; |
| 101 template <typename SelectorQueryTrait> | 104 template <typename SelectorQueryTrait> |
| 102 void Execute(ContainerNode& root_node, | 105 void Execute(ContainerNode& root_node, |
| 103 typename SelectorQueryTrait::OutputType&) const; | 106 typename SelectorQueryTrait::OutputType&) const; |
| 104 | 107 |
| 105 bool SelectorListMatches(ContainerNode& root_node, Element&) const; | 108 bool SelectorListMatches(ContainerNode& root_node, Element&) const; |
| 106 | 109 |
| 107 CSSSelectorList selector_list_; | 110 CSSSelectorList selector_list_; |
| 108 // Contains the list of CSSSelector's to match, but without ones that could | 111 // Contains the list of CSSSelector's to match, but without ones that could |
| 109 // never match like pseudo elements, div::before. This can be empty, while | 112 // never match like pseudo elements, div::before. This can be empty, while |
| 110 // m_selectorList will never be empty as SelectorQueryCache::add would have | 113 // m_selectorList will never be empty as SelectorQueryCache::add would have |
| 111 // thrown an exception. | 114 // thrown an exception. |
| 112 Vector<const CSSSelector*> selectors_; | 115 Vector<const CSSSelector*> selectors_; |
| 116 AtomicString selector_id_; |
| 117 bool selector_id_is_rightmost_ : 1; |
| 118 bool selector_id_affected_by_sibling_combinator_ : 1; |
| 113 bool uses_deep_combinator_or_shadow_pseudo_ : 1; | 119 bool uses_deep_combinator_or_shadow_pseudo_ : 1; |
| 114 bool needs_updated_distribution_ : 1; | 120 bool needs_updated_distribution_ : 1; |
| 115 }; | 121 }; |
| 116 | 122 |
| 117 class SelectorQueryCache { | 123 class SelectorQueryCache { |
| 118 USING_FAST_MALLOC(SelectorQueryCache); | 124 USING_FAST_MALLOC(SelectorQueryCache); |
| 119 | 125 |
| 120 public: | 126 public: |
| 121 SelectorQuery* Add(const AtomicString&, const Document&, ExceptionState&); | 127 SelectorQuery* Add(const AtomicString&, const Document&, ExceptionState&); |
| 122 void Invalidate(); | 128 void Invalidate(); |
| 123 | 129 |
| 124 private: | 130 private: |
| 125 HashMap<AtomicString, std::unique_ptr<SelectorQuery>> entries_; | 131 HashMap<AtomicString, std::unique_ptr<SelectorQuery>> entries_; |
| 126 }; | 132 }; |
| 127 | 133 |
| 128 } // namespace blink | 134 } // namespace blink |
| 129 | 135 |
| 130 #endif | 136 #endif |
| OLD | NEW |