Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / core / events / DragEvent.cpp
blob941ebc94e393fcafad37e96295f9414bba630be8
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.
5 #include "config.h"
6 #include "core/events/DragEvent.h"
8 #include "core/clipboard/DataTransfer.h"
9 #include "core/dom/Element.h"
10 #include "core/events/EventDispatcher.h"
12 namespace blink {
14 PassRefPtrWillBeRawPtr<DragEvent> DragEvent::create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view,
15 int detail, int screenX, int screenY, int windowX, int windowY,
16 int movementX, int movementY,
17 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
18 short button, unsigned short buttons,
19 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, DataTransfer* dataTransfer, PlatformMouseEvent::SyntheticEventType syntheticEventType,
20 double uiCreateTime)
22 return adoptRefWillBeNoop(new DragEvent(type, canBubble, cancelable, view,
23 detail, screenX, screenY, windowX, windowY,
24 movementX, movementY,
25 ctrlKey, altKey, shiftKey, metaKey, button, buttons, relatedTarget, dataTransfer, syntheticEventType, uiCreateTime));
29 DragEvent::DragEvent()
30 : m_dataTransfer(nullptr)
34 DragEvent::DragEvent(DataTransfer* dataTransfer)
35 : m_dataTransfer(dataTransfer)
39 DragEvent::DragEvent(const AtomicString& eventType, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view,
40 int detail, int screenX, int screenY, int windowX, int windowY,
41 int movementX, int movementY,
42 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
43 short button, unsigned short buttons, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget,
44 DataTransfer* dataTransfer, PlatformMouseEvent::SyntheticEventType syntheticEventType,
45 double uiCreateTime)
46 : MouseEvent(eventType, canBubble, cancelable, view, detail, screenX, screenY,
47 windowX, windowY, movementX, movementY, ctrlKey, altKey, shiftKey, metaKey, button, buttons, relatedTarget,
48 syntheticEventType, uiCreateTime)
49 , m_dataTransfer(dataTransfer)
54 DragEvent::DragEvent(const AtomicString& type, const DragEventInit& initializer)
55 : MouseEvent(type, initializer)
56 , m_dataTransfer(initializer.dataTransfer())
60 bool DragEvent::isDragEvent() const
62 return true;
65 bool DragEvent::isMouseEvent() const
67 return false;
70 PassRefPtrWillBeRawPtr<EventDispatchMediator> DragEvent::createMediator()
72 return DragEventDispatchMediator::create(this);
75 DEFINE_TRACE(DragEvent)
77 visitor->trace(m_dataTransfer);
78 MouseEvent::trace(visitor);
81 PassRefPtrWillBeRawPtr<DragEventDispatchMediator> DragEventDispatchMediator::create(PassRefPtrWillBeRawPtr<DragEvent> dragEvent)
83 return adoptRefWillBeNoop(new DragEventDispatchMediator(dragEvent));
86 DragEventDispatchMediator::DragEventDispatchMediator(PassRefPtrWillBeRawPtr<DragEvent> dragEvent)
87 : EventDispatchMediator(dragEvent)
91 DragEvent& DragEventDispatchMediator::event() const
93 return toDragEvent(EventDispatchMediator::event());
96 bool DragEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) const
98 event().eventPath().adjustForRelatedTarget(dispatcher.node(), event().relatedTarget());
99 return EventDispatchMediator::dispatchEvent(dispatcher);
102 } // namespace blink