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, 2013 Apple Inc. All rights reserved.
6 *
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.
11 *
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.
16 *
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.
21 *
22 */
23
24#ifndef UIEvent_h
25#define UIEvent_h
26
27#include "DOMWindow.h"
28#include "Event.h"
29
30namespace WebCore {
31
32typedef DOMWindow AbstractView;
33
34struct UIEventInit : public EventInit {
35    UIEventInit();
36    UIEventInit(bool bubbles, bool cancelable);
37
38    RefPtr<AbstractView> view;
39    int detail;
40};
41
42class UIEvent : public Event {
43public:
44    static PassRefPtr<UIEvent> create()
45    {
46        return adoptRef(new UIEvent);
47    }
48    static PassRefPtr<UIEvent> create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView> view, int detail)
49    {
50        return adoptRef(new UIEvent(type, canBubble, cancelable, view, detail));
51    }
52    static PassRefPtr<UIEvent> create(const AtomicString& type, const UIEventInit& initializer)
53    {
54        return adoptRef(new UIEvent(type, initializer));
55    }
56    virtual ~UIEvent();
57
58    void initUIEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>, int detail);
59
60    AbstractView* view() const { return m_view.get(); }
61    int detail() const { return m_detail; }
62
63    virtual EventInterface eventInterface() const override;
64    virtual bool isUIEvent() const override;
65
66    virtual int keyCode() const;
67    virtual int charCode() const;
68
69    virtual int layerX();
70    virtual int layerY();
71
72    virtual int pageX() const;
73    virtual int pageY() const;
74
75    virtual int which() const;
76
77protected:
78    UIEvent();
79    UIEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>, int detail);
80    UIEvent(const AtomicString& type, bool canBubble, bool cancelable, double timestamp, PassRefPtr<AbstractView>, int detail);
81    UIEvent(const AtomicString&, const UIEventInit&);
82
83private:
84    RefPtr<AbstractView> m_view;
85    int m_detail;
86};
87
88EVENT_TYPE_CASTS(UIEvent)
89
90} // namespace WebCore
91
92#endif // UIEvent_h
93