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 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r
ights 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "wtf/TerminatedArrayBuilder.h" | 46 #include "wtf/TerminatedArrayBuilder.h" |
47 | 47 |
48 namespace WebCore { | 48 namespace WebCore { |
49 | 49 |
50 using namespace HTMLNames; | 50 using namespace HTMLNames; |
51 | 51 |
52 // ----------------------------------------------------------------- | 52 // ----------------------------------------------------------------- |
53 | 53 |
54 static inline bool isSelectorMatchingHTMLBasedOnRuleHash(const CSSSelector& sele
ctor) | 54 static inline bool isSelectorMatchingHTMLBasedOnRuleHash(const CSSSelector& sele
ctor) |
55 { | 55 { |
56 if (selector.m_match == CSSSelector::Tag) { | 56 if (selector.match() == CSSSelector::Tag) { |
57 const AtomicString& selectorNamespace = selector.tagQName().namespaceURI
(); | 57 const AtomicString& selectorNamespace = selector.tagQName().namespaceURI
(); |
58 if (selectorNamespace != starAtom && selectorNamespace != xhtmlNamespace
URI) | 58 if (selectorNamespace != starAtom && selectorNamespace != xhtmlNamespace
URI) |
59 return false; | 59 return false; |
60 if (selector.relation() == CSSSelector::SubSelector) { | 60 if (selector.relation() == CSSSelector::SubSelector) { |
61 ASSERT(selector.tagHistory()); | 61 ASSERT(selector.tagHistory()); |
62 return isSelectorMatchingHTMLBasedOnRuleHash(*selector.tagHistory())
; | 62 return isSelectorMatchingHTMLBasedOnRuleHash(*selector.tagHistory())
; |
63 } | 63 } |
64 return true; | 64 return true; |
65 } | 65 } |
66 if (SelectorChecker::isCommonPseudoClassSelector(selector)) | 66 if (SelectorChecker::isCommonPseudoClassSelector(selector)) |
67 return true; | 67 return true; |
68 return selector.m_match == CSSSelector::Id || selector.m_match == CSSSelecto
r::Class; | 68 return selector.match() == CSSSelector::Id || selector.match() == CSSSelecto
r::Class; |
69 } | 69 } |
70 | 70 |
71 static inline bool selectorListContainsUncommonAttributeSelector(const CSSSelect
or* selector) | 71 static inline bool selectorListContainsUncommonAttributeSelector(const CSSSelect
or* selector) |
72 { | 72 { |
73 const CSSSelectorList* selectorList = selector->selectorList(); | 73 const CSSSelectorList* selectorList = selector->selectorList(); |
74 if (!selectorList) | 74 if (!selectorList) |
75 return false; | 75 return false; |
76 for (const CSSSelector* selector = selectorList->first(); selector; selector
= CSSSelectorList::next(*selector)) { | 76 for (const CSSSelector* selector = selectorList->first(); selector; selector
= CSSSelectorList::next(*selector)) { |
77 for (const CSSSelector* component = selector; component; component = com
ponent->tagHistory()) { | 77 for (const CSSSelector* component = selector; component; component = com
ponent->tagHistory()) { |
78 if (component->isAttributeSelector()) | 78 if (component->isAttributeSelector()) |
(...skipping 29 matching lines...) Expand all Loading... |
108 return true; | 108 return true; |
109 if (selectorListContainsUncommonAttributeSelector(current)) | 109 if (selectorListContainsUncommonAttributeSelector(current)) |
110 return true; | 110 return true; |
111 } | 111 } |
112 return false; | 112 return false; |
113 } | 113 } |
114 | 114 |
115 static inline PropertyWhitelistType determinePropertyWhitelistType(const AddRule
Flags addRuleFlags, const CSSSelector& selector) | 115 static inline PropertyWhitelistType determinePropertyWhitelistType(const AddRule
Flags addRuleFlags, const CSSSelector& selector) |
116 { | 116 { |
117 for (const CSSSelector* component = &selector; component; component = compon
ent->tagHistory()) { | 117 for (const CSSSelector* component = &selector; component; component = compon
ent->tagHistory()) { |
118 if (component->pseudoType() == CSSSelector::PseudoCue || (component->m_m
atch == CSSSelector::PseudoElement && component->value() == TextTrackCue::cueSha
dowPseudoId())) | 118 if (component->pseudoType() == CSSSelector::PseudoCue || (component->mat
ch() == CSSSelector::PseudoElement && component->value() == TextTrackCue::cueSha
dowPseudoId())) |
119 return PropertyWhitelistCue; | 119 return PropertyWhitelistCue; |
120 if (component->pseudoType() == CSSSelector::PseudoFirstLetter) | 120 if (component->pseudoType() == CSSSelector::PseudoFirstLetter) |
121 return PropertyWhitelistFirstLetter; | 121 return PropertyWhitelistFirstLetter; |
122 } | 122 } |
123 return PropertyWhitelistNone; | 123 return PropertyWhitelistNone; |
124 } | 124 } |
125 | 125 |
126 RuleData::RuleData(StyleRule* rule, unsigned selectorIndex, unsigned position, A
ddRuleFlags addRuleFlags) | 126 RuleData::RuleData(StyleRule* rule, unsigned selectorIndex, unsigned position, A
ddRuleFlags addRuleFlags) |
127 : m_rule(rule) | 127 : m_rule(rule) |
128 , m_selectorIndex(selectorIndex) | 128 , m_selectorIndex(selectorIndex) |
(...skipping 15 matching lines...) Expand all Loading... |
144 void RuleSet::addToRuleSet(const AtomicString& key, PendingRuleMap& map, const R
uleData& ruleData) | 144 void RuleSet::addToRuleSet(const AtomicString& key, PendingRuleMap& map, const R
uleData& ruleData) |
145 { | 145 { |
146 OwnPtrWillBeMember<WillBeHeapLinkedStack<RuleData> >& rules = map.add(key, n
ullptr).storedValue->value; | 146 OwnPtrWillBeMember<WillBeHeapLinkedStack<RuleData> >& rules = map.add(key, n
ullptr).storedValue->value; |
147 if (!rules) | 147 if (!rules) |
148 rules = adoptPtrWillBeNoop(new WillBeHeapLinkedStack<RuleData>); | 148 rules = adoptPtrWillBeNoop(new WillBeHeapLinkedStack<RuleData>); |
149 rules->push(ruleData); | 149 rules->push(ruleData); |
150 } | 150 } |
151 | 151 |
152 static void extractValuesforSelector(const CSSSelector* selector, AtomicString&
id, AtomicString& className, AtomicString& customPseudoElementName, AtomicString
& tagName) | 152 static void extractValuesforSelector(const CSSSelector* selector, AtomicString&
id, AtomicString& className, AtomicString& customPseudoElementName, AtomicString
& tagName) |
153 { | 153 { |
154 switch (selector->m_match) { | 154 switch (selector->match()) { |
155 case CSSSelector::Id: | 155 case CSSSelector::Id: |
156 id = selector->value(); | 156 id = selector->value(); |
157 break; | 157 break; |
158 case CSSSelector::Class: | 158 case CSSSelector::Class: |
159 className = selector->value(); | 159 className = selector->value(); |
160 break; | 160 break; |
161 case CSSSelector::Tag: | 161 case CSSSelector::Tag: |
162 if (selector->tagQName().localName() != starAtom) | 162 if (selector->tagQName().localName() != starAtom) |
163 tagName = selector->tagQName().localName(); | 163 tagName = selector->tagQName().localName(); |
164 break; | 164 break; |
| 165 default: |
| 166 break; |
165 } | 167 } |
166 if (selector->isCustomPseudoElement()) | 168 if (selector->isCustomPseudoElement()) |
167 customPseudoElementName = selector->value(); | 169 customPseudoElementName = selector->value(); |
168 } | 170 } |
169 | 171 |
170 bool RuleSet::findBestRuleSetAndAdd(const CSSSelector& component, RuleData& rule
Data) | 172 bool RuleSet::findBestRuleSetAndAdd(const CSSSelector& component, RuleData& rule
Data) |
171 { | 173 { |
172 AtomicString id; | 174 AtomicString id; |
173 AtomicString className; | 175 AtomicString className; |
174 AtomicString customPseudoElementName; | 176 AtomicString customPseudoElementName; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 413 |
412 #ifndef NDEBUG | 414 #ifndef NDEBUG |
413 void RuleSet::show() | 415 void RuleSet::show() |
414 { | 416 { |
415 for (WillBeHeapVector<RuleData>::const_iterator it = m_allRules.begin(); it
!= m_allRules.end(); ++it) | 417 for (WillBeHeapVector<RuleData>::const_iterator it = m_allRules.begin(); it
!= m_allRules.end(); ++it) |
416 it->selector().show(); | 418 it->selector().show(); |
417 } | 419 } |
418 #endif | 420 #endif |
419 | 421 |
420 } // namespace WebCore | 422 } // namespace WebCore |
OLD | NEW |