OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "WebNodeList.h" | 32 #include "WebNodeList.h" |
33 | 33 |
34 #include "core/dom/Node.h" | 34 #include "core/dom/Node.h" |
35 #include "core/dom/NodeList.h" | 35 #include "core/dom/NodeList.h" |
| 36 #include "core/html/HTMLCollection.h" |
36 #include "wtf/PassRefPtr.h" | 37 #include "wtf/PassRefPtr.h" |
37 | 38 |
38 #include "WebNode.h" | 39 #include "WebNode.h" |
39 | 40 |
40 using namespace WebCore; | 41 using namespace WebCore; |
41 | 42 |
42 namespace blink { | 43 namespace blink { |
43 | 44 |
| 45 // FIXME(crbug.com/235008): Remove once chromium has been updated to stop using |
| 46 // WebCollection as a WebNodeList. |
| 47 class NodeListWithInternalCollection FINAL : public NodeList { |
| 48 public: |
| 49 explicit NodeListWithInternalCollection(HTMLCollection* collection) |
| 50 : m_collection(collection) |
| 51 { |
| 52 } |
| 53 |
| 54 // We have null checks in the following methods because WebNodeList does not
have a isNull() method |
| 55 // and callers need to be moved to WebNodeCollection and need to handle null
using |
| 56 // WebNodeCollection::isNull(). |
| 57 virtual unsigned length() const OVERRIDE { return m_collection ? m_collectio
n->length() : 0; } |
| 58 virtual Node* item(unsigned index) const OVERRIDE { return m_collection ? m_
collection->item(index) : 0; } |
| 59 virtual Node* namedItem(const AtomicString& elementId) const OVERRIDE { retu
rn m_collection ? m_collection->namedItem(elementId) : 0; } |
| 60 |
| 61 private: |
| 62 RefPtr<HTMLCollection> m_collection; |
| 63 }; |
| 64 |
| 65 WebNodeList::WebNodeList(const WebNodeCollection& n) |
| 66 : m_private(0) |
| 67 { |
| 68 assign(new NodeListWithInternalCollection(n.m_private)); |
| 69 } |
| 70 |
44 void WebNodeList::reset() | 71 void WebNodeList::reset() |
45 { | 72 { |
46 assign(0); | 73 assign(0); |
47 } | 74 } |
48 | 75 |
49 void WebNodeList::assign(const WebNodeList& other) | 76 void WebNodeList::assign(const WebNodeList& other) |
50 { | 77 { |
51 NodeList* p = const_cast<NodeList*>(other.m_private); | 78 NodeList* p = const_cast<NodeList*>(other.m_private); |
52 if (p) | 79 if (p) |
53 p->ref(); | 80 p->ref(); |
(...skipping 17 matching lines...) Expand all Loading... |
71 { | 98 { |
72 return m_private->length(); | 99 return m_private->length(); |
73 } | 100 } |
74 | 101 |
75 WebNode WebNodeList::item(size_t index) const | 102 WebNode WebNodeList::item(size_t index) const |
76 { | 103 { |
77 return WebNode(m_private->item(index)); | 104 return WebNode(m_private->item(index)); |
78 } | 105 } |
79 | 106 |
80 } // namespace blink | 107 } // namespace blink |
OLD | NEW |