Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / dom / NamedNodeMap.cpp
index f75ce65..8d0d9f2 100644 (file)
@@ -35,6 +35,7 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
+#if !ENABLE(OILPAN)
 void NamedNodeMap::ref()
 {
     m_element->ref();
@@ -44,6 +45,7 @@ void NamedNodeMap::deref()
 {
     m_element->deref();
 }
+#endif
 
 PassRefPtr<Node> NamedNodeMap::getNamedItem(const AtomicString& name) const
 {
@@ -55,52 +57,52 @@ PassRefPtr<Node> NamedNodeMap::getNamedItemNS(const AtomicString& namespaceURI,
     return m_element->getAttributeNodeNS(namespaceURI, localName);
 }
 
-PassRefPtr<Node> NamedNodeMap::removeNamedItem(const AtomicString& name, ExceptionState& es)
+PassRefPtr<Node> NamedNodeMap::removeNamedItem(const AtomicString& name, ExceptionState& exceptionState)
 {
     size_t index = m_element->hasAttributes() ? m_element->getAttributeItemIndex(name, m_element->shouldIgnoreAttributeCase()) : kNotFound;
     if (index == kNotFound) {
-        es.throwUninformativeAndGenericDOMException(NotFoundError);
-        return 0;
+        exceptionState.throwDOMException(NotFoundError, "No item with name '" + name + "' was found.");
+        return nullptr;
     }
     return m_element->detachAttribute(index);
 }
 
-PassRefPtr<Node> NamedNodeMap::removeNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName, ExceptionState& es)
+PassRefPtr<Node> NamedNodeMap::removeNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName, ExceptionState& exceptionState)
 {
     size_t index = m_element->hasAttributes() ? m_element->getAttributeItemIndex(QualifiedName(nullAtom, localName, namespaceURI)) : kNotFound;
     if (index == kNotFound) {
-        es.throwUninformativeAndGenericDOMException(NotFoundError);
-        return 0;
+        exceptionState.throwDOMException(NotFoundError, "No item with name '" + namespaceURI + "::" + localName + "' was found.");
+        return nullptr;
     }
     return m_element->detachAttribute(index);
 }
 
-PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* node, ExceptionState& es)
+PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* node, ExceptionState& exceptionState)
 {
     if (!node) {
-        es.throwUninformativeAndGenericDOMException(NotFoundError);
-        return 0;
+        exceptionState.throwDOMException(NotFoundError, "The node provided was null.");
+        return nullptr;
     }
 
     // Not mentioned in spec: throw a HIERARCHY_REQUEST_ERROR if the user passes in a non-attribute node
     if (!node->isAttributeNode()) {
-        es.throwUninformativeAndGenericDOMException(HierarchyRequestError);
-        return 0;
+        exceptionState.throwDOMException(HierarchyRequestError, "The node provided is not an attribute node.");
+        return nullptr;
     }
 
-    return m_element->setAttributeNode(toAttr(node), es);
+    return m_element->setAttributeNode(toAttr(node), exceptionState);
 }
 
-PassRefPtr<Node> NamedNodeMap::setNamedItemNS(Node* node, ExceptionState& es)
+PassRefPtr<Node> NamedNodeMap::setNamedItemNS(Node* node, ExceptionState& exceptionState)
 {
-    return setNamedItem(node, es);
+    return setNamedItem(node, exceptionState);
 }
 
 PassRefPtr<Node> NamedNodeMap::item(unsigned index) const
 {
     if (index >= length())
-        return 0;
-    return m_element->ensureAttr(m_element->attributeItem(index)->name());
+        return nullptr;
+    return m_element->ensureAttr(m_element->attributeItem(index).name());
 }
 
 size_t NamedNodeMap::length() const
@@ -110,4 +112,9 @@ size_t NamedNodeMap::length() const
     return m_element->attributeCount();
 }
 
+void NamedNodeMap::trace(Visitor* visitor)
+{
+    visitor->trace(m_element);
+}
+
 } // namespace WebCore