summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/events/drag_event.h
blob: cd002a4b3d3c697393c9e332861fdd7da045f3dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EVENTS_DRAG_EVENT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_EVENTS_DRAG_EVENT_H_

#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/events/mouse_event.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"

namespace blink {

class DataTransfer;
class DragEventInit;

class CORE_EXPORT DragEvent final : public MouseEvent {
  DEFINE_WRAPPERTYPEINFO();

 public:
  static DragEvent* Create() { return MakeGarbageCollected<DragEvent>(); }

  static DragEvent* Create(const AtomicString& type,
                           const DragEventInit* initializer,
                           base::TimeTicks platform_time_stamp,
                           SyntheticEventType synthetic_event_type) {
    return MakeGarbageCollected<DragEvent>(
        type, initializer, platform_time_stamp, synthetic_event_type);
  }

  static DragEvent* Create(const AtomicString& type,
                           const DragEventInit* initializer) {
    return MakeGarbageCollected<DragEvent>(
        type, initializer, base::TimeTicks::Now(), kRealOrIndistinguishable);
  }

  DragEvent();
  DragEvent(const AtomicString& type,
            const DragEventInit*,
            base::TimeTicks platform_time_stamp,
            SyntheticEventType);

  DataTransfer* getDataTransfer() const override {
    return IsDragEvent() ? data_transfer_.Get() : nullptr;
  }

  bool IsDragEvent() const override;
  bool IsMouseEvent() const override;

  DispatchEventResult DispatchEvent(EventDispatcher&) override;

  void Trace(Visitor*) override;

 private:
  Member<DataTransfer> data_transfer_;
};

template <>
struct DowncastTraits<DragEvent> {
  static bool AllowFrom(const Event& event) { return event.IsDragEvent(); }
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_EVENTS_DRAG_EVENT_H_