| 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 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 class AssignedNodesOptions; | 39 class AssignedNodesOptions; |
| 40 | 40 |
| 41 class CORE_EXPORT HTMLSlotElement final : public HTMLElement { | 41 class CORE_EXPORT HTMLSlotElement final : public HTMLElement { |
| 42 DEFINE_WRAPPERTYPEINFO(); | 42 DEFINE_WRAPPERTYPEINFO(); |
| 43 public: | 43 public: |
| 44 DECLARE_NODE_FACTORY(HTMLSlotElement); | 44 DECLARE_NODE_FACTORY(HTMLSlotElement); |
| 45 | 45 |
| 46 const HeapVector<Member<Node>>& assignedNodes() const { ASSERT(!needsDistrib
utionRecalc()); return m_assignedNodes; } | 46 const HeapVector<Member<Node>>& assignedNodes() const { return m_assignedNod
es; } |
| 47 const HeapVector<Member<Node>>& getDistributedNodes(); | 47 const HeapVector<Member<Node>>& getDistributedNodes(); |
| 48 const HeapVector<Member<Node>> assignedNodesForBinding(const AssignedNodesOp
tions&); | 48 const HeapVector<Member<Node>> assignedNodesForBinding(const AssignedNodesOp
tions&); |
| 49 | 49 |
| 50 Node* firstDistributedNode() const { return m_distributedNodes.isEmpty() ? n
ullptr : m_distributedNodes.first().get(); } | 50 Node* firstDistributedNode() const { return m_distributedNodes.isEmpty() ? n
ullptr : m_distributedNodes.first().get(); } |
| 51 Node* lastDistributedNode() const { return m_distributedNodes.isEmpty() ? nu
llptr : m_distributedNodes.last().get(); } | 51 Node* lastDistributedNode() const { return m_distributedNodes.isEmpty() ? nu
llptr : m_distributedNodes.last().get(); } |
| 52 | 52 |
| 53 Node* distributedNodeNextTo(const Node&) const; | 53 Node* distributedNodeNextTo(const Node&) const; |
| 54 Node* distributedNodePreviousTo(const Node&) const; | 54 Node* distributedNodePreviousTo(const Node&) const; |
| 55 | 55 |
| 56 void appendAssignedNode(Node&); | 56 void appendAssignedNode(Node&); |
| 57 void willUpdateAssignment(); |
| 57 void appendDistributedNode(Node&); | 58 void appendDistributedNode(Node&); |
| 58 void appendDistributedNodesFrom(const HTMLSlotElement& other); | 59 void appendDistributedNodesFrom(const HTMLSlotElement& other); |
| 59 void willUpdateDistribution(); | 60 void willUpdateDistribution(); |
| 61 void appendFallbackNode(Node&); |
| 62 void willUpdateFallback(); |
| 60 | 63 |
| 61 bool hasSlotChangeEventListener(); | 64 void didUpdateAssignment(); |
| 62 | 65 void updateFallbackNodes(); |
| 63 void updateDistributedNodesWithFallback(); | 66 void updateDistributedNodesWithFallback(); |
| 64 void didUpdateDistribution(); | 67 void didUpdateDistribution(); |
| 65 | 68 |
| 69 void fireSlotChangeEvent(); |
| 70 |
| 66 void attach(const AttachContext& = AttachContext()) final; | 71 void attach(const AttachContext& = AttachContext()) final; |
| 67 void detach(const AttachContext& = AttachContext()) final; | 72 void detach(const AttachContext& = AttachContext()) final; |
| 68 | 73 |
| 69 void attributeChanged(const QualifiedName&, const AtomicString& oldValue, co
nst AtomicString& newValue, AttributeModificationReason = ModifiedDirectly) fina
l; | 74 void attributeChanged(const QualifiedName&, const AtomicString& oldValue, co
nst AtomicString& newValue, AttributeModificationReason = ModifiedDirectly) fina
l; |
| 70 | 75 |
| 71 short tabIndex() const override; | 76 short tabIndex() const override; |
| 72 AtomicString name() const; | 77 AtomicString name() const; |
| 73 | 78 |
| 79 bool hasSlotChangeEventInMicrotask() const { return m_slotchangeEventAdded;
} |
| 80 |
| 74 DECLARE_VIRTUAL_TRACE(); | 81 DECLARE_VIRTUAL_TRACE(); |
| 75 | 82 |
| 76 private: | 83 private: |
| 77 HTMLSlotElement(Document&); | 84 HTMLSlotElement(Document&); |
| 78 | 85 |
| 86 enum AssignmentState { |
| 87 AssignmentOnGoing, |
| 88 AssignmentDone, |
| 89 AssignmentChanged, |
| 90 AssignmentUnchanged |
| 91 }; |
| 92 |
| 79 enum DistributionState { | 93 enum DistributionState { |
| 80 DistributionOnGoing, | 94 DistributionOnGoing, |
| 81 DistributionDone, | 95 DistributionDone, |
| 82 DistributionChanged, | 96 DistributionChanged, |
| 83 DistributionUnchanged | 97 DistributionUnchanged |
| 84 }; | 98 }; |
| 85 | 99 |
| 86 void clearDistribution(); | 100 void clearDistribution(); |
| 87 void childrenChanged(const ChildrenChange&) final; | 101 void childrenChanged(const ChildrenChange&) final; |
| 88 InsertionNotificationRequest insertedInto(ContainerNode*) final; | 102 InsertionNotificationRequest insertedInto(ContainerNode*) final; |
| 89 void removedFrom(ContainerNode*) final; | 103 void removedFrom(ContainerNode*) final; |
| 90 void willRecalcStyle(StyleRecalcChange) final; | 104 void willRecalcStyle(StyleRecalcChange) final; |
| 91 | 105 |
| 92 void dispatchSlotChangeEvent(); | 106 void dispatchSlotChangeEvent(); |
| 107 bool assignmentChanged(); |
| 93 bool distributionChanged(); | 108 bool distributionChanged(); |
| 109 bool fallbackChanged(); |
| 94 | 110 |
| 95 HeapVector<Member<Node>> m_assignedNodes; | 111 HeapVector<Member<Node>> m_assignedNodes; |
| 96 HeapVector<Member<Node>> m_distributedNodes; | 112 HeapVector<Member<Node>> m_distributedNodes; |
| 113 HeapVector<Member<Node>> m_fallbackNodes; |
| 97 HeapHashMap<Member<const Node>, size_t> m_distributedIndices; | 114 HeapHashMap<Member<const Node>, size_t> m_distributedIndices; |
| 115 HeapVector<Member<Node>> m_oldAssignedNodes; |
| 98 // TODO(hayato): Remove m_oldDistibutedNodes and make SlotAssignment check t
he diffirence between old and new distributed nodes for each slot to save the me
mories. | 116 // TODO(hayato): Remove m_oldDistibutedNodes and make SlotAssignment check t
he diffirence between old and new distributed nodes for each slot to save the me
mories. |
| 99 HeapVector<Member<Node>> m_oldDistributedNodes; | 117 HeapVector<Member<Node>> m_oldDistributedNodes; |
| 118 HeapVector<Member<Node>> m_oldFallbackNodes; |
| 100 DistributionState m_distributionState; | 119 DistributionState m_distributionState; |
| 120 AssignmentState m_assignmentState; |
| 121 bool m_slotchangeEventAdded; |
| 101 }; | 122 }; |
| 102 | 123 |
| 103 } // namespace blink | 124 } // namespace blink |
| 104 | 125 |
| 105 #endif // HTMLSlotElement_h | 126 #endif // HTMLSlotElement_h |
| OLD | NEW |