| 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 10 matching lines...) Expand all Loading... |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 * | 24 * |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef TreeScopeEventContext_h | 27 #ifndef TreeScopeEventContext_h |
| 28 #define TreeScopeEventContext_h | 28 #define TreeScopeEventContext_h |
| 29 | 29 |
| 30 #include "core/dom/Node.h" | 30 #include "core/dom/Node.h" |
| 31 #include "core/dom/NodeList.h" | 31 #include "core/dom/StaticNodeList.h" |
| 32 #include "core/dom/TreeScope.h" | 32 #include "core/dom/TreeScope.h" |
| 33 #include "core/events/EventTarget.h" | 33 #include "core/events/EventTarget.h" |
| 34 #include "wtf/PassRefPtr.h" | 34 #include "wtf/PassRefPtr.h" |
| 35 #include "wtf/RefPtr.h" | 35 #include "wtf/RefPtr.h" |
| 36 #include "wtf/Vector.h" | 36 #include "wtf/Vector.h" |
| 37 | 37 |
| 38 namespace WebCore { | 38 namespace WebCore { |
| 39 | 39 |
| 40 class EventPath; | 40 class EventPath; |
| 41 class EventTarget; | 41 class EventTarget; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 53 | 53 |
| 54 EventTarget* target() const { return m_target.get(); } | 54 EventTarget* target() const { return m_target.get(); } |
| 55 void setTarget(PassRefPtrWillBeRawPtr<EventTarget>); | 55 void setTarget(PassRefPtrWillBeRawPtr<EventTarget>); |
| 56 | 56 |
| 57 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } | 57 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } |
| 58 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget>); | 58 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget>); |
| 59 | 59 |
| 60 TouchEventContext* touchEventContext() const { return m_touchEventContext.ge
t(); } | 60 TouchEventContext* touchEventContext() const { return m_touchEventContext.ge
t(); } |
| 61 TouchEventContext* ensureTouchEventContext(); | 61 TouchEventContext* ensureTouchEventContext(); |
| 62 | 62 |
| 63 PassRefPtrWillBeRawPtr<NodeList> ensureEventPath(EventPath&); | 63 PassRefPtrWillBeRawPtr<StaticNodeList> ensureEventPath(EventPath&); |
| 64 | 64 |
| 65 bool isInclusiveAncestorOf(const TreeScopeEventContext&); | 65 bool isInclusiveAncestorOf(const TreeScopeEventContext&); |
| 66 void addChild(TreeScopeEventContext& child) { m_children.append(&child); } | 66 void addChild(TreeScopeEventContext& child) { m_children.append(&child); } |
| 67 | 67 |
| 68 // For ancestor-descendant relationship check in Q(1). | 68 // For ancestor-descendant relationship check in Q(1). |
| 69 // Preprocessing takes O(N). | 69 // Preprocessing takes O(N). |
| 70 int calculatePrePostOrderNumber(int orderNumber); | 70 int calculatePrePostOrderNumber(int orderNumber); |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 TreeScopeEventContext(TreeScope&); | 73 TreeScopeEventContext(TreeScope&); |
| 74 | 74 |
| 75 #ifndef NDEBUG | 75 #ifndef NDEBUG |
| 76 bool isUnreachableNode(EventTarget&); | 76 bool isUnreachableNode(EventTarget&); |
| 77 #endif | 77 #endif |
| 78 | 78 |
| 79 RawPtrWillBeMember<TreeScope> m_treeScope; | 79 RawPtrWillBeMember<TreeScope> m_treeScope; |
| 80 RefPtrWillBeMember<EventTarget> m_target; | 80 RefPtrWillBeMember<EventTarget> m_target; |
| 81 RefPtrWillBeMember<EventTarget> m_relatedTarget; | 81 RefPtrWillBeMember<EventTarget> m_relatedTarget; |
| 82 RefPtrWillBeMember<NodeList> m_eventPath; | 82 RefPtrWillBeMember<StaticNodeList> m_eventPath; |
| 83 RefPtrWillBeMember<TouchEventContext> m_touchEventContext; | 83 RefPtrWillBeMember<TouchEventContext> m_touchEventContext; |
| 84 | 84 |
| 85 WillBeHeapVector<RawPtrWillBeMember<TreeScopeEventContext> > m_children; | 85 WillBeHeapVector<RawPtrWillBeMember<TreeScopeEventContext> > m_children; |
| 86 int m_preOrder; | 86 int m_preOrder; |
| 87 int m_postOrder; | 87 int m_postOrder; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 #ifndef NDEBUG | 90 #ifndef NDEBUG |
| 91 inline bool TreeScopeEventContext::isUnreachableNode(EventTarget& target) | 91 inline bool TreeScopeEventContext::isUnreachableNode(EventTarget& target) |
| 92 { | 92 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 111 | 111 |
| 112 inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventCon
text& other) | 112 inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventCon
text& other) |
| 113 { | 113 { |
| 114 ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && ot
her.m_postOrder != -1); | 114 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; | 115 return m_preOrder <= other.m_preOrder && other.m_postOrder <= m_postOrder; |
| 116 } | 116 } |
| 117 | 117 |
| 118 } | 118 } |
| 119 | 119 |
| 120 #endif // TreeScopeEventContext_h | 120 #endif // TreeScopeEventContext_h |
| OLD | NEW |