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

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

Issue 2270293002: Replace ASSERT*() with DCHECK*() in core/events/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: isUnreachableNode -> checkReachableNode Created 4 years, 4 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
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } 57 EventTarget* relatedTarget() const { return m_relatedTarget.get(); }
58 void setRelatedTarget(EventTarget*); 58 void setRelatedTarget(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 HeapVector<Member<EventTarget>>& ensureEventPath(EventPath&); 63 HeapVector<Member<EventTarget>>& ensureEventPath(EventPath&);
64 64
65 bool isInclusiveAncestorOf(const TreeScopeEventContext&) const; 65 bool isInclusiveAncestorOf(const TreeScopeEventContext&) const;
66 bool isDescendantOf(const TreeScopeEventContext&) const; 66 bool isDescendantOf(const TreeScopeEventContext&) const;
67 #if ENABLE(ASSERT) 67 #if DCHECK_IS_ON()
68 bool isExclusivePartOf(const TreeScopeEventContext&) const; 68 bool isExclusivePartOf(const TreeScopeEventContext&) const;
69 #endif 69 #endif
70 void addChild(TreeScopeEventContext& child) { m_children.append(&child); } 70 void addChild(TreeScopeEventContext& child) { m_children.append(&child); }
71 71
72 // For ancestor-descendant relationship check in O(1). 72 // For ancestor-descendant relationship check in O(1).
73 // Preprocessing takes O(N). 73 // Preprocessing takes O(N).
74 int calculateTreeOrderAndSetNearestAncestorClosedTree(int orderNumber, TreeS copeEventContext* nearestAncestorClosedTreeScopeEventContext); 74 int calculateTreeOrderAndSetNearestAncestorClosedTree(int orderNumber, TreeS copeEventContext* nearestAncestorClosedTreeScopeEventContext);
75 75
76 TreeScopeEventContext* containingClosedShadowTree() const { return m_contain ingClosedShadowTree.get(); } 76 TreeScopeEventContext* containingClosedShadowTree() const { return m_contain ingClosedShadowTree.get(); }
77 77
78 private: 78 private:
79 TreeScopeEventContext(TreeScope&); 79 TreeScopeEventContext(TreeScope&);
80 80
81 #if ENABLE(ASSERT) 81 void checkReachableNode(EventTarget&);
82 bool isUnreachableNode(EventTarget&);
83 #endif
84 82
85 bool isUnclosedTreeOf(const TreeScopeEventContext& other); 83 bool isUnclosedTreeOf(const TreeScopeEventContext& other);
86 84
87 Member<TreeScope> m_treeScope; 85 Member<TreeScope> m_treeScope;
88 Member<Node> m_rootNode; // Prevents TreeScope from being freed. TreeScope i tself isn't RefCounted. 86 Member<Node> m_rootNode; // Prevents TreeScope from being freed. TreeScope i tself isn't RefCounted.
89 Member<EventTarget> m_target; 87 Member<EventTarget> m_target;
90 Member<EventTarget> m_relatedTarget; 88 Member<EventTarget> m_relatedTarget;
91 Member<HeapVector<Member<EventTarget>>> m_eventPath; 89 Member<HeapVector<Member<EventTarget>>> m_eventPath;
92 Member<TouchEventContext> m_touchEventContext; 90 Member<TouchEventContext> m_touchEventContext;
93 Member<TreeScopeEventContext> m_containingClosedShadowTree; 91 Member<TreeScopeEventContext> m_containingClosedShadowTree;
94 92
95 HeapVector<Member<TreeScopeEventContext>> m_children; 93 HeapVector<Member<TreeScopeEventContext>> m_children;
96 int m_preOrder; 94 int m_preOrder;
97 int m_postOrder; 95 int m_postOrder;
98 }; 96 };
99 97
100 #if ENABLE(ASSERT) 98 #if DCHECK_IS_ON()
101 inline bool TreeScopeEventContext::isUnreachableNode(EventTarget& target) 99 inline void TreeScopeEventContext::checkReachableNode(EventTarget& target)
102 { 100 {
101 if (!target.toNode())
102 return;
103 // FIXME: Checks also for SVG elements. 103 // FIXME: Checks also for SVG elements.
104 return target.toNode() && !target.toNode()->isSVGElement() && !target.toNode ()->treeScope().isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(treeScope ()); 104 if (target.toNode()->isSVGElement())
105 return;
106 DCHECK(target.toNode()->treeScope().isInclusiveOlderSiblingShadowRootOrAnces torTreeScopeOf(treeScope()));
107 }
108 #else
109 inline void TreeScopeEventContext::checkReachableNode(EventTarget&)
110 {
105 } 111 }
106 #endif 112 #endif
107 113
108 inline void TreeScopeEventContext::setTarget(EventTarget* target) 114 inline void TreeScopeEventContext::setTarget(EventTarget* target)
109 { 115 {
110 ASSERT(target); 116 DCHECK(target);
111 ASSERT(!isUnreachableNode(*target)); 117 checkReachableNode(*target);
112 m_target = target; 118 m_target = target;
113 } 119 }
114 120
115 inline void TreeScopeEventContext::setRelatedTarget(EventTarget* relatedTarget) 121 inline void TreeScopeEventContext::setRelatedTarget(EventTarget* relatedTarget)
116 { 122 {
117 ASSERT(relatedTarget); 123 DCHECK(relatedTarget);
118 ASSERT(!isUnreachableNode(*relatedTarget)); 124 checkReachableNode(*relatedTarget);
119 m_relatedTarget = relatedTarget; 125 m_relatedTarget = relatedTarget;
120 } 126 }
121 127
122 inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventCon text& other) const 128 inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventCon text& other) const
123 { 129 {
124 ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && ot her.m_postOrder != -1); 130 DCHECK_NE(m_preOrder, -1);
131 DCHECK_NE(m_postOrder, -1);
132 DCHECK_NE(other.m_preOrder, -1);
133 DCHECK_NE(other.m_postOrder, -1);
125 return m_preOrder <= other.m_preOrder && other.m_postOrder <= m_postOrder; 134 return m_preOrder <= other.m_preOrder && other.m_postOrder <= m_postOrder;
126 } 135 }
127 136
128 inline bool TreeScopeEventContext::isDescendantOf(const TreeScopeEventContext& o ther) const 137 inline bool TreeScopeEventContext::isDescendantOf(const TreeScopeEventContext& o ther) const
129 { 138 {
130 ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && ot her.m_postOrder != -1); 139 DCHECK_NE(m_preOrder, -1);
140 DCHECK_NE(m_postOrder, -1);
141 DCHECK_NE(other.m_preOrder, -1);
142 DCHECK_NE(other.m_postOrder, -1);
131 return other.m_preOrder < m_preOrder && m_postOrder < other.m_postOrder; 143 return other.m_preOrder < m_preOrder && m_postOrder < other.m_postOrder;
132 } 144 }
133 145
134 #if ENABLE(ASSERT) 146 #if DCHECK_IS_ON()
135 inline bool TreeScopeEventContext::isExclusivePartOf(const TreeScopeEventContext & other) const 147 inline bool TreeScopeEventContext::isExclusivePartOf(const TreeScopeEventContext & other) const
136 { 148 {
137 ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && ot her.m_postOrder != -1); 149 DCHECK_NE(m_preOrder, -1);
150 DCHECK_NE(m_postOrder, -1);
151 DCHECK_NE(other.m_preOrder, -1);
152 DCHECK_NE(other.m_postOrder, -1);
138 return (m_preOrder < other.m_preOrder && m_postOrder < other.m_preOrder) 153 return (m_preOrder < other.m_preOrder && m_postOrder < other.m_preOrder)
139 || (m_preOrder > other.m_preOrder && m_preOrder > other.m_postOrder); 154 || (m_preOrder > other.m_preOrder && m_preOrder > other.m_postOrder);
140 } 155 }
141 #endif 156 #endif
142 157
143 } // namespace blink 158 } // namespace blink
144 159
145 #endif // TreeScopeEventContext_h 160 #endif // TreeScopeEventContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698