Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Side by Side Diff: third_party/WebKit/Source/core/dom/SelectorQuery.h

Issue 2875673006: Allow using SelectorQuery fast paths in quirks mode and disconnected subtrees. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/SelectorQuery.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 unsigned slow_traversing_shadow_tree_scan; 74 unsigned slow_traversing_shadow_tree_scan;
75 }; 75 };
76 // Used by unit tests to get information about what paths were taken during 76 // Used by unit tests to get information about what paths were taken during
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;
85
86 template <typename SelectorQueryTrait> 84 template <typename SelectorQueryTrait>
87 void ExecuteWithId(ContainerNode& root_node, 85 void ExecuteWithId(ContainerNode& root_node,
88 typename SelectorQueryTrait::OutputType&) const; 86 typename SelectorQueryTrait::OutputType&) const;
89 template <typename SelectorQueryTrait> 87 template <typename SelectorQueryTrait>
90 void FindTraverseRootsAndExecute( 88 void FindTraverseRootsAndExecute(
91 ContainerNode& root_node, 89 ContainerNode& root_node,
92 typename SelectorQueryTrait::OutputType&) const; 90 typename SelectorQueryTrait::OutputType&) const;
93 template <typename SelectorQueryTrait> 91 template <typename SelectorQueryTrait>
94 void ExecuteForTraverseRoot(ContainerNode& traverse_root, 92 void ExecuteForTraverseRoot(ContainerNode& traverse_root,
95 ContainerNode& root_node, 93 ContainerNode& root_node,
(...skipping 15 matching lines...) Expand all
111 // Contains the list of CSSSelector's to match, but without ones that could 109 // Contains the list of CSSSelector's to match, but without ones that could
112 // never match like pseudo elements, div::before. This can be empty, while 110 // never match like pseudo elements, div::before. This can be empty, while
113 // m_selectorList will never be empty as SelectorQueryCache::add would have 111 // m_selectorList will never be empty as SelectorQueryCache::add would have
114 // thrown an exception. 112 // thrown an exception.
115 Vector<const CSSSelector*> selectors_; 113 Vector<const CSSSelector*> selectors_;
116 AtomicString selector_id_; 114 AtomicString selector_id_;
117 bool selector_id_is_rightmost_ : 1; 115 bool selector_id_is_rightmost_ : 1;
118 bool selector_id_affected_by_sibling_combinator_ : 1; 116 bool selector_id_affected_by_sibling_combinator_ : 1;
119 bool uses_deep_combinator_or_shadow_pseudo_ : 1; 117 bool uses_deep_combinator_or_shadow_pseudo_ : 1;
120 bool needs_updated_distribution_ : 1; 118 bool needs_updated_distribution_ : 1;
119 bool use_slow_scan_ : 1;
121 }; 120 };
122 121
123 class SelectorQueryCache { 122 class SelectorQueryCache {
124 USING_FAST_MALLOC(SelectorQueryCache); 123 USING_FAST_MALLOC(SelectorQueryCache);
125 124
126 public: 125 public:
127 SelectorQuery* Add(const AtomicString&, const Document&, ExceptionState&); 126 SelectorQuery* Add(const AtomicString&, const Document&, ExceptionState&);
128 void Invalidate(); 127 void Invalidate();
129 128
130 private: 129 private:
131 HashMap<AtomicString, std::unique_ptr<SelectorQuery>> entries_; 130 HashMap<AtomicString, std::unique_ptr<SelectorQuery>> entries_;
132 }; 131 };
133 132
134 } // namespace blink 133 } // namespace blink
135 134
136 #endif 135 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/SelectorQuery.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698