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.
27 #include "Clipboard.h"
28 #include "EventDispatchMediator.h"
29 #include "MouseRelatedEvent.h"
33 class EventDispatcher;
34 class PlatformMouseEvent;
36 // Introduced in DOM Level 2
37 class MouseEvent : public MouseRelatedEvent {
39 static PassRefPtr<MouseEvent> create()
41 return adoptRef(new MouseEvent);
43 static PassRefPtr<MouseEvent> create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView> view,
44 int detail, int screenX, int screenY, int pageX, int pageY,
45 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button,
46 PassRefPtr<EventTarget> relatedTarget, PassRefPtr<Clipboard> clipboard = 0, bool isSimulated = false)
48 return adoptRef(new MouseEvent(type, canBubble, cancelable, view, detail, screenX, screenY, pageX, pageY,
49 ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget, clipboard, isSimulated));
51 static PassRefPtr<MouseEvent> create(const AtomicString& eventType, PassRefPtr<AbstractView>, const PlatformMouseEvent&, int detail, PassRefPtr<Node> relatedTarget);
53 virtual ~MouseEvent();
55 void initMouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>,
56 int detail, int screenX, int screenY, int clientX, int clientY,
57 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
58 unsigned short button, PassRefPtr<EventTarget> relatedTarget);
60 // WinIE uses 1,4,2 for left/middle/right but not for click (just for mousedown/up, maybe others),
61 // but we will match the standard DOM.
62 unsigned short button() const { return m_button; }
63 bool buttonDown() const { return m_buttonDown; }
64 EventTarget* relatedTarget() const { return m_relatedTarget.get(); }
65 void setRelatedTarget(PassRefPtr<EventTarget> relatedTarget) { m_relatedTarget = relatedTarget; }
67 Clipboard* clipboard() const { return m_clipboard.get(); }
69 Node* toElement() const;
70 Node* fromElement() const;
72 Clipboard* dataTransfer() const { return isDragEvent() ? m_clipboard.get() : 0; }
74 virtual bool isMouseEvent() const;
75 virtual bool isDragEvent() const;
76 virtual int which() const;
79 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>,
80 int detail, int screenX, int screenY, int pageX, int pageY,
81 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button,
82 PassRefPtr<EventTarget> relatedTarget, PassRefPtr<Clipboard> clipboard, bool isSimulated);
87 unsigned short m_button;
89 RefPtr<EventTarget> m_relatedTarget;
90 RefPtr<Clipboard> m_clipboard;
93 class SimulatedMouseEvent : public MouseEvent {
95 static PassRefPtr<SimulatedMouseEvent> create(const AtomicString& eventType, PassRefPtr<AbstractView>, PassRefPtr<Event> underlyingEvent);
96 virtual ~SimulatedMouseEvent();
99 SimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<AbstractView>, PassRefPtr<Event> underlyingEvent);
102 class MouseEventDispatchMediator : public EventDispatchMediator {
104 static PassRefPtr<MouseEventDispatchMediator> create(PassRefPtr<MouseEvent>);
107 explicit MouseEventDispatchMediator(PassRefPtr<MouseEvent>);
108 MouseEvent* event() const;
110 virtual bool dispatchEvent(EventDispatcher*) const;
113 } // namespace WebCore
115 #endif // MouseEvent_h