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

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

Issue 1305733002: Fix for calculation of event.path for closed mode shadow root (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: isUnclosedTreeOf() Created 5 years, 3 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/EventPath.cpp ('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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void setTarget(PassRefPtrWillBeRawPtr<EventTarget>); 58 void setTarget(PassRefPtrWillBeRawPtr<EventTarget>);
59 59
60 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } 60 EventTarget* relatedTarget() const { return m_relatedTarget.get(); }
61 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget>); 61 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget>);
62 62
63 TouchEventContext* touchEventContext() const { return m_touchEventContext.ge t(); } 63 TouchEventContext* touchEventContext() const { return m_touchEventContext.ge t(); }
64 TouchEventContext* ensureTouchEventContext(); 64 TouchEventContext* ensureTouchEventContext();
65 65
66 WillBeHeapVector<RefPtrWillBeMember<EventTarget>>& ensureEventPath(EventPath &); 66 WillBeHeapVector<RefPtrWillBeMember<EventTarget>>& ensureEventPath(EventPath &);
67 67
68 bool isInclusiveAncestorOf(const TreeScopeEventContext&); 68 bool isInclusiveAncestorOf(const TreeScopeEventContext&) const;
69 bool isDescendantOf(const TreeScopeEventContext&) const;
70 #if ENABLE(ASSERT)
71 bool isExclusivePartOf(const TreeScopeEventContext&) const;
72 #endif
69 void addChild(TreeScopeEventContext& child) { m_children.append(&child); } 73 void addChild(TreeScopeEventContext& child) { m_children.append(&child); }
70 74
71 // For ancestor-descendant relationship check in Q(1). 75 // For ancestor-descendant relationship check in O(1).
72 // Preprocessing takes O(N). 76 // Preprocessing takes O(N).
73 int calculatePrePostOrderNumber(int orderNumber); 77 int calculateTreeOrderAndSetNearestAncestorClosedTree(int orderNumber, TreeS copeEventContext* nearestAncestorClosedTreeScopeEventContext);
78
79 TreeScopeEventContext* containingClosedShadowTree() const { return m_contain ingClosedShadowTree.get(); }
74 80
75 private: 81 private:
76 TreeScopeEventContext(TreeScope&); 82 TreeScopeEventContext(TreeScope&);
77 83
78 #if ENABLE(ASSERT) 84 #if ENABLE(ASSERT)
79 bool isUnreachableNode(EventTarget&); 85 bool isUnreachableNode(EventTarget&);
80 #endif 86 #endif
81 87
88 bool isUnclosedTreeOf(const TreeScopeEventContext& other);
89
82 RawPtrWillBeMember<TreeScope> m_treeScope; 90 RawPtrWillBeMember<TreeScope> m_treeScope;
83 RefPtrWillBeMember<Node> m_rootNode; // Prevents TreeScope from being freed. TreeScope itself isn't RefCounted. 91 RefPtrWillBeMember<Node> m_rootNode; // Prevents TreeScope from being freed. TreeScope itself isn't RefCounted.
84 RefPtrWillBeMember<EventTarget> m_target; 92 RefPtrWillBeMember<EventTarget> m_target;
85 RefPtrWillBeMember<EventTarget> m_relatedTarget; 93 RefPtrWillBeMember<EventTarget> m_relatedTarget;
86 OwnPtrWillBeMember<WillBeHeapVector<RefPtrWillBeMember<EventTarget>>> m_even tPath; 94 OwnPtrWillBeMember<WillBeHeapVector<RefPtrWillBeMember<EventTarget>>> m_even tPath;
87 RefPtrWillBeMember<TouchEventContext> m_touchEventContext; 95 RefPtrWillBeMember<TouchEventContext> m_touchEventContext;
96 RawPtrWillBeMember<TreeScopeEventContext> m_containingClosedShadowTree;
88 97
89 WillBeHeapVector<RawPtrWillBeMember<TreeScopeEventContext>> m_children; 98 WillBeHeapVector<RawPtrWillBeMember<TreeScopeEventContext>> m_children;
90 int m_preOrder; 99 int m_preOrder;
91 int m_postOrder; 100 int m_postOrder;
92 }; 101 };
93 102
94 #if ENABLE(ASSERT) 103 #if ENABLE(ASSERT)
95 inline bool TreeScopeEventContext::isUnreachableNode(EventTarget& target) 104 inline bool TreeScopeEventContext::isUnreachableNode(EventTarget& target)
96 { 105 {
97 // FIXME: Checks also for SVG elements. 106 // FIXME: Checks also for SVG elements.
98 return target.toNode() && !target.toNode()->isSVGElement() && !target.toNode ()->treeScope().isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(treeScope ()); 107 return target.toNode() && !target.toNode()->isSVGElement() && !target.toNode ()->treeScope().isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(treeScope ());
99 } 108 }
100 #endif 109 #endif
101 110
102 inline void TreeScopeEventContext::setTarget(PassRefPtrWillBeRawPtr<EventTarget> target) 111 inline void TreeScopeEventContext::setTarget(PassRefPtrWillBeRawPtr<EventTarget> target)
103 { 112 {
104 ASSERT(target); 113 ASSERT(target);
105 ASSERT(!isUnreachableNode(*target)); 114 ASSERT(!isUnreachableNode(*target));
106 m_target = target; 115 m_target = target;
107 } 116 }
108 117
109 inline void TreeScopeEventContext::setRelatedTarget(PassRefPtrWillBeRawPtr<Event Target> relatedTarget) 118 inline void TreeScopeEventContext::setRelatedTarget(PassRefPtrWillBeRawPtr<Event Target> relatedTarget)
110 { 119 {
111 ASSERT(relatedTarget); 120 ASSERT(relatedTarget);
112 ASSERT(!isUnreachableNode(*relatedTarget)); 121 ASSERT(!isUnreachableNode(*relatedTarget));
113 m_relatedTarget = relatedTarget; 122 m_relatedTarget = relatedTarget;
114 } 123 }
115 124
116 inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventCon text& other) 125 inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventCon text& other) const
117 { 126 {
118 ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && ot her.m_postOrder != -1); 127 ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && ot her.m_postOrder != -1);
119 return m_preOrder <= other.m_preOrder && other.m_postOrder <= m_postOrder; 128 return m_preOrder <= other.m_preOrder && other.m_postOrder <= m_postOrder;
120 } 129 }
121 130
131 inline bool TreeScopeEventContext::isDescendantOf(const TreeScopeEventContext& o ther) const
132 {
133 ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && ot her.m_postOrder != -1);
134 return other.m_preOrder < m_preOrder && m_postOrder < other.m_postOrder;
135 }
136
137 #if ENABLE(ASSERT)
138 inline bool TreeScopeEventContext::isExclusivePartOf(const TreeScopeEventContext & other) const
139 {
140 ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && ot her.m_postOrder != -1);
141 return (m_preOrder < other.m_preOrder && m_postOrder < other.m_preOrder)
142 || (m_preOrder > other.m_preOrder && m_preOrder > other.m_postOrder);
143 }
144 #endif
145
122 } 146 }
123 147
124 #endif // TreeScopeEventContext_h 148 #endif // TreeScopeEventContext_h
OLDNEW
« no previous file with comments | « Source/core/events/EventPath.cpp ('k') | Source/core/events/TreeScopeEventContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698