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 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 // The DOM user must explicitly clone Attr nodes to re-use them in other ele
ments. | 1887 // The DOM user must explicitly clone Attr nodes to re-use them in other ele
ments. |
1888 if (attrNode->ownerElement()) { | 1888 if (attrNode->ownerElement()) { |
1889 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 exceptionState.throwDOMException(InUseAttributeError, "The node provided
is an attribute node that is already an attribute of another Element; attribute
nodes must be explicitly cloned."); |
1890 return nullptr; | 1890 return nullptr; |
1891 } | 1891 } |
1892 | 1892 |
1893 synchronizeAllAttributes(); | 1893 synchronizeAllAttributes(); |
1894 UniqueElementData& elementData = ensureUniqueElementData(); | 1894 UniqueElementData& elementData = ensureUniqueElementData(); |
1895 | 1895 |
1896 size_t index = elementData.getAttributeItemIndex(attrNode->qualifiedName(),
shouldIgnoreAttributeCase()); | 1896 size_t index = elementData.getAttributeItemIndex(attrNode->qualifiedName(),
shouldIgnoreAttributeCase()); |
| 1897 AtomicString localName; |
1897 if (index != kNotFound) { | 1898 if (index != kNotFound) { |
1898 if (oldAttrNode) | 1899 const Attribute& attr = elementData.attributeItem(index); |
1899 detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData.at
tributeItem(index).value()); | 1900 |
1900 else | 1901 // If the name of the ElementData attribute doesn't |
1901 oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), el
ementData.attributeItem(index).value()); | 1902 // (case-sensitively) match that of the Attr node, record it |
| 1903 // on the Attr so that it can correctly resolve the value on |
| 1904 // the Element. |
| 1905 if (!attr.name().matches(attrNode->qualifiedName())) |
| 1906 localName = attr.localName(); |
| 1907 |
| 1908 if (oldAttrNode) { |
| 1909 detachAttrNodeFromElementWithValue(oldAttrNode.get(), attr.value()); |
| 1910 } else { |
| 1911 // FIXME: using attrNode's name rather than the |
| 1912 // Attribute's for the replaced Attr is compatible with |
| 1913 // all but Gecko (and, arguably, the DOM Level1 spec text.) |
| 1914 // Consider switching. |
| 1915 oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), at
tr.value()); |
| 1916 } |
1902 } | 1917 } |
1903 | 1918 |
1904 setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), No
tInSynchronizationOfLazyAttribute); | 1919 setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), No
tInSynchronizationOfLazyAttribute); |
1905 | 1920 |
1906 attrNode->attachToElement(this); | 1921 attrNode->attachToElement(this, localName); |
1907 treeScope().adoptIfNeeded(*attrNode); | 1922 treeScope().adoptIfNeeded(*attrNode); |
1908 ensureAttrNodeListForElement(this).append(attrNode); | 1923 ensureAttrNodeListForElement(this).append(attrNode); |
1909 | 1924 |
1910 return oldAttrNode.release(); | 1925 return oldAttrNode.release(); |
1911 } | 1926 } |
1912 | 1927 |
1913 PassRefPtrWillBeRawPtr<Attr> Element::setAttributeNodeNS(Attr* attr, ExceptionSt
ate& exceptionState) | 1928 PassRefPtrWillBeRawPtr<Attr> Element::setAttributeNodeNS(Attr* attr, ExceptionSt
ate& exceptionState) |
1914 { | 1929 { |
1915 return setAttributeNode(attr, exceptionState); | 1930 return setAttributeNode(attr, exceptionState); |
1916 } | 1931 } |
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3310 | 3325 |
3311 void Element::trace(Visitor* visitor) | 3326 void Element::trace(Visitor* visitor) |
3312 { | 3327 { |
3313 if (hasRareData()) | 3328 if (hasRareData()) |
3314 visitor->trace(elementRareData()); | 3329 visitor->trace(elementRareData()); |
3315 | 3330 |
3316 ContainerNode::trace(visitor); | 3331 ContainerNode::trace(visitor); |
3317 } | 3332 } |
3318 | 3333 |
3319 } // namespace WebCore | 3334 } // namespace WebCore |
OLD | NEW |