| 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 24 matching lines...) Expand all Loading... |
| 35 #include "core/dom/NodeList.h" | 35 #include "core/dom/NodeList.h" |
| 36 #include "public/web/WebNode.h" | 36 #include "public/web/WebNode.h" |
| 37 #include "wtf/PassRefPtr.h" | 37 #include "wtf/PassRefPtr.h" |
| 38 | 38 |
| 39 using namespace WebCore; | 39 using namespace WebCore; |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 void WebNodeList::reset() | 43 void WebNodeList::reset() |
| 44 { | 44 { |
| 45 assign(0); | 45 m_private.reset(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void WebNodeList::assign(const WebNodeList& other) | 48 void WebNodeList::assign(const WebNodeList& other) |
| 49 { | 49 { |
| 50 NodeList* p = const_cast<NodeList*>(other.m_private); | 50 m_private = other.m_private; |
| 51 if (p) | |
| 52 p->ref(); | |
| 53 assign(p); | |
| 54 } | 51 } |
| 55 | 52 |
| 56 WebNodeList::WebNodeList(const PassRefPtr<NodeList>& col) | 53 WebNodeList::WebNodeList(const PassRefPtrWillBeRawPtr<NodeList>& list) |
| 57 : m_private(static_cast<NodeList*>(col.leakRef())) | 54 : m_private(list) |
| 58 { | 55 { |
| 59 } | 56 } |
| 60 | 57 |
| 61 void WebNodeList::assign(NodeList* p) | 58 WebNodeList& WebNodeList::operator=(const PassRefPtrWillBeRawPtr<NodeList>& list
) |
| 62 { | 59 { |
| 63 // p is already ref'd for us by the caller | 60 m_private = list; |
| 64 if (m_private) | 61 return *this; |
| 65 m_private->deref(); | |
| 66 m_private = p; | |
| 67 } | 62 } |
| 68 | 63 |
| 69 unsigned WebNodeList::length() const | 64 unsigned WebNodeList::length() const |
| 70 { | 65 { |
| 71 return m_private->length(); | 66 return m_private->length(); |
| 72 } | 67 } |
| 73 | 68 |
| 74 WebNode WebNodeList::item(size_t index) const | 69 WebNode WebNodeList::item(size_t index) const |
| 75 { | 70 { |
| 76 return WebNode(m_private->item(index)); | 71 return WebNode(m_private->item(index)); |
| 77 } | 72 } |
| 78 | 73 |
| 79 } // namespace blink | 74 } // namespace blink |
| OLD | NEW |