⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 118889 in webkit


Ignore:
Timestamp:
May 29, 2012, 9:05:53 PM (14 years ago)
Author:
hayato@chromium.org
Message:

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):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r118888 r118889  
     12012-05-29  Hayato Ito  <hayato@chromium.org>
     2
     3        Add assertions to make sure that event's target and relatedTarget are accessible.
     4        https://bugs.webkit.org/show_bug.cgi?id=87641
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        No new tests. No new functionality except for assertions.
     9
     10        * dom/EventContext.cpp:
     11        (WebCore::EventContext::EventContext):
     12        * dom/EventContext.h:
     13        (WebCore):
     14        (EventContext):
     15        (WebCore::EventContext::setRelatedTarget):
     16        (WebCore::EventContext::accessible):
     17
    1182012-05-29  Kent Tamura  <tkent@chromium.org>
    219
  • trunk/Source/WebCore/dom/EventContext.cpp

    r117394 r118889  
    4242    , m_relatedTarget(0)
    4343{
     44    ASSERT(m_node);
     45    ASSERT(!m_target || m_target->toNode() || accessible(m_target->toNode()));
    4446}
    4547
  • trunk/Source/WebCore/dom/EventContext.h

    r117394 r118889  
    2828#define EventContext_h
    2929
     30#include "EventTarget.h"
     31#include "Node.h"
     32#include "TreeScope.h"
    3033#include <wtf/RefPtr.h>
    3134
    3235namespace WebCore {
    3336
    34 class EventTarget;
    3537class Event;
    36 class Node;
    3738
    3839class EventContext {
     
    4950
    5051private:
     52#ifndef NDEBUG
     53    bool accessible(Node*);
     54#endif
    5155    RefPtr<Node> m_node;
    5256    RefPtr<EventTarget> m_currentTarget;
     
    7781inline void EventContext::setRelatedTarget(PassRefPtr<EventTarget> relatedTarget)
    7882{
     83    ASSERT(!relatedTarget || !relatedTarget->toNode() || accessible(relatedTarget->toNode()));
    7984    m_relatedTarget = relatedTarget;
    8085}
     86
     87#ifndef NDEBUG
     88inline bool EventContext::accessible(Node* target)
     89{
     90    ASSERT(target);
     91    TreeScope* targetScope = target->treeScope();
     92    for (TreeScope* scope = m_node->treeScope(); scope; scope = scope->parentTreeScope()) {
     93        if (scope == targetScope)
     94            return true;
     95    }
     96    return false;
     97}
     98#endif
    8199
    82100}
Note: See TracChangeset for help on using the changeset viewer.