| 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. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. |
| 8 * All rights reserved. | 8 * All rights reserved. |
| 9 * (C) 2007 Eric Seidel (eric@webkit.org) | 9 * (C) 2007 Eric Seidel (eric@webkit.org) |
| 10 * | 10 * |
| (...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 } | 1250 } |
| 1251 | 1251 |
| 1252 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, | 1252 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, |
| 1253 bool inQuirksMode) { | 1253 bool inQuirksMode) { |
| 1254 if (inQuirksMode) | 1254 if (inQuirksMode) |
| 1255 return value.lowerASCII(); | 1255 return value.lowerASCII(); |
| 1256 return value; | 1256 return value; |
| 1257 } | 1257 } |
| 1258 | 1258 |
| 1259 DISABLE_CFI_PERF | 1259 DISABLE_CFI_PERF |
| 1260 void Element::attributeChanged(const QualifiedName& name, | 1260 void Element::attributeChanged(const AttributeModificationParams& params) { |
| 1261 const AtomicString& oldValue, | 1261 const QualifiedName& name = params.name; |
| 1262 const AtomicString& newValue, | |
| 1263 AttributeModificationReason reason) { | |
| 1264 if (ElementShadow* parentElementShadow = | 1262 if (ElementShadow* parentElementShadow = |
| 1265 shadowWhereNodeCanBeDistributedForV0(*this)) { | 1263 shadowWhereNodeCanBeDistributedForV0(*this)) { |
| 1266 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow, | 1264 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow, |
| 1267 name, newValue)) | 1265 name, params.newValue)) |
| 1268 parentElementShadow->setNeedsDistributionRecalc(); | 1266 parentElementShadow->setNeedsDistributionRecalc(); |
| 1269 } | 1267 } |
| 1270 if (name == HTMLNames::slotAttr && oldValue != newValue) { | 1268 if (name == HTMLNames::slotAttr && params.oldValue != params.newValue) { |
| 1271 if (ShadowRoot* root = v1ShadowRootOfParent()) | 1269 if (ShadowRoot* root = v1ShadowRootOfParent()) { |
| 1272 root->ensureSlotAssignment().hostChildSlotNameChanged(oldValue, newValue); | 1270 root->ensureSlotAssignment().hostChildSlotNameChanged(params.oldValue, |
| 1271 params.newValue); |
| 1272 } |
| 1273 } | 1273 } |
| 1274 | 1274 |
| 1275 parseAttribute(name, oldValue, newValue); | 1275 parseAttribute(params); |
| 1276 | 1276 |
| 1277 document().incDOMTreeVersion(); | 1277 document().incDOMTreeVersion(); |
| 1278 | 1278 |
| 1279 if (name == HTMLNames::idAttr) { | 1279 if (name == HTMLNames::idAttr) { |
| 1280 AtomicString oldId = elementData()->idForStyleResolution(); | 1280 AtomicString oldId = elementData()->idForStyleResolution(); |
| 1281 AtomicString newId = | 1281 AtomicString newId = |
| 1282 makeIdForStyleResolution(newValue, document().inQuirksMode()); | 1282 makeIdForStyleResolution(params.newValue, document().inQuirksMode()); |
| 1283 if (newId != oldId) { | 1283 if (newId != oldId) { |
| 1284 elementData()->setIdForStyleResolution(newId); | 1284 elementData()->setIdForStyleResolution(newId); |
| 1285 document().styleEngine().idChangedForElement(oldId, newId, *this); | 1285 document().styleEngine().idChangedForElement(oldId, newId, *this); |
| 1286 } | 1286 } |
| 1287 } else if (name == classAttr) { | 1287 } else if (name == classAttr) { |
| 1288 classAttributeChanged(newValue); | 1288 classAttributeChanged(params.newValue); |
| 1289 } else if (name == HTMLNames::nameAttr) { | 1289 } else if (name == HTMLNames::nameAttr) { |
| 1290 setHasName(!newValue.isNull()); | 1290 setHasName(!params.newValue.isNull()); |
| 1291 } else if (isStyledElement()) { | 1291 } else if (isStyledElement()) { |
| 1292 if (name == styleAttr) { | 1292 if (name == styleAttr) { |
| 1293 styleAttributeChanged(newValue, reason); | 1293 styleAttributeChanged(params.newValue, params.reason); |
| 1294 } else if (isPresentationAttribute(name)) { | 1294 } else if (isPresentationAttribute(name)) { |
| 1295 elementData()->m_presentationAttributeStyleIsDirty = true; | 1295 elementData()->m_presentationAttributeStyleIsDirty = true; |
| 1296 setNeedsStyleRecalc(LocalStyleChange, | 1296 setNeedsStyleRecalc(LocalStyleChange, |
| 1297 StyleChangeReasonForTracing::fromAttribute(name)); | 1297 StyleChangeReasonForTracing::fromAttribute(name)); |
| 1298 } | 1298 } |
| 1299 } | 1299 } |
| 1300 | 1300 |
| 1301 invalidateNodeListCachesInAncestors(&name, this); | 1301 invalidateNodeListCachesInAncestors(&name, this); |
| 1302 | 1302 |
| 1303 // If there is currently no StyleResolver, we can't be sure that this | 1303 // If there is currently no StyleResolver, we can't be sure that this |
| 1304 // attribute change won't affect style. | 1304 // attribute change won't affect style. |
| 1305 if (!document().styleResolver()) | 1305 if (!document().styleResolver()) |
| 1306 setNeedsStyleRecalc(SubtreeStyleChange, | 1306 setNeedsStyleRecalc(SubtreeStyleChange, |
| 1307 StyleChangeReasonForTracing::fromAttribute(name)); | 1307 StyleChangeReasonForTracing::fromAttribute(name)); |
| 1308 | 1308 |
| 1309 if (isConnected()) { | 1309 if (isConnected()) { |
| 1310 if (AXObjectCache* cache = document().existingAXObjectCache()) | 1310 if (AXObjectCache* cache = document().existingAXObjectCache()) |
| 1311 cache->handleAttributeChanged(name, this); | 1311 cache->handleAttributeChanged(name, this); |
| 1312 } | 1312 } |
| 1313 | 1313 |
| 1314 if (reason == AttributeModificationReason::kDirectly && | 1314 if (params.reason == AttributeModificationReason::kDirectly && |
| 1315 name == tabindexAttr && adjustedFocusedElementInTreeScope() == this) { | 1315 name == tabindexAttr && adjustedFocusedElementInTreeScope() == this) { |
| 1316 // The attribute change may cause supportsFocus() to return false | 1316 // The attribute change may cause supportsFocus() to return false |
| 1317 // for the element which had focus. | 1317 // for the element which had focus. |
| 1318 // | 1318 // |
| 1319 // TODO(tkent): We should avoid updating style. We'd like to check only | 1319 // TODO(tkent): We should avoid updating style. We'd like to check only |
| 1320 // DOM-level focusability here. | 1320 // DOM-level focusability here. |
| 1321 document().updateStyleAndLayoutTreeForNode(this); | 1321 document().updateStyleAndLayoutTreeForNode(this); |
| 1322 if (!supportsFocus()) | 1322 if (!supportsFocus()) |
| 1323 blur(); | 1323 blur(); |
| 1324 } | 1324 } |
| 1325 } | 1325 } |
| 1326 | 1326 |
| 1327 bool Element::hasLegalLinkAttribute(const QualifiedName&) const { | 1327 bool Element::hasLegalLinkAttribute(const QualifiedName&) const { |
| 1328 return false; | 1328 return false; |
| 1329 } | 1329 } |
| 1330 | 1330 |
| 1331 const QualifiedName& Element::subResourceAttributeName() const { | 1331 const QualifiedName& Element::subResourceAttributeName() const { |
| 1332 return QualifiedName::null(); | 1332 return QualifiedName::null(); |
| 1333 } | 1333 } |
| 1334 | 1334 |
| 1335 inline void Element::attributeChangedFromParserOrByCloning( | 1335 inline void Element::attributeChangedFromParserOrByCloning( |
| 1336 const QualifiedName& name, | 1336 const QualifiedName& name, |
| 1337 const AtomicString& newValue, | 1337 const AtomicString& newValue, |
| 1338 AttributeModificationReason reason) { | 1338 AttributeModificationReason reason) { |
| 1339 if (name == isAttr) | 1339 if (name == isAttr) |
| 1340 V0CustomElementRegistrationContext::setTypeExtension(this, newValue); | 1340 V0CustomElementRegistrationContext::setTypeExtension(this, newValue); |
| 1341 attributeChanged(name, nullAtom, newValue, reason); | 1341 attributeChanged( |
| 1342 AttributeModificationParams(name, nullAtom, newValue, reason)); |
| 1342 } | 1343 } |
| 1343 | 1344 |
| 1344 template <typename CharacterType> | 1345 template <typename CharacterType> |
| 1345 static inline ClassStringContent classStringHasClassName( | 1346 static inline ClassStringContent classStringHasClassName( |
| 1346 const CharacterType* characters, | 1347 const CharacterType* characters, |
| 1347 unsigned length) { | 1348 unsigned length) { |
| 1348 DCHECK_GT(length, 0u); | 1349 DCHECK_GT(length, 0u); |
| 1349 | 1350 |
| 1350 unsigned i = 0; | 1351 unsigned i = 0; |
| 1351 do { | 1352 do { |
| (...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2444 if (index == kNotFound) { | 2445 if (index == kNotFound) { |
| 2445 exceptionState.throwDOMException( | 2446 exceptionState.throwDOMException( |
| 2446 NotFoundError, "The attribute was not found on this element."); | 2447 NotFoundError, "The attribute was not found on this element."); |
| 2447 return nullptr; | 2448 return nullptr; |
| 2448 } | 2449 } |
| 2449 | 2450 |
| 2450 detachAttrNodeAtIndex(attr, index); | 2451 detachAttrNodeAtIndex(attr, index); |
| 2451 return attr; | 2452 return attr; |
| 2452 } | 2453 } |
| 2453 | 2454 |
| 2454 void Element::parseAttribute(const QualifiedName& name, | 2455 void Element::parseAttribute(const AttributeModificationParams& params) { |
| 2455 const AtomicString&, | 2456 if (params.name == tabindexAttr) { |
| 2456 const AtomicString& value) { | |
| 2457 if (name == tabindexAttr) { | |
| 2458 int tabindex = 0; | 2457 int tabindex = 0; |
| 2459 if (value.isEmpty() || !parseHTMLInteger(value, tabindex)) { | 2458 if (params.newValue.isEmpty() || |
| 2459 !parseHTMLInteger(params.newValue, tabindex)) { |
| 2460 clearTabIndexExplicitlyIfNeeded(); | 2460 clearTabIndexExplicitlyIfNeeded(); |
| 2461 } else { | 2461 } else { |
| 2462 // We only set when value is in integer range. | 2462 // We only set when value is in integer range. |
| 2463 setTabIndexExplicitly(); | 2463 setTabIndexExplicitly(); |
| 2464 } | 2464 } |
| 2465 } else if (name == XMLNames::langAttr) { | 2465 } else if (params.name == XMLNames::langAttr) { |
| 2466 pseudoStateChanged(CSSSelector::PseudoLang); | 2466 pseudoStateChanged(CSSSelector::PseudoLang); |
| 2467 } | 2467 } |
| 2468 } | 2468 } |
| 2469 | 2469 |
| 2470 bool Element::parseAttributeName(QualifiedName& out, | 2470 bool Element::parseAttributeName(QualifiedName& out, |
| 2471 const AtomicString& namespaceURI, | 2471 const AtomicString& namespaceURI, |
| 2472 const AtomicString& qualifiedName, | 2472 const AtomicString& qualifiedName, |
| 2473 ExceptionState& exceptionState) { | 2473 ExceptionState& exceptionState) { |
| 2474 AtomicString prefix, localName; | 2474 AtomicString prefix, localName; |
| 2475 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, | 2475 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, |
| (...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3537 MutationRecord::createAttributes(this, name, oldValue)); | 3537 MutationRecord::createAttributes(this, name, oldValue)); |
| 3538 | 3538 |
| 3539 InspectorInstrumentation::willModifyDOMAttr(this, oldValue, newValue); | 3539 InspectorInstrumentation::willModifyDOMAttr(this, oldValue, newValue); |
| 3540 } | 3540 } |
| 3541 | 3541 |
| 3542 DISABLE_CFI_PERF | 3542 DISABLE_CFI_PERF |
| 3543 void Element::didAddAttribute(const QualifiedName& name, | 3543 void Element::didAddAttribute(const QualifiedName& name, |
| 3544 const AtomicString& value) { | 3544 const AtomicString& value) { |
| 3545 if (name == HTMLNames::idAttr) | 3545 if (name == HTMLNames::idAttr) |
| 3546 updateId(nullAtom, value); | 3546 updateId(nullAtom, value); |
| 3547 attributeChanged(name, nullAtom, value, | 3547 attributeChanged(AttributeModificationParams( |
| 3548 AttributeModificationReason::kDirectly); | 3548 name, nullAtom, value, AttributeModificationReason::kDirectly)); |
| 3549 InspectorInstrumentation::didModifyDOMAttr(this, name, value); | 3549 InspectorInstrumentation::didModifyDOMAttr(this, name, value); |
| 3550 dispatchSubtreeModifiedEvent(); | 3550 dispatchSubtreeModifiedEvent(); |
| 3551 } | 3551 } |
| 3552 | 3552 |
| 3553 void Element::didModifyAttribute(const QualifiedName& name, | 3553 void Element::didModifyAttribute(const QualifiedName& name, |
| 3554 const AtomicString& oldValue, | 3554 const AtomicString& oldValue, |
| 3555 const AtomicString& newValue) { | 3555 const AtomicString& newValue) { |
| 3556 if (name == HTMLNames::idAttr) | 3556 if (name == HTMLNames::idAttr) |
| 3557 updateId(oldValue, newValue); | 3557 updateId(oldValue, newValue); |
| 3558 attributeChanged(name, oldValue, newValue, | 3558 attributeChanged(AttributeModificationParams( |
| 3559 AttributeModificationReason::kDirectly); | 3559 name, oldValue, newValue, AttributeModificationReason::kDirectly)); |
| 3560 InspectorInstrumentation::didModifyDOMAttr(this, name, newValue); | 3560 InspectorInstrumentation::didModifyDOMAttr(this, name, newValue); |
| 3561 // Do not dispatch a DOMSubtreeModified event here; see bug 81141. | 3561 // Do not dispatch a DOMSubtreeModified event here; see bug 81141. |
| 3562 } | 3562 } |
| 3563 | 3563 |
| 3564 void Element::didRemoveAttribute(const QualifiedName& name, | 3564 void Element::didRemoveAttribute(const QualifiedName& name, |
| 3565 const AtomicString& oldValue) { | 3565 const AtomicString& oldValue) { |
| 3566 if (name == HTMLNames::idAttr) | 3566 if (name == HTMLNames::idAttr) |
| 3567 updateId(oldValue, nullAtom); | 3567 updateId(oldValue, nullAtom); |
| 3568 attributeChanged(name, oldValue, nullAtom, | 3568 attributeChanged(AttributeModificationParams( |
| 3569 AttributeModificationReason::kDirectly); | 3569 name, oldValue, nullAtom, AttributeModificationReason::kDirectly)); |
| 3570 InspectorInstrumentation::didRemoveDOMAttr(this, name); | 3570 InspectorInstrumentation::didRemoveDOMAttr(this, name); |
| 3571 dispatchSubtreeModifiedEvent(); | 3571 dispatchSubtreeModifiedEvent(); |
| 3572 } | 3572 } |
| 3573 | 3573 |
| 3574 static bool needsURLResolutionForInlineStyle(const Element& element, | 3574 static bool needsURLResolutionForInlineStyle(const Element& element, |
| 3575 const Document& oldDocument, | 3575 const Document& oldDocument, |
| 3576 const Document& newDocument) { | 3576 const Document& newDocument) { |
| 3577 if (oldDocument == newDocument) | 3577 if (oldDocument == newDocument) |
| 3578 return false; | 3578 return false; |
| 3579 if (oldDocument.baseURL() == newDocument.baseURL()) | 3579 if (oldDocument.baseURL() == newDocument.baseURL()) |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4080 Vector<String, 4> argv; | 4080 Vector<String, 4> argv; |
| 4081 argv.push_back(element); | 4081 argv.push_back(element); |
| 4082 argv.push_back(fastGetAttribute(attr1)); | 4082 argv.push_back(fastGetAttribute(attr1)); |
| 4083 argv.push_back(fastGetAttribute(attr2)); | 4083 argv.push_back(fastGetAttribute(attr2)); |
| 4084 argv.push_back(fastGetAttribute(attr3)); | 4084 argv.push_back(fastGetAttribute(attr3)); |
| 4085 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data()); | 4085 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data()); |
| 4086 } | 4086 } |
| 4087 | 4087 |
| 4088 void Element::logUpdateAttributeIfIsolatedWorldAndInDocument( | 4088 void Element::logUpdateAttributeIfIsolatedWorldAndInDocument( |
| 4089 const char element[], | 4089 const char element[], |
| 4090 const QualifiedName& attributeName, | 4090 const AttributeModificationParams& params) { |
| 4091 const AtomicString& oldValue, | |
| 4092 const AtomicString& newValue) { | |
| 4093 if (!isConnected()) | 4091 if (!isConnected()) |
| 4094 return; | 4092 return; |
| 4095 V8DOMActivityLogger* activityLogger = | 4093 V8DOMActivityLogger* activityLogger = |
| 4096 V8DOMActivityLogger::currentActivityLoggerIfIsolatedWorld(); | 4094 V8DOMActivityLogger::currentActivityLoggerIfIsolatedWorld(); |
| 4097 if (!activityLogger) | 4095 if (!activityLogger) |
| 4098 return; | 4096 return; |
| 4099 Vector<String, 4> argv; | 4097 Vector<String, 4> argv; |
| 4100 argv.push_back(element); | 4098 argv.push_back(element); |
| 4101 argv.push_back(attributeName.toString()); | 4099 argv.push_back(params.name.toString()); |
| 4102 argv.push_back(oldValue); | 4100 argv.push_back(params.oldValue); |
| 4103 argv.push_back(newValue); | 4101 argv.push_back(params.newValue); |
| 4104 activityLogger->logEvent("blinkSetAttribute", argv.size(), argv.data()); | 4102 activityLogger->logEvent("blinkSetAttribute", argv.size(), argv.data()); |
| 4105 } | 4103 } |
| 4106 | 4104 |
| 4107 DEFINE_TRACE(Element) { | 4105 DEFINE_TRACE(Element) { |
| 4108 if (hasRareData()) | 4106 if (hasRareData()) |
| 4109 visitor->trace(elementRareData()); | 4107 visitor->trace(elementRareData()); |
| 4110 visitor->trace(m_elementData); | 4108 visitor->trace(m_elementData); |
| 4111 ContainerNode::trace(visitor); | 4109 ContainerNode::trace(visitor); |
| 4112 } | 4110 } |
| 4113 | 4111 |
| 4114 DEFINE_TRACE_WRAPPERS(Element) { | 4112 DEFINE_TRACE_WRAPPERS(Element) { |
| 4115 if (hasRareData()) { | 4113 if (hasRareData()) { |
| 4116 visitor->traceWrappers(elementRareData()); | 4114 visitor->traceWrappers(elementRareData()); |
| 4117 } | 4115 } |
| 4118 ContainerNode::traceWrappers(visitor); | 4116 ContainerNode::traceWrappers(visitor); |
| 4119 } | 4117 } |
| 4120 | 4118 |
| 4121 } // namespace blink | 4119 } // namespace blink |
| OLD | NEW |