Chromium Code Reviews| 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 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | |
| 1314 if (reason == AttributeModificationReason::kDirectly && | |
| 1315 name == tabindexAttr && adjustedFocusedElementInTreeScope() == this) { | |
| 1316 // supportsFocus() behavior depends on element classes. It's hard to avoid | |
| 1317 // to call it, and it needs up-to-date style. | |
|
kochi
2016/12/21 05:58:09
nit: s/avoid to call/avoid calling/
Let me unders
tkent
2016/12/21 06:51:15
We don't call supportsFocus() and updateStyleAndLa
kochi
2016/12/21 08:05:19
Looks good.
| |
| 1318 document().updateStyleAndLayoutTreeForNode(this); | |
| 1319 if (!supportsFocus()) | |
| 1320 blur(); | |
| 1321 } | |
| 1313 } | 1322 } |
| 1314 | 1323 |
| 1315 bool Element::hasLegalLinkAttribute(const QualifiedName&) const { | 1324 bool Element::hasLegalLinkAttribute(const QualifiedName&) const { |
| 1316 return false; | 1325 return false; |
| 1317 } | 1326 } |
| 1318 | 1327 |
| 1319 const QualifiedName& Element::subResourceAttributeName() const { | 1328 const QualifiedName& Element::subResourceAttributeName() const { |
| 1320 return QualifiedName::null(); | 1329 return QualifiedName::null(); |
| 1321 } | 1330 } |
| 1322 | 1331 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1481 ->cachedShareableElementDataWithAttributes(attributeVector); | 1490 ->cachedShareableElementDataWithAttributes(attributeVector); |
| 1482 else | 1491 else |
| 1483 m_elementData = | 1492 m_elementData = |
| 1484 ShareableElementData::createWithAttributes(attributeVector); | 1493 ShareableElementData::createWithAttributes(attributeVector); |
| 1485 } | 1494 } |
| 1486 | 1495 |
| 1487 parserDidSetAttributes(); | 1496 parserDidSetAttributes(); |
| 1488 | 1497 |
| 1489 // Use attributeVector instead of m_elementData because attributeChanged might | 1498 // Use attributeVector instead of m_elementData because attributeChanged might |
| 1490 // modify m_elementData. | 1499 // modify m_elementData. |
| 1491 for (const auto& attribute : attributeVector) | 1500 for (const auto& attribute : attributeVector) { |
| 1492 attributeChangedFromParserOrByCloning(attribute.name(), attribute.value(), | 1501 attributeChangedFromParserOrByCloning( |
| 1493 ModifiedDirectly); | 1502 attribute.name(), attribute.value(), |
| 1503 AttributeModificationReason::kByParser); | |
| 1504 } | |
| 1494 } | 1505 } |
| 1495 | 1506 |
| 1496 bool Element::hasEquivalentAttributes(const Element* other) const { | 1507 bool Element::hasEquivalentAttributes(const Element* other) const { |
| 1497 synchronizeAllAttributes(); | 1508 synchronizeAllAttributes(); |
| 1498 other->synchronizeAllAttributes(); | 1509 other->synchronizeAllAttributes(); |
| 1499 if (elementData() == other->elementData()) | 1510 if (elementData() == other->elementData()) |
| 1500 return true; | 1511 return true; |
| 1501 if (elementData()) | 1512 if (elementData()) |
| 1502 return elementData()->isEquivalent(other->elementData()); | 1513 return elementData()->isEquivalent(other->elementData()); |
| 1503 if (other->elementData()) | 1514 if (other->elementData()) |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2437 return attr; | 2448 return attr; |
| 2438 } | 2449 } |
| 2439 | 2450 |
| 2440 void Element::parseAttribute(const QualifiedName& name, | 2451 void Element::parseAttribute(const QualifiedName& name, |
| 2441 const AtomicString&, | 2452 const AtomicString&, |
| 2442 const AtomicString& value) { | 2453 const AtomicString& value) { |
| 2443 if (name == tabindexAttr) { | 2454 if (name == tabindexAttr) { |
| 2444 int tabindex = 0; | 2455 int tabindex = 0; |
| 2445 if (value.isEmpty() || !parseHTMLInteger(value, tabindex)) { | 2456 if (value.isEmpty() || !parseHTMLInteger(value, tabindex)) { |
| 2446 clearTabIndexExplicitlyIfNeeded(); | 2457 clearTabIndexExplicitlyIfNeeded(); |
| 2447 if (adjustedFocusedElementInTreeScope() == this) { | |
| 2448 // We might want to call blur(), but it's dangerous to dispatch | |
| 2449 // events here. | |
| 2450 document().setNeedsFocusedElementCheck(); | |
| 2451 } | |
| 2452 } else { | 2458 } else { |
| 2453 // We only set when value is in integer range. | 2459 // We only set when value is in integer range. |
| 2454 setTabIndexExplicitly(); | 2460 setTabIndexExplicitly(); |
| 2455 } | 2461 } |
| 2456 } else if (name == XMLNames::langAttr) { | 2462 } else if (name == XMLNames::langAttr) { |
| 2457 pseudoStateChanged(CSSSelector::PseudoLang); | 2463 pseudoStateChanged(CSSSelector::PseudoLang); |
| 2458 } | 2464 } |
| 2459 } | 2465 } |
| 2460 | 2466 |
| 2461 bool Element::parseAttributeName(QualifiedName& out, | 2467 bool Element::parseAttributeName(QualifiedName& out, |
| (...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3520 MutationRecord::createAttributes(this, name, oldValue)); | 3526 MutationRecord::createAttributes(this, name, oldValue)); |
| 3521 | 3527 |
| 3522 InspectorInstrumentation::willModifyDOMAttr(this, oldValue, newValue); | 3528 InspectorInstrumentation::willModifyDOMAttr(this, oldValue, newValue); |
| 3523 } | 3529 } |
| 3524 | 3530 |
| 3525 DISABLE_CFI_PERF | 3531 DISABLE_CFI_PERF |
| 3526 void Element::didAddAttribute(const QualifiedName& name, | 3532 void Element::didAddAttribute(const QualifiedName& name, |
| 3527 const AtomicString& value) { | 3533 const AtomicString& value) { |
| 3528 if (name == HTMLNames::idAttr) | 3534 if (name == HTMLNames::idAttr) |
| 3529 updateId(nullAtom, value); | 3535 updateId(nullAtom, value); |
| 3530 attributeChanged(name, nullAtom, value); | 3536 attributeChanged(name, nullAtom, value, |
| 3537 AttributeModificationReason::kDirectly); | |
| 3531 InspectorInstrumentation::didModifyDOMAttr(this, name, value); | 3538 InspectorInstrumentation::didModifyDOMAttr(this, name, value); |
| 3532 dispatchSubtreeModifiedEvent(); | 3539 dispatchSubtreeModifiedEvent(); |
| 3533 } | 3540 } |
| 3534 | 3541 |
| 3535 void Element::didModifyAttribute(const QualifiedName& name, | 3542 void Element::didModifyAttribute(const QualifiedName& name, |
| 3536 const AtomicString& oldValue, | 3543 const AtomicString& oldValue, |
| 3537 const AtomicString& newValue) { | 3544 const AtomicString& newValue) { |
| 3538 if (name == HTMLNames::idAttr) | 3545 if (name == HTMLNames::idAttr) |
| 3539 updateId(oldValue, newValue); | 3546 updateId(oldValue, newValue); |
| 3540 attributeChanged(name, oldValue, newValue); | 3547 attributeChanged(name, oldValue, newValue, |
| 3548 AttributeModificationReason::kDirectly); | |
| 3541 InspectorInstrumentation::didModifyDOMAttr(this, name, newValue); | 3549 InspectorInstrumentation::didModifyDOMAttr(this, name, newValue); |
| 3542 // Do not dispatch a DOMSubtreeModified event here; see bug 81141. | 3550 // Do not dispatch a DOMSubtreeModified event here; see bug 81141. |
| 3543 } | 3551 } |
| 3544 | 3552 |
| 3545 void Element::didRemoveAttribute(const QualifiedName& name, | 3553 void Element::didRemoveAttribute(const QualifiedName& name, |
| 3546 const AtomicString& oldValue) { | 3554 const AtomicString& oldValue) { |
| 3547 if (name == HTMLNames::idAttr) | 3555 if (name == HTMLNames::idAttr) |
| 3548 updateId(oldValue, nullAtom); | 3556 updateId(oldValue, nullAtom); |
| 3549 attributeChanged(name, oldValue, nullAtom); | 3557 attributeChanged(name, oldValue, nullAtom, |
| 3558 AttributeModificationReason::kDirectly); | |
| 3550 InspectorInstrumentation::didRemoveDOMAttr(this, name); | 3559 InspectorInstrumentation::didRemoveDOMAttr(this, name); |
| 3551 dispatchSubtreeModifiedEvent(); | 3560 dispatchSubtreeModifiedEvent(); |
| 3552 } | 3561 } |
| 3553 | 3562 |
| 3554 static bool needsURLResolutionForInlineStyle(const Element& element, | 3563 static bool needsURLResolutionForInlineStyle(const Element& element, |
| 3555 const Document& oldDocument, | 3564 const Document& oldDocument, |
| 3556 const Document& newDocument) { | 3565 const Document& newDocument) { |
| 3557 if (oldDocument == newDocument) | 3566 if (oldDocument == newDocument) |
| 3558 return false; | 3567 return false; |
| 3559 if (oldDocument.baseURL() == newDocument.baseURL()) | 3568 if (oldDocument.baseURL() == newDocument.baseURL()) |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3736 toUniqueElementData(other.m_elementData)->makeShareableCopy(); | 3745 toUniqueElementData(other.m_elementData)->makeShareableCopy(); |
| 3737 | 3746 |
| 3738 if (!other.m_elementData->isUnique() && | 3747 if (!other.m_elementData->isUnique() && |
| 3739 !ownerDocumentsHaveDifferentCaseSensitivity && | 3748 !ownerDocumentsHaveDifferentCaseSensitivity && |
| 3740 !needsURLResolutionForInlineStyle(other, other.document(), document())) | 3749 !needsURLResolutionForInlineStyle(other, other.document(), document())) |
| 3741 m_elementData = other.m_elementData; | 3750 m_elementData = other.m_elementData; |
| 3742 else | 3751 else |
| 3743 m_elementData = other.m_elementData->makeUniqueCopy(); | 3752 m_elementData = other.m_elementData->makeUniqueCopy(); |
| 3744 | 3753 |
| 3745 AttributeCollection attributes = m_elementData->attributes(); | 3754 AttributeCollection attributes = m_elementData->attributes(); |
| 3746 for (const Attribute& attr : attributes) | 3755 for (const Attribute& attr : attributes) { |
| 3747 attributeChangedFromParserOrByCloning(attr.name(), attr.value(), | 3756 attributeChangedFromParserOrByCloning( |
| 3748 ModifiedByCloning); | 3757 attr.name(), attr.value(), AttributeModificationReason::kByCloning); |
| 3758 } | |
| 3749 } | 3759 } |
| 3750 | 3760 |
| 3751 void Element::cloneDataFromElement(const Element& other) { | 3761 void Element::cloneDataFromElement(const Element& other) { |
| 3752 cloneAttributesFromElement(other); | 3762 cloneAttributesFromElement(other); |
| 3753 copyNonAttributePropertiesFromElement(other); | 3763 copyNonAttributePropertiesFromElement(other); |
| 3754 } | 3764 } |
| 3755 | 3765 |
| 3756 void Element::createUniqueElementData() { | 3766 void Element::createUniqueElementData() { |
| 3757 if (!m_elementData) { | 3767 if (!m_elementData) { |
| 3758 m_elementData = UniqueElementData::create(); | 3768 m_elementData = UniqueElementData::create(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3833 void Element::styleAttributeChanged( | 3843 void Element::styleAttributeChanged( |
| 3834 const AtomicString& newStyleString, | 3844 const AtomicString& newStyleString, |
| 3835 AttributeModificationReason modificationReason) { | 3845 AttributeModificationReason modificationReason) { |
| 3836 DCHECK(isStyledElement()); | 3846 DCHECK(isStyledElement()); |
| 3837 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst(); | 3847 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst(); |
| 3838 if (document().scriptableDocumentParser() && !document().isInDocumentWrite()) | 3848 if (document().scriptableDocumentParser() && !document().isInDocumentWrite()) |
| 3839 startLineNumber = document().scriptableDocumentParser()->lineNumber(); | 3849 startLineNumber = document().scriptableDocumentParser()->lineNumber(); |
| 3840 | 3850 |
| 3841 if (newStyleString.isNull()) { | 3851 if (newStyleString.isNull()) { |
| 3842 ensureUniqueElementData().m_inlineStyle.clear(); | 3852 ensureUniqueElementData().m_inlineStyle.clear(); |
| 3843 } else if (modificationReason == ModifiedByCloning || | 3853 } else if (modificationReason == AttributeModificationReason::kByCloning || |
| 3844 ContentSecurityPolicy::shouldBypassMainWorld(&document()) || | 3854 ContentSecurityPolicy::shouldBypassMainWorld(&document()) || |
| 3845 (containingShadowRoot() && | 3855 (containingShadowRoot() && |
| 3846 containingShadowRoot()->type() == ShadowRootType::UserAgent) || | 3856 containingShadowRoot()->type() == ShadowRootType::UserAgent) || |
| 3847 document().contentSecurityPolicy()->allowInlineStyle( | 3857 document().contentSecurityPolicy()->allowInlineStyle( |
| 3848 this, document().url(), String(), startLineNumber, | 3858 this, document().url(), String(), startLineNumber, |
| 3849 newStyleString)) { | 3859 newStyleString)) { |
| 3850 setInlineStyleFromString(newStyleString); | 3860 setInlineStyleFromString(newStyleString); |
| 3851 } | 3861 } |
| 3852 | 3862 |
| 3853 elementData()->m_styleAttributeIsDirty = false; | 3863 elementData()->m_styleAttributeIsDirty = false; |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4091 } | 4101 } |
| 4092 | 4102 |
| 4093 DEFINE_TRACE_WRAPPERS(Element) { | 4103 DEFINE_TRACE_WRAPPERS(Element) { |
| 4094 if (hasRareData()) { | 4104 if (hasRareData()) { |
| 4095 visitor->traceWrappers(elementRareData()); | 4105 visitor->traceWrappers(elementRareData()); |
| 4096 } | 4106 } |
| 4097 ContainerNode::traceWrappers(visitor); | 4107 ContainerNode::traceWrappers(visitor); |
| 4098 } | 4108 } |
| 4099 | 4109 |
| 4100 } // namespace blink | 4110 } // namespace blink |
| OLD | NEW |