Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/html/HTMLSlotElement.h" | 32 #include "core/html/HTMLSlotElement.h" |
| 33 | 33 |
| 34 #include "core/HTMLNames.h" | 34 #include "core/HTMLNames.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 using namespace HTMLNames; | 38 using namespace HTMLNames; |
| 39 | 39 |
| 40 PassRefPtrWillBeRawPtr<HTMLSlotElement> HTMLSlotElement::create(Document& docume nt) | |
| 41 { | |
| 42 return adoptRefWillBeNoop(new HTMLSlotElement(document)); | |
| 43 } | |
| 44 | |
| 45 inline HTMLSlotElement::HTMLSlotElement(Document& document) | 40 inline HTMLSlotElement::HTMLSlotElement(Document& document) |
| 46 : HTMLElement(slotTag, document) | 41 : HTMLElement(slotTag, document) |
| 47 { | 42 { |
| 48 } | 43 } |
| 49 | 44 |
| 50 HTMLSlotElement::~HTMLSlotElement() | 45 DEFINE_NODE_FACTORY(HTMLSlotElement); |
| 46 | |
| 47 void HTMLSlotElement::appendAssignedNode(Node& node) | |
| 51 { | 48 { |
| 49 m_assignedNodes.append(&node); | |
| 50 } | |
| 51 | |
| 52 void HTMLSlotElement::appendDistributedNode(Node& node) | |
| 53 { | |
| 54 m_distributedNodes.append(&node); | |
| 55 } | |
| 56 | |
| 57 void HTMLSlotElement::appendDistributedNodes(const Vector<RefPtr<Node>>& nodes) | |
| 58 { | |
| 59 m_distributedNodes.appendVector(nodes); | |
| 60 } | |
| 61 | |
| 62 void HTMLSlotElement::clearDistribution() | |
| 63 { | |
| 64 m_assignedNodes.clear(); | |
| 65 m_distributedNodes.clear(); | |
| 66 } | |
| 67 | |
| 68 Node* HTMLSlotElement::distributedNodeNextTo(const Node& node) const | |
| 69 { | |
| 70 size_t index = m_distributedNodes.find(&node); | |
| 71 if (index == kNotFound || index + 1 == m_distributedNodes.size()) | |
| 72 return nullptr; | |
| 73 return m_distributedNodes[index + 1].get(); | |
| 74 } | |
| 75 | |
| 76 Node* HTMLSlotElement::distributedNodePreviousTo(const Node& node) const | |
| 77 { | |
| 78 size_t index = m_distributedNodes.find(&node); | |
| 79 if (index == kNotFound || index == 0) | |
| 80 return nullptr; | |
| 81 return m_distributedNodes[index - 1].get(); | |
| 82 } | |
| 83 | |
| 84 void HTMLSlotElement::attach(const AttachContext& context) | |
| 85 { | |
| 86 for (size_t i = 0; i < m_distributedNodes.size(); ++i) { | |
|
tkent
2015/12/10 04:23:02
for (auto& node : m_distributedNodes) {
if (no
hayato
2015/12/10 08:11:21
Done.
| |
| 87 if (m_distributedNodes[i]->needsAttach()) | |
| 88 m_distributedNodes[i]->attach(context); | |
| 89 } | |
| 90 | |
| 91 HTMLElement::attach(context); | |
| 92 } | |
| 93 | |
| 94 void HTMLSlotElement::detach(const AttachContext& context) | |
| 95 { | |
| 96 for (size_t i = 0; i < m_distributedNodes.size(); ++i) | |
|
tkent
2015/12/10 04:23:02
Ditto.
hayato
2015/12/10 08:11:21
Done.
| |
| 97 m_distributedNodes[i]->lazyReattachIfAttached(); | |
| 98 | |
| 99 HTMLElement::detach(context); | |
| 52 } | 100 } |
| 53 | 101 |
| 54 DEFINE_TRACE(HTMLSlotElement) | 102 DEFINE_TRACE(HTMLSlotElement) |
| 55 { | 103 { |
| 56 HTMLElement::trace(visitor); | 104 HTMLElement::trace(visitor); |
|
tkent
2015/12/10 04:23:02
Need to trace m_assingedNodes and m_distributedNod
hayato
2015/12/10 08:11:21
Done.
| |
| 57 } | 105 } |
| 58 | 106 |
| 59 } | 107 } |
| OLD | NEW |