| OLD | NEW |
| 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 23 matching lines...) Expand all Loading... |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class CSSSelector; | 36 class CSSSelector; |
| 37 class ContainerNode; | 37 class ContainerNode; |
| 38 class Element; | 38 class Element; |
| 39 class RenderStyle; | 39 class RenderStyle; |
| 40 | 40 |
| 41 class SelectorChecker { | 41 class SelectorChecker { |
| 42 WTF_MAKE_NONCOPYABLE(SelectorChecker); | 42 WTF_MAKE_NONCOPYABLE(SelectorChecker); |
| 43 public: | 43 public: |
| 44 enum Mode { ResolvingStyle = 0, QueryingRules, SharingRules }; | 44 explicit SelectorChecker(); |
| 45 explicit SelectorChecker(Document&, Mode); | |
| 46 | 45 |
| 47 struct SelectorCheckingContext { | 46 struct SelectorCheckingContext { |
| 48 STACK_ALLOCATED(); | 47 STACK_ALLOCATED(); |
| 49 public: | 48 public: |
| 50 // Initial selector constructor | 49 // Initial selector constructor |
| 51 SelectorCheckingContext(const CSSSelector& selector, Element* element) | 50 SelectorCheckingContext(const CSSSelector& selector, const Element* elem
ent) |
| 52 : selector(&selector) | 51 : selector(&selector) |
| 53 , element(element) | 52 , element(element) |
| 54 , scope(nullptr) | 53 , scope(nullptr) |
| 55 , elementStyle(0) | |
| 56 { | 54 { |
| 57 } | 55 } |
| 58 | 56 |
| 59 const CSSSelector* selector; | 57 const CSSSelector* selector; |
| 60 RawPtr<Element> element; | 58 const Element* element; |
| 61 RawPtr<const ContainerNode> scope; | 59 RawPtr<const ContainerNode> scope; |
| 62 RenderStyle* elementStyle; | |
| 63 }; | 60 }; |
| 64 | 61 |
| 65 bool match(const SelectorCheckingContext&) const; | 62 bool match(const SelectorCheckingContext&); |
| 63 |
| 64 bool matchedAttributeSelector() const { return m_matchedAttributeSelector; } |
| 65 bool matchedFocusSelector() const { return m_matchedFocusSelector; } |
| 66 bool matchedHoverSelector() const { return m_matchedHoverSelector; } |
| 67 bool matchedActiveSelector() const { return m_matchedActiveSelector; } |
| 66 | 68 |
| 67 static bool tagMatches(const Element&, const QualifiedName&); | 69 static bool tagMatches(const Element&, const QualifiedName&); |
| 68 static bool isHostInItsShadowTree(const Element&, const ContainerNode* scope
); | 70 static bool isHostInItsShadowTree(const Element&, const ContainerNode* scope
); |
| 69 | 71 |
| 70 private: | 72 private: |
| 71 bool checkPseudoClass(const SelectorCheckingContext&) const; | 73 bool checkPseudoClass(const SelectorCheckingContext&); |
| 72 bool checkOne(const SelectorCheckingContext&) const; | 74 bool checkOne(const SelectorCheckingContext&); |
| 73 | |
| 74 Mode mode() const { return m_mode; } | |
| 75 | 75 |
| 76 static bool checkExactAttribute(const Element&, const QualifiedName& selecto
rAttributeName, const StringImpl* value); | 76 static bool checkExactAttribute(const Element&, const QualifiedName& selecto
rAttributeName, const StringImpl* value); |
| 77 static bool matchesFocusPseudoClass(const Element&); | 77 static bool matchesFocusPseudoClass(const Element&); |
| 78 | 78 |
| 79 Mode m_mode; | 79 bool m_matchedAttributeSelector; |
| 80 bool m_matchedFocusSelector; |
| 81 bool m_matchedHoverSelector; |
| 82 bool m_matchedActiveSelector; |
| 80 }; | 83 }; |
| 81 | 84 |
| 82 inline bool SelectorChecker::tagMatches(const Element& element, const QualifiedN
ame& tagQName) | 85 inline bool SelectorChecker::tagMatches(const Element& element, const QualifiedN
ame& tagQName) |
| 83 { | 86 { |
| 84 const AtomicString& localName = tagQName.localName(); | 87 const AtomicString& localName = tagQName.localName(); |
| 85 return localName == starAtom || localName == element.localName(); | 88 return localName == starAtom || localName == element.localName(); |
| 86 } | 89 } |
| 87 | 90 |
| 88 inline bool SelectorChecker::checkExactAttribute(const Element& element, const Q
ualifiedName& selectorAttributeName, const StringImpl* value) | 91 inline bool SelectorChecker::checkExactAttribute(const Element& element, const Q
ualifiedName& selectorAttributeName, const StringImpl* value) |
| 89 { | 92 { |
| 90 AttributeCollection attributes = element.attributesWithoutUpdate(); | 93 AttributeCollection attributes = element.attributesWithoutUpdate(); |
| 91 AttributeCollection::iterator end = attributes.end(); | 94 AttributeCollection::iterator end = attributes.end(); |
| 92 for (AttributeCollection::iterator it = attributes.begin(); it != end; ++it)
{ | 95 for (AttributeCollection::iterator it = attributes.begin(); it != end; ++it)
{ |
| 93 if (it->matches(selectorAttributeName) && (!value || it->value().impl()
== value)) | 96 if (it->matches(selectorAttributeName) && (!value || it->value().impl()
== value)) |
| 94 return true; | 97 return true; |
| 95 } | 98 } |
| 96 return false; | 99 return false; |
| 97 } | 100 } |
| 98 | 101 |
| 99 inline bool SelectorChecker::isHostInItsShadowTree(const Element& element, const
ContainerNode* scope) | 102 inline bool SelectorChecker::isHostInItsShadowTree(const Element& element, const
ContainerNode* scope) |
| 100 { | 103 { |
| 101 return scope && scope->isInShadowTree() && scope->shadowHost() == element; | 104 return scope && scope->isInShadowTree() && scope->shadowHost() == element; |
| 102 } | 105 } |
| 103 | 106 |
| 104 } | 107 } |
| 105 | 108 |
| 106 #endif // SKY_ENGINE_CORE_CSS_SELECTORCHECKER_H_ | 109 #endif // SKY_ENGINE_CORE_CSS_SELECTORCHECKER_H_ |
| OLD | NEW |