Chromium Code Reviews| 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 25 matching lines...) Expand all Loading... | |
| 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; |
| 42 class Node; | 42 class Node; |
| 43 class TouchEventContext; | 43 class TouchEventContext; |
| 44 class TreeScope; | 44 class TreeScope; |
| 45 | 45 |
| 46 class TreeScopeEventContext : public RefCounted<TreeScopeEventContext> { | 46 class TreeScopeEventContext : public RefCountedWillBeGarbageCollected<TreeScopeE ventContext> { |
|
haraken
2014/06/12 05:51:43
Add FINAL.
tkent
2014/06/12 06:24:48
Done.
| |
| 47 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(TreeScopeEventContext); | |
| 47 public: | 48 public: |
| 48 static PassRefPtr<TreeScopeEventContext> create(TreeScope&); | 49 static PassRefPtrWillBeRawPtr<TreeScopeEventContext> create(TreeScope&); |
| 49 ~TreeScopeEventContext(); | 50 void trace(Visitor*); |
| 50 | 51 |
| 51 TreeScope& treeScope() const { return m_treeScope; } | 52 TreeScope& treeScope() const { return *m_treeScope; } |
| 52 | 53 |
| 53 EventTarget* target() const { return m_target.get(); } | 54 EventTarget* target() const { return m_target.get(); } |
| 54 void setTarget(PassRefPtrWillBeRawPtr<EventTarget>); | 55 void setTarget(PassRefPtrWillBeRawPtr<EventTarget>); |
| 55 | 56 |
| 56 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } | 57 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } |
| 57 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget>); | 58 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget>); |
| 58 | 59 |
| 59 TouchEventContext* touchEventContext() const { return m_touchEventContext.ge t(); } | 60 TouchEventContext* touchEventContext() const { return m_touchEventContext.ge t(); } |
| 60 TouchEventContext* ensureTouchEventContext(); | 61 TouchEventContext* ensureTouchEventContext(); |
| 61 | 62 |
| 62 PassRefPtrWillBeRawPtr<NodeList> ensureEventPath(EventPath&); | 63 PassRefPtrWillBeRawPtr<NodeList> ensureEventPath(EventPath&); |
| 63 | 64 |
| 64 bool isInclusiveAncestorOf(const TreeScopeEventContext&); | 65 bool isInclusiveAncestorOf(const TreeScopeEventContext&); |
| 65 void addChild(TreeScopeEventContext& child) { m_children.append(&child); } | 66 void addChild(TreeScopeEventContext& child) { m_children.append(&child); } |
| 66 | 67 |
| 67 // For ancestor-descendant relationship check in Q(1). | 68 // For ancestor-descendant relationship check in Q(1). |
| 68 // Preprocessing takes O(N). | 69 // Preprocessing takes O(N). |
| 69 int calculatePrePostOrderNumber(int orderNumber); | 70 int calculatePrePostOrderNumber(int orderNumber); |
| 70 | 71 |
| 71 private: | 72 private: |
| 72 TreeScopeEventContext(TreeScope&); | 73 TreeScopeEventContext(TreeScope&); |
| 73 | 74 |
| 74 #ifndef NDEBUG | 75 #ifndef NDEBUG |
| 75 bool isUnreachableNode(EventTarget&); | 76 bool isUnreachableNode(EventTarget&); |
| 76 #endif | 77 #endif |
| 77 | 78 |
| 78 TreeScope& m_treeScope; | 79 RawPtrWillBeMember<TreeScope> m_treeScope; |
| 79 RefPtrWillBePersistent<EventTarget> m_target; | 80 RefPtrWillBeMember<EventTarget> m_target; |
| 80 RefPtrWillBePersistent<EventTarget> m_relatedTarget; | 81 RefPtrWillBeMember<EventTarget> m_relatedTarget; |
| 81 RefPtrWillBePersistent<NodeList> m_eventPath; | 82 RefPtrWillBeMember<NodeList> m_eventPath; |
| 82 RefPtrWillBePersistent<TouchEventContext> m_touchEventContext; | 83 RefPtrWillBeMember<TouchEventContext> m_touchEventContext; |
| 83 | 84 |
| 84 Vector<TreeScopeEventContext*> m_children; | 85 WillBeHeapVector<RawPtrWillBeMember<TreeScopeEventContext> > m_children; |
| 85 int m_preOrder; | 86 int m_preOrder; |
| 86 int m_postOrder; | 87 int m_postOrder; |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 #ifndef NDEBUG | 90 #ifndef NDEBUG |
| 90 inline bool TreeScopeEventContext::isUnreachableNode(EventTarget& target) | 91 inline bool TreeScopeEventContext::isUnreachableNode(EventTarget& target) |
| 91 { | 92 { |
| 92 // FIXME: Checks also for SVG elements. | 93 // FIXME: Checks also for SVG elements. |
| 93 return target.toNode() && !target.toNode()->isSVGElement() && !target.toNode ()->treeScope().isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(m_treeSco pe); | 94 return target.toNode() && !target.toNode()->isSVGElement() && !target.toNode ()->treeScope().isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(treeScope ()); |
| 94 } | 95 } |
| 95 #endif | 96 #endif |
| 96 | 97 |
| 97 inline void TreeScopeEventContext::setTarget(PassRefPtrWillBeRawPtr<EventTarget> target) | 98 inline void TreeScopeEventContext::setTarget(PassRefPtrWillBeRawPtr<EventTarget> target) |
| 98 { | 99 { |
| 99 ASSERT(target); | 100 ASSERT(target); |
| 100 ASSERT(!isUnreachableNode(*target)); | 101 ASSERT(!isUnreachableNode(*target)); |
| 101 m_target = target; | 102 m_target = target; |
| 102 } | 103 } |
| 103 | 104 |
| 104 inline void TreeScopeEventContext::setRelatedTarget(PassRefPtrWillBeRawPtr<Event Target> relatedTarget) | 105 inline void TreeScopeEventContext::setRelatedTarget(PassRefPtrWillBeRawPtr<Event Target> relatedTarget) |
| 105 { | 106 { |
| 106 ASSERT(relatedTarget); | 107 ASSERT(relatedTarget); |
| 107 ASSERT(!isUnreachableNode(*relatedTarget)); | 108 ASSERT(!isUnreachableNode(*relatedTarget)); |
| 108 m_relatedTarget = relatedTarget; | 109 m_relatedTarget = relatedTarget; |
| 109 } | 110 } |
| 110 | 111 |
| 111 inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventCon text& other) | 112 inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventCon text& other) |
| 112 { | 113 { |
| 113 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); |
| 114 return m_preOrder <= other.m_preOrder && other.m_postOrder <= m_postOrder; | 115 return m_preOrder <= other.m_preOrder && other.m_postOrder <= m_postOrder; |
| 115 } | 116 } |
| 116 | 117 |
| 117 } | 118 } |
| 118 | 119 |
| 119 #endif // TreeScopeEventContext_h | 120 #endif // TreeScopeEventContext_h |
| OLD | NEW |