Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: Source/web/WebNodeList.cpp

Issue 150653007: Remove code allowing implicit conversion from WebElementCollection to WebNodeList. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | public/web/WebElementCollection.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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/Element.h" 34 #include "WebNode.h"
35 #include "core/dom/Node.h" 35 #include "core/dom/Node.h"
36 #include "core/dom/NodeList.h" 36 #include "core/dom/NodeList.h"
37 #include "core/html/HTMLCollection.h"
38 #include "wtf/PassRefPtr.h" 37 #include "wtf/PassRefPtr.h"
39 38
40 #include "WebNode.h"
41
42 using namespace WebCore; 39 using namespace WebCore;
43 40
44 namespace blink { 41 namespace blink {
45 42
46 // FIXME(crbug.com/235008): Remove once chromium has been updated to stop using
47 // WebCollection as a WebNodeList.
48 class NodeListWithInternalCollection FINAL : public NodeList {
49 public:
50 static PassRefPtr<NodeListWithInternalCollection> create(HTMLCollection* col lection)
51 {
52 return adoptRef(new NodeListWithInternalCollection(collection));
53 }
54
55 // We have null checks in the following methods because WebNodeList does not have a isNull() method
56 // and callers need to be moved to WebElementCollection and need to handle n ull using
57 // WebElementCollection::isNull().
58 virtual unsigned length() const OVERRIDE { return m_collection ? m_collectio n->length() : 0; }
59 virtual Node* item(unsigned index) const OVERRIDE { return m_collection ? m_ collection->item(index) : 0; }
60
61 private:
62 explicit NodeListWithInternalCollection(HTMLCollection* collection)
63 : m_collection(collection)
64 {
65 }
66
67 RefPtr<HTMLCollection> m_collection;
68 };
69
70 WebNodeList::WebNodeList(const WebElementCollection& n)
71 : m_private(0)
72 {
73 assign(NodeListWithInternalCollection::create(n.m_private).leakRef());
74 }
75
76 void WebNodeList::reset() 43 void WebNodeList::reset()
77 { 44 {
78 assign(0); 45 assign(0);
79 } 46 }
80 47
81 void WebNodeList::assign(const WebNodeList& other) 48 void WebNodeList::assign(const WebNodeList& other)
82 { 49 {
83 NodeList* p = const_cast<NodeList*>(other.m_private); 50 NodeList* p = const_cast<NodeList*>(other.m_private);
84 if (p) 51 if (p)
85 p->ref(); 52 p->ref();
(...skipping 17 matching lines...) Expand all
103 { 70 {
104 return m_private->length(); 71 return m_private->length();
105 } 72 }
106 73
107 WebNode WebNodeList::item(size_t index) const 74 WebNode WebNodeList::item(size_t index) const
108 { 75 {
109 return WebNode(m_private->item(index)); 76 return WebNode(m_private->item(index));
110 } 77 }
111 78
112 } // namespace blink 79 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | public/web/WebElementCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698