Commit 0b144341 authored by tkent@chromium.org's avatar tkent@chromium.org

Oilpan: Improve Oilpan support in EventContext and EventPath.

* TreeScopeEventContext
 Move to Oilpan heap.
* WindowEvnetContext
 Declare as STACK_ALLOCATED(), and remove Persistent<>s.
* EventPath
 Eliminate raw pointers.

BUG=

Review URL: https://codereview.chromium.org/336463002

git-svn-id: svn://svn.chromium.org/blink/trunk@176114 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e9795d60
...@@ -80,7 +80,7 @@ static inline EventDispatchBehavior determineDispatchBehavior(Event* event, Shad ...@@ -80,7 +80,7 @@ static inline EventDispatchBehavior determineDispatchBehavior(Event* event, Shad
} }
EventPath::EventPath(Event* event) EventPath::EventPath(Event* event)
: m_node(0) : m_node(nullptr)
, m_event(event) , m_event(event)
{ {
} }
...@@ -112,7 +112,7 @@ void EventPath::calculatePath() ...@@ -112,7 +112,7 @@ void EventPath::calculatePath()
{ {
ASSERT(m_node); ASSERT(m_node);
ASSERT(m_nodeEventContexts.isEmpty()); ASSERT(m_nodeEventContexts.isEmpty());
m_node->document().updateDistributionForNodeIfNeeded(const_cast<Node*>(m_node)); m_node->document().updateDistributionForNodeIfNeeded(const_cast<Node*>(m_node.get()));
Node* current = m_node; Node* current = m_node;
addNodeEventContext(current); addNodeEventContext(current);
...@@ -153,7 +153,7 @@ void EventPath::calculateTreeScopePrePostOrderNumbers() ...@@ -153,7 +153,7 @@ void EventPath::calculateTreeScopePrePostOrderNumbers()
// Precondition: // Precondition:
// - TreeScopes in m_treeScopeEventContexts must be *connected* in the same tree of trees. // - TreeScopes in m_treeScopeEventContexts must be *connected* in the same tree of trees.
// - The root tree must be included. // - The root tree must be included.
HashMap<const TreeScope*, TreeScopeEventContext*> treeScopeEventContextMap; WillBeHeapHashMap<RawPtrWillBeMember<const TreeScope>, RawPtrWillBeMember<TreeScopeEventContext> > treeScopeEventContextMap;
for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i)
treeScopeEventContextMap.add(&m_treeScopeEventContexts[i]->treeScope(), m_treeScopeEventContexts[i].get()); treeScopeEventContextMap.add(&m_treeScopeEventContexts[i]->treeScope(), m_treeScopeEventContexts[i].get());
TreeScopeEventContext* rootTree = 0; TreeScopeEventContext* rootTree = 0;
...@@ -230,7 +230,7 @@ void EventPath::buildRelatedNodeMap(const Node* relatedNode, RelatedTargetMap& r ...@@ -230,7 +230,7 @@ void EventPath::buildRelatedNodeMap(const Node* relatedNode, RelatedTargetMap& r
EventTarget* EventPath::findRelatedNode(TreeScope* scope, RelatedTargetMap& relatedTargetMap) EventTarget* EventPath::findRelatedNode(TreeScope* scope, RelatedTargetMap& relatedTargetMap)
{ {
Vector<TreeScope*, 32> parentTreeScopes; WillBeHeapVector<RawPtrWillBeMember<TreeScope>, 32> parentTreeScopes;
EventTarget* relatedNode = 0; EventTarget* relatedNode = 0;
while (scope) { while (scope) {
parentTreeScopes.append(scope); parentTreeScopes.append(scope);
...@@ -242,7 +242,7 @@ EventTarget* EventPath::findRelatedNode(TreeScope* scope, RelatedTargetMap& rela ...@@ -242,7 +242,7 @@ EventTarget* EventPath::findRelatedNode(TreeScope* scope, RelatedTargetMap& rela
scope = scope->olderShadowRootOrParentTreeScope(); scope = scope->olderShadowRootOrParentTreeScope();
} }
ASSERT(relatedNode); ASSERT(relatedNode);
for (Vector<TreeScope*, 32>::iterator iter = parentTreeScopes.begin(); iter < parentTreeScopes.end(); ++iter) for (WillBeHeapVector<RawPtrWillBeMember<TreeScope>, 32>::iterator iter = parentTreeScopes.begin(); iter < parentTreeScopes.end(); ++iter)
relatedTargetMap.add(*iter, relatedNode); relatedTargetMap.add(*iter, relatedNode);
return relatedNode; return relatedNode;
} }
...@@ -298,7 +298,7 @@ void EventPath::adjustForTouchEvent(Node* node, TouchEvent& touchEvent) ...@@ -298,7 +298,7 @@ void EventPath::adjustForTouchEvent(Node* node, TouchEvent& touchEvent)
WillBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedTouches; WillBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedTouches;
WillBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedTargetTouches; WillBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedTargetTouches;
WillBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedChangedTouches; WillBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedChangedTouches;
Vector<TreeScope*> treeScopes; WillBeHeapVector<RawPtrWillBeMember<TreeScope> > treeScopes;
for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) { for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) {
TouchEventContext* touchEventContext = m_treeScopeEventContexts[i]->ensureTouchEventContext(); TouchEventContext* touchEventContext = m_treeScopeEventContexts[i]->ensureTouchEventContext();
...@@ -323,7 +323,7 @@ void EventPath::adjustForTouchEvent(Node* node, TouchEvent& touchEvent) ...@@ -323,7 +323,7 @@ void EventPath::adjustForTouchEvent(Node* node, TouchEvent& touchEvent)
#endif #endif
} }
void EventPath::adjustTouchList(const Node* node, const TouchList* touchList, WillBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedTouchList, const Vector<TreeScope*>& treeScopes) void EventPath::adjustTouchList(const Node* node, const TouchList* touchList, WillBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedTouchList, const WillBeHeapVector<RawPtrWillBeMember<TreeScope> >& treeScopes)
{ {
if (!touchList) if (!touchList)
return; return;
...@@ -348,7 +348,9 @@ void EventPath::checkReachability(TreeScope& treeScope, TouchList& touchList) ...@@ -348,7 +348,9 @@ void EventPath::checkReachability(TreeScope& treeScope, TouchList& touchList)
void EventPath::trace(Visitor* visitor) void EventPath::trace(Visitor* visitor)
{ {
visitor->trace(m_nodeEventContexts); visitor->trace(m_nodeEventContexts);
visitor->trace(m_node);
visitor->trace(m_event); visitor->trace(m_event);
visitor->trace(m_treeScopeEventContexts);
} }
} // namespace } // namespace
...@@ -81,12 +81,12 @@ private: ...@@ -81,12 +81,12 @@ private:
void shrink(size_t newSize) { m_nodeEventContexts.shrink(newSize); } void shrink(size_t newSize) { m_nodeEventContexts.shrink(newSize); }
void shrinkIfNeeded(const Node* target, const EventTarget* relatedTarget); void shrinkIfNeeded(const Node* target, const EventTarget* relatedTarget);
void adjustTouchList(const Node*, const TouchList*, WillBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedTouchList, const Vector<TreeScope*>& treeScopes); void adjustTouchList(const Node*, const TouchList*, WillBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedTouchList, const WillBeHeapVector<RawPtrWillBeMember<TreeScope> >& treeScopes);
typedef HashMap<TreeScope*, RefPtr<TreeScopeEventContext> > TreeScopeEventContextMap; typedef WillBeHeapHashMap<RawPtrWillBeMember<TreeScope>, RefPtrWillBeMember<TreeScopeEventContext> > TreeScopeEventContextMap;
TreeScopeEventContext* ensureTreeScopeEventContext(Node* currentTarget, TreeScope*, TreeScopeEventContextMap&); TreeScopeEventContext* ensureTreeScopeEventContext(Node* currentTarget, TreeScope*, TreeScopeEventContextMap&);
typedef HashMap<TreeScope*, EventTarget*> RelatedTargetMap; typedef WillBeHeapHashMap<RawPtrWillBeMember<TreeScope>, RawPtrWillBeMember<EventTarget> > RelatedTargetMap;
static void buildRelatedNodeMap(const Node*, RelatedTargetMap&); static void buildRelatedNodeMap(const Node*, RelatedTargetMap&);
static EventTarget* findRelatedNode(TreeScope*, RelatedTargetMap&); static EventTarget* findRelatedNode(TreeScope*, RelatedTargetMap&);
...@@ -96,9 +96,9 @@ private: ...@@ -96,9 +96,9 @@ private:
#endif #endif
WillBeHeapVector<NodeEventContext, 64> m_nodeEventContexts; WillBeHeapVector<NodeEventContext, 64> m_nodeEventContexts;
Node* m_node; RawPtrWillBeMember<Node> m_node;
RawPtrWillBeMember<Event> m_event; RawPtrWillBeMember<Event> m_event;
Vector<RefPtr<TreeScopeEventContext> > m_treeScopeEventContexts; WillBeHeapVector<RefPtrWillBeMember<TreeScopeEventContext> > m_treeScopeEventContexts;
}; };
} // namespace } // namespace
......
...@@ -50,6 +50,7 @@ void NodeEventContext::trace(Visitor* visitor) ...@@ -50,6 +50,7 @@ void NodeEventContext::trace(Visitor* visitor)
{ {
visitor->trace(m_node); visitor->trace(m_node);
visitor->trace(m_currentTarget); visitor->trace(m_currentTarget);
visitor->trace(m_treeScopeEventContext);
} }
void NodeEventContext::handleLocalEvents(Event* event) const void NodeEventContext::handleLocalEvents(Event* event) const
......
...@@ -48,7 +48,7 @@ public: ...@@ -48,7 +48,7 @@ public:
Node* node() const { return m_node.get(); } Node* node() const { return m_node.get(); }
void setTreeScopeEventContext(PassRefPtr<TreeScopeEventContext> prpTreeScopeEventContext) { m_treeScopeEventContext = prpTreeScopeEventContext; } void setTreeScopeEventContext(PassRefPtrWillBeRawPtr<TreeScopeEventContext> prpTreeScopeEventContext) { m_treeScopeEventContext = prpTreeScopeEventContext; }
TreeScopeEventContext& treeScopeEventContext() { ASSERT(m_treeScopeEventContext); return *m_treeScopeEventContext; } TreeScopeEventContext& treeScopeEventContext() { ASSERT(m_treeScopeEventContext); return *m_treeScopeEventContext; }
EventTarget* target() const { return m_treeScopeEventContext->target(); } EventTarget* target() const { return m_treeScopeEventContext->target(); }
...@@ -61,7 +61,7 @@ public: ...@@ -61,7 +61,7 @@ public:
private: private:
RefPtrWillBeMember<Node> m_node; RefPtrWillBeMember<Node> m_node;
RefPtrWillBeMember<EventTarget> m_currentTarget; RefPtrWillBeMember<EventTarget> m_currentTarget;
RefPtr<TreeScopeEventContext> m_treeScopeEventContext; RefPtrWillBeMember<TreeScopeEventContext> m_treeScopeEventContext;
}; };
} }
......
...@@ -59,9 +59,9 @@ TouchEventContext* TreeScopeEventContext::ensureTouchEventContext() ...@@ -59,9 +59,9 @@ TouchEventContext* TreeScopeEventContext::ensureTouchEventContext()
return m_touchEventContext.get(); return m_touchEventContext.get();
} }
PassRefPtr<TreeScopeEventContext> TreeScopeEventContext::create(TreeScope& treeScope) PassRefPtrWillBeRawPtr<TreeScopeEventContext> TreeScopeEventContext::create(TreeScope& treeScope)
{ {
return adoptRef(new TreeScopeEventContext(treeScope)); return adoptRefWillBeNoop(new TreeScopeEventContext(treeScope));
} }
TreeScopeEventContext::TreeScopeEventContext(TreeScope& treeScope) TreeScopeEventContext::TreeScopeEventContext(TreeScope& treeScope)
...@@ -71,8 +71,18 @@ TreeScopeEventContext::TreeScopeEventContext(TreeScope& treeScope) ...@@ -71,8 +71,18 @@ TreeScopeEventContext::TreeScopeEventContext(TreeScope& treeScope)
{ {
} }
TreeScopeEventContext::~TreeScopeEventContext() DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(TreeScopeEventContext)
void TreeScopeEventContext::trace(Visitor* visitor)
{ {
visitor->trace(m_treeScope);
visitor->trace(m_target);
visitor->trace(m_relatedTarget);
visitor->trace(m_eventPath);
visitor->trace(m_touchEventContext);
#if ENABLE(OILPAN)
visitor->trace(m_children);
#endif
} }
int TreeScopeEventContext::calculatePrePostOrderNumber(int orderNumber) int TreeScopeEventContext::calculatePrePostOrderNumber(int orderNumber)
......
...@@ -43,12 +43,13 @@ class Node; ...@@ -43,12 +43,13 @@ class Node;
class TouchEventContext; class TouchEventContext;
class TreeScope; class TreeScope;
class TreeScopeEventContext : public RefCounted<TreeScopeEventContext> { class TreeScopeEventContext FINAL : public RefCountedWillBeGarbageCollected<TreeScopeEventContext> {
DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(TreeScopeEventContext);
public: public:
static PassRefPtr<TreeScopeEventContext> create(TreeScope&); static PassRefPtrWillBeRawPtr<TreeScopeEventContext> create(TreeScope&);
~TreeScopeEventContext(); void trace(Visitor*);
TreeScope& treeScope() const { return m_treeScope; } TreeScope& treeScope() const { return *m_treeScope; }
EventTarget* target() const { return m_target.get(); } EventTarget* target() const { return m_target.get(); }
void setTarget(PassRefPtrWillBeRawPtr<EventTarget>); void setTarget(PassRefPtrWillBeRawPtr<EventTarget>);
...@@ -75,13 +76,13 @@ private: ...@@ -75,13 +76,13 @@ private:
bool isUnreachableNode(EventTarget&); bool isUnreachableNode(EventTarget&);
#endif #endif
TreeScope& m_treeScope; RawPtrWillBeMember<TreeScope> m_treeScope;
RefPtrWillBePersistent<EventTarget> m_target; RefPtrWillBeMember<EventTarget> m_target;
RefPtrWillBePersistent<EventTarget> m_relatedTarget; RefPtrWillBeMember<EventTarget> m_relatedTarget;
RefPtrWillBePersistent<NodeList> m_eventPath; RefPtrWillBeMember<NodeList> m_eventPath;
RefPtrWillBePersistent<TouchEventContext> m_touchEventContext; RefPtrWillBeMember<TouchEventContext> m_touchEventContext;
Vector<TreeScopeEventContext*> m_children; WillBeHeapVector<RawPtrWillBeMember<TreeScopeEventContext> > m_children;
int m_preOrder; int m_preOrder;
int m_postOrder; int m_postOrder;
}; };
...@@ -90,7 +91,7 @@ private: ...@@ -90,7 +91,7 @@ private:
inline bool TreeScopeEventContext::isUnreachableNode(EventTarget& target) inline bool TreeScopeEventContext::isUnreachableNode(EventTarget& target)
{ {
// FIXME: Checks also for SVG elements. // FIXME: Checks also for SVG elements.
return target.toNode() && !target.toNode()->isSVGElement() && !target.toNode()->treeScope().isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(m_treeScope); return target.toNode() && !target.toNode()->isSVGElement() && !target.toNode()->treeScope().isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(treeScope());
} }
#endif #endif
......
...@@ -39,6 +39,7 @@ class Node; ...@@ -39,6 +39,7 @@ class Node;
class NodeEventContext; class NodeEventContext;
class WindowEventContext { class WindowEventContext {
STACK_ALLOCATED();
public: public:
WindowEventContext(Event*, PassRefPtrWillBeRawPtr<Node>, const NodeEventContext*); WindowEventContext(Event*, PassRefPtrWillBeRawPtr<Node>, const NodeEventContext*);
...@@ -47,8 +48,8 @@ public: ...@@ -47,8 +48,8 @@ public:
bool handleLocalEvents(Event* event); bool handleLocalEvents(Event* event);
private: private:
RefPtrWillBePersistent<DOMWindow> m_window; RefPtrWillBeMember<DOMWindow> m_window;
RefPtrWillBePersistent<EventTarget> m_target; RefPtrWillBeMember<EventTarget> m_target;
}; };
inline DOMWindow* WindowEventContext::window() const inline DOMWindow* WindowEventContext::window() const
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment