OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "sky/engine/core/events/TreeScopeEventContext.h" | 31 #include "sky/engine/core/events/TreeScopeEventContext.h" |
32 #include "sky/engine/platform/heap/Handle.h" | 32 #include "sky/engine/platform/heap/Handle.h" |
33 #include "sky/engine/wtf/HashMap.h" | 33 #include "sky/engine/wtf/HashMap.h" |
34 #include "sky/engine/wtf/Vector.h" | 34 #include "sky/engine/wtf/Vector.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 class Event; | 38 class Event; |
39 class EventTarget; | 39 class EventTarget; |
40 class Node; | 40 class Node; |
41 class TouchEvent; | |
42 class TouchList; | |
43 class TreeScope; | 41 class TreeScope; |
44 | 42 |
45 class EventPath final { | 43 class EventPath final { |
46 public: | 44 public: |
47 explicit EventPath(Event*); | 45 explicit EventPath(Event*); |
48 explicit EventPath(Node*); | 46 explicit EventPath(Node*); |
49 void resetWith(Node*); | 47 void resetWith(Node*); |
50 | 48 |
51 NodeEventContext& operator[](size_t index) { return m_nodeEventContexts[inde
x]; } | 49 NodeEventContext& operator[](size_t index) { return m_nodeEventContexts[inde
x]; } |
52 const NodeEventContext& operator[](size_t index) const { return m_nodeEventC
ontexts[index]; } | 50 const NodeEventContext& operator[](size_t index) const { return m_nodeEventC
ontexts[index]; } |
53 NodeEventContext& last() { return m_nodeEventContexts[size() - 1]; } | 51 NodeEventContext& last() { return m_nodeEventContexts[size() - 1]; } |
54 | 52 |
55 bool isEmpty() const { return m_nodeEventContexts.isEmpty(); } | 53 bool isEmpty() const { return m_nodeEventContexts.isEmpty(); } |
56 size_t size() const { return m_nodeEventContexts.size(); } | 54 size_t size() const { return m_nodeEventContexts.size(); } |
57 | 55 |
58 void adjustForRelatedTarget(Node*, EventTarget* relatedTarget); | 56 void adjustForRelatedTarget(Node*, EventTarget* relatedTarget); |
59 void adjustForTouchEvent(Node*, TouchEvent&); | |
60 | 57 |
61 static EventTarget* eventTargetRespectingTargetRules(Node*); | 58 static EventTarget* eventTargetRespectingTargetRules(Node*); |
62 | 59 |
63 private: | 60 private: |
64 EventPath(); | 61 EventPath(); |
65 | 62 |
66 NodeEventContext& at(size_t index) { return m_nodeEventContexts[index]; } | 63 NodeEventContext& at(size_t index) { return m_nodeEventContexts[index]; } |
67 | 64 |
68 void addNodeEventContext(Node*); | 65 void addNodeEventContext(Node*); |
69 | 66 |
70 void calculatePath(); | 67 void calculatePath(); |
71 void calculateAdjustedTargets(); | 68 void calculateAdjustedTargets(); |
72 void calculateTreeScopePrePostOrderNumbers(); | 69 void calculateTreeScopePrePostOrderNumbers(); |
73 | 70 |
74 void shrink(size_t newSize) { m_nodeEventContexts.shrink(newSize); } | 71 void shrink(size_t newSize) { m_nodeEventContexts.shrink(newSize); } |
75 void shrinkIfNeeded(const Node* target, const EventTarget* relatedTarget); | 72 void shrinkIfNeeded(const Node* target, const EventTarget* relatedTarget); |
76 | 73 |
77 void adjustTouchList(const Node*, const TouchList*, Vector<RawPtr<TouchList>
> adjustedTouchList, const Vector<RawPtr<TreeScope> >& treeScopes); | |
78 | |
79 typedef HashMap<RawPtr<TreeScope>, RefPtr<TreeScopeEventContext> > TreeScope
EventContextMap; | 74 typedef HashMap<RawPtr<TreeScope>, RefPtr<TreeScopeEventContext> > TreeScope
EventContextMap; |
80 TreeScopeEventContext* ensureTreeScopeEventContext(Node* currentTarget, Tree
Scope*, TreeScopeEventContextMap&); | 75 TreeScopeEventContext* ensureTreeScopeEventContext(Node* currentTarget, Tree
Scope*, TreeScopeEventContextMap&); |
81 | 76 |
82 typedef HashMap<RawPtr<TreeScope>, RawPtr<EventTarget> > RelatedTargetMap; | 77 typedef HashMap<RawPtr<TreeScope>, RawPtr<EventTarget> > RelatedTargetMap; |
83 | 78 |
84 static void buildRelatedNodeMap(const Node*, RelatedTargetMap&); | 79 static void buildRelatedNodeMap(const Node*, RelatedTargetMap&); |
85 static EventTarget* findRelatedNode(TreeScope*, RelatedTargetMap&); | 80 static EventTarget* findRelatedNode(TreeScope*, RelatedTargetMap&); |
86 | 81 |
87 #if ENABLE(ASSERT) | |
88 static void checkReachability(TreeScope&, TouchList&); | |
89 #endif | |
90 | |
91 Vector<NodeEventContext, 64> m_nodeEventContexts; | 82 Vector<NodeEventContext, 64> m_nodeEventContexts; |
92 RawPtr<Node> m_node; | 83 RawPtr<Node> m_node; |
93 RawPtr<Event> m_event; | 84 RawPtr<Event> m_event; |
94 Vector<RefPtr<TreeScopeEventContext> > m_treeScopeEventContexts; | 85 Vector<RefPtr<TreeScopeEventContext> > m_treeScopeEventContexts; |
95 }; | 86 }; |
96 | 87 |
97 } // namespace | 88 } // namespace |
98 | 89 |
99 #endif // SKY_ENGINE_CORE_EVENTS_EVENTPATH_H_ | 90 #endif // SKY_ENGINE_CORE_EVENTS_EVENTPATH_H_ |
OLD | NEW |