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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 // true. | 424 // true. |
425 toSVGElement(this)->synchronizeAnimatedSVGAttribute(QualifiedName(nullAt
om, localName, nullAtom)); | 425 toSVGElement(this)->synchronizeAnimatedSVGAttribute(QualifiedName(nullAt
om, localName, nullAtom)); |
426 } | 426 } |
427 } | 427 } |
428 | 428 |
429 const AtomicString& Element::getAttribute(const QualifiedName& name) const | 429 const AtomicString& Element::getAttribute(const QualifiedName& name) const |
430 { | 430 { |
431 if (!elementData()) | 431 if (!elementData()) |
432 return nullAtom; | 432 return nullAtom; |
433 synchronizeAttribute(name); | 433 synchronizeAttribute(name); |
434 if (const Attribute* attribute = attributes().find(name)) | 434 if (const Attribute* attribute = elementData()->attributes().find(name)) |
435 return attribute->value(); | 435 return attribute->value(); |
436 return nullAtom; | 436 return nullAtom; |
437 } | 437 } |
438 | 438 |
439 bool Element::shouldIgnoreAttributeCase() const | 439 bool Element::shouldIgnoreAttributeCase() const |
440 { | 440 { |
441 return isHTMLElement() && document().isHTMLDocument(); | 441 return isHTMLElement() && document().isHTMLDocument(); |
442 } | 442 } |
443 | 443 |
444 void Element::scrollIntoView(bool alignToTop) | 444 void Element::scrollIntoView(bool alignToTop) |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 if (index != kNotFound) | 903 if (index != kNotFound) |
904 removeAttributeInternal(index, inSynchronizationOfLazyAttribute); | 904 removeAttributeInternal(index, inSynchronizationOfLazyAttribute); |
905 return; | 905 return; |
906 } | 906 } |
907 | 907 |
908 if (index == kNotFound) { | 908 if (index == kNotFound) { |
909 appendAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute
); | 909 appendAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute
); |
910 return; | 910 return; |
911 } | 911 } |
912 | 912 |
913 const Attribute& existingAttribute = attributes().at(index); | 913 const Attribute& existingAttribute = elementData()->attributes().at(index); |
914 QualifiedName existingAttributeName = existingAttribute.name(); | 914 QualifiedName existingAttributeName = existingAttribute.name(); |
915 | 915 |
916 if (!inSynchronizationOfLazyAttribute) | 916 if (!inSynchronizationOfLazyAttribute) |
917 willModifyAttribute(existingAttributeName, existingAttribute.value(), ne
wValue); | 917 willModifyAttribute(existingAttributeName, existingAttribute.value(), ne
wValue); |
918 | 918 |
919 if (newValue != existingAttribute.value()) { | 919 if (newValue != existingAttribute.value()) { |
920 // If there is an Attr node hooked to this attribute, the Attr::setValue
() call below | 920 // If there is an Attr node hooked to this attribute, the Attr::setValue
() call below |
921 // will write into the ElementData. | 921 // will write into the ElementData. |
922 // FIXME: Refactor this so it makes some sense. | 922 // FIXME: Refactor this so it makes some sense. |
923 if (RefPtrWillBeRawPtr<Attr> attrNode = inSynchronizationOfLazyAttribute
? nullptr : attrIfExists(existingAttributeName)) | 923 if (RefPtrWillBeRawPtr<Attr> attrNode = inSynchronizationOfLazyAttribute
? nullptr : attrIfExists(existingAttributeName)) |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 if (document().elementDataCache()) | 1128 if (document().elementDataCache()) |
1129 m_elementData = document().elementDataCache()->cachedShareableElementDat
aWithAttributes(attributeVector); | 1129 m_elementData = document().elementDataCache()->cachedShareableElementDat
aWithAttributes(attributeVector); |
1130 else | 1130 else |
1131 m_elementData = ShareableElementData::createWithAttributes(attributeVect
or); | 1131 m_elementData = ShareableElementData::createWithAttributes(attributeVect
or); |
1132 | 1132 |
1133 // Use attributeVector instead of m_elementData because attributeChanged mig
ht modify m_elementData. | 1133 // Use attributeVector instead of m_elementData because attributeChanged mig
ht modify m_elementData. |
1134 for (unsigned i = 0; i < attributeVector.size(); ++i) | 1134 for (unsigned i = 0; i < attributeVector.size(); ++i) |
1135 attributeChangedFromParserOrByCloning(attributeVector[i].name(), attribu
teVector[i].value(), ModifiedDirectly); | 1135 attributeChangedFromParserOrByCloning(attributeVector[i].name(), attribu
teVector[i].value(), ModifiedDirectly); |
1136 } | 1136 } |
1137 | 1137 |
1138 bool Element::hasAttributes() const | |
1139 { | |
1140 synchronizeAllAttributes(); | |
1141 return elementData() && !elementData()->attributes().isEmpty(); | |
1142 } | |
1143 | |
1144 bool Element::hasEquivalentAttributes(const Element* other) const | 1138 bool Element::hasEquivalentAttributes(const Element* other) const |
1145 { | 1139 { |
1146 synchronizeAllAttributes(); | 1140 synchronizeAllAttributes(); |
1147 other->synchronizeAllAttributes(); | 1141 other->synchronizeAllAttributes(); |
1148 if (elementData() == other->elementData()) | 1142 if (elementData() == other->elementData()) |
1149 return true; | 1143 return true; |
1150 if (elementData()) | 1144 if (elementData()) |
1151 return elementData()->isEquivalent(other->elementData()); | 1145 return elementData()->isEquivalent(other->elementData()); |
1152 if (other->elementData()) | 1146 if (other->elementData()) |
1153 return other->elementData()->isEquivalent(elementData()); | 1147 return other->elementData()->isEquivalent(elementData()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 return; | 1179 return; |
1186 | 1180 |
1187 m_tagName.setPrefix(prefix.isEmpty() ? AtomicString() : prefix); | 1181 m_tagName.setPrefix(prefix.isEmpty() ? AtomicString() : prefix); |
1188 } | 1182 } |
1189 | 1183 |
1190 const AtomicString& Element::locateNamespacePrefix(const AtomicString& namespace
ToLocate) const | 1184 const AtomicString& Element::locateNamespacePrefix(const AtomicString& namespace
ToLocate) const |
1191 { | 1185 { |
1192 if (!prefix().isNull() && namespaceURI() == namespaceToLocate) | 1186 if (!prefix().isNull() && namespaceURI() == namespaceToLocate) |
1193 return prefix(); | 1187 return prefix(); |
1194 | 1188 |
1195 if (hasAttributes()) { | 1189 AttributeCollection attributes = this->attributes(); |
1196 AttributeCollection attributes = this->attributes(); | 1190 AttributeCollection::const_iterator end = attributes.end(); |
1197 AttributeCollection::const_iterator end = attributes.end(); | 1191 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it) { |
1198 for (AttributeCollection::const_iterator it = attributes.begin(); it !=
end; ++it) { | 1192 if (it->prefix() == xmlnsAtom && it->value() == namespaceToLocate) |
1199 if (it->prefix() == xmlnsAtom && it->value() == namespaceToLocate) | 1193 return it->localName(); |
1200 return it->localName(); | |
1201 } | |
1202 } | 1194 } |
1203 | 1195 |
1204 if (Element* parent = parentElement()) | 1196 if (Element* parent = parentElement()) |
1205 return parent->locateNamespacePrefix(namespaceToLocate); | 1197 return parent->locateNamespacePrefix(namespaceToLocate); |
1206 | 1198 |
1207 return nullAtom; | 1199 return nullAtom; |
1208 } | 1200 } |
1209 | 1201 |
1210 KURL Element::baseURI() const | 1202 KURL Element::baseURI() const |
1211 { | 1203 { |
(...skipping 1750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2962 } | 2954 } |
2963 } | 2955 } |
2964 ASSERT_NOT_REACHED(); | 2956 ASSERT_NOT_REACHED(); |
2965 } | 2957 } |
2966 | 2958 |
2967 void Element::detachAllAttrNodesFromElement() | 2959 void Element::detachAllAttrNodesFromElement() |
2968 { | 2960 { |
2969 AttrNodeList* list = this->attrNodeList(); | 2961 AttrNodeList* list = this->attrNodeList(); |
2970 ASSERT(list); | 2962 ASSERT(list); |
2971 | 2963 |
2972 AttributeCollection attributes = this->attributes(); | 2964 AttributeCollection attributes = elementData()->attributes(); |
2973 AttributeCollection::const_iterator end = attributes.end(); | 2965 AttributeCollection::const_iterator end = attributes.end(); |
2974 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it) { | 2966 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it) { |
2975 if (RefPtrWillBeRawPtr<Attr> attrNode = findAttrNodeInList(*list, it->na
me())) | 2967 if (RefPtrWillBeRawPtr<Attr> attrNode = findAttrNodeInList(*list, it->na
me())) |
2976 attrNode->detachFromElementWithValue(it->value()); | 2968 attrNode->detachFromElementWithValue(it->value()); |
2977 } | 2969 } |
2978 | 2970 |
2979 removeAttrNodeList(); | 2971 removeAttrNodeList(); |
2980 } | 2972 } |
2981 | 2973 |
2982 void Element::willRecalcStyle(StyleRecalcChange) | 2974 void Element::willRecalcStyle(StyleRecalcChange) |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3276 { | 3268 { |
3277 #if ENABLE(OILPAN) | 3269 #if ENABLE(OILPAN) |
3278 if (hasRareData()) | 3270 if (hasRareData()) |
3279 visitor->trace(elementRareData()); | 3271 visitor->trace(elementRareData()); |
3280 visitor->trace(m_elementData); | 3272 visitor->trace(m_elementData); |
3281 #endif | 3273 #endif |
3282 ContainerNode::trace(visitor); | 3274 ContainerNode::trace(visitor); |
3283 } | 3275 } |
3284 | 3276 |
3285 } // namespace blink | 3277 } // namespace blink |
OLD | NEW |