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

Unified Diff: Source/core/dom/SelectorQuery.h

Issue 142513003: Use Traits in SelectorQuery to avoid a lot of code duplication (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Take Adam's feedback into consideration Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/dom/SelectorQuery.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/SelectorQuery.h
diff --git a/Source/core/dom/SelectorQuery.h b/Source/core/dom/SelectorQuery.h
index e11c566902389f254f4f58b13284f2bd9ff16bb6..db952daec1945f51a7847a41ffa2ad6e32c18e56 100644
--- a/Source/core/dom/SelectorQuery.h
+++ b/Source/core/dom/SelectorQuery.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Samsung Electronics. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -58,16 +59,25 @@ private:
bool canUseFastQuery(const Node& rootNode) const;
bool selectorMatches(const SelectorData&, Element&, const Node&) const;
- void collectElementsByClassName(Node& rootNode, const AtomicString& className, Vector<RefPtr<Node> >&) const;
- Element* findElementByClassName(Node& rootNode, const AtomicString& className) const;
- void collectElementsByTagName(Node& rootNode, const QualifiedName& tagName, Vector<RefPtr<Node> >&) const;
- Element* findElementByTagName(Node& rootNode, const QualifiedName& tagName) const;
- PassOwnPtr<SimpleNodeList> findTraverseRoots(Node& rootNode, bool& matchTraverseRoots) const;
- void executeSlowQueryAll(Node& rootNode, Vector<RefPtr<Node> >& matchedElements) const;
- void executeQueryAll(Node& rootNode, Vector<RefPtr<Node> >& matchedElements) const;
- Node* findTraverseRoot(Node& rootNode, bool& matchTraverseRoot) const;
- Element* executeSlowQueryFirst(Node& rootNode) const;
- Element* executeQueryFirst(Node& rootNode) const;
+
+ template <typename SelectorQueryTrait>
+ void collectElementsByClassName(Node& rootNode, const AtomicString& className, typename SelectorQueryTrait::OutputType&) const;
+ template <typename SelectorQueryTrait>
+ void collectElementsByTagName(Node& rootNode, const QualifiedName& tagName, typename SelectorQueryTrait::OutputType&) const;
+
+ template <typename SelectorQueryTrait>
+ void findTraverseRootsAndExecute(Node& rootNode, typename SelectorQueryTrait::OutputType&) const;
+
+ enum MatchTraverseRootState { DoesNotMatchTraverseRoots, MatchesTraverseRoots };
+ template <typename SelectorQueryTrait>
+ void executeForTraverseRoot(const SelectorData&, Node* traverseRoot, MatchTraverseRootState, Node& rootNode, typename SelectorQueryTrait::OutputType&) const;
+ template <typename SelectorQueryTrait, typename SimpleNodeListType>
+ void executeForTraverseRoots(const SelectorData&, SimpleNodeListType& traverseRoots, MatchTraverseRootState, Node& rootNode, typename SelectorQueryTrait::OutputType&) const;
+
+ template <typename SelectorQueryTrait>
+ void executeSlow(Node& rootNode, typename SelectorQueryTrait::OutputType&) const;
+ template <typename SelectorQueryTrait>
+ void execute(Node& rootNode, typename SelectorQueryTrait::OutputType&) const;
const CSSSelector* selectorForIdLookup(const CSSSelector*) const;
Vector<SelectorData> m_selectors;
« no previous file with comments | « no previous file | Source/core/dom/SelectorQuery.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698