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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 } | 303 } |
304 | 304 |
305 PassRefPtrWillBeRawPtr<Element> Element::cloneElementWithoutAttributesAndChildre
n() | 305 PassRefPtrWillBeRawPtr<Element> Element::cloneElementWithoutAttributesAndChildre
n() |
306 { | 306 { |
307 return document().createElement(tagQName(), false); | 307 return document().createElement(tagQName(), false); |
308 } | 308 } |
309 | 309 |
310 PassRefPtrWillBeRawPtr<Attr> Element::detachAttribute(size_t index) | 310 PassRefPtrWillBeRawPtr<Attr> Element::detachAttribute(size_t index) |
311 { | 311 { |
312 ASSERT(elementData()); | 312 ASSERT(elementData()); |
313 const Attribute& attribute = elementData()->attributeItem(index); | 313 const Attribute& attribute = elementData()->attributeAt(index); |
314 RefPtrWillBeRawPtr<Attr> attrNode = attrIfExists(attribute.name()); | 314 RefPtrWillBeRawPtr<Attr> attrNode = attrIfExists(attribute.name()); |
315 if (attrNode) | 315 if (attrNode) |
316 detachAttrNodeAtIndex(attrNode.get(), index); | 316 detachAttrNodeAtIndex(attrNode.get(), index); |
317 else { | 317 else { |
318 attrNode = Attr::create(document(), attribute.name(), attribute.value())
; | 318 attrNode = Attr::create(document(), attribute.name(), attribute.value())
; |
319 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); | 319 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); |
320 } | 320 } |
321 return attrNode.release(); | 321 return attrNode.release(); |
322 } | 322 } |
323 | 323 |
324 void Element::detachAttrNodeAtIndex(Attr* attr, size_t index) | 324 void Element::detachAttrNodeAtIndex(Attr* attr, size_t index) |
325 { | 325 { |
326 ASSERT(attr); | 326 ASSERT(attr); |
327 ASSERT(elementData()); | 327 ASSERT(elementData()); |
328 | 328 |
329 const Attribute& attribute = elementData()->attributeItem(index); | 329 const Attribute& attribute = elementData()->attributeAt(index); |
330 ASSERT(attribute.name() == attr->qualifiedName()); | 330 ASSERT(attribute.name() == attr->qualifiedName()); |
331 detachAttrNodeFromElementWithValue(attr, attribute.value()); | 331 detachAttrNodeFromElementWithValue(attr, attribute.value()); |
332 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); | 332 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); |
333 } | 333 } |
334 | 334 |
335 void Element::removeAttribute(const QualifiedName& name) | 335 void Element::removeAttribute(const QualifiedName& name) |
336 { | 336 { |
337 if (!elementData()) | 337 if (!elementData()) |
338 return; | 338 return; |
339 | 339 |
340 size_t index = elementData()->getAttributeItemIndex(name); | 340 size_t index = elementData()->findAttributeIndexByName(name); |
341 if (index == kNotFound) | 341 if (index == kNotFound) |
342 return; | 342 return; |
343 | 343 |
344 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); | 344 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); |
345 } | 345 } |
346 | 346 |
347 void Element::setBooleanAttribute(const QualifiedName& name, bool value) | 347 void Element::setBooleanAttribute(const QualifiedName& name, bool value) |
348 { | 348 { |
349 if (value) | 349 if (value) |
350 setAttribute(name, emptyAtom); | 350 setAttribute(name, emptyAtom); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 // true. | 455 // true. |
456 toSVGElement(this)->synchronizeAnimatedSVGAttribute(QualifiedName(nullAt
om, localName, nullAtom)); | 456 toSVGElement(this)->synchronizeAnimatedSVGAttribute(QualifiedName(nullAt
om, localName, nullAtom)); |
457 } | 457 } |
458 } | 458 } |
459 | 459 |
460 const AtomicString& Element::getAttribute(const QualifiedName& name) const | 460 const AtomicString& Element::getAttribute(const QualifiedName& name) const |
461 { | 461 { |
462 if (!elementData()) | 462 if (!elementData()) |
463 return nullAtom; | 463 return nullAtom; |
464 synchronizeAttribute(name); | 464 synchronizeAttribute(name); |
465 if (const Attribute* attribute = getAttributeItem(name)) | 465 if (const Attribute* attribute = findAttributeByName(name)) |
466 return attribute->value(); | 466 return attribute->value(); |
467 return nullAtom; | 467 return nullAtom; |
468 } | 468 } |
469 | 469 |
470 void Element::scrollIntoView(bool alignToTop) | 470 void Element::scrollIntoView(bool alignToTop) |
471 { | 471 { |
472 document().updateLayoutIgnorePendingStylesheets(); | 472 document().updateLayoutIgnorePendingStylesheets(); |
473 | 473 |
474 if (!renderer()) | 474 if (!renderer()) |
475 return; | 475 return; |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 return IntRect(); | 900 return IntRect(); |
901 // FIXME: this should probably respect transforms | 901 // FIXME: this should probably respect transforms |
902 return document().view()->contentsToScreen(renderer()->absoluteBoundingBoxRe
ctIgnoringTransforms()); | 902 return document().view()->contentsToScreen(renderer()->absoluteBoundingBoxRe
ctIgnoringTransforms()); |
903 } | 903 } |
904 | 904 |
905 const AtomicString& Element::getAttribute(const AtomicString& localName) const | 905 const AtomicString& Element::getAttribute(const AtomicString& localName) const |
906 { | 906 { |
907 if (!elementData()) | 907 if (!elementData()) |
908 return nullAtom; | 908 return nullAtom; |
909 synchronizeAttribute(localName); | 909 synchronizeAttribute(localName); |
910 if (const Attribute* attribute = elementData()->getAttributeItem(localName,
shouldIgnoreAttributeCase())) | 910 if (const Attribute* attribute = elementData()->findAttributeByName(localNam
e, shouldIgnoreAttributeCase())) |
911 return attribute->value(); | 911 return attribute->value(); |
912 return nullAtom; | 912 return nullAtom; |
913 } | 913 } |
914 | 914 |
915 const AtomicString& Element::getAttributeNS(const AtomicString& namespaceURI, co
nst AtomicString& localName) const | 915 const AtomicString& Element::getAttributeNS(const AtomicString& namespaceURI, co
nst AtomicString& localName) const |
916 { | 916 { |
917 return getAttribute(QualifiedName(nullAtom, localName, namespaceURI)); | 917 return getAttribute(QualifiedName(nullAtom, localName, namespaceURI)); |
918 } | 918 } |
919 | 919 |
920 void Element::setAttribute(const AtomicString& localName, const AtomicString& va
lue, ExceptionState& exceptionState) | 920 void Element::setAttribute(const AtomicString& localName, const AtomicString& va
lue, ExceptionState& exceptionState) |
921 { | 921 { |
922 if (!Document::isValidName(localName)) { | 922 if (!Document::isValidName(localName)) { |
923 exceptionState.throwDOMException(InvalidCharacterError, "'" + localName
+ "' is not a valid attribute name."); | 923 exceptionState.throwDOMException(InvalidCharacterError, "'" + localName
+ "' is not a valid attribute name."); |
924 return; | 924 return; |
925 } | 925 } |
926 | 926 |
927 synchronizeAttribute(localName); | 927 synchronizeAttribute(localName); |
928 const AtomicString& caseAdjustedLocalName = shouldIgnoreAttributeCase() ? lo
calName.lower() : localName; | 928 const AtomicString& caseAdjustedLocalName = shouldIgnoreAttributeCase() ? lo
calName.lower() : localName; |
929 | 929 |
930 size_t index = elementData() ? elementData()->getAttributeItemIndex(caseAdju
stedLocalName, false) : kNotFound; | 930 size_t index = elementData() ? elementData()->findAttributeIndexByName(caseA
djustedLocalName, false) : kNotFound; |
931 const QualifiedName& qName = index != kNotFound ? attributeItem(index).name(
) : QualifiedName(nullAtom, caseAdjustedLocalName, nullAtom); | 931 const QualifiedName& qName = index != kNotFound ? attributeAt(index).name()
: QualifiedName(nullAtom, caseAdjustedLocalName, nullAtom); |
932 setAttributeInternal(index, qName, value, NotInSynchronizationOfLazyAttribut
e); | 932 setAttributeInternal(index, qName, value, NotInSynchronizationOfLazyAttribut
e); |
933 } | 933 } |
934 | 934 |
935 void Element::setAttribute(const QualifiedName& name, const AtomicString& value) | 935 void Element::setAttribute(const QualifiedName& name, const AtomicString& value) |
936 { | 936 { |
937 synchronizeAttribute(name); | 937 synchronizeAttribute(name); |
938 size_t index = elementData() ? elementData()->getAttributeItemIndex(name) :
kNotFound; | 938 size_t index = elementData() ? elementData()->findAttributeIndexByName(name)
: kNotFound; |
939 setAttributeInternal(index, name, value, NotInSynchronizationOfLazyAttribute
); | 939 setAttributeInternal(index, name, value, NotInSynchronizationOfLazyAttribute
); |
940 } | 940 } |
941 | 941 |
942 void Element::setSynchronizedLazyAttribute(const QualifiedName& name, const Atom
icString& value) | 942 void Element::setSynchronizedLazyAttribute(const QualifiedName& name, const Atom
icString& value) |
943 { | 943 { |
944 size_t index = elementData() ? elementData()->getAttributeItemIndex(name) :
kNotFound; | 944 size_t index = elementData() ? elementData()->findAttributeIndexByName(name)
: kNotFound; |
945 setAttributeInternal(index, name, value, InSynchronizationOfLazyAttribute); | 945 setAttributeInternal(index, name, value, InSynchronizationOfLazyAttribute); |
946 } | 946 } |
947 | 947 |
948 ALWAYS_INLINE void Element::setAttributeInternal(size_t index, const QualifiedNa
me& name, const AtomicString& newValue, SynchronizationOfLazyAttribute inSynchro
nizationOfLazyAttribute) | 948 ALWAYS_INLINE void Element::setAttributeInternal(size_t index, const QualifiedNa
me& name, const AtomicString& newValue, SynchronizationOfLazyAttribute inSynchro
nizationOfLazyAttribute) |
949 { | 949 { |
950 if (newValue.isNull()) { | 950 if (newValue.isNull()) { |
951 if (index != kNotFound) | 951 if (index != kNotFound) |
952 removeAttributeInternal(index, inSynchronizationOfLazyAttribute); | 952 removeAttributeInternal(index, inSynchronizationOfLazyAttribute); |
953 return; | 953 return; |
954 } | 954 } |
955 | 955 |
956 if (index == kNotFound) { | 956 if (index == kNotFound) { |
957 addAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute); | 957 appendAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute
); |
958 return; | 958 return; |
959 } | 959 } |
960 | 960 |
961 const Attribute& existingAttribute = attributeItem(index); | 961 const Attribute& existingAttribute = attributeAt(index); |
962 QualifiedName existingAttributeName = existingAttribute.name(); | 962 QualifiedName existingAttributeName = existingAttribute.name(); |
963 | 963 |
964 if (!inSynchronizationOfLazyAttribute) | 964 if (!inSynchronizationOfLazyAttribute) |
965 willModifyAttribute(existingAttributeName, existingAttribute.value(), ne
wValue); | 965 willModifyAttribute(existingAttributeName, existingAttribute.value(), ne
wValue); |
966 | 966 |
967 if (newValue != existingAttribute.value()) { | 967 if (newValue != existingAttribute.value()) { |
968 // If there is an Attr node hooked to this attribute, the Attr::setValue
() call below | 968 // If there is an Attr node hooked to this attribute, the Attr::setValue
() call below |
969 // will write into the ElementData. | 969 // will write into the ElementData. |
970 // FIXME: Refactor this so it makes some sense. | 970 // FIXME: Refactor this so it makes some sense. |
971 if (RefPtrWillBeRawPtr<Attr> attrNode = inSynchronizationOfLazyAttribute
? nullptr : attrIfExists(existingAttributeName)) | 971 if (RefPtrWillBeRawPtr<Attr> attrNode = inSynchronizationOfLazyAttribute
? nullptr : attrIfExists(existingAttributeName)) |
972 attrNode->setValue(newValue); | 972 attrNode->setValue(newValue); |
973 else | 973 else |
974 ensureUniqueElementData().attributeItem(index).setValue(newValue); | 974 ensureUniqueElementData().attributeAt(index).setValue(newValue); |
975 } | 975 } |
976 | 976 |
977 if (!inSynchronizationOfLazyAttribute) | 977 if (!inSynchronizationOfLazyAttribute) |
978 didModifyAttribute(existingAttributeName, newValue); | 978 didModifyAttribute(existingAttributeName, newValue); |
979 } | 979 } |
980 | 980 |
981 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b
ool inQuirksMode) | 981 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b
ool inQuirksMode) |
982 { | 982 { |
983 if (inQuirksMode) | 983 if (inQuirksMode) |
984 return value.lower(); | 984 return value.lower(); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 m_elementData = ShareableElementData::createWithAttributes(attributeVect
or); | 1179 m_elementData = ShareableElementData::createWithAttributes(attributeVect
or); |
1180 | 1180 |
1181 // Use attributeVector instead of m_elementData because attributeChanged mig
ht modify m_elementData. | 1181 // Use attributeVector instead of m_elementData because attributeChanged mig
ht modify m_elementData. |
1182 for (unsigned i = 0; i < attributeVector.size(); ++i) | 1182 for (unsigned i = 0; i < attributeVector.size(); ++i) |
1183 attributeChangedFromParserOrByCloning(attributeVector[i].name(), attribu
teVector[i].value(), ModifiedDirectly); | 1183 attributeChangedFromParserOrByCloning(attributeVector[i].name(), attribu
teVector[i].value(), ModifiedDirectly); |
1184 } | 1184 } |
1185 | 1185 |
1186 bool Element::hasAttributes() const | 1186 bool Element::hasAttributes() const |
1187 { | 1187 { |
1188 synchronizeAllAttributes(); | 1188 synchronizeAllAttributes(); |
1189 return elementData() && elementData()->length(); | 1189 return elementData() && elementData()->hasAttributes(); |
1190 } | 1190 } |
1191 | 1191 |
1192 bool Element::hasEquivalentAttributes(const Element* other) const | 1192 bool Element::hasEquivalentAttributes(const Element* other) const |
1193 { | 1193 { |
1194 synchronizeAllAttributes(); | 1194 synchronizeAllAttributes(); |
1195 other->synchronizeAllAttributes(); | 1195 other->synchronizeAllAttributes(); |
1196 if (elementData() == other->elementData()) | 1196 if (elementData() == other->elementData()) |
1197 return true; | 1197 return true; |
1198 if (elementData()) | 1198 if (elementData()) |
1199 return elementData()->isEquivalent(other->elementData()); | 1199 return elementData()->isEquivalent(other->elementData()); |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1885 // InUseAttributeError: Raised if node is an Attr that is already an attribu
te of another Element object. | 1885 // InUseAttributeError: Raised if node is an Attr that is already an attribu
te of another Element object. |
1886 // The DOM user must explicitly clone Attr nodes to re-use them in other ele
ments. | 1886 // The DOM user must explicitly clone Attr nodes to re-use them in other ele
ments. |
1887 if (attrNode->ownerElement()) { | 1887 if (attrNode->ownerElement()) { |
1888 exceptionState.throwDOMException(InUseAttributeError, "The node provided
is an attribute node that is already an attribute of another Element; attribute
nodes must be explicitly cloned."); | 1888 exceptionState.throwDOMException(InUseAttributeError, "The node provided
is an attribute node that is already an attribute of another Element; attribute
nodes must be explicitly cloned."); |
1889 return nullptr; | 1889 return nullptr; |
1890 } | 1890 } |
1891 | 1891 |
1892 synchronizeAllAttributes(); | 1892 synchronizeAllAttributes(); |
1893 UniqueElementData& elementData = ensureUniqueElementData(); | 1893 UniqueElementData& elementData = ensureUniqueElementData(); |
1894 | 1894 |
1895 size_t index = elementData.getAttributeItemIndex(attrNode->qualifiedName(),
shouldIgnoreAttributeCase()); | 1895 size_t index = elementData.findAttributeIndexByName(attrNode->qualifiedName(
), shouldIgnoreAttributeCase()); |
1896 AtomicString localName; | 1896 AtomicString localName; |
1897 if (index != kNotFound) { | 1897 if (index != kNotFound) { |
1898 const Attribute& attr = elementData.attributeItem(index); | 1898 const Attribute& attr = elementData.attributeAt(index); |
1899 | 1899 |
1900 // If the name of the ElementData attribute doesn't | 1900 // If the name of the ElementData attribute doesn't |
1901 // (case-sensitively) match that of the Attr node, record it | 1901 // (case-sensitively) match that of the Attr node, record it |
1902 // on the Attr so that it can correctly resolve the value on | 1902 // on the Attr so that it can correctly resolve the value on |
1903 // the Element. | 1903 // the Element. |
1904 if (!attr.name().matches(attrNode->qualifiedName())) | 1904 if (!attr.name().matches(attrNode->qualifiedName())) |
1905 localName = attr.localName(); | 1905 localName = attr.localName(); |
1906 | 1906 |
1907 if (oldAttrNode) { | 1907 if (oldAttrNode) { |
1908 detachAttrNodeFromElementWithValue(oldAttrNode.get(), attr.value()); | 1908 detachAttrNodeFromElementWithValue(oldAttrNode.get(), attr.value()); |
(...skipping 28 matching lines...) Expand all Loading... |
1937 } | 1937 } |
1938 if (attr->ownerElement() != this) { | 1938 if (attr->ownerElement() != this) { |
1939 exceptionState.throwDOMException(NotFoundError, "The node provided is ow
ned by another element."); | 1939 exceptionState.throwDOMException(NotFoundError, "The node provided is ow
ned by another element."); |
1940 return nullptr; | 1940 return nullptr; |
1941 } | 1941 } |
1942 | 1942 |
1943 ASSERT(document() == attr->document()); | 1943 ASSERT(document() == attr->document()); |
1944 | 1944 |
1945 synchronizeAttribute(attr->qualifiedName()); | 1945 synchronizeAttribute(attr->qualifiedName()); |
1946 | 1946 |
1947 size_t index = elementData()->getAttrIndex(attr); | 1947 size_t index = elementData()->findAttrNodeIndex(attr); |
1948 if (index == kNotFound) { | 1948 if (index == kNotFound) { |
1949 exceptionState.throwDOMException(NotFoundError, "The attribute was not f
ound on this element."); | 1949 exceptionState.throwDOMException(NotFoundError, "The attribute was not f
ound on this element."); |
1950 return nullptr; | 1950 return nullptr; |
1951 } | 1951 } |
1952 | 1952 |
1953 RefPtrWillBeRawPtr<Attr> guard(attr); | 1953 RefPtrWillBeRawPtr<Attr> guard(attr); |
1954 detachAttrNodeAtIndex(attr, index); | 1954 detachAttrNodeAtIndex(attr, index); |
1955 return guard.release(); | 1955 return guard.release(); |
1956 } | 1956 } |
1957 | 1957 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1998 return; | 1998 return; |
1999 setAttribute(parsedName, value); | 1999 setAttribute(parsedName, value); |
2000 } | 2000 } |
2001 | 2001 |
2002 void Element::removeAttributeInternal(size_t index, SynchronizationOfLazyAttribu
te inSynchronizationOfLazyAttribute) | 2002 void Element::removeAttributeInternal(size_t index, SynchronizationOfLazyAttribu
te inSynchronizationOfLazyAttribute) |
2003 { | 2003 { |
2004 ASSERT_WITH_SECURITY_IMPLICATION(index < attributeCount()); | 2004 ASSERT_WITH_SECURITY_IMPLICATION(index < attributeCount()); |
2005 | 2005 |
2006 UniqueElementData& elementData = ensureUniqueElementData(); | 2006 UniqueElementData& elementData = ensureUniqueElementData(); |
2007 | 2007 |
2008 QualifiedName name = elementData.attributeItem(index).name(); | 2008 QualifiedName name = elementData.attributeAt(index).name(); |
2009 AtomicString valueBeingRemoved = elementData.attributeItem(index).value(); | 2009 AtomicString valueBeingRemoved = elementData.attributeAt(index).value(); |
2010 | 2010 |
2011 if (!inSynchronizationOfLazyAttribute) { | 2011 if (!inSynchronizationOfLazyAttribute) { |
2012 if (!valueBeingRemoved.isNull()) | 2012 if (!valueBeingRemoved.isNull()) |
2013 willModifyAttribute(name, valueBeingRemoved, nullAtom); | 2013 willModifyAttribute(name, valueBeingRemoved, nullAtom); |
2014 } | 2014 } |
2015 | 2015 |
2016 if (RefPtrWillBeRawPtr<Attr> attrNode = attrIfExists(name)) | 2016 if (RefPtrWillBeRawPtr<Attr> attrNode = attrIfExists(name)) |
2017 detachAttrNodeFromElementWithValue(attrNode.get(), elementData.attribute
Item(index).value()); | 2017 detachAttrNodeFromElementWithValue(attrNode.get(), elementData.attribute
At(index).value()); |
2018 | 2018 |
2019 elementData.removeAttribute(index); | 2019 elementData.removeAttributeAt(index); |
2020 | 2020 |
2021 if (!inSynchronizationOfLazyAttribute) | 2021 if (!inSynchronizationOfLazyAttribute) |
2022 didRemoveAttribute(name); | 2022 didRemoveAttribute(name); |
2023 } | 2023 } |
2024 | 2024 |
2025 void Element::addAttributeInternal(const QualifiedName& name, const AtomicString
& value, SynchronizationOfLazyAttribute inSynchronizationOfLazyAttribute) | 2025 void Element::appendAttributeInternal(const QualifiedName& name, const AtomicStr
ing& value, SynchronizationOfLazyAttribute inSynchronizationOfLazyAttribute) |
2026 { | 2026 { |
2027 if (!inSynchronizationOfLazyAttribute) | 2027 if (!inSynchronizationOfLazyAttribute) |
2028 willModifyAttribute(name, nullAtom, value); | 2028 willModifyAttribute(name, nullAtom, value); |
2029 ensureUniqueElementData().addAttribute(name, value); | 2029 ensureUniqueElementData().appendAttribute(name, value); |
2030 if (!inSynchronizationOfLazyAttribute) | 2030 if (!inSynchronizationOfLazyAttribute) |
2031 didAddAttribute(name, value); | 2031 didAddAttribute(name, value); |
2032 } | 2032 } |
2033 | 2033 |
2034 void Element::removeAttribute(const AtomicString& name) | 2034 void Element::removeAttribute(const AtomicString& name) |
2035 { | 2035 { |
2036 if (!elementData()) | 2036 if (!elementData()) |
2037 return; | 2037 return; |
2038 | 2038 |
2039 AtomicString localName = shouldIgnoreAttributeCase() ? name.lower() : name; | 2039 AtomicString localName = shouldIgnoreAttributeCase() ? name.lower() : name; |
2040 size_t index = elementData()->getAttributeItemIndex(localName, false); | 2040 size_t index = elementData()->findAttributeIndexByName(localName, false); |
2041 if (index == kNotFound) { | 2041 if (index == kNotFound) { |
2042 if (UNLIKELY(localName == styleAttr) && elementData()->m_styleAttributeI
sDirty && isStyledElement()) | 2042 if (UNLIKELY(localName == styleAttr) && elementData()->m_styleAttributeI
sDirty && isStyledElement()) |
2043 removeAllInlineStyleProperties(); | 2043 removeAllInlineStyleProperties(); |
2044 return; | 2044 return; |
2045 } | 2045 } |
2046 | 2046 |
2047 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); | 2047 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); |
2048 } | 2048 } |
2049 | 2049 |
2050 void Element::removeAttributeNS(const AtomicString& namespaceURI, const AtomicSt
ring& localName) | 2050 void Element::removeAttributeNS(const AtomicString& namespaceURI, const AtomicSt
ring& localName) |
2051 { | 2051 { |
2052 removeAttribute(QualifiedName(nullAtom, localName, namespaceURI)); | 2052 removeAttribute(QualifiedName(nullAtom, localName, namespaceURI)); |
2053 } | 2053 } |
2054 | 2054 |
2055 PassRefPtrWillBeRawPtr<Attr> Element::getAttributeNode(const AtomicString& local
Name) | 2055 PassRefPtrWillBeRawPtr<Attr> Element::getAttributeNode(const AtomicString& local
Name) |
2056 { | 2056 { |
2057 if (!elementData()) | 2057 if (!elementData()) |
2058 return nullptr; | 2058 return nullptr; |
2059 synchronizeAttribute(localName); | 2059 synchronizeAttribute(localName); |
2060 const Attribute* attribute = elementData()->getAttributeItem(localName, shou
ldIgnoreAttributeCase()); | 2060 const Attribute* attribute = elementData()->findAttributeByName(localName, s
houldIgnoreAttributeCase()); |
2061 if (!attribute) | 2061 if (!attribute) |
2062 return nullptr; | 2062 return nullptr; |
2063 return ensureAttr(attribute->name()); | 2063 return ensureAttr(attribute->name()); |
2064 } | 2064 } |
2065 | 2065 |
2066 PassRefPtrWillBeRawPtr<Attr> Element::getAttributeNodeNS(const AtomicString& nam
espaceURI, const AtomicString& localName) | 2066 PassRefPtrWillBeRawPtr<Attr> Element::getAttributeNodeNS(const AtomicString& nam
espaceURI, const AtomicString& localName) |
2067 { | 2067 { |
2068 if (!elementData()) | 2068 if (!elementData()) |
2069 return nullptr; | 2069 return nullptr; |
2070 QualifiedName qName(nullAtom, localName, namespaceURI); | 2070 QualifiedName qName(nullAtom, localName, namespaceURI); |
2071 synchronizeAttribute(qName); | 2071 synchronizeAttribute(qName); |
2072 const Attribute* attribute = elementData()->getAttributeItem(qName); | 2072 const Attribute* attribute = elementData()->findAttributeByName(qName); |
2073 if (!attribute) | 2073 if (!attribute) |
2074 return nullptr; | 2074 return nullptr; |
2075 return ensureAttr(attribute->name()); | 2075 return ensureAttr(attribute->name()); |
2076 } | 2076 } |
2077 | 2077 |
2078 bool Element::hasAttribute(const AtomicString& localName) const | 2078 bool Element::hasAttribute(const AtomicString& localName) const |
2079 { | 2079 { |
2080 if (!elementData()) | 2080 if (!elementData()) |
2081 return false; | 2081 return false; |
2082 synchronizeAttribute(localName); | 2082 synchronizeAttribute(localName); |
2083 return elementData()->getAttributeItem(shouldIgnoreAttributeCase() ? localNa
me.lower() : localName, false); | 2083 return elementData()->findAttributeByName(shouldIgnoreAttributeCase() ? loca
lName.lower() : localName, false); |
2084 } | 2084 } |
2085 | 2085 |
2086 bool Element::hasAttributeNS(const AtomicString& namespaceURI, const AtomicStrin
g& localName) const | 2086 bool Element::hasAttributeNS(const AtomicString& namespaceURI, const AtomicStrin
g& localName) const |
2087 { | 2087 { |
2088 if (!elementData()) | 2088 if (!elementData()) |
2089 return false; | 2089 return false; |
2090 QualifiedName qName(nullAtom, localName, namespaceURI); | 2090 QualifiedName qName(nullAtom, localName, namespaceURI); |
2091 synchronizeAttribute(qName); | 2091 synchronizeAttribute(qName); |
2092 return elementData()->getAttributeItem(qName); | 2092 return elementData()->findAttributeByName(qName); |
2093 } | 2093 } |
2094 | 2094 |
2095 void Element::focus(bool restorePreviousSelection, FocusType type) | 2095 void Element::focus(bool restorePreviousSelection, FocusType type) |
2096 { | 2096 { |
2097 if (!inDocument()) | 2097 if (!inDocument()) |
2098 return; | 2098 return; |
2099 | 2099 |
2100 if (document().focusedElement() == this) | 2100 if (document().focusedElement() == this) |
2101 return; | 2101 return; |
2102 | 2102 |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2471 | 2471 |
2472 AtomicString Element::computeInheritedLanguage() const | 2472 AtomicString Element::computeInheritedLanguage() const |
2473 { | 2473 { |
2474 const Node* n = this; | 2474 const Node* n = this; |
2475 AtomicString value; | 2475 AtomicString value; |
2476 // The language property is inherited, so we iterate over the parents to fin
d the first language. | 2476 // The language property is inherited, so we iterate over the parents to fin
d the first language. |
2477 do { | 2477 do { |
2478 if (n->isElementNode()) { | 2478 if (n->isElementNode()) { |
2479 if (const ElementData* elementData = toElement(n)->elementData()) { | 2479 if (const ElementData* elementData = toElement(n)->elementData()) { |
2480 // Spec: xml:lang takes precedence -- http://www.w3.org/TR/xhtml
1/#C_7 | 2480 // Spec: xml:lang takes precedence -- http://www.w3.org/TR/xhtml
1/#C_7 |
2481 if (const Attribute* attribute = elementData->getAttributeItem(X
MLNames::langAttr)) | 2481 if (const Attribute* attribute = elementData->findAttributeByNam
e(XMLNames::langAttr)) |
2482 value = attribute->value(); | 2482 value = attribute->value(); |
2483 else if (const Attribute* attribute = elementData->getAttributeI
tem(HTMLNames::langAttr)) | 2483 else if (const Attribute* attribute = elementData->findAttribute
ByName(HTMLNames::langAttr)) |
2484 value = attribute->value(); | 2484 value = attribute->value(); |
2485 } | 2485 } |
2486 } else if (n->isDocumentNode()) { | 2486 } else if (n->isDocumentNode()) { |
2487 // checking the MIME content-language | 2487 // checking the MIME content-language |
2488 value = toDocument(n)->contentLanguage(); | 2488 value = toDocument(n)->contentLanguage(); |
2489 } | 2489 } |
2490 | 2490 |
2491 n = n->parentNode(); | 2491 n = n->parentNode(); |
2492 } while (n && value.isNull()); | 2492 } while (n && value.isNull()); |
2493 | 2493 |
(...skipping 11 matching lines...) Expand all Loading... |
2505 document().cancelFocusAppearanceUpdate(); | 2505 document().cancelFocusAppearanceUpdate(); |
2506 } | 2506 } |
2507 | 2507 |
2508 void Element::normalizeAttributes() | 2508 void Element::normalizeAttributes() |
2509 { | 2509 { |
2510 if (!hasAttributes()) | 2510 if (!hasAttributes()) |
2511 return; | 2511 return; |
2512 // attributeCount() cannot be cached before the loop because the attributes | 2512 // attributeCount() cannot be cached before the loop because the attributes |
2513 // list is altered while iterating. | 2513 // list is altered while iterating. |
2514 for (unsigned i = 0; i < attributeCount(); ++i) { | 2514 for (unsigned i = 0; i < attributeCount(); ++i) { |
2515 if (RefPtrWillBeRawPtr<Attr> attr = attrIfExists(attributeItem(i).name()
)) | 2515 if (RefPtrWillBeRawPtr<Attr> attr = attrIfExists(attributeAt(i).name())) |
2516 attr->normalize(); | 2516 attr->normalize(); |
2517 } | 2517 } |
2518 } | 2518 } |
2519 | 2519 |
2520 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change) | 2520 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change) |
2521 { | 2521 { |
2522 ASSERT(!needsStyleRecalc()); | 2522 ASSERT(!needsStyleRecalc()); |
2523 PseudoElement* element = pseudoElement(pseudoId); | 2523 PseudoElement* element = pseudoElement(pseudoId); |
2524 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS
tyle(change))) { | 2524 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS
tyle(change))) { |
2525 | 2525 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2598 ElementRareData& rareData = ensureElementRareData(); | 2598 ElementRareData& rareData = ensureElementRareData(); |
2599 if (!rareData.dataset()) | 2599 if (!rareData.dataset()) |
2600 rareData.setDataset(DatasetDOMStringMap::create(this)); | 2600 rareData.setDataset(DatasetDOMStringMap::create(this)); |
2601 return *rareData.dataset(); | 2601 return *rareData.dataset(); |
2602 } | 2602 } |
2603 | 2603 |
2604 KURL Element::getURLAttribute(const QualifiedName& name) const | 2604 KURL Element::getURLAttribute(const QualifiedName& name) const |
2605 { | 2605 { |
2606 #if !ASSERT_DISABLED | 2606 #if !ASSERT_DISABLED |
2607 if (elementData()) { | 2607 if (elementData()) { |
2608 if (const Attribute* attribute = getAttributeItem(name)) | 2608 if (const Attribute* attribute = findAttributeByName(name)) |
2609 ASSERT(isURLAttribute(*attribute)); | 2609 ASSERT(isURLAttribute(*attribute)); |
2610 } | 2610 } |
2611 #endif | 2611 #endif |
2612 return document().completeURL(stripLeadingAndTrailingHTMLSpaces(getAttribute
(name))); | 2612 return document().completeURL(stripLeadingAndTrailingHTMLSpaces(getAttribute
(name))); |
2613 } | 2613 } |
2614 | 2614 |
2615 KURL Element::getNonEmptyURLAttribute(const QualifiedName& name) const | 2615 KURL Element::getNonEmptyURLAttribute(const QualifiedName& name) const |
2616 { | 2616 { |
2617 #if !ASSERT_DISABLED | 2617 #if !ASSERT_DISABLED |
2618 if (elementData()) { | 2618 if (elementData()) { |
2619 if (const Attribute* attribute = getAttributeItem(name)) | 2619 if (const Attribute* attribute = findAttributeByName(name)) |
2620 ASSERT(isURLAttribute(*attribute)); | 2620 ASSERT(isURLAttribute(*attribute)); |
2621 } | 2621 } |
2622 #endif | 2622 #endif |
2623 String value = stripLeadingAndTrailingHTMLSpaces(getAttribute(name)); | 2623 String value = stripLeadingAndTrailingHTMLSpaces(getAttribute(name)); |
2624 if (value.isEmpty()) | 2624 if (value.isEmpty()) |
2625 return KURL(); | 2625 return KURL(); |
2626 return document().completeURL(value); | 2626 return document().completeURL(value); |
2627 } | 2627 } |
2628 | 2628 |
2629 int Element::getIntegralAttribute(const QualifiedName& attributeName) const | 2629 int Element::getIntegralAttribute(const QualifiedName& attributeName) const |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3323 | 3323 |
3324 void Element::trace(Visitor* visitor) | 3324 void Element::trace(Visitor* visitor) |
3325 { | 3325 { |
3326 if (hasRareData()) | 3326 if (hasRareData()) |
3327 visitor->trace(elementRareData()); | 3327 visitor->trace(elementRareData()); |
3328 | 3328 |
3329 ContainerNode::trace(visitor); | 3329 ContainerNode::trace(visitor); |
3330 } | 3330 } |
3331 | 3331 |
3332 } // namespace WebCore | 3332 } // namespace WebCore |
OLD | NEW |