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 17 matching lines...) Expand all Loading... |
28 #include "bindings/v8/ExceptionState.h" | 28 #include "bindings/v8/ExceptionState.h" |
29 #include "core/dom/Attr.h" | 29 #include "core/dom/Attr.h" |
30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
31 #include "core/dom/Element.h" | 31 #include "core/dom/Element.h" |
32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
33 | 33 |
34 namespace WebCore { | 34 namespace WebCore { |
35 | 35 |
36 using namespace HTMLNames; | 36 using namespace HTMLNames; |
37 | 37 |
38 static inline bool shouldIgnoreAttributeCase(const Element* e) | |
39 { | |
40 return e && e->document().isHTMLDocument() && e->isHTMLElement(); | |
41 } | |
42 | |
43 void NamedNodeMap::ref() | 38 void NamedNodeMap::ref() |
44 { | 39 { |
45 m_element->ref(); | 40 m_element->ref(); |
46 } | 41 } |
47 | 42 |
48 void NamedNodeMap::deref() | 43 void NamedNodeMap::deref() |
49 { | 44 { |
50 m_element->deref(); | 45 m_element->deref(); |
51 } | 46 } |
52 | 47 |
53 PassRefPtr<Node> NamedNodeMap::getNamedItem(const AtomicString& name) const | 48 PassRefPtr<Node> NamedNodeMap::getNamedItem(const AtomicString& name) const |
54 { | 49 { |
55 return m_element->getAttributeNode(name); | 50 return m_element->getAttributeNode(name); |
56 } | 51 } |
57 | 52 |
58 PassRefPtr<Node> NamedNodeMap::getNamedItemNS(const AtomicString& namespaceURI,
const AtomicString& localName) const | 53 PassRefPtr<Node> NamedNodeMap::getNamedItemNS(const AtomicString& namespaceURI,
const AtomicString& localName) const |
59 { | 54 { |
60 return m_element->getAttributeNodeNS(namespaceURI, localName); | 55 return m_element->getAttributeNodeNS(namespaceURI, localName); |
61 } | 56 } |
62 | 57 |
63 PassRefPtr<Node> NamedNodeMap::removeNamedItem(const AtomicString& name, Excepti
onState& es) | 58 PassRefPtr<Node> NamedNodeMap::removeNamedItem(const AtomicString& name, Excepti
onState& es) |
64 { | 59 { |
65 size_t index = m_element->hasAttributes() ? m_element->getAttributeItemIndex
(name, shouldIgnoreAttributeCase(m_element)) : kNotFound; | 60 size_t index = m_element->hasAttributes() ? m_element->getAttributeItemIndex
(name, m_element->shouldIgnoreAttributeCase()) : kNotFound; |
66 if (index == kNotFound) { | 61 if (index == kNotFound) { |
67 es.throwUninformativeAndGenericDOMException(NotFoundError); | 62 es.throwUninformativeAndGenericDOMException(NotFoundError); |
68 return 0; | 63 return 0; |
69 } | 64 } |
70 return m_element->detachAttribute(index); | 65 return m_element->detachAttribute(index); |
71 } | 66 } |
72 | 67 |
73 PassRefPtr<Node> NamedNodeMap::removeNamedItemNS(const AtomicString& namespaceUR
I, const AtomicString& localName, ExceptionState& es) | 68 PassRefPtr<Node> NamedNodeMap::removeNamedItemNS(const AtomicString& namespaceUR
I, const AtomicString& localName, ExceptionState& es) |
74 { | 69 { |
75 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; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 104 } |
110 | 105 |
111 size_t NamedNodeMap::length() const | 106 size_t NamedNodeMap::length() const |
112 { | 107 { |
113 if (!m_element->hasAttributes()) | 108 if (!m_element->hasAttributes()) |
114 return 0; | 109 return 0; |
115 return m_element->attributeCount(); | 110 return m_element->attributeCount(); |
116 } | 111 } |
117 | 112 |
118 } // namespace WebCore | 113 } // namespace WebCore |
OLD | NEW |