1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 #include "core/events/PointerEvent.h"
8 #include "core/dom/Element.h"
9 #include "core/events/EventDispatcher.h"
13 PointerEvent::PointerEvent()
24 PointerEvent::PointerEvent(const AtomicString
& type
, const PointerEventInit
& initializer
)
25 : MouseEvent(type
, initializer
)
34 if (initializer
.hasPointerId())
35 m_pointerId
= initializer
.pointerId();
36 if (initializer
.hasWidth())
37 m_width
= initializer
.width();
38 if (initializer
.hasHeight())
39 m_height
= initializer
.height();
40 if (initializer
.hasPressure())
41 m_pressure
= initializer
.pressure();
42 if (initializer
.hasTiltX())
43 m_tiltX
= initializer
.tiltX();
44 if (initializer
.hasTiltY())
45 m_tiltY
= initializer
.tiltY();
46 if (initializer
.hasPointerType())
47 m_pointerType
= initializer
.pointerType();
48 if (initializer
.hasIsPrimary())
49 m_isPrimary
= initializer
.isPrimary();
52 bool PointerEvent::isMouseEvent() const
57 bool PointerEvent::isPointerEvent() const
62 PassRefPtrWillBeRawPtr
<EventDispatchMediator
> PointerEvent::createMediator()
64 return PointerEventDispatchMediator::create(this);
67 DEFINE_TRACE(PointerEvent
)
69 MouseEvent::trace(visitor
);
72 PassRefPtrWillBeRawPtr
<PointerEventDispatchMediator
> PointerEventDispatchMediator::create(PassRefPtrWillBeRawPtr
<PointerEvent
> pointerEvent
)
74 return adoptRefWillBeNoop(new PointerEventDispatchMediator(pointerEvent
));
77 PointerEventDispatchMediator::PointerEventDispatchMediator(PassRefPtrWillBeRawPtr
<PointerEvent
> pointerEvent
)
78 : EventDispatchMediator(pointerEvent
)
82 PointerEvent
& PointerEventDispatchMediator::event() const
84 return toPointerEvent(EventDispatchMediator::event());
87 bool PointerEventDispatchMediator::dispatchEvent(EventDispatcher
& dispatcher
) const
89 if (isDisabledFormControl(&dispatcher
.node()))
92 if (event().type().isEmpty())
93 return true; // Shouldn't happen.
95 ASSERT(!event().target() || event().target() != event().relatedTarget());
97 EventTarget
* relatedTarget
= event().relatedTarget();
98 event().eventPath().adjustForRelatedTarget(dispatcher
.node(), relatedTarget
);
100 dispatcher
.dispatch();
101 return !event().defaultHandled() && !event().defaultPrevented();