| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 void RuleFeatureSet::addSelectorFeatures(const CSSSelector& selector) | 50 void RuleFeatureSet::addSelectorFeatures(const CSSSelector& selector) |
| 51 { | 51 { |
| 52 if (selector.match() == CSSSelector::Class) | 52 if (selector.match() == CSSSelector::Class) |
| 53 m_classNames.add(selector.value()); | 53 m_classNames.add(selector.value()); |
| 54 else if (selector.match() == CSSSelector::Id) | 54 else if (selector.match() == CSSSelector::Id) |
| 55 m_idNames.add(selector.value()); | 55 m_idNames.add(selector.value()); |
| 56 else if (selector.isAttributeSelector()) | 56 else if (selector.isAttributeSelector()) |
| 57 m_attributeNames.add(selector.attribute().localName()); | 57 m_attributeNames.add(selector.attribute().localName()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) | |
| 61 { | |
| 62 collectFeaturesFromSelector(ruleData.selector()); | |
| 63 | |
| 64 if (ruleData.containsAttributeSelector()) | |
| 65 attributeRules.append(RuleFeature(ruleData.rule(), ruleData.selectorInde
x())); | |
| 66 } | |
| 67 | |
| 68 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector) | 60 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector) |
| 69 { | 61 { |
| 70 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { | 62 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { |
| 71 addSelectorFeatures(*current); | 63 addSelectorFeatures(*current); |
| 72 collectFeaturesFromSelectorList(current->selectorList()); | 64 collectFeaturesFromSelectorList(current->selectorList()); |
| 73 } | 65 } |
| 74 } | 66 } |
| 75 | 67 |
| 76 void RuleFeatureSet::collectFeaturesFromSelectorList(const CSSSelectorList* sele
ctorList) | 68 void RuleFeatureSet::collectFeaturesFromSelectorList(const CSSSelectorList* sele
ctorList) |
| 77 { | 69 { |
| 78 if (!selectorList) | 70 if (!selectorList) |
| 79 return; | 71 return; |
| 80 | 72 |
| 81 for (const CSSSelector* selector = selectorList->first(); selector; selector
= CSSSelectorList::next(*selector)) | 73 for (const CSSSelector* selector = selectorList->first(); selector; selector
= CSSSelectorList::next(*selector)) |
| 82 collectFeaturesFromSelector(*selector); | 74 collectFeaturesFromSelector(*selector); |
| 83 } | 75 } |
| 84 | 76 |
| 85 void RuleFeatureSet::add(const RuleFeatureSet& other) | 77 void RuleFeatureSet::add(const RuleFeatureSet& other) |
| 86 { | 78 { |
| 87 for (HashSet<AtomicString>::const_iterator it = other.m_classNames.begin();
it != other.m_classNames.end(); ++it) | 79 for (HashSet<AtomicString>::const_iterator it = other.m_classNames.begin();
it != other.m_classNames.end(); ++it) |
| 88 m_classNames.add(*it); | 80 m_classNames.add(*it); |
| 89 for (HashSet<AtomicString>::const_iterator it = other.m_attributeNames.begin
(); it != other.m_attributeNames.end(); ++it) | 81 for (HashSet<AtomicString>::const_iterator it = other.m_attributeNames.begin
(); it != other.m_attributeNames.end(); ++it) |
| 90 m_attributeNames.add(*it); | 82 m_attributeNames.add(*it); |
| 91 for (HashSet<AtomicString>::const_iterator it = other.m_idNames.begin(); it
!= other.m_idNames.end(); ++it) | 83 for (HashSet<AtomicString>::const_iterator it = other.m_idNames.begin(); it
!= other.m_idNames.end(); ++it) |
| 92 m_idNames.add(*it); | 84 m_idNames.add(*it); |
| 93 | |
| 94 attributeRules.appendVector(other.attributeRules); | |
| 95 } | 85 } |
| 96 | 86 |
| 97 void RuleFeatureSet::clear() | 87 void RuleFeatureSet::clear() |
| 98 { | 88 { |
| 99 attributeRules.clear(); | |
| 100 m_classNames.clear(); | 89 m_classNames.clear(); |
| 101 m_attributeNames.clear(); | 90 m_attributeNames.clear(); |
| 102 m_idNames.clear(); | 91 m_idNames.clear(); |
| 103 } | 92 } |
| 104 | 93 |
| 105 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitStr
ing& changedClasses, Element& element) | 94 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitStr
ing& changedClasses, Element& element) |
| 106 { | 95 { |
| 107 unsigned changedSize = changedClasses.size(); | 96 unsigned changedSize = changedClasses.size(); |
| 108 for (unsigned i = 0; i < changedSize; ++i) { | 97 for (unsigned i = 0; i < changedSize; ++i) { |
| 109 scheduleStyleInvalidationForClassChange(changedClasses[i], element); | 98 scheduleStyleInvalidationForClassChange(changedClasses[i], element); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 152 } |
| 164 } | 153 } |
| 165 | 154 |
| 166 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const AtomicString&
className, Element& element) | 155 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const AtomicString&
className, Element& element) |
| 167 { | 156 { |
| 168 if (m_classNames.contains(className)) | 157 if (m_classNames.contains(className)) |
| 169 element.setNeedsStyleRecalc(LocalStyleChange); | 158 element.setNeedsStyleRecalc(LocalStyleChange); |
| 170 } | 159 } |
| 171 | 160 |
| 172 } // namespace blink | 161 } // namespace blink |
| OLD | NEW |