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 |
74 DECLARE_VIRTUAL_TRACE(); | 79 DECLARE_VIRTUAL_TRACE(); |
75 | 80 |
76 private: | 81 private: |
77 HTMLSlotElement(Document&); | 82 HTMLSlotElement(Document&); |
78 | 83 |
| 84 enum AssignmentState { |
| 85 AssignmentOnGoing, |
| 86 AssignmentDone, |
| 87 AssignmentChanged, |
| 88 AssignmentUnchanged |
| 89 }; |
| 90 |
79 enum DistributionState { | 91 enum DistributionState { |
80 DistributionOnGoing, | 92 DistributionOnGoing, |
81 DistributionDone, | 93 DistributionDone, |
82 DistributionChanged, | 94 DistributionChanged, |
83 DistributionUnchanged | 95 DistributionUnchanged |
84 }; | 96 }; |
85 | 97 |
86 void clearDistribution(); | 98 void clearDistribution(); |
87 void childrenChanged(const ChildrenChange&) final; | 99 void childrenChanged(const ChildrenChange&) final; |
88 InsertionNotificationRequest insertedInto(ContainerNode*) final; | 100 InsertionNotificationRequest insertedInto(ContainerNode*) final; |
89 void removedFrom(ContainerNode*) final; | 101 void removedFrom(ContainerNode*) final; |
90 void willRecalcStyle(StyleRecalcChange) final; | 102 void willRecalcStyle(StyleRecalcChange) final; |
91 | 103 |
92 void dispatchSlotChangeEvent(); | 104 void dispatchSlotChangeEvent(); |
| 105 bool assignmentChanged(); |
93 bool distributionChanged(); | 106 bool distributionChanged(); |
| 107 bool fallbackChanged(); |
94 | 108 |
95 HeapVector<Member<Node>> m_assignedNodes; | 109 HeapVector<Member<Node>> m_assignedNodes; |
96 HeapVector<Member<Node>> m_distributedNodes; | 110 HeapVector<Member<Node>> m_distributedNodes; |
| 111 HeapVector<Member<Node>> m_fallbackNodes; |
97 HeapHashMap<Member<const Node>, size_t> m_distributedIndices; | 112 HeapHashMap<Member<const Node>, size_t> m_distributedIndices; |
| 113 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. | 114 // 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; | 115 HeapVector<Member<Node>> m_oldDistributedNodes; |
| 116 HeapVector<Member<Node>> m_oldFallbackNodes; |
100 DistributionState m_distributionState; | 117 DistributionState m_distributionState; |
| 118 AssignmentState m_assignmentState; |
| 119 bool m_slotchangeEventAdded; |
101 }; | 120 }; |
102 | 121 |
103 } // namespace blink | 122 } // namespace blink |
104 | 123 |
105 #endif // HTMLSlotElement_h | 124 #endif // HTMLSlotElement_h |
OLD | NEW |