| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
| 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) | 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) |
| 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "core/events/MouseRelatedEvent.h" | 30 #include "core/events/MouseRelatedEvent.h" |
| 31 #include "platform/PlatformMouseEvent.h" | 31 #include "platform/PlatformMouseEvent.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 class DataTransfer; | 34 class DataTransfer; |
| 35 class EventDispatcher; | 35 class EventDispatcher; |
| 36 | 36 |
| 37 class CORE_EXPORT MouseEvent : public MouseRelatedEvent { | 37 class CORE_EXPORT MouseEvent : public MouseRelatedEvent { |
| 38 DEFINE_WRAPPERTYPEINFO(); | 38 DEFINE_WRAPPERTYPEINFO(); |
| 39 public: | 39 public: |
| 40 static PassRefPtrWillBeRawPtr<MouseEvent> create() | 40 static RawPtr<MouseEvent> create() |
| 41 { | 41 { |
| 42 return adoptRefWillBeNoop(new MouseEvent); | 42 return adoptRefWillBeNoop(new MouseEvent); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // TODO(mustaq): Should replace most/all of these params with a MouseEventIn
it. | 45 // TODO(mustaq): Should replace most/all of these params with a MouseEventIn
it. |
| 46 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& type, b
ool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>, | 46 static RawPtr<MouseEvent> create(const AtomicString& type, bool canBubble, b
ool cancelable, RawPtr<AbstractView>, |
| 47 int detail, int screenX, int screenY, int windowX, int windowY, | 47 int detail, int screenX, int screenY, int windowX, int windowY, |
| 48 int movementX, int movementY, PlatformEvent::Modifiers, | 48 int movementX, int movementY, PlatformEvent::Modifiers, |
| 49 short button, unsigned short buttons, | 49 short button, unsigned short buttons, |
| 50 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, | 50 RawPtr<EventTarget> relatedTarget, |
| 51 double platformTimeStamp, | 51 double platformTimeStamp, |
| 52 PlatformMouseEvent::SyntheticEventType, | 52 PlatformMouseEvent::SyntheticEventType, |
| 53 const String& region); | 53 const String& region); |
| 54 | 54 |
| 55 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventTy
pe, PassRefPtrWillBeRawPtr<AbstractView>, const PlatformMouseEvent&, int detail,
PassRefPtrWillBeRawPtr<Node> relatedTarget); | 55 static RawPtr<MouseEvent> create(const AtomicString& eventType, RawPtr<Abstr
actView>, const PlatformMouseEvent&, int detail, RawPtr<Node> relatedTarget); |
| 56 | 56 |
| 57 static PassRefPtrWillBeRawPtr<MouseEvent> create(ScriptState*, const AtomicS
tring& eventType, const MouseEventInit&); | 57 static RawPtr<MouseEvent> create(ScriptState*, const AtomicString& eventType
, const MouseEventInit&); |
| 58 | 58 |
| 59 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventTy
pe, PassRefPtrWillBeRawPtr<AbstractView>, PassRefPtrWillBeRawPtr<Event> underlyi
ngEvent, SimulatedClickCreationScope); | 59 static RawPtr<MouseEvent> create(const AtomicString& eventType, RawPtr<Abstr
actView>, RawPtr<Event> underlyingEvent, SimulatedClickCreationScope); |
| 60 | 60 |
| 61 ~MouseEvent() override; | 61 ~MouseEvent() override; |
| 62 | 62 |
| 63 static unsigned short platformModifiersToButtons(unsigned modifiers); | 63 static unsigned short platformModifiersToButtons(unsigned modifiers); |
| 64 static unsigned short buttonToButtons(short button); | 64 static unsigned short buttonToButtons(short button); |
| 65 | 65 |
| 66 void initMouseEvent(ScriptState*, const AtomicString& type, bool canBubble,
bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>, | 66 void initMouseEvent(ScriptState*, const AtomicString& type, bool canBubble,
bool cancelable, RawPtr<AbstractView>, |
| 67 int detail, int screenX, int screenY, int clientX, int clientY, | 67 int detail, int screenX, int screenY, int clientX, int clientY, |
| 68 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, | 68 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, |
| 69 short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, unsigne
d short buttons = 0); | 69 short button, RawPtr<EventTarget> relatedTarget, unsigned short buttons
= 0); |
| 70 | 70 |
| 71 // WinIE uses 1,4,2 for left/middle/right but not for click (just for moused
own/up, maybe others), | 71 // WinIE uses 1,4,2 for left/middle/right but not for click (just for moused
own/up, maybe others), |
| 72 // but we will match the standard DOM. | 72 // but we will match the standard DOM. |
| 73 virtual short button() const { return m_button == -1 ? 0 : m_button; } | 73 virtual short button() const { return m_button == -1 ? 0 : m_button; } |
| 74 unsigned short buttons() const { return m_buttons; } | 74 unsigned short buttons() const { return m_buttons; } |
| 75 bool buttonDown() const { return m_button != -1; } | 75 bool buttonDown() const { return m_button != -1; } |
| 76 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } | 76 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } |
| 77 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget> relatedTarget) { m
_relatedTarget = relatedTarget; } | 77 void setRelatedTarget(RawPtr<EventTarget> relatedTarget) { m_relatedTarget =
relatedTarget; } |
| 78 PlatformMouseEvent::SyntheticEventType getSyntheticEventType() const { retur
n m_syntheticEventType; } | 78 PlatformMouseEvent::SyntheticEventType getSyntheticEventType() const { retur
n m_syntheticEventType; } |
| 79 const String& region() const { return m_region; } | 79 const String& region() const { return m_region; } |
| 80 void setRegion(const String& region) { m_region = region; } | 80 void setRegion(const String& region) { m_region = region; } |
| 81 | 81 |
| 82 Node* toElement() const; | 82 Node* toElement() const; |
| 83 Node* fromElement() const; | 83 Node* fromElement() const; |
| 84 | 84 |
| 85 virtual DataTransfer* getDataTransfer() const { return nullptr; } | 85 virtual DataTransfer* getDataTransfer() const { return nullptr; } |
| 86 | 86 |
| 87 bool fromTouch() const { return m_syntheticEventType == PlatformMouseEvent::
FromTouch; } | 87 bool fromTouch() const { return m_syntheticEventType == PlatformMouseEvent::
FromTouch; } |
| 88 | 88 |
| 89 const AtomicString& interfaceName() const override; | 89 const AtomicString& interfaceName() const override; |
| 90 | 90 |
| 91 bool isMouseEvent() const override; | 91 bool isMouseEvent() const override; |
| 92 int which() const final; | 92 int which() const final; |
| 93 | 93 |
| 94 PassRefPtrWillBeRawPtr<EventDispatchMediator> createMediator() override; | 94 RawPtr<EventDispatchMediator> createMediator() override; |
| 95 | 95 |
| 96 enum class Buttons : unsigned { | 96 enum class Buttons : unsigned { |
| 97 None = 0, | 97 None = 0, |
| 98 Left = 1 << 0, | 98 Left = 1 << 0, |
| 99 Right = 1 << 1, | 99 Right = 1 << 1, |
| 100 Middle = 1 << 2 | 100 Middle = 1 << 2 |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 DECLARE_VIRTUAL_TRACE(); | 103 DECLARE_VIRTUAL_TRACE(); |
| 104 | 104 |
| 105 protected: | 105 protected: |
| 106 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRe
fPtrWillBeRawPtr<AbstractView>, | 106 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, RawPtr
<AbstractView>, |
| 107 int detail, int screenX, int screenY, int windowX, int windowY, | 107 int detail, int screenX, int screenY, int windowX, int windowY, |
| 108 int movementX, int movementY, | 108 int movementX, int movementY, |
| 109 PlatformEvent::Modifiers, short button, unsigned short buttons, | 109 PlatformEvent::Modifiers, short button, unsigned short buttons, |
| 110 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, | 110 RawPtr<EventTarget> relatedTarget, |
| 111 double platformTimeStamp, | 111 double platformTimeStamp, |
| 112 PlatformMouseEvent::SyntheticEventType, | 112 PlatformMouseEvent::SyntheticEventType, |
| 113 const String& region); | 113 const String& region); |
| 114 | 114 |
| 115 MouseEvent(const AtomicString& type, const MouseEventInit&); | 115 MouseEvent(const AtomicString& type, const MouseEventInit&); |
| 116 | 116 |
| 117 MouseEvent(); | 117 MouseEvent(); |
| 118 | 118 |
| 119 short rawButton() const { return m_button; } | 119 short rawButton() const { return m_button; } |
| 120 | 120 |
| 121 private: | 121 private: |
| 122 friend class MouseEventDispatchMediator; | 122 friend class MouseEventDispatchMediator; |
| 123 void initMouseEventInternal(const AtomicString& type, bool canBubble, bool c
ancelable, PassRefPtrWillBeRawPtr<AbstractView>, | 123 void initMouseEventInternal(const AtomicString& type, bool canBubble, bool c
ancelable, RawPtr<AbstractView>, |
| 124 int detail, int screenX, int screenY, int clientX, int clientY, | 124 int detail, int screenX, int screenY, int clientX, int clientY, |
| 125 PlatformEvent::Modifiers, | 125 PlatformEvent::Modifiers, |
| 126 short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, InputDe
viceCapabilities* sourceCapabilities, unsigned short buttons = 0); | 126 short button, RawPtr<EventTarget> relatedTarget, InputDeviceCapabilities
* sourceCapabilities, unsigned short buttons = 0); |
| 127 | 127 |
| 128 short m_button; | 128 short m_button; |
| 129 unsigned short m_buttons; | 129 unsigned short m_buttons; |
| 130 RefPtrWillBeMember<EventTarget> m_relatedTarget; | 130 Member<EventTarget> m_relatedTarget; |
| 131 PlatformMouseEvent::SyntheticEventType m_syntheticEventType; | 131 PlatformMouseEvent::SyntheticEventType m_syntheticEventType; |
| 132 String m_region; | 132 String m_region; |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 class MouseEventDispatchMediator final : public EventDispatchMediator { | 135 class MouseEventDispatchMediator final : public EventDispatchMediator { |
| 136 public: | 136 public: |
| 137 static PassRefPtrWillBeRawPtr<MouseEventDispatchMediator> create(PassRefPtrW
illBeRawPtr<MouseEvent>); | 137 static RawPtr<MouseEventDispatchMediator> create(RawPtr<MouseEvent>); |
| 138 | 138 |
| 139 private: | 139 private: |
| 140 explicit MouseEventDispatchMediator(PassRefPtrWillBeRawPtr<MouseEvent>); | 140 explicit MouseEventDispatchMediator(RawPtr<MouseEvent>); |
| 141 MouseEvent& event() const; | 141 MouseEvent& event() const; |
| 142 | 142 |
| 143 DispatchEventResult dispatchEvent(EventDispatcher&) const override; | 143 DispatchEventResult dispatchEvent(EventDispatcher&) const override; |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 DEFINE_EVENT_TYPE_CASTS(MouseEvent); | 146 DEFINE_EVENT_TYPE_CASTS(MouseEvent); |
| 147 | 147 |
| 148 } // namespace blink | 148 } // namespace blink |
| 149 | 149 |
| 150 #endif // MouseEvent_h | 150 #endif // MouseEvent_h |
| OLD | NEW |