OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2014 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "sky/engine/wtf/RefPtr.h" | 34 #include "sky/engine/wtf/RefPtr.h" |
35 #include "sky/engine/wtf/Vector.h" | 35 #include "sky/engine/wtf/Vector.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 class EventPath; | 39 class EventPath; |
40 class EventTarget; | 40 class EventTarget; |
41 class Node; | 41 class Node; |
42 template <typename NodeType> class StaticNodeTypeList; | 42 template <typename NodeType> class StaticNodeTypeList; |
43 typedef StaticNodeTypeList<Node> StaticNodeList; | 43 typedef StaticNodeTypeList<Node> StaticNodeList; |
44 class TouchEventContext; | |
45 class TreeScope; | 44 class TreeScope; |
46 | 45 |
47 class TreeScopeEventContext final : public RefCounted<TreeScopeEventContext> { | 46 class TreeScopeEventContext final : public RefCounted<TreeScopeEventContext> { |
48 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(TreeScopeEventContext); | 47 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(TreeScopeEventContext); |
49 public: | 48 public: |
50 static PassRefPtr<TreeScopeEventContext> create(TreeScope&); | 49 static PassRefPtr<TreeScopeEventContext> create(TreeScope&); |
51 | 50 |
52 TreeScope& treeScope() const { return *m_treeScope; } | 51 TreeScope& treeScope() const { return *m_treeScope; } |
53 | 52 |
54 EventTarget* target() const { return m_target.get(); } | 53 EventTarget* target() const { return m_target.get(); } |
55 void setTarget(PassRefPtr<EventTarget>); | 54 void setTarget(PassRefPtr<EventTarget>); |
56 | 55 |
57 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } | 56 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } |
58 void setRelatedTarget(PassRefPtr<EventTarget>); | 57 void setRelatedTarget(PassRefPtr<EventTarget>); |
59 | 58 |
60 TouchEventContext* touchEventContext() const { return m_touchEventContext.ge
t(); } | |
61 TouchEventContext* ensureTouchEventContext(); | |
62 | |
63 PassRefPtr<StaticNodeList> ensureEventPath(EventPath&); | 59 PassRefPtr<StaticNodeList> ensureEventPath(EventPath&); |
64 | 60 |
65 bool isInclusiveAncestorOf(const TreeScopeEventContext&); | 61 bool isInclusiveAncestorOf(const TreeScopeEventContext&); |
66 void addChild(TreeScopeEventContext& child) { m_children.append(&child); } | 62 void addChild(TreeScopeEventContext& child) { m_children.append(&child); } |
67 | 63 |
68 // For ancestor-descendant relationship check in Q(1). | 64 // For ancestor-descendant relationship check in Q(1). |
69 // Preprocessing takes O(N). | 65 // Preprocessing takes O(N). |
70 int calculatePrePostOrderNumber(int orderNumber); | 66 int calculatePrePostOrderNumber(int orderNumber); |
71 | 67 |
72 private: | 68 private: |
73 TreeScopeEventContext(TreeScope&); | 69 TreeScopeEventContext(TreeScope&); |
74 | 70 |
75 #if ENABLE(ASSERT) | 71 #if ENABLE(ASSERT) |
76 bool isUnreachableNode(EventTarget&); | 72 bool isUnreachableNode(EventTarget&); |
77 #endif | 73 #endif |
78 | 74 |
79 RawPtr<TreeScope> m_treeScope; | 75 RawPtr<TreeScope> m_treeScope; |
80 RefPtr<EventTarget> m_target; | 76 RefPtr<EventTarget> m_target; |
81 RefPtr<EventTarget> m_relatedTarget; | 77 RefPtr<EventTarget> m_relatedTarget; |
82 RefPtr<StaticNodeList> m_eventPath; | 78 RefPtr<StaticNodeList> m_eventPath; |
83 RefPtr<TouchEventContext> m_touchEventContext; | |
84 | 79 |
85 Vector<RawPtr<TreeScopeEventContext> > m_children; | 80 Vector<RawPtr<TreeScopeEventContext> > m_children; |
86 int m_preOrder; | 81 int m_preOrder; |
87 int m_postOrder; | 82 int m_postOrder; |
88 }; | 83 }; |
89 | 84 |
90 #if ENABLE(ASSERT) | 85 #if ENABLE(ASSERT) |
91 inline bool TreeScopeEventContext::isUnreachableNode(EventTarget& target) | 86 inline bool TreeScopeEventContext::isUnreachableNode(EventTarget& target) |
92 { | 87 { |
93 // FIXME: Checks also for SVG elements. | 88 // FIXME: Checks also for SVG elements. |
(...skipping 17 matching lines...) Expand all Loading... |
111 | 106 |
112 inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventCon
text& other) | 107 inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventCon
text& other) |
113 { | 108 { |
114 ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && ot
her.m_postOrder != -1); | 109 ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && ot
her.m_postOrder != -1); |
115 return m_preOrder <= other.m_preOrder && other.m_postOrder <= m_postOrder; | 110 return m_preOrder <= other.m_preOrder && other.m_postOrder <= m_postOrder; |
116 } | 111 } |
117 | 112 |
118 } | 113 } |
119 | 114 |
120 #endif // SKY_ENGINE_CORE_EVENTS_TREESCOPEEVENTCONTEXT_H_ | 115 #endif // SKY_ENGINE_CORE_EVENTS_TREESCOPEEVENTCONTEXT_H_ |
OLD | NEW |