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

Side by Side Diff: Source/core/dom/EventContext.h

Issue 14508005: Support an Event Path API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: event.path() now returns a different view for each node. Created 7 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All Rights Reserved. 2 * Copyright (C) 2010 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 Node* node() const { return m_node.get(); } 46 Node* node() const { return m_node.get(); }
47 EventTarget* target() const { return m_target.get(); } 47 EventTarget* target() const { return m_target.get(); }
48 bool currentTargetSameAsTarget() const { return m_currentTarget.get() == m_t arget.get(); } 48 bool currentTargetSameAsTarget() const { return m_currentTarget.get() == m_t arget.get(); }
49 virtual void handleLocalEvents(Event*) const; 49 virtual void handleLocalEvents(Event*) const;
50 virtual bool isMouseOrFocusEventContext() const; 50 virtual bool isMouseOrFocusEventContext() const;
51 virtual bool isTouchEventContext() const; 51 virtual bool isTouchEventContext() const;
52 52
53 protected: 53 protected:
54 #ifndef NDEBUG 54 #ifndef NDEBUG
55 bool isUnreachableNode(EventTarget*); 55 bool isUnreachableNode(EventTarget*);
56 bool isReachable(Node*) const;
57 #endif 56 #endif
58 RefPtr<Node> m_node; 57 RefPtr<Node> m_node;
59 RefPtr<EventTarget> m_currentTarget; 58 RefPtr<EventTarget> m_currentTarget;
60 RefPtr<EventTarget> m_target; 59 RefPtr<EventTarget> m_target;
61 }; 60 };
62 61
63 typedef Vector<OwnPtr<EventContext>, 32> EventPath; 62 typedef Vector<OwnPtr<EventContext>, 32> EventPath;
64 63
65 class MouseOrFocusEventContext : public EventContext { 64 class MouseOrFocusEventContext : public EventContext {
66 public: 65 public:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 inline TouchEventContext* toTouchEventContext(EventContext* eventContext) 99 inline TouchEventContext* toTouchEventContext(EventContext* eventContext)
101 { 100 {
102 ASSERT_WITH_SECURITY_IMPLICATION(!eventContext || eventContext->isTouchEvent Context()); 101 ASSERT_WITH_SECURITY_IMPLICATION(!eventContext || eventContext->isTouchEvent Context());
103 return static_cast<TouchEventContext*>(eventContext); 102 return static_cast<TouchEventContext*>(eventContext);
104 } 103 }
105 104
106 #ifndef NDEBUG 105 #ifndef NDEBUG
107 inline bool EventContext::isUnreachableNode(EventTarget* target) 106 inline bool EventContext::isUnreachableNode(EventTarget* target)
108 { 107 {
109 // FIXME: Checks also for SVG elements. 108 // FIXME: Checks also for SVG elements.
110 return target && target->toNode() && !target->toNode()->isSVGElement() && !i sReachable(target->toNode()); 109 return target && target->toNode() && !target->toNode()->isSVGElement() && !m _node->canReach(target->toNode());
111 }
112
113 inline bool EventContext::isReachable(Node* target) const
114 {
115 ASSERT(target);
116 TreeScope* targetScope = target->treeScope();
117 for (TreeScope* scope = m_node->treeScope(); scope; scope = scope->parentTre eScope()) {
118 if (scope == targetScope)
119 return true;
120 }
121 return false;
122 } 110 }
123 #endif 111 #endif
124 112
125 inline void MouseOrFocusEventContext::setRelatedTarget(PassRefPtr<EventTarget> r elatedTarget) 113 inline void MouseOrFocusEventContext::setRelatedTarget(PassRefPtr<EventTarget> r elatedTarget)
126 { 114 {
127 ASSERT(!isUnreachableNode(relatedTarget.get())); 115 ASSERT(!isUnreachableNode(relatedTarget.get()));
128 m_relatedTarget = relatedTarget; 116 m_relatedTarget = relatedTarget;
129 } 117 }
130 118
131 } 119 }
132 120
133 #endif // EventContext_h 121 #endif // EventContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698