| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 static bool containsUncommonAttributeSelector(const CSSSelector& selector) | 72 static bool containsUncommonAttributeSelector(const CSSSelector& selector) |
| 73 { | 73 { |
| 74 const CSSSelector* current = &selector; | 74 const CSSSelector* current = &selector; |
| 75 for (; current; current = current->tagHistory()) { | 75 for (; current; current = current->tagHistory()) { |
| 76 // Allow certain common attributes (used in the default style) in the se
lectors that match the current element. | 76 // Allow certain common attributes (used in the default style) in the se
lectors that match the current element. |
| 77 if (current->isAttributeSelector() && !isCommonAttributeSelectorAttribut
e(current->attribute())) | 77 if (current->isAttributeSelector() && !isCommonAttributeSelectorAttribut
e(current->attribute())) |
| 78 return true; | 78 return true; |
| 79 if (selectorListContainsUncommonAttributeSelector(current)) | 79 if (selectorListContainsUncommonAttributeSelector(current)) |
| 80 return true; | 80 return true; |
| 81 if (current->relationIsAffectedByPseudoContent() || current->pseudoType(
) == CSSSelector::PseudoSlotted) | 81 if (current->relationIsAffectedByPseudoContent() || current->getPseudoTy
pe() == CSSSelector::PseudoSlotted) |
| 82 return false; | 82 return false; |
| 83 if (current->relation() != CSSSelector::SubSelector) { | 83 if (current->relation() != CSSSelector::SubSelector) { |
| 84 current = current->tagHistory(); | 84 current = current->tagHistory(); |
| 85 break; | 85 break; |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 for (; current; current = current->tagHistory()) { | 89 for (; current; current = current->tagHistory()) { |
| 90 if (current->isAttributeSelector()) | 90 if (current->isAttributeSelector()) |
| 91 return true; | 91 return true; |
| 92 if (selectorListContainsUncommonAttributeSelector(current)) | 92 if (selectorListContainsUncommonAttributeSelector(current)) |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| 95 return false; | 95 return false; |
| 96 } | 96 } |
| 97 | 97 |
| 98 static inline PropertyWhitelistType determinePropertyWhitelistType(const AddRule
Flags addRuleFlags, const CSSSelector& selector) | 98 static inline PropertyWhitelistType determinePropertyWhitelistType(const AddRule
Flags addRuleFlags, const CSSSelector& selector) |
| 99 { | 99 { |
| 100 for (const CSSSelector* component = &selector; component; component = compon
ent->tagHistory()) { | 100 for (const CSSSelector* component = &selector; component; component = compon
ent->tagHistory()) { |
| 101 if (component->pseudoType() == CSSSelector::PseudoCue || (component->mat
ch() == CSSSelector::PseudoElement && component->value() == TextTrackCue::cueSha
dowPseudoId())) | 101 if (component->getPseudoType() == CSSSelector::PseudoCue || (component->
match() == CSSSelector::PseudoElement && component->value() == TextTrackCue::cue
ShadowPseudoId())) |
| 102 return PropertyWhitelistCue; | 102 return PropertyWhitelistCue; |
| 103 if (component->pseudoType() == CSSSelector::PseudoFirstLetter) | 103 if (component->getPseudoType() == CSSSelector::PseudoFirstLetter) |
| 104 return PropertyWhitelistFirstLetter; | 104 return PropertyWhitelistFirstLetter; |
| 105 } | 105 } |
| 106 return PropertyWhitelistNone; | 106 return PropertyWhitelistNone; |
| 107 } | 107 } |
| 108 | 108 |
| 109 RuleData::RuleData(StyleRule* rule, unsigned selectorIndex, unsigned position, A
ddRuleFlags addRuleFlags) | 109 RuleData::RuleData(StyleRule* rule, unsigned selectorIndex, unsigned position, A
ddRuleFlags addRuleFlags) |
| 110 : m_rule(rule) | 110 : m_rule(rule) |
| 111 , m_selectorIndex(selectorIndex) | 111 , m_selectorIndex(selectorIndex) |
| 112 , m_isLastInArray(false) | 112 , m_isLastInArray(false) |
| 113 , m_position(position) | 113 , m_position(position) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 137 case CSSSelector::Class: | 137 case CSSSelector::Class: |
| 138 className = selector->value(); | 138 className = selector->value(); |
| 139 break; | 139 break; |
| 140 case CSSSelector::Tag: | 140 case CSSSelector::Tag: |
| 141 if (selector->tagQName().localName() != starAtom) | 141 if (selector->tagQName().localName() != starAtom) |
| 142 tagName = selector->tagQName().localName(); | 142 tagName = selector->tagQName().localName(); |
| 143 break; | 143 break; |
| 144 default: | 144 default: |
| 145 break; | 145 break; |
| 146 } | 146 } |
| 147 if (selector->pseudoType() == CSSSelector::PseudoWebKitCustomElement) | 147 if (selector->getPseudoType() == CSSSelector::PseudoWebKitCustomElement) |
| 148 customPseudoElementName = selector->value(); | 148 customPseudoElementName = selector->value(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 bool RuleSet::findBestRuleSetAndAdd(const CSSSelector& component, RuleData& rule
Data) | 151 bool RuleSet::findBestRuleSetAndAdd(const CSSSelector& component, RuleData& rule
Data) |
| 152 { | 152 { |
| 153 AtomicString id; | 153 AtomicString id; |
| 154 AtomicString className; | 154 AtomicString className; |
| 155 AtomicString customPseudoElementName; | 155 AtomicString customPseudoElementName; |
| 156 AtomicString tagName; | 156 AtomicString tagName; |
| 157 | 157 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 176 } | 176 } |
| 177 if (!customPseudoElementName.isEmpty()) { | 177 if (!customPseudoElementName.isEmpty()) { |
| 178 // Custom pseudos come before ids and classes in the order of tagHistory
, and have a relation of | 178 // Custom pseudos come before ids and classes in the order of tagHistory
, and have a relation of |
| 179 // ShadowPseudo between them. Therefore we should never be a situation w
here extractValuesforSelector | 179 // ShadowPseudo between them. Therefore we should never be a situation w
here extractValuesforSelector |
| 180 // finsd id and className in addition to custom pseudo. | 180 // finsd id and className in addition to custom pseudo. |
| 181 ASSERT(id.isEmpty() && className.isEmpty()); | 181 ASSERT(id.isEmpty() && className.isEmpty()); |
| 182 addToRuleSet(customPseudoElementName, ensurePendingRules()->shadowPseudo
ElementRules, ruleData); | 182 addToRuleSet(customPseudoElementName, ensurePendingRules()->shadowPseudo
ElementRules, ruleData); |
| 183 return true; | 183 return true; |
| 184 } | 184 } |
| 185 | 185 |
| 186 switch (component.pseudoType()) { | 186 switch (component.getPseudoType()) { |
| 187 case CSSSelector::PseudoCue: | 187 case CSSSelector::PseudoCue: |
| 188 m_cuePseudoRules.append(ruleData); | 188 m_cuePseudoRules.append(ruleData); |
| 189 return true; | 189 return true; |
| 190 case CSSSelector::PseudoLink: | 190 case CSSSelector::PseudoLink: |
| 191 case CSSSelector::PseudoVisited: | 191 case CSSSelector::PseudoVisited: |
| 192 case CSSSelector::PseudoAnyLink: | 192 case CSSSelector::PseudoAnyLink: |
| 193 m_linkPseudoClassRules.append(ruleData); | 193 m_linkPseudoClassRules.append(ruleData); |
| 194 return true; | 194 return true; |
| 195 case CSSSelector::PseudoFocus: | 195 case CSSSelector::PseudoFocus: |
| 196 m_focusPseudoClassRules.append(ruleData); | 196 m_focusPseudoClassRules.append(ruleData); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 401 |
| 402 #ifndef NDEBUG | 402 #ifndef NDEBUG |
| 403 void RuleSet::show() const | 403 void RuleSet::show() const |
| 404 { | 404 { |
| 405 for (const auto& rule: m_allRules) | 405 for (const auto& rule: m_allRules) |
| 406 rule.selector().show(); | 406 rule.selector().show(); |
| 407 } | 407 } |
| 408 #endif | 408 #endif |
| 409 | 409 |
| 410 } // namespace blink | 410 } // namespace blink |
| OLD | NEW |