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

Side by Side Diff: sky/engine/core/css/SelectorChecker.h

Issue 801283006: Get rid of SelectorCheckingContext. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: missing static. Created 5 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 unified diff | Download patch
« no previous file with comments | « sky/engine/core/css/ElementRuleCollector.cpp ('k') | sky/engine/core/css/SelectorChecker.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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 10 matching lines...) Expand all
21 * 21 *
22 * You should have received a copy of the GNU Library General Public License 22 * You should have received a copy of the GNU Library General Public License
23 * along with this library; see the file COPYING.LIB. If not, write to 23 * along with this library; see the file COPYING.LIB. If not, write to
24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 * Boston, MA 02110-1301, USA. 25 * Boston, MA 02110-1301, USA.
26 */ 26 */
27 27
28 #ifndef SKY_ENGINE_CORE_CSS_SELECTORCHECKER_H_ 28 #ifndef SKY_ENGINE_CORE_CSS_SELECTORCHECKER_H_
29 #define SKY_ENGINE_CORE_CSS_SELECTORCHECKER_H_ 29 #define SKY_ENGINE_CORE_CSS_SELECTORCHECKER_H_
30 30
31 #include "sky/engine/core/css/CSSSelector.h"
32 #include "sky/engine/core/dom/Element.h" 31 #include "sky/engine/core/dom/Element.h"
33 32
34 namespace blink { 33 namespace blink {
35 34
36 class CSSSelector; 35 class CSSSelector;
37 class ContainerNode; 36 class ContainerNode;
38 class Element; 37 class Element;
39 class RenderStyle;
40 38
41 class SelectorChecker { 39 class SelectorChecker {
42 WTF_MAKE_NONCOPYABLE(SelectorChecker); 40 WTF_MAKE_NONCOPYABLE(SelectorChecker);
43 public: 41 public:
44 explicit SelectorChecker(); 42 explicit SelectorChecker(const Element&);
45 43
46 struct SelectorCheckingContext { 44 // TODO(esprehn): scope should never be null.
47 STACK_ALLOCATED(); 45 bool match(const CSSSelector&, const ContainerNode* scope);
48 public:
49 // Initial selector constructor
50 SelectorCheckingContext(const CSSSelector& selector, const Element* elem ent)
51 : selector(&selector)
52 , element(element)
53 , scope(nullptr)
54 {
55 }
56
57 const CSSSelector* selector;
58 const Element* element;
59 RawPtr<const ContainerNode> scope;
60 };
61
62 bool match(const SelectorCheckingContext&);
63 46
64 bool matchedAttributeSelector() const { return m_matchedAttributeSelector; } 47 bool matchedAttributeSelector() const { return m_matchedAttributeSelector; }
65 bool matchedFocusSelector() const { return m_matchedFocusSelector; } 48 bool matchedFocusSelector() const { return m_matchedFocusSelector; }
66 bool matchedHoverSelector() const { return m_matchedHoverSelector; } 49 bool matchedHoverSelector() const { return m_matchedHoverSelector; }
67 bool matchedActiveSelector() const { return m_matchedActiveSelector; } 50 bool matchedActiveSelector() const { return m_matchedActiveSelector; }
68 51
69 static bool tagMatches(const Element&, const QualifiedName&);
70 static bool isHostInItsShadowTree(const Element&, const ContainerNode* scope ); 52 static bool isHostInItsShadowTree(const Element&, const ContainerNode* scope );
71 53
72 private: 54 private:
73 bool checkPseudoClass(const SelectorCheckingContext&); 55 bool checkPseudoClass(const CSSSelector&, const ContainerNode* scope);
74 bool checkOne(const SelectorCheckingContext&); 56 bool checkOne(const CSSSelector&, const ContainerNode* scope);
75 57
76 static bool checkExactAttribute(const Element&, const QualifiedName& selecto rAttributeName, const StringImpl* value); 58 const Element& m_element;
77 static bool matchesFocusPseudoClass(const Element&);
78
79 bool m_matchedAttributeSelector; 59 bool m_matchedAttributeSelector;
80 bool m_matchedFocusSelector; 60 bool m_matchedFocusSelector;
81 bool m_matchedHoverSelector; 61 bool m_matchedHoverSelector;
82 bool m_matchedActiveSelector; 62 bool m_matchedActiveSelector;
83 }; 63 };
84 64
85 inline bool SelectorChecker::tagMatches(const Element& element, const QualifiedN ame& tagQName)
86 {
87 const AtomicString& localName = tagQName.localName();
88 return localName == starAtom || localName == element.localName();
89 }
90
91 inline bool SelectorChecker::checkExactAttribute(const Element& element, const Q ualifiedName& selectorAttributeName, const StringImpl* value)
92 {
93 AttributeCollection attributes = element.attributesWithoutUpdate();
94 AttributeCollection::iterator end = attributes.end();
95 for (AttributeCollection::iterator it = attributes.begin(); it != end; ++it) {
96 if (it->matches(selectorAttributeName) && (!value || it->value().impl() == value))
97 return true;
98 }
99 return false;
100 }
101
102 inline bool SelectorChecker::isHostInItsShadowTree(const Element& element, const ContainerNode* scope) 65 inline bool SelectorChecker::isHostInItsShadowTree(const Element& element, const ContainerNode* scope)
103 { 66 {
104 return scope && scope->isInShadowTree() && scope->shadowHost() == element; 67 return scope && scope->isInShadowTree() && scope->shadowHost() == element;
105 } 68 }
106 69
107 } 70 }
108 71
109 #endif // SKY_ENGINE_CORE_CSS_SELECTORCHECKER_H_ 72 #endif // SKY_ENGINE_CORE_CSS_SELECTORCHECKER_H_
OLDNEW
« no previous file with comments | « sky/engine/core/css/ElementRuleCollector.cpp ('k') | sky/engine/core/css/SelectorChecker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698