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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 || selector.isAttributeSelector()) | 47 || selector.isAttributeSelector()) |
48 return true; | 48 return true; |
49 if (selector.m_match == CSSSelector::PseudoElement) { | 49 if (selector.m_match == CSSSelector::PseudoElement) { |
50 switch (selector.pseudoType()) { | 50 switch (selector.pseudoType()) { |
51 case CSSSelector::PseudoBefore: | 51 case CSSSelector::PseudoBefore: |
52 case CSSSelector::PseudoAfter: | 52 case CSSSelector::PseudoAfter: |
53 case CSSSelector::PseudoBackdrop: | 53 case CSSSelector::PseudoBackdrop: |
54 case CSSSelector::PseudoShadow: | 54 case CSSSelector::PseudoShadow: |
55 return true; | 55 return true; |
56 default: | 56 default: |
57 return false; | 57 return selector.isCustomPseudoElement(); |
58 } | 58 } |
59 } | 59 } |
60 if (selector.m_match != CSSSelector::PseudoClass) | 60 if (selector.m_match != CSSSelector::PseudoClass) |
61 return false; | 61 return false; |
62 switch (selector.pseudoType()) { | 62 switch (selector.pseudoType()) { |
63 case CSSSelector::PseudoEmpty: | 63 case CSSSelector::PseudoEmpty: |
64 case CSSSelector::PseudoFirstChild: | 64 case CSSSelector::PseudoFirstChild: |
65 case CSSSelector::PseudoFirstOfType: | 65 case CSSSelector::PseudoFirstOfType: |
66 case CSSSelector::PseudoLastChild: | 66 case CSSSelector::PseudoLastChild: |
67 case CSSSelector::PseudoLastOfType: | 67 case CSSSelector::PseudoLastOfType: |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 // This method is somewhat conservative in what it accepts. | 105 // This method is somewhat conservative in what it accepts. |
106 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInval idation(const CSSSelector& selector) | 106 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInval idation(const CSSSelector& selector) |
107 { | 107 { |
108 bool foundDescendantRelation = false; | 108 bool foundDescendantRelation = false; |
109 bool foundIdent = false; | 109 bool foundIdent = false; |
110 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) { | 110 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) { |
111 | 111 |
112 // FIXME: next up: Tag and Id. | 112 // FIXME: next up: Tag and Id. |
esprehn
2014/04/01 08:23:29
You should remove this comment, we support tags an
rune
2014/04/01 08:41:34
No, we don't. We need to add them to the if-test b
| |
113 if (component->m_match == CSSSelector::Class || component->isAttributeSe lector()) { | 113 if (component->m_match == CSSSelector::Class || component->isAttributeSe lector() || component->isCustomPseudoElement()) { |
114 if (!foundDescendantRelation) | 114 if (!foundDescendantRelation) |
115 foundIdent = true; | 115 foundIdent = true; |
116 } else if (component->pseudoType() == CSSSelector::PseudoHost || compone nt->pseudoType() == CSSSelector::PseudoAny) { | 116 } else if (component->pseudoType() == CSSSelector::PseudoHost || compone nt->pseudoType() == CSSSelector::PseudoAny) { |
117 if (const CSSSelectorList* selectorList = component->selectorList()) { | 117 if (const CSSSelectorList* selectorList = component->selectorList()) { |
118 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) { | 118 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) { |
119 InvalidationSetMode hostMode = supportsClassDescendantInvali dation(*selector); | 119 InvalidationSetMode hostMode = supportsClassDescendantInvali dation(*selector); |
120 if (hostMode == UseSubtreeStyleChange) | 120 if (hostMode == UseSubtreeStyleChange) |
121 return foundDescendantRelation ? UseLocalStyleChange : U seSubtreeStyleChange; | 121 return foundDescendantRelation ? UseLocalStyleChange : U seSubtreeStyleChange; |
122 if (hostMode == AddFeatures) | 122 if (hostMode == AddFeatures) |
123 foundIdent = true; | 123 foundIdent = true; |
(...skipping 21 matching lines...) Expand all Loading... | |
145 void RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector, InvalidationSetFeatures& features) | 145 void RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector, InvalidationSetFeatures& features) |
146 { | 146 { |
147 if (selector.m_match == CSSSelector::Tag) | 147 if (selector.m_match == CSSSelector::Tag) |
148 features.tagName = selector.tagQName().localName(); | 148 features.tagName = selector.tagQName().localName(); |
149 else if (selector.m_match == CSSSelector::Id) | 149 else if (selector.m_match == CSSSelector::Id) |
150 features.id = selector.value(); | 150 features.id = selector.value(); |
151 else if (selector.m_match == CSSSelector::Class) | 151 else if (selector.m_match == CSSSelector::Class) |
152 features.classes.append(selector.value()); | 152 features.classes.append(selector.value()); |
153 else if (selector.isAttributeSelector()) | 153 else if (selector.isAttributeSelector()) |
154 features.attributes.append(selector.attribute().localName()); | 154 features.attributes.append(selector.attribute().localName()); |
155 else if (selector.isCustomPseudoElement()) | |
156 features.customPseudoElement = true; | |
155 } | 157 } |
156 | 158 |
157 RuleFeatureSet::RuleFeatureSet() | 159 RuleFeatureSet::RuleFeatureSet() |
158 : m_targetedStyleRecalcEnabled(RuntimeEnabledFeatures::targetedStyleRecalcEn abled()) | 160 : m_targetedStyleRecalcEnabled(RuntimeEnabledFeatures::targetedStyleRecalcEn abled()) |
159 { | 161 { |
160 } | 162 } |
161 | 163 |
162 DescendantInvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSS elector& selector) | 164 DescendantInvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSS elector& selector) |
163 { | 165 { |
164 if (selector.m_match == CSSSelector::Class) | 166 if (selector.m_match == CSSSelector::Class) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 for (const CSSSelector* current = &selector; current; current = current->tag History()) { | 211 for (const CSSSelector* current = &selector; current; current = current->tag History()) { |
210 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) { | 212 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) { |
211 if (!features.id.isEmpty()) | 213 if (!features.id.isEmpty()) |
212 invalidationSet->addId(features.id); | 214 invalidationSet->addId(features.id); |
213 if (!features.tagName.isEmpty()) | 215 if (!features.tagName.isEmpty()) |
214 invalidationSet->addTagName(features.tagName); | 216 invalidationSet->addTagName(features.tagName); |
215 for (Vector<AtomicString>::const_iterator it = features.classes.begi n(); it != features.classes.end(); ++it) | 217 for (Vector<AtomicString>::const_iterator it = features.classes.begi n(); it != features.classes.end(); ++it) |
216 invalidationSet->addClass(*it); | 218 invalidationSet->addClass(*it); |
217 for (Vector<AtomicString>::const_iterator it = features.attributes.b egin(); it != features.attributes.end(); ++it) | 219 for (Vector<AtomicString>::const_iterator it = features.attributes.b egin(); it != features.attributes.end(); ++it) |
218 invalidationSet->addAttribute(*it); | 220 invalidationSet->addAttribute(*it); |
221 if (features.customPseudoElement) | |
222 invalidationSet->setCustomPseudoInvalid(); | |
219 } else if (current->pseudoType() == CSSSelector::PseudoHost || current-> pseudoType() == CSSSelector::PseudoAny) { | 223 } else if (current->pseudoType() == CSSSelector::PseudoHost || current-> pseudoType() == CSSSelector::PseudoAny) { |
220 if (const CSSSelectorList* selectorList = current->selectorList()) { | 224 if (const CSSSelectorList* selectorList = current->selectorList()) { |
221 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) | 225 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) |
222 addFeaturesToInvalidationSets(*selector, features); | 226 addFeaturesToInvalidationSets(*selector, features); |
223 } | 227 } |
224 } | 228 } |
225 } | 229 } |
226 } | 230 } |
227 | 231 |
228 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) | 232 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 if (node->isElementNode()) | 427 if (node->isElementNode()) |
424 m_pendingInvalidationMap.remove(toElement(node)); | 428 m_pendingInvalidationMap.remove(toElement(node)); |
425 } | 429 } |
426 | 430 |
427 RuleFeatureSet::PendingInvalidationMap& RuleFeatureSet::pendingInvalidationMap() | 431 RuleFeatureSet::PendingInvalidationMap& RuleFeatureSet::pendingInvalidationMap() |
428 { | 432 { |
429 return m_pendingInvalidationMap; | 433 return m_pendingInvalidationMap; |
430 } | 434 } |
431 | 435 |
432 } // namespace WebCore | 436 } // namespace WebCore |
OLD | NEW |