| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 m_idNames.add(*it); | 84 m_idNames.add(*it); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void RuleFeatureSet::clear() | 87 void RuleFeatureSet::clear() |
| 88 { | 88 { |
| 89 m_classNames.clear(); | 89 m_classNames.clear(); |
| 90 m_attributeNames.clear(); | 90 m_attributeNames.clear(); |
| 91 m_idNames.clear(); | 91 m_idNames.clear(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitStr
ing& changedClasses, Element& element) | |
| 95 { | |
| 96 unsigned changedSize = changedClasses.size(); | |
| 97 for (unsigned i = 0; i < changedSize; ++i) { | |
| 98 scheduleStyleInvalidationForClassChange(changedClasses[i], element); | |
| 99 } | |
| 100 } | |
| 101 | |
| 102 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitStr
ing& oldClasses, const SpaceSplitString& newClasses, Element& element) | |
| 103 { | |
| 104 if (!oldClasses.size()) { | |
| 105 scheduleStyleInvalidationForClassChange(newClasses, element); | |
| 106 return; | |
| 107 } | |
| 108 | |
| 109 // Class vectors tend to be very short. This is faster than using a hash tab
le. | |
| 110 BitVector remainingClassBits; | |
| 111 remainingClassBits.ensureSize(oldClasses.size()); | |
| 112 | |
| 113 for (unsigned i = 0; i < newClasses.size(); ++i) { | |
| 114 bool found = false; | |
| 115 for (unsigned j = 0; j < oldClasses.size(); ++j) { | |
| 116 if (newClasses[i] == oldClasses[j]) { | |
| 117 // Mark each class that is still in the newClasses so we can ski
p doing | |
| 118 // an n^2 search below when looking for removals. We can't break
from | |
| 119 // this loop early since a class can appear more than once. | |
| 120 remainingClassBits.quickSet(j); | |
| 121 found = true; | |
| 122 } | |
| 123 } | |
| 124 // Class was added. | |
| 125 if (!found) | |
| 126 scheduleStyleInvalidationForClassChange(newClasses[i], element); | |
| 127 } | |
| 128 | |
| 129 for (unsigned i = 0; i < oldClasses.size(); ++i) { | |
| 130 if (remainingClassBits.quickGet(i)) | |
| 131 continue; | |
| 132 // Class was removed. | |
| 133 scheduleStyleInvalidationForClassChange(oldClasses[i], element); | |
| 134 } | |
| 135 } | |
| 136 | |
| 137 void RuleFeatureSet::scheduleStyleInvalidationForAttributeChange(const Qualified
Name& attributeName, Element& element) | |
| 138 { | |
| 139 if (m_attributeNames.contains(attributeName.localName())) | |
| 140 element.setNeedsStyleRecalc(LocalStyleChange); | |
| 141 } | |
| 142 | |
| 143 void RuleFeatureSet::scheduleStyleInvalidationForIdChange(const AtomicString& ol
dId, const AtomicString& newId, Element& element) | |
| 144 { | |
| 145 if (!oldId.isEmpty()) { | |
| 146 if (m_idNames.contains(oldId)) | |
| 147 element.setNeedsStyleRecalc(LocalStyleChange); | |
| 148 } | |
| 149 if (!newId.isEmpty()) { | |
| 150 if (m_idNames.contains(newId)) | |
| 151 element.setNeedsStyleRecalc(LocalStyleChange); | |
| 152 } | |
| 153 } | |
| 154 | |
| 155 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const AtomicString&
className, Element& element) | |
| 156 { | |
| 157 if (m_classNames.contains(className)) | |
| 158 element.setNeedsStyleRecalc(LocalStyleChange); | |
| 159 } | |
| 160 | |
| 161 } // namespace blink | 94 } // namespace blink |
| OLD | NEW |