| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
| 5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
| 8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 } | 1222 } |
| 1223 | 1223 |
| 1224 inline void Element::attributeChangedFromParserOrByCloning(const QualifiedName&
name, const AtomicString& newValue, AttributeModificationReason reason) | 1224 inline void Element::attributeChangedFromParserOrByCloning(const QualifiedName&
name, const AtomicString& newValue, AttributeModificationReason reason) |
| 1225 { | 1225 { |
| 1226 if (name == isAttr) | 1226 if (name == isAttr) |
| 1227 CustomElementRegistrationContext::setTypeExtension(this, newValue); | 1227 CustomElementRegistrationContext::setTypeExtension(this, newValue); |
| 1228 attributeChanged(name, newValue, reason); | 1228 attributeChanged(name, newValue, reason); |
| 1229 } | 1229 } |
| 1230 | 1230 |
| 1231 template <typename CharacterType> | 1231 template <typename CharacterType> |
| 1232 static inline bool classStringHasClassName(const CharacterType* characters, unsi
gned length) | 1232 static inline ClassStringContent classStringHasClassName(const CharacterType* ch
aracters, unsigned length) |
| 1233 { | 1233 { |
| 1234 ASSERT(length > 0); | 1234 ASSERT(length > 0); |
| 1235 | 1235 |
| 1236 unsigned i = 0; | 1236 unsigned i = 0; |
| 1237 do { | 1237 do { |
| 1238 if (isNotHTMLSpace<CharacterType>(characters[i])) | 1238 if (isNotHTMLSpace<CharacterType>(characters[i])) |
| 1239 break; | 1239 break; |
| 1240 ++i; | 1240 ++i; |
| 1241 } while (i < length); | 1241 } while (i < length); |
| 1242 | 1242 |
| 1243 return i < length; | 1243 if (i == length && length == 1) |
| 1244 return Empty; |
| 1245 if (i == length && length > 1) |
| 1246 return WhiteSpaceOnly; |
| 1247 |
| 1248 return HasClasses; |
| 1244 } | 1249 } |
| 1245 | 1250 |
| 1246 static inline bool classStringHasClassName(const AtomicString& newClassString) | 1251 static inline ClassStringContent classStringHasClassName(const AtomicString& new
ClassString) |
| 1247 { | 1252 { |
| 1248 unsigned length = newClassString.length(); | 1253 unsigned length = newClassString.length(); |
| 1249 | 1254 |
| 1250 if (!length) | 1255 if (!length) |
| 1251 return false; | 1256 return Empty; |
| 1252 | 1257 |
| 1253 if (newClassString.is8Bit()) | 1258 if (newClassString.is8Bit()) |
| 1254 return classStringHasClassName(newClassString.characters8(), length); | 1259 return classStringHasClassName(newClassString.characters8(), length); |
| 1255 return classStringHasClassName(newClassString.characters16(), length); | 1260 return classStringHasClassName(newClassString.characters16(), length); |
| 1256 } | 1261 } |
| 1257 | 1262 |
| 1258 void Element::classAttributeChanged(const AtomicString& newClassString) | 1263 void Element::classAttributeChanged(const AtomicString& newClassString) |
| 1259 { | 1264 { |
| 1260 StyleResolver* styleResolver = document().styleResolver(); | 1265 StyleResolver* styleResolver = document().styleResolver(); |
| 1261 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver && styl
eChangeType() < SubtreeStyleChange; | 1266 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver && styl
eChangeType() < SubtreeStyleChange; |
| 1262 | 1267 |
| 1263 ASSERT(elementData()); | 1268 ASSERT(elementData()); |
| 1264 if (classStringHasClassName(newClassString)) { | 1269 ClassStringContent classStringContentType = classStringHasClassName(newClass
String); |
| 1265 const bool shouldFoldCase = document().inQuirksMode(); | 1270 const bool shouldFoldCase = document().inQuirksMode(); |
| 1271 if (classStringContentType == HasClasses) { |
| 1266 const SpaceSplitString oldClasses = elementData()->classNames(); | 1272 const SpaceSplitString oldClasses = elementData()->classNames(); |
| 1267 elementData()->setClass(newClassString, shouldFoldCase); | 1273 elementData()->setClass(newClassString, shouldFoldCase); |
| 1268 const SpaceSplitString& newClasses = elementData()->classNames(); | 1274 const SpaceSplitString& newClasses = elementData()->classNames(); |
| 1269 if (testShouldInvalidateStyle) | 1275 if (testShouldInvalidateStyle) |
| 1270 document().styleEngine().classChangedForElement(oldClasses, newClass
es, *this); | 1276 document().styleEngine().classChangedForElement(oldClasses, newClass
es, *this); |
| 1271 } else { | 1277 } else { |
| 1272 const SpaceSplitString& oldClasses = elementData()->classNames(); | 1278 const SpaceSplitString& oldClasses = elementData()->classNames(); |
| 1273 if (testShouldInvalidateStyle) | 1279 if (testShouldInvalidateStyle) |
| 1274 document().styleEngine().classChangedForElement(oldClasses, *this); | 1280 document().styleEngine().classChangedForElement(oldClasses, *this); |
| 1275 elementData()->clearClass(); | 1281 if (classStringContentType == WhiteSpaceOnly) |
| 1282 elementData()->setClass(newClassString, shouldFoldCase); |
| 1283 else |
| 1284 elementData()->clearClass(); |
| 1276 } | 1285 } |
| 1277 | 1286 |
| 1278 if (hasRareData()) | 1287 if (hasRareData()) |
| 1279 elementRareData()->clearClassListValueForQuirksMode(); | 1288 elementRareData()->clearClassListValueForQuirksMode(); |
| 1280 } | 1289 } |
| 1281 | 1290 |
| 1282 bool Element::shouldInvalidateDistributionWhenAttributeChanged(ElementShadow* el
ementShadow, const QualifiedName& name, const AtomicString& newValue) | 1291 bool Element::shouldInvalidateDistributionWhenAttributeChanged(ElementShadow* el
ementShadow, const QualifiedName& name, const AtomicString& newValue) |
| 1283 { | 1292 { |
| 1284 ASSERT(elementShadow); | 1293 ASSERT(elementShadow); |
| 1285 const SelectRuleFeatureSet& featureSet = elementShadow->ensureSelectFeatureS
et(); | 1294 const SelectRuleFeatureSet& featureSet = elementShadow->ensureSelectFeatureS
et(); |
| 1286 | 1295 |
| 1287 if (name == HTMLNames::idAttr) { | 1296 if (name == HTMLNames::idAttr) { |
| 1288 AtomicString oldId = elementData()->idForStyleResolution(); | 1297 AtomicString oldId = elementData()->idForStyleResolution(); |
| 1289 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui
rksMode()); | 1298 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui
rksMode()); |
| 1290 if (newId != oldId) { | 1299 if (newId != oldId) { |
| 1291 if (!oldId.isEmpty() && featureSet.hasSelectorForId(oldId)) | 1300 if (!oldId.isEmpty() && featureSet.hasSelectorForId(oldId)) |
| 1292 return true; | 1301 return true; |
| 1293 if (!newId.isEmpty() && featureSet.hasSelectorForId(newId)) | 1302 if (!newId.isEmpty() && featureSet.hasSelectorForId(newId)) |
| 1294 return true; | 1303 return true; |
| 1295 } | 1304 } |
| 1296 } | 1305 } |
| 1297 | 1306 |
| 1298 if (name == HTMLNames::classAttr) { | 1307 if (name == HTMLNames::classAttr) { |
| 1299 const AtomicString& newClassString = newValue; | 1308 const AtomicString& newClassString = newValue; |
| 1300 if (classStringHasClassName(newClassString)) { | 1309 |
| 1310 if (classStringHasClassName(newClassString) == HasClasses) { |
| 1301 const SpaceSplitString& oldClasses = elementData()->classNames(); | 1311 const SpaceSplitString& oldClasses = elementData()->classNames(); |
| 1302 const SpaceSplitString newClasses(newClassString, document().inQuirk
sMode() ? SpaceSplitString::ShouldFoldCase : SpaceSplitString::ShouldNotFoldCase
); | 1312 const SpaceSplitString newClasses(newClassString, document().inQuirk
sMode() ? SpaceSplitString::ShouldFoldCase : SpaceSplitString::ShouldNotFoldCase
); |
| 1303 if (featureSet.checkSelectorsForClassChange(oldClasses, newClasses)) | 1313 if (featureSet.checkSelectorsForClassChange(oldClasses, newClasses)) |
| 1304 return true; | 1314 return true; |
| 1305 } else { | 1315 } else { |
| 1306 const SpaceSplitString& oldClasses = elementData()->classNames(); | 1316 const SpaceSplitString& oldClasses = elementData()->classNames(); |
| 1307 if (featureSet.checkSelectorsForClassChange(oldClasses)) | 1317 if (featureSet.checkSelectorsForClassChange(oldClasses)) |
| 1308 return true; | 1318 return true; |
| 1309 } | 1319 } |
| 1310 } | 1320 } |
| (...skipping 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3564 { | 3574 { |
| 3565 #if ENABLE(OILPAN) | 3575 #if ENABLE(OILPAN) |
| 3566 if (hasRareData()) | 3576 if (hasRareData()) |
| 3567 visitor->trace(elementRareData()); | 3577 visitor->trace(elementRareData()); |
| 3568 visitor->trace(m_elementData); | 3578 visitor->trace(m_elementData); |
| 3569 #endif | 3579 #endif |
| 3570 ContainerNode::trace(visitor); | 3580 ContainerNode::trace(visitor); |
| 3571 } | 3581 } |
| 3572 | 3582 |
| 3573 } // namespace blink | 3583 } // namespace blink |
| OLD | NEW |