OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "wtf/PassRefPtr.h" | 34 #include "wtf/PassRefPtr.h" |
35 #include "wtf/RefPtr.h" | 35 #include "wtf/RefPtr.h" |
36 #include "wtf/Vector.h" | 36 #include "wtf/Vector.h" |
37 | 37 |
38 namespace WebCore { | 38 namespace WebCore { |
39 | 39 |
40 class Node; | 40 class Node; |
41 | 41 |
42 class StaticNodeList FINAL : public NodeList { | 42 class StaticNodeList FINAL : public NodeList { |
43 public: | 43 public: |
44 static PassRefPtr<StaticNodeList> adopt(Vector<RefPtr<Node> >& nodes) | 44 static PassRefPtr<StaticNodeList> adopt(Vector<RefPtr<Node> >& nodes); |
45 { | |
46 RefPtr<StaticNodeList> nodeList = adoptRef(new StaticNodeList); | |
47 nodeList->m_nodes.swap(nodes); | |
48 return nodeList.release(); | |
49 } | |
50 | 45 |
51 static PassRefPtr<StaticNodeList> createEmpty() | 46 static PassRefPtr<StaticNodeList> createEmpty() |
52 { | 47 { |
53 return adoptRef(new StaticNodeList); | 48 return adoptRef(new StaticNodeList); |
54 } | 49 } |
55 | 50 |
| 51 virtual ~StaticNodeList(); |
| 52 |
56 virtual unsigned length() const OVERRIDE; | 53 virtual unsigned length() const OVERRIDE; |
57 virtual Node* item(unsigned index) const OVERRIDE; | 54 virtual Node* item(unsigned index) const OVERRIDE; |
58 | 55 |
59 private: | 56 private: |
| 57 // If AllocationSize() is larger than this, we report it as external |
| 58 // allocated memory to V8. |
| 59 const static ptrdiff_t externalMemoryReportSizeLimit = 1024; |
| 60 |
| 61 ptrdiff_t AllocationSize() |
| 62 { |
| 63 return m_nodes.capacity() * sizeof(RefPtr<Node>); |
| 64 } |
| 65 |
60 Vector<RefPtr<Node> > m_nodes; | 66 Vector<RefPtr<Node> > m_nodes; |
61 }; | 67 }; |
62 | 68 |
63 } // namespace WebCore | 69 } // namespace WebCore |
64 | 70 |
65 #endif // StaticNodeList_h | 71 #endif // StaticNodeList_h |
OLD | NEW |