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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 PassRefPtr<Node> NamedNodeMap::getNamedItemNS(const AtomicString& namespaceURI,
const AtomicString& localName) const | 53 PassRefPtr<Node> NamedNodeMap::getNamedItemNS(const AtomicString& namespaceURI,
const AtomicString& localName) const |
54 { | 54 { |
55 return m_element->getAttributeNodeNS(namespaceURI, localName); | 55 return m_element->getAttributeNodeNS(namespaceURI, localName); |
56 } | 56 } |
57 | 57 |
58 PassRefPtr<Node> NamedNodeMap::removeNamedItem(const AtomicString& name, Excepti
onState& exceptionState) | 58 PassRefPtr<Node> NamedNodeMap::removeNamedItem(const AtomicString& name, Excepti
onState& exceptionState) |
59 { | 59 { |
60 size_t index = m_element->hasAttributes() ? m_element->getAttributeItemIndex
(name, m_element->shouldIgnoreAttributeCase()) : kNotFound; | 60 size_t index = m_element->hasAttributes() ? m_element->getAttributeItemIndex
(name, m_element->shouldIgnoreAttributeCase()) : kNotFound; |
61 if (index == kNotFound) { | 61 if (index == kNotFound) { |
62 exceptionState.throwDOMException(NotFoundError, "No item with name '" +
name + "' was found."); | 62 exceptionState.throwDOMException(NotFoundError, "No item with name '" +
name + "' was found."); |
63 return 0; | 63 return nullptr; |
64 } | 64 } |
65 return m_element->detachAttribute(index); | 65 return m_element->detachAttribute(index); |
66 } | 66 } |
67 | 67 |
68 PassRefPtr<Node> NamedNodeMap::removeNamedItemNS(const AtomicString& namespaceUR
I, const AtomicString& localName, ExceptionState& exceptionState) | 68 PassRefPtr<Node> NamedNodeMap::removeNamedItemNS(const AtomicString& namespaceUR
I, const AtomicString& localName, ExceptionState& exceptionState) |
69 { | 69 { |
70 size_t index = m_element->hasAttributes() ? m_element->getAttributeItemIndex
(QualifiedName(nullAtom, localName, namespaceURI)) : kNotFound; | 70 size_t index = m_element->hasAttributes() ? m_element->getAttributeItemIndex
(QualifiedName(nullAtom, localName, namespaceURI)) : kNotFound; |
71 if (index == kNotFound) { | 71 if (index == kNotFound) { |
72 exceptionState.throwDOMException(NotFoundError, "No item with name '" +
namespaceURI + "::" + localName + "' was found."); | 72 exceptionState.throwDOMException(NotFoundError, "No item with name '" +
namespaceURI + "::" + localName + "' was found."); |
73 return 0; | 73 return nullptr; |
74 } | 74 } |
75 return m_element->detachAttribute(index); | 75 return m_element->detachAttribute(index); |
76 } | 76 } |
77 | 77 |
78 PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* node, ExceptionState& exceptio
nState) | 78 PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* node, ExceptionState& exceptio
nState) |
79 { | 79 { |
80 if (!node) { | 80 if (!node) { |
81 exceptionState.throwDOMException(NotFoundError, "The node provided was n
ull."); | 81 exceptionState.throwDOMException(NotFoundError, "The node provided was n
ull."); |
82 return 0; | 82 return nullptr; |
83 } | 83 } |
84 | 84 |
85 // Not mentioned in spec: throw a HIERARCHY_REQUEST_ERROR if the user passes
in a non-attribute node | 85 // Not mentioned in spec: throw a HIERARCHY_REQUEST_ERROR if the user passes
in a non-attribute node |
86 if (!node->isAttributeNode()) { | 86 if (!node->isAttributeNode()) { |
87 exceptionState.throwDOMException(HierarchyRequestError, "The node provid
ed is not an attribute node."); | 87 exceptionState.throwDOMException(HierarchyRequestError, "The node provid
ed is not an attribute node."); |
88 return 0; | 88 return nullptr; |
89 } | 89 } |
90 | 90 |
91 return m_element->setAttributeNode(toAttr(node), exceptionState); | 91 return m_element->setAttributeNode(toAttr(node), exceptionState); |
92 } | 92 } |
93 | 93 |
94 PassRefPtr<Node> NamedNodeMap::setNamedItemNS(Node* node, ExceptionState& except
ionState) | 94 PassRefPtr<Node> NamedNodeMap::setNamedItemNS(Node* node, ExceptionState& except
ionState) |
95 { | 95 { |
96 return setNamedItem(node, exceptionState); | 96 return setNamedItem(node, exceptionState); |
97 } | 97 } |
98 | 98 |
99 PassRefPtr<Node> NamedNodeMap::item(unsigned index) const | 99 PassRefPtr<Node> NamedNodeMap::item(unsigned index) const |
100 { | 100 { |
101 if (index >= length()) | 101 if (index >= length()) |
102 return 0; | 102 return nullptr; |
103 return m_element->ensureAttr(m_element->attributeItem(index)->name()); | 103 return m_element->ensureAttr(m_element->attributeItem(index)->name()); |
104 } | 104 } |
105 | 105 |
106 size_t NamedNodeMap::length() const | 106 size_t NamedNodeMap::length() const |
107 { | 107 { |
108 if (!m_element->hasAttributes()) | 108 if (!m_element->hasAttributes()) |
109 return 0; | 109 return 0; |
110 return m_element->attributeCount(); | 110 return m_element->attributeCount(); |
111 } | 111 } |
112 | 112 |
113 } // namespace WebCore | 113 } // namespace WebCore |
OLD | NEW |