Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / events / MouseEvent.h
blobc946cd00f1d725a490ea0a8150508d5f1d52b1c0
1 /*
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #ifndef MouseEvent_h
25 #define MouseEvent_h
27 #include "core/CoreExport.h"
28 #include "core/events/EventDispatchMediator.h"
29 #include "core/events/MouseEventInit.h"
30 #include "core/events/MouseRelatedEvent.h"
31 #include "platform/PlatformMouseEvent.h"
33 namespace blink {
34 class DataTransfer;
35 class EventDispatcher;
37 class CORE_EXPORT MouseEvent : public MouseRelatedEvent {
38 DEFINE_WRAPPERTYPEINFO();
39 public:
40 static PassRefPtrWillBeRawPtr<MouseEvent> create()
42 return adoptRefWillBeNoop(new MouseEvent);
45 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>,
46 int detail, int screenX, int screenY, int windowX, int windowY,
47 int movementX, int movementY,
48 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, short button, unsigned short buttons,
49 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget,
50 PlatformMouseEvent::SyntheticEventType = PlatformMouseEvent::RealOrIndistinguishable,
51 double uiCreateTime = 0);
53 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventType, PassRefPtrWillBeRawPtr<AbstractView>, const PlatformMouseEvent&, int detail, PassRefPtrWillBeRawPtr<Node> relatedTarget);
55 static PassRefPtrWillBeRawPtr<MouseEvent> create(ScriptState*, const AtomicString& eventType, const MouseEventInit&);
57 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventType, PassRefPtrWillBeRawPtr<AbstractView>, PassRefPtrWillBeRawPtr<Event> underlyingEvent, SimulatedClickCreationScope);
59 ~MouseEvent() override;
61 static unsigned short platformModifiersToButtons(unsigned modifiers);
63 void initMouseEvent(ScriptState*, const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>,
64 int detail, int screenX, int screenY, int clientX, int clientY,
65 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
66 short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, unsigned short buttons = 0);
68 void initMouseEventInternal(ScriptState*, const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>,
69 int detail, int screenX, int screenY, int clientX, int clientY,
70 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
71 short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, InputDeviceCapabilities* sourceCapabilities, unsigned short buttons = 0);
74 // WinIE uses 1,4,2 for left/middle/right but not for click (just for mousedown/up, maybe others),
75 // but we will match the standard DOM.
76 short button() const { return m_button == -1 ? 0 : m_button; }
77 unsigned short buttons() const { return m_buttons; }
78 bool buttonDown() const { return m_button != -1; }
79 EventTarget* relatedTarget() const { return m_relatedTarget.get(); }
80 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget> relatedTarget) { m_relatedTarget = relatedTarget; }
81 PlatformMouseEvent::SyntheticEventType syntheticEventType() const { return m_syntheticEventType; }
83 Node* toElement() const;
84 Node* fromElement() const;
86 virtual DataTransfer* dataTransfer() const { return nullptr; }
88 bool fromTouch() const { return m_syntheticEventType == PlatformMouseEvent::FromTouch; }
90 const AtomicString& interfaceName() const override;
92 bool isMouseEvent() const override;
93 int which() const final;
95 PassRefPtrWillBeRawPtr<EventDispatchMediator> createMediator() override;
97 DECLARE_VIRTUAL_TRACE();
99 protected:
100 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>,
101 int detail, int screenX, int screenY, int windowX, int windowY,
102 int movementX, int movementY,
103 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, short button, unsigned short buttons,
104 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget,
105 PlatformMouseEvent::SyntheticEventType, double uiCreateTime = 0);
107 MouseEvent(const AtomicString& type, const MouseEventInit&);
109 MouseEvent();
111 private:
112 short m_button;
113 unsigned short m_buttons;
114 RefPtrWillBeMember<EventTarget> m_relatedTarget;
115 PlatformMouseEvent::SyntheticEventType m_syntheticEventType;
118 class MouseEventDispatchMediator final : public EventDispatchMediator {
119 public:
120 static PassRefPtrWillBeRawPtr<MouseEventDispatchMediator> create(PassRefPtrWillBeRawPtr<MouseEvent>);
122 private:
123 explicit MouseEventDispatchMediator(PassRefPtrWillBeRawPtr<MouseEvent>);
124 MouseEvent& event() const;
126 bool dispatchEvent(EventDispatcher&) const override;
129 DEFINE_EVENT_TYPE_CASTS(MouseEvent);
131 } // namespace blink
133 #endif // MouseEvent_h