Commit cfba43b6 authored by hayato@chromium.org's avatar hayato@chromium.org

Add assertions to make sure that event's target and relatedTarget are accessible.

https://bugs.webkit.org/show_bug.cgi?id=87641

Reviewed by Dimitri Glazkov.

No new tests. No new functionality except for assertions.

* dom/EventContext.cpp:
(WebCore::EventContext::EventContext):
* dom/EventContext.h:
(WebCore):
(EventContext):
(WebCore::EventContext::setRelatedTarget):
(WebCore::EventContext::accessible):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@118889 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 560ec954
2012-05-29 Hayato Ito <hayato@chromium.org>
Add assertions to make sure that event's target and relatedTarget are accessible.
https://bugs.webkit.org/show_bug.cgi?id=87641
Reviewed by Dimitri Glazkov.
No new tests. No new functionality except for assertions.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext):
* dom/EventContext.h:
(WebCore):
(EventContext):
(WebCore::EventContext::setRelatedTarget):
(WebCore::EventContext::accessible):
2012-05-29 Kent Tamura <tkent@chromium.org>
Fix inefficient usage of traverseNextNode()
......
......@@ -41,6 +41,8 @@ EventContext::EventContext(PassRefPtr<Node> node, PassRefPtr<EventTarget> curren
, m_target(target)
, m_relatedTarget(0)
{
ASSERT(m_node);
ASSERT(!m_target || m_target->toNode() || accessible(m_target->toNode()));
}
void EventContext::handleLocalEvents(Event* event) const
......
......@@ -27,13 +27,14 @@
#ifndef EventContext_h
#define EventContext_h
#include "EventTarget.h"
#include "Node.h"
#include "TreeScope.h"
#include <wtf/RefPtr.h>
namespace WebCore {
class EventTarget;
class Event;
class Node;
class EventContext {
public:
......@@ -48,6 +49,9 @@ public:
void setRelatedTarget(PassRefPtr<EventTarget>);
private:
#ifndef NDEBUG
bool accessible(Node*);
#endif
RefPtr<Node> m_node;
RefPtr<EventTarget> m_currentTarget;
RefPtr<EventTarget> m_target;
......@@ -76,9 +80,23 @@ inline EventTarget* EventContext::relatedTarget() const
inline void EventContext::setRelatedTarget(PassRefPtr<EventTarget> relatedTarget)
{
ASSERT(!relatedTarget || !relatedTarget->toNode() || accessible(relatedTarget->toNode()));
m_relatedTarget = relatedTarget;
}
#ifndef NDEBUG
inline bool EventContext::accessible(Node* target)
{
ASSERT(target);
TreeScope* targetScope = target->treeScope();
for (TreeScope* scope = m_node->treeScope(); scope; scope = scope->parentTreeScope()) {
if (scope == targetScope)
return true;
}
return false;
}
#endif
}
#endif // EventContext_h
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