| 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 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
reserved. |
| 7 * (C) 2007 Eric Seidel (eric@webkit.org) | 7 * (C) 2007 Eric Seidel (eric@webkit.org) |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 { | 39 { |
| 40 m_element->ref(); | 40 m_element->ref(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void NamedNodeMap::deref() | 43 void NamedNodeMap::deref() |
| 44 { | 44 { |
| 45 m_element->deref(); | 45 m_element->deref(); |
| 46 } | 46 } |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 PassRefPtrWillBeRawPtr<Node> NamedNodeMap::getNamedItem(const AtomicString& name
) const | 49 PassRefPtrWillBeRawPtr<Attr> NamedNodeMap::getNamedItem(const AtomicString& name
) const |
| 50 { | 50 { |
| 51 return m_element->getAttributeNode(name); | 51 return m_element->getAttributeNode(name); |
| 52 } | 52 } |
| 53 | 53 |
| 54 PassRefPtrWillBeRawPtr<Node> NamedNodeMap::getNamedItemNS(const AtomicString& na
mespaceURI, const AtomicString& localName) const | 54 PassRefPtrWillBeRawPtr<Attr> NamedNodeMap::getNamedItemNS(const AtomicString& na
mespaceURI, const AtomicString& localName) const |
| 55 { | 55 { |
| 56 return m_element->getAttributeNodeNS(namespaceURI, localName); | 56 return m_element->getAttributeNodeNS(namespaceURI, localName); |
| 57 } | 57 } |
| 58 | 58 |
| 59 PassRefPtrWillBeRawPtr<Node> NamedNodeMap::removeNamedItem(const AtomicString& n
ame, ExceptionState& exceptionState) | 59 PassRefPtrWillBeRawPtr<Attr> NamedNodeMap::removeNamedItem(const AtomicString& n
ame, ExceptionState& exceptionState) |
| 60 { | 60 { |
| 61 size_t index = m_element->attributes().findIndex(name, m_element->shouldIgno
reAttributeCase()); | 61 size_t index = m_element->attributes().findIndex(name, m_element->shouldIgno
reAttributeCase()); |
| 62 if (index == kNotFound) { | 62 if (index == kNotFound) { |
| 63 exceptionState.throwDOMException(NotFoundError, "No item with name '" +
name + "' was found."); | 63 exceptionState.throwDOMException(NotFoundError, "No item with name '" +
name + "' was found."); |
| 64 return nullptr; | 64 return nullptr; |
| 65 } | 65 } |
| 66 return m_element->detachAttribute(index); | 66 return m_element->detachAttribute(index); |
| 67 } | 67 } |
| 68 | 68 |
| 69 PassRefPtrWillBeRawPtr<Node> NamedNodeMap::removeNamedItemNS(const AtomicString&
namespaceURI, const AtomicString& localName, ExceptionState& exceptionState) | 69 PassRefPtrWillBeRawPtr<Attr> NamedNodeMap::removeNamedItemNS(const AtomicString&
namespaceURI, const AtomicString& localName, ExceptionState& exceptionState) |
| 70 { | 70 { |
| 71 size_t index = m_element->attributes().findIndex(QualifiedName(nullAtom, loc
alName, namespaceURI)); | 71 size_t index = m_element->attributes().findIndex(QualifiedName(nullAtom, loc
alName, namespaceURI)); |
| 72 if (index == kNotFound) { | 72 if (index == kNotFound) { |
| 73 exceptionState.throwDOMException(NotFoundError, "No item with name '" +
namespaceURI + "::" + localName + "' was found."); | 73 exceptionState.throwDOMException(NotFoundError, "No item with name '" +
namespaceURI + "::" + localName + "' was found."); |
| 74 return nullptr; | 74 return nullptr; |
| 75 } | 75 } |
| 76 return m_element->detachAttribute(index); | 76 return m_element->detachAttribute(index); |
| 77 } | 77 } |
| 78 | 78 |
| 79 PassRefPtrWillBeRawPtr<Node> NamedNodeMap::setNamedItem(Node* node, ExceptionSta
te& exceptionState) | 79 PassRefPtrWillBeRawPtr<Attr> NamedNodeMap::setNamedItem(Attr* attr, ExceptionSta
te& exceptionState) |
| 80 { | 80 { |
| 81 if (!node) { | 81 ASSERT(attr); |
| 82 exceptionState.throwDOMException(NotFoundError, "The node provided was n
ull."); | 82 return m_element->setAttributeNode(attr, exceptionState); |
| 83 return nullptr; | |
| 84 } | |
| 85 | |
| 86 // Not mentioned in spec: throw a HIERARCHY_REQUEST_ERROR if the user passes
in a non-attribute node | |
| 87 if (!node->isAttributeNode()) { | |
| 88 exceptionState.throwDOMException(HierarchyRequestError, "The node provid
ed is not an attribute node."); | |
| 89 return nullptr; | |
| 90 } | |
| 91 | |
| 92 return m_element->setAttributeNode(toAttr(node), exceptionState); | |
| 93 } | 83 } |
| 94 | 84 |
| 95 PassRefPtrWillBeRawPtr<Node> NamedNodeMap::setNamedItemNS(Node* node, ExceptionS
tate& exceptionState) | 85 PassRefPtrWillBeRawPtr<Attr> NamedNodeMap::setNamedItemNS(Attr* attr, ExceptionS
tate& exceptionState) |
| 96 { | 86 { |
| 97 return setNamedItem(node, exceptionState); | 87 ASSERT(attr); |
| 88 return m_element->setAttributeNodeNS(attr, exceptionState); |
| 98 } | 89 } |
| 99 | 90 |
| 100 PassRefPtrWillBeRawPtr<Node> NamedNodeMap::item(unsigned index) const | 91 PassRefPtrWillBeRawPtr<Attr> NamedNodeMap::item(unsigned index) const |
| 101 { | 92 { |
| 102 AttributeCollection attributes = m_element->attributes(); | 93 AttributeCollection attributes = m_element->attributes(); |
| 103 if (index >= attributes.size()) | 94 if (index >= attributes.size()) |
| 104 return nullptr; | 95 return nullptr; |
| 105 return m_element->ensureAttr(attributes[index].name()); | 96 return m_element->ensureAttr(attributes[index].name()); |
| 106 } | 97 } |
| 107 | 98 |
| 108 size_t NamedNodeMap::length() const | 99 size_t NamedNodeMap::length() const |
| 109 { | 100 { |
| 110 return m_element->attributes().size(); | 101 return m_element->attributes().size(); |
| 111 } | 102 } |
| 112 | 103 |
| 113 void NamedNodeMap::trace(Visitor* visitor) | 104 void NamedNodeMap::trace(Visitor* visitor) |
| 114 { | 105 { |
| 115 visitor->trace(m_element); | 106 visitor->trace(m_element); |
| 116 } | 107 } |
| 117 | 108 |
| 118 } // namespace blink | 109 } // namespace blink |
| OLD | NEW |