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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/events/EventPath.cpp ('k') | Source/core/events/TreeScopeEventContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/events/TreeScopeEventContext.h
diff --git a/Source/core/events/TreeScopeEventContext.h b/Source/core/events/TreeScopeEventContext.h
index 1dad8e30b1dd75d03d917023319a9db258bdceab..cd9b8f6a27c557fd239cdc47f63031c4898eeeb5 100644
--- a/Source/core/events/TreeScopeEventContext.h
+++ b/Source/core/events/TreeScopeEventContext.h
@@ -65,12 +65,18 @@ public:
WillBeHeapVector<RefPtrWillBeMember<EventTarget>>& ensureEventPath(EventPath&);
- bool isInclusiveAncestorOf(const TreeScopeEventContext&);
+ bool isInclusiveAncestorOf(const TreeScopeEventContext&) const;
+ bool isDescendantOf(const TreeScopeEventContext&) const;
+#if ENABLE(ASSERT)
+ bool isExclusivePartOf(const TreeScopeEventContext&) const;
+#endif
void addChild(TreeScopeEventContext& child) { m_children.append(&child); }
- // For ancestor-descendant relationship check in Q(1).
+ // For ancestor-descendant relationship check in O(1).
// Preprocessing takes O(N).
- int calculatePrePostOrderNumber(int orderNumber);
+ int calculateTreeOrderAndSetNearestAncestorClosedTree(int orderNumber, TreeScopeEventContext* nearestAncestorClosedTreeScopeEventContext);
+
+ TreeScopeEventContext* containingClosedShadowTree() const { return m_containingClosedShadowTree.get(); }
private:
TreeScopeEventContext(TreeScope&);
@@ -79,12 +85,15 @@ private:
bool isUnreachableNode(EventTarget&);
#endif
+ bool isUnclosedTreeOf(const TreeScopeEventContext& other);
+
RawPtrWillBeMember<TreeScope> m_treeScope;
RefPtrWillBeMember<Node> m_rootNode; // Prevents TreeScope from being freed. TreeScope itself isn't RefCounted.
RefPtrWillBeMember<EventTarget> m_target;
RefPtrWillBeMember<EventTarget> m_relatedTarget;
OwnPtrWillBeMember<WillBeHeapVector<RefPtrWillBeMember<EventTarget>>> m_eventPath;
RefPtrWillBeMember<TouchEventContext> m_touchEventContext;
+ RawPtrWillBeMember<TreeScopeEventContext> m_containingClosedShadowTree;
WillBeHeapVector<RawPtrWillBeMember<TreeScopeEventContext>> m_children;
int m_preOrder;
@@ -113,12 +122,27 @@ inline void TreeScopeEventContext::setRelatedTarget(PassRefPtrWillBeRawPtr<Event
m_relatedTarget = relatedTarget;
}
-inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventContext& other)
+inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventContext& other) const
{
ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && other.m_postOrder != -1);
return m_preOrder <= other.m_preOrder && other.m_postOrder <= m_postOrder;
}
+inline bool TreeScopeEventContext::isDescendantOf(const TreeScopeEventContext& other) const
+{
+ ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && other.m_postOrder != -1);
+ return other.m_preOrder < m_preOrder && m_postOrder < other.m_postOrder;
+}
+
+#if ENABLE(ASSERT)
+inline bool TreeScopeEventContext::isExclusivePartOf(const TreeScopeEventContext& other) const
+{
+ ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && other.m_postOrder != -1);
+ return (m_preOrder < other.m_preOrder && m_postOrder < other.m_preOrder)
+ || (m_preOrder > other.m_preOrder && m_preOrder > other.m_postOrder);
+}
+#endif
+
}
#endif // TreeScopeEventContext_h
« 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