Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: Source/core/events/TreeScopeEventContext.h

Issue 334713006: Use stricter typing for NodeLists throughout the code base (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/events/NodeEventContext.h ('k') | Source/core/events/TreeScopeEventContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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"
32 #include "core/dom/TreeScope.h" 31 #include "core/dom/TreeScope.h"
33 #include "core/events/EventTarget.h" 32 #include "core/events/EventTarget.h"
34 #include "wtf/PassRefPtr.h" 33 #include "wtf/PassRefPtr.h"
35 #include "wtf/RefPtr.h" 34 #include "wtf/RefPtr.h"
36 #include "wtf/Vector.h" 35 #include "wtf/Vector.h"
37 36
38 namespace WebCore { 37 namespace WebCore {
39 38
40 class EventPath; 39 class EventPath;
41 class EventTarget; 40 class EventTarget;
42 class Node; 41 class Node;
42 class StaticNodeList;
43 class TouchEventContext; 43 class TouchEventContext;
44 class TreeScope; 44 class TreeScope;
45 45
46 class TreeScopeEventContext FINAL : public RefCountedWillBeGarbageCollected<Tree ScopeEventContext> { 46 class TreeScopeEventContext FINAL : public RefCountedWillBeGarbageCollected<Tree ScopeEventContext> {
47 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(TreeScopeEventContext); 47 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(TreeScopeEventContext);
48 public: 48 public:
49 static PassRefPtrWillBeRawPtr<TreeScopeEventContext> create(TreeScope&); 49 static PassRefPtrWillBeRawPtr<TreeScopeEventContext> create(TreeScope&);
50 void trace(Visitor*); 50 void trace(Visitor*);
51 51
52 TreeScope& treeScope() const { return *m_treeScope; } 52 TreeScope& treeScope() const { return *m_treeScope; }
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
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
OLDNEW
« no previous file with comments | « Source/core/events/NodeEventContext.h ('k') | Source/core/events/TreeScopeEventContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698