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

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

Issue 14581013: Optimized querySelector(All) when selector contains #id. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed review issues in Patch Set 2 Created 7 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 | « PerformanceTests/Parser/query-selector-id-last.html ('k') | 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 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 PassRefPtr<Element> queryFirst(Node* rootNode) const; 49 PassRefPtr<Element> queryFirst(Node* rootNode) const;
50 50
51 private: 51 private:
52 struct SelectorData { 52 struct SelectorData {
53 SelectorData(const CSSSelector* selector, bool isFastCheckable) : select or(selector), isFastCheckable(isFastCheckable) { } 53 SelectorData(const CSSSelector* selector, bool isFastCheckable) : select or(selector), isFastCheckable(isFastCheckable) { }
54 const CSSSelector* selector; 54 const CSSSelector* selector;
55 bool isFastCheckable; 55 bool isFastCheckable;
56 }; 56 };
57 57
58 bool selectorMatches(const SelectorData&, Element*, const Node*) const; 58 bool selectorMatches(const SelectorData&, Element*, const Node*) const;
59 bool canUseIdLookup(Node* rootNode) const; 59 std::pair<bool, Node*> findTraverseRoot(Node* traverseRoot) const;
60 template <bool firstMatchOnly> 60 template <bool firstMatchOnly>
61 void execute(Node* rootNode, Vector<RefPtr<Node> >&) const; 61 void execute(Node* rootNode, Vector<RefPtr<Node> >&) const;
62 62
63 Vector<SelectorData> m_selectors; 63 Vector<SelectorData> m_selectors;
64 }; 64 };
65 65
66 class SelectorQuery { 66 class SelectorQuery {
67 WTF_MAKE_NONCOPYABLE(SelectorQuery); 67 WTF_MAKE_NONCOPYABLE(SelectorQuery);
68 WTF_MAKE_FAST_ALLOCATED; 68 WTF_MAKE_FAST_ALLOCATED;
69 public: 69 public:
(...skipping 12 matching lines...) Expand all
82 SelectorQuery* add(const AtomicString&, Document*, ExceptionCode&); 82 SelectorQuery* add(const AtomicString&, Document*, ExceptionCode&);
83 void invalidate(); 83 void invalidate();
84 84
85 private: 85 private:
86 HashMap<AtomicString, OwnPtr<SelectorQuery> > m_entries; 86 HashMap<AtomicString, OwnPtr<SelectorQuery> > m_entries;
87 }; 87 };
88 88
89 } 89 }
90 90
91 #endif 91 #endif
OLDNEW
« no previous file with comments | « PerformanceTests/Parser/query-selector-id-last.html ('k') | Source/core/dom/SelectorQuery.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698