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

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

Issue 794123004: Make TreeScopeEventContext have a RefPtr to TreeScope.rootNode to guard TreeScope. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Yet another miinimization Created 6 years 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
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 class TouchEventContext; 44 class TouchEventContext;
45 class TreeScope; 45 class TreeScope;
46 46
47 class TreeScopeEventContext final : public RefCountedWillBeGarbageCollected<Tree ScopeEventContext> { 47 class TreeScopeEventContext final : public RefCountedWillBeGarbageCollected<Tree ScopeEventContext> {
48 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(TreeScopeEventContext); 48 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(TreeScopeEventContext);
49 public: 49 public:
50 static PassRefPtrWillBeRawPtr<TreeScopeEventContext> create(TreeScope&); 50 static PassRefPtrWillBeRawPtr<TreeScopeEventContext> create(TreeScope&);
51 void trace(Visitor*); 51 void trace(Visitor*);
52 52
53 TreeScope& treeScope() const { return *m_treeScope; } 53 TreeScope& treeScope() const { return *m_treeScope; }
54 Node& rootNode() const { return *m_rootNode; }
54 55
55 EventTarget* target() const { return m_target.get(); } 56 EventTarget* target() const { return m_target.get(); }
56 void setTarget(PassRefPtrWillBeRawPtr<EventTarget>); 57 void setTarget(PassRefPtrWillBeRawPtr<EventTarget>);
57 58
58 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } 59 EventTarget* relatedTarget() const { return m_relatedTarget.get(); }
59 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget>); 60 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget>);
60 61
61 TouchEventContext* touchEventContext() const { return m_touchEventContext.ge t(); } 62 TouchEventContext* touchEventContext() const { return m_touchEventContext.ge t(); }
62 TouchEventContext* ensureTouchEventContext(); 63 TouchEventContext* ensureTouchEventContext();
63 64
64 PassRefPtrWillBeRawPtr<StaticNodeList> ensureEventPath(EventPath&); 65 PassRefPtrWillBeRawPtr<StaticNodeList> ensureEventPath(EventPath&);
65 66
66 bool isInclusiveAncestorOf(const TreeScopeEventContext&); 67 bool isInclusiveAncestorOf(const TreeScopeEventContext&);
67 void addChild(TreeScopeEventContext& child) { m_children.append(&child); } 68 void addChild(TreeScopeEventContext& child) { m_children.append(&child); }
68 69
69 // For ancestor-descendant relationship check in Q(1). 70 // For ancestor-descendant relationship check in Q(1).
70 // Preprocessing takes O(N). 71 // Preprocessing takes O(N).
71 int calculatePrePostOrderNumber(int orderNumber); 72 int calculatePrePostOrderNumber(int orderNumber);
72 73
73 private: 74 private:
74 TreeScopeEventContext(TreeScope&); 75 TreeScopeEventContext(TreeScope&);
75 76
76 #if ENABLE(ASSERT) 77 #if ENABLE(ASSERT)
77 bool isUnreachableNode(EventTarget&); 78 bool isUnreachableNode(EventTarget&);
78 #endif 79 #endif
79 80
80 RawPtrWillBeMember<TreeScope> m_treeScope; 81 RawPtrWillBeMember<TreeScope> m_treeScope;
82 RefPtrWillBeMember<Node> m_rootNode; // Prevents TreeScope from being freed. TreeScope itself isn't RefCounted.
81 RefPtrWillBeMember<EventTarget> m_target; 83 RefPtrWillBeMember<EventTarget> m_target;
82 RefPtrWillBeMember<EventTarget> m_relatedTarget; 84 RefPtrWillBeMember<EventTarget> m_relatedTarget;
83 RefPtrWillBeMember<StaticNodeList> m_eventPath; 85 RefPtrWillBeMember<StaticNodeList> m_eventPath;
84 RefPtrWillBeMember<TouchEventContext> m_touchEventContext; 86 RefPtrWillBeMember<TouchEventContext> m_touchEventContext;
85 87
86 WillBeHeapVector<RawPtrWillBeMember<TreeScopeEventContext>> m_children; 88 WillBeHeapVector<RawPtrWillBeMember<TreeScopeEventContext>> m_children;
87 int m_preOrder; 89 int m_preOrder;
88 int m_postOrder; 90 int m_postOrder;
89 }; 91 };
90 92
(...skipping 21 matching lines...) Expand all
112 114
113 inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventCon text& other) 115 inline bool TreeScopeEventContext::isInclusiveAncestorOf(const TreeScopeEventCon text& other)
114 { 116 {
115 ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && ot her.m_postOrder != -1); 117 ASSERT(m_preOrder != -1 && m_postOrder != -1 && other.m_preOrder != -1 && ot her.m_postOrder != -1);
116 return m_preOrder <= other.m_preOrder && other.m_postOrder <= m_postOrder; 118 return m_preOrder <= other.m_preOrder && other.m_postOrder <= m_postOrder;
117 } 119 }
118 120
119 } 121 }
120 122
121 #endif // TreeScopeEventContext_h 123 #endif // TreeScopeEventContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698