OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2015 Google Inc. All rights reserved. | 2 * Copyright (C) 2015 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 return m_distributedNodes; | 76 return m_distributedNodes; |
77 } | 77 } |
78 | 78 |
79 void HTMLSlotElement::appendAssignedNode(Node& node) | 79 void HTMLSlotElement::appendAssignedNode(Node& node) |
80 { | 80 { |
81 m_assignedNodes.append(&node); | 81 m_assignedNodes.append(&node); |
82 } | 82 } |
83 | 83 |
84 void HTMLSlotElement::appendDistributedNode(Node& node) | 84 void HTMLSlotElement::appendDistributedNode(Node& node) |
85 { | 85 { |
86 size_t size = m_distributedNodes.size(); | |
86 m_distributedNodes.append(&node); | 87 m_distributedNodes.append(&node); |
88 m_distributedIndices.set(&node, size); | |
87 } | 89 } |
88 | 90 |
89 void HTMLSlotElement::appendDistributedNodesFrom(const HTMLSlotElement& other) | 91 void HTMLSlotElement::appendDistributedNodesFrom(const HTMLSlotElement& other) |
90 { | 92 { |
93 size_t index = m_distributedNodes.size(); | |
91 m_distributedNodes.appendVector(other.m_distributedNodes); | 94 m_distributedNodes.appendVector(other.m_distributedNodes); |
95 for (WillBeHeapHashMap<RawPtrWillBeMember<const Node>, size_t>::const_iterat or it = other.m_distributedIndices.begin(); it != other.m_distributedIndices.end (); ++it) { | |
kochi
2016/01/27 08:29:13
You can write "for (const auto& it = other.m_distr
yuzuchan
2016/02/01 05:40:42
Done.
| |
96 const Node* node = it.get()->key; | |
kochi
2016/01/27 08:29:13
You can write "it->key".
yuzuchan
2016/02/01 05:40:42
Done.
| |
97 m_distributedIndices.set(node, index); | |
98 index++; | |
kochi
2016/01/27 08:29:13
You can write line97 as m_distributedIndices.set(n
yuzuchan
2016/02/01 05:40:42
Done.
| |
99 } | |
92 } | 100 } |
93 | 101 |
94 void HTMLSlotElement::clearDistribution() | 102 void HTMLSlotElement::clearDistribution() |
95 { | 103 { |
96 m_assignedNodes.clear(); | 104 m_assignedNodes.clear(); |
97 m_distributedNodes.clear(); | 105 m_distributedNodes.clear(); |
106 m_distributedIndices.clear(); | |
98 } | 107 } |
99 | 108 |
100 Node* HTMLSlotElement::distributedNodeNextTo(const Node& node) const | 109 Node* HTMLSlotElement::distributedNodeNextTo(const Node& node) const |
101 { | 110 { |
102 size_t index = m_distributedNodes.find(&node); | 111 WillBeHeapHashMap<RawPtrWillBeMember<const Node>, size_t>::const_iterator it = m_distributedIndices.find(&node); |
kochi
2016/01/27 08:29:13
You can write "const auto it = ...".
yuzuchan
2016/02/01 05:40:42
Done.
| |
103 if (index == kNotFound || index + 1 == m_distributedNodes.size()) | 112 if (it == m_distributedIndices.end()) |
113 return nullptr; | |
114 size_t index = it.get()->value; | |
kochi
2016/01/27 08:29:13
You can write "it->value".
yuzuchan
2016/02/01 05:40:42
Done.
| |
115 if (index + 1 == m_distributedNodes.size()) | |
104 return nullptr; | 116 return nullptr; |
105 return m_distributedNodes[index + 1].get(); | 117 return m_distributedNodes[index + 1].get(); |
106 } | 118 } |
107 | 119 |
108 Node* HTMLSlotElement::distributedNodePreviousTo(const Node& node) const | 120 Node* HTMLSlotElement::distributedNodePreviousTo(const Node& node) const |
109 { | 121 { |
110 size_t index = m_distributedNodes.find(&node); | 122 WillBeHeapHashMap<RawPtrWillBeMember<const Node>, size_t>::const_iterator it = m_distributedIndices.find(&node); |
kochi
2016/01/27 08:29:13
You can write "const auto it = ...".
yuzuchan
2016/02/01 05:40:42
Done.
| |
111 if (index == kNotFound || index == 0) | 123 if (it == m_distributedIndices.end()) |
124 return nullptr; | |
125 size_t index = it.get()->value; | |
kochi
2016/01/27 08:29:13
You can write "it->value".
yuzuchan
2016/02/01 05:40:42
Done.
| |
126 if (index == 0) | |
112 return nullptr; | 127 return nullptr; |
113 return m_distributedNodes[index - 1].get(); | 128 return m_distributedNodes[index - 1].get(); |
114 } | 129 } |
115 | 130 |
116 void HTMLSlotElement::attach(const AttachContext& context) | 131 void HTMLSlotElement::attach(const AttachContext& context) |
117 { | 132 { |
118 for (auto& node : m_distributedNodes) { | 133 for (auto& node : m_distributedNodes) { |
119 if (node->needsAttach()) | 134 if (node->needsAttach()) |
120 node->attach(context); | 135 node->attach(context); |
121 } | 136 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 continue; | 210 continue; |
196 if (isHTMLSlotElement(child)) | 211 if (isHTMLSlotElement(child)) |
197 appendDistributedNodesFrom(toHTMLSlotElement(child)); | 212 appendDistributedNodesFrom(toHTMLSlotElement(child)); |
198 else | 213 else |
199 appendDistributedNode(child); | 214 appendDistributedNode(child); |
200 } | 215 } |
201 } | 216 } |
202 | 217 |
203 DEFINE_TRACE(HTMLSlotElement) | 218 DEFINE_TRACE(HTMLSlotElement) |
204 { | 219 { |
220 #if ENABLE(OILPAN) | |
205 visitor->trace(m_assignedNodes); | 221 visitor->trace(m_assignedNodes); |
206 visitor->trace(m_distributedNodes); | 222 visitor->trace(m_distributedNodes); |
223 visitor->trace(m_distributedIndices); | |
224 #endif | |
207 HTMLElement::trace(visitor); | 225 HTMLElement::trace(visitor); |
208 } | 226 } |
209 | 227 |
210 } | 228 } |
OLD | NEW |