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 25 matching lines...) Expand all Loading... |
36 #include <v8.h> | 36 #include <v8.h> |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 class Element; | 40 class Element; |
41 class Node; | 41 class Node; |
42 | 42 |
43 template <typename NodeType> | 43 template <typename NodeType> |
44 class StaticNodeTypeList final : public NodeList { | 44 class StaticNodeTypeList final : public NodeList { |
45 public: | 45 public: |
46 static PassRefPtrWillBeRawPtr<StaticNodeTypeList> adopt(WillBeHeapVector<Ref
PtrWillBeMember<NodeType> >& nodes); | 46 static PassRefPtrWillBeRawPtr<StaticNodeTypeList> adopt(WillBeHeapVector<Ref
PtrWillBeMember<NodeType>>& nodes); |
47 | 47 |
48 static PassRefPtrWillBeRawPtr<StaticNodeTypeList> createEmpty() | 48 static PassRefPtrWillBeRawPtr<StaticNodeTypeList> createEmpty() |
49 { | 49 { |
50 return adoptRefWillBeNoop(new StaticNodeTypeList); | 50 return adoptRefWillBeNoop(new StaticNodeTypeList); |
51 } | 51 } |
52 | 52 |
53 virtual ~StaticNodeTypeList(); | 53 virtual ~StaticNodeTypeList(); |
54 | 54 |
55 virtual unsigned length() const override; | 55 virtual unsigned length() const override; |
56 virtual NodeType* item(unsigned index) const override; | 56 virtual NodeType* item(unsigned index) const override; |
57 | 57 |
58 DECLARE_VIRTUAL_TRACE(); | 58 DECLARE_VIRTUAL_TRACE(); |
59 | 59 |
60 private: | 60 private: |
61 ptrdiff_t AllocationSize() | 61 ptrdiff_t AllocationSize() |
62 { | 62 { |
63 return m_nodes.capacity() * sizeof(RefPtrWillBeMember<NodeType>); | 63 return m_nodes.capacity() * sizeof(RefPtrWillBeMember<NodeType>); |
64 } | 64 } |
65 | 65 |
66 WillBeHeapVector<RefPtrWillBeMember<NodeType> > m_nodes; | 66 WillBeHeapVector<RefPtrWillBeMember<NodeType>> m_nodes; |
67 }; | 67 }; |
68 | 68 |
69 typedef StaticNodeTypeList<Node> StaticNodeList; | 69 typedef StaticNodeTypeList<Node> StaticNodeList; |
70 typedef StaticNodeTypeList<Element> StaticElementList; | 70 typedef StaticNodeTypeList<Element> StaticElementList; |
71 | 71 |
72 template <typename NodeType> | 72 template <typename NodeType> |
73 PassRefPtrWillBeRawPtr<StaticNodeTypeList<NodeType> > StaticNodeTypeList<NodeTyp
e>::adopt(WillBeHeapVector<RefPtrWillBeMember<NodeType> >& nodes) | 73 PassRefPtrWillBeRawPtr<StaticNodeTypeList<NodeType>> StaticNodeTypeList<NodeType
>::adopt(WillBeHeapVector<RefPtrWillBeMember<NodeType>>& nodes) |
74 { | 74 { |
75 RefPtrWillBeRawPtr<StaticNodeTypeList<NodeType> > nodeList = adoptRefWillBeN
oop(new StaticNodeTypeList<NodeType>); | 75 RefPtrWillBeRawPtr<StaticNodeTypeList<NodeType>> nodeList = adoptRefWillBeNo
op(new StaticNodeTypeList<NodeType>); |
76 nodeList->m_nodes.swap(nodes); | 76 nodeList->m_nodes.swap(nodes); |
77 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(nodeList->A
llocationSize()); | 77 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(nodeList->A
llocationSize()); |
78 return nodeList.release(); | 78 return nodeList.release(); |
79 } | 79 } |
80 | 80 |
81 template <typename NodeType> | 81 template <typename NodeType> |
82 StaticNodeTypeList<NodeType>::~StaticNodeTypeList() | 82 StaticNodeTypeList<NodeType>::~StaticNodeTypeList() |
83 { | 83 { |
84 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-Allocation
Size()); | 84 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-Allocation
Size()); |
85 } | 85 } |
(...skipping 26 matching lines...) Expand all Loading... |
112 void StaticNodeTypeList<NodeType>::trace(Visitor* visitor) | 112 void StaticNodeTypeList<NodeType>::trace(Visitor* visitor) |
113 #endif | 113 #endif |
114 { | 114 { |
115 visitor->trace(m_nodes); | 115 visitor->trace(m_nodes); |
116 NodeList::trace(visitor); | 116 NodeList::trace(visitor); |
117 } | 117 } |
118 | 118 |
119 } // namespace blink | 119 } // namespace blink |
120 | 120 |
121 #endif // StaticNodeList_h | 121 #endif // StaticNodeList_h |
OLD | NEW |