Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/HTMLSlotElement.cpp |
| diff --git a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp |
| index 230144be09fef59eae872e1986c2f5ecaaa7d010..897a2716098d07b85bdcb4fa7bb73b066b8da202 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp |
| @@ -83,32 +83,47 @@ void HTMLSlotElement::appendAssignedNode(Node& node) |
| void HTMLSlotElement::appendDistributedNode(Node& node) |
| { |
| + size_t size = m_distributedNodes.size(); |
| m_distributedNodes.append(&node); |
| + m_distributedIndices.set(&node, size); |
| } |
| void HTMLSlotElement::appendDistributedNodesFrom(const HTMLSlotElement& other) |
| { |
| + size_t index = m_distributedNodes.size(); |
| m_distributedNodes.appendVector(other.m_distributedNodes); |
| + for (WillBeHeapHashMap<RawPtrWillBeMember<const Node>, size_t>::const_iterator 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.
|
| + 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.
|
| + m_distributedIndices.set(node, index); |
| + 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.
|
| + } |
| } |
| void HTMLSlotElement::clearDistribution() |
| { |
| m_assignedNodes.clear(); |
| m_distributedNodes.clear(); |
| + m_distributedIndices.clear(); |
| } |
| Node* HTMLSlotElement::distributedNodeNextTo(const Node& node) const |
| { |
| - size_t index = m_distributedNodes.find(&node); |
| - if (index == kNotFound || index + 1 == m_distributedNodes.size()) |
| + 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.
|
| + if (it == m_distributedIndices.end()) |
| + return nullptr; |
| + 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.
|
| + if (index + 1 == m_distributedNodes.size()) |
| return nullptr; |
| return m_distributedNodes[index + 1].get(); |
| } |
| Node* HTMLSlotElement::distributedNodePreviousTo(const Node& node) const |
| { |
| - size_t index = m_distributedNodes.find(&node); |
| - if (index == kNotFound || index == 0) |
| + 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.
|
| + if (it == m_distributedIndices.end()) |
| + return nullptr; |
| + 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.
|
| + if (index == 0) |
| return nullptr; |
| return m_distributedNodes[index - 1].get(); |
| } |
| @@ -202,8 +217,11 @@ void HTMLSlotElement::updateDistributedNodesWithFallback() |
| DEFINE_TRACE(HTMLSlotElement) |
| { |
| +#if ENABLE(OILPAN) |
| visitor->trace(m_assignedNodes); |
| visitor->trace(m_distributedNodes); |
| + visitor->trace(m_distributedIndices); |
| +#endif |
| HTMLElement::trace(visitor); |
| } |