Drop ExceptionCodeDescription class
[WebKit-https.git] / Source / WebKit / WebProcess / InjectedBundle / API / gtk / DOM / WebKitDOMWheelEvent.cpp
1 /*
2  *  This file is part of the WebKit open source project.
3  *
4  *  This library is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Library General Public
6  *  License as published by the Free Software Foundation; either
7  *  version 2 of the License, or (at your option) any later version.
8  *
9  *  This library is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  *  Library General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Library General Public License
15  *  along with this library; see the file COPYING.LIB.  If not, write to
16  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  *  Boston, MA 02110-1301, USA.
18  */
19
20 #include "config.h"
21 #include "WebKitDOMWheelEvent.h"
22
23 #include <WebCore/CSSImportRule.h>
24 #include "DOMObjectCache.h"
25 #include <WebCore/Document.h>
26 #include <WebCore/ExceptionCode.h>
27 #include <WebCore/JSMainThreadExecState.h>
28 #include "WebKitDOMDOMWindowPrivate.h"
29 #include "WebKitDOMEventPrivate.h"
30 #include "WebKitDOMPrivate.h"
31 #include "WebKitDOMWheelEventPrivate.h"
32 #include "ConvertToUTF8String.h"
33 #include <wtf/GetPtr.h>
34 #include <wtf/RefPtr.h>
35
36 namespace WebKit {
37
38 WebKitDOMWheelEvent* kit(WebCore::WheelEvent* obj)
39 {
40     return WEBKIT_DOM_WHEEL_EVENT(kit(static_cast<WebCore::Event*>(obj)));
41 }
42
43 WebCore::WheelEvent* core(WebKitDOMWheelEvent* request)
44 {
45     return request ? static_cast<WebCore::WheelEvent*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0;
46 }
47
48 WebKitDOMWheelEvent* wrapWheelEvent(WebCore::WheelEvent* coreObject)
49 {
50     ASSERT(coreObject);
51     return WEBKIT_DOM_WHEEL_EVENT(g_object_new(WEBKIT_DOM_TYPE_WHEEL_EVENT, "core-object", coreObject, nullptr));
52 }
53
54 } // namespace WebKit
55
56 G_DEFINE_TYPE(WebKitDOMWheelEvent, webkit_dom_wheel_event, WEBKIT_DOM_TYPE_MOUSE_EVENT)
57
58 enum {
59     PROP_0,
60     PROP_WHEEL_DELTA_X,
61     PROP_WHEEL_DELTA_Y,
62     PROP_WHEEL_DELTA,
63 };
64
65 static void webkit_dom_wheel_event_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec)
66 {
67     WebKitDOMWheelEvent* self = WEBKIT_DOM_WHEEL_EVENT(object);
68
69     switch (propertyId) {
70     case PROP_WHEEL_DELTA_X:
71         g_value_set_long(value, webkit_dom_wheel_event_get_wheel_delta_x(self));
72         break;
73     case PROP_WHEEL_DELTA_Y:
74         g_value_set_long(value, webkit_dom_wheel_event_get_wheel_delta_y(self));
75         break;
76     case PROP_WHEEL_DELTA:
77         g_value_set_long(value, webkit_dom_wheel_event_get_wheel_delta(self));
78         break;
79     default:
80         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
81         break;
82     }
83 }
84
85 static void webkit_dom_wheel_event_class_init(WebKitDOMWheelEventClass* requestClass)
86 {
87     GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass);
88     gobjectClass->get_property = webkit_dom_wheel_event_get_property;
89
90     g_object_class_install_property(
91         gobjectClass,
92         PROP_WHEEL_DELTA_X,
93         g_param_spec_long(
94             "wheel-delta-x",
95             "WheelEvent:wheel-delta-x",
96             "read-only glong WheelEvent:wheel-delta-x",
97             G_MINLONG, G_MAXLONG, 0,
98             WEBKIT_PARAM_READABLE));
99
100     g_object_class_install_property(
101         gobjectClass,
102         PROP_WHEEL_DELTA_Y,
103         g_param_spec_long(
104             "wheel-delta-y",
105             "WheelEvent:wheel-delta-y",
106             "read-only glong WheelEvent:wheel-delta-y",
107             G_MINLONG, G_MAXLONG, 0,
108             WEBKIT_PARAM_READABLE));
109
110     g_object_class_install_property(
111         gobjectClass,
112         PROP_WHEEL_DELTA,
113         g_param_spec_long(
114             "wheel-delta",
115             "WheelEvent:wheel-delta",
116             "read-only glong WheelEvent:wheel-delta",
117             G_MINLONG, G_MAXLONG, 0,
118             WEBKIT_PARAM_READABLE));
119 }
120
121 static void webkit_dom_wheel_event_init(WebKitDOMWheelEvent* request)
122 {
123     UNUSED_PARAM(request);
124 }
125
126 void webkit_dom_wheel_event_init_wheel_event(WebKitDOMWheelEvent* self, glong wheelDeltaX, glong wheelDeltaY, WebKitDOMDOMWindow* view, glong screenX, glong screenY, glong clientX, glong clientY, gboolean ctrlKey, gboolean altKey, gboolean shiftKey, gboolean metaKey)
127 {
128     WebCore::JSMainThreadNullState state;
129     g_return_if_fail(WEBKIT_DOM_IS_WHEEL_EVENT(self));
130     g_return_if_fail(WEBKIT_DOM_IS_DOM_WINDOW(view));
131     WebCore::WheelEvent* item = WebKit::core(self);
132     WebCore::DOMWindow* convertedView = WebKit::core(view);
133     item->initWheelEvent(wheelDeltaX, wheelDeltaY, convertedView, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey);
134 }
135
136 glong webkit_dom_wheel_event_get_wheel_delta_x(WebKitDOMWheelEvent* self)
137 {
138     WebCore::JSMainThreadNullState state;
139     g_return_val_if_fail(WEBKIT_DOM_IS_WHEEL_EVENT(self), 0);
140     WebCore::WheelEvent* item = WebKit::core(self);
141     glong result = item->wheelDeltaX();
142     return result;
143 }
144
145 glong webkit_dom_wheel_event_get_wheel_delta_y(WebKitDOMWheelEvent* self)
146 {
147     WebCore::JSMainThreadNullState state;
148     g_return_val_if_fail(WEBKIT_DOM_IS_WHEEL_EVENT(self), 0);
149     WebCore::WheelEvent* item = WebKit::core(self);
150     glong result = item->wheelDeltaY();
151     return result;
152 }
153
154 glong webkit_dom_wheel_event_get_wheel_delta(WebKitDOMWheelEvent* self)
155 {
156     WebCore::JSMainThreadNullState state;
157     g_return_val_if_fail(WEBKIT_DOM_IS_WHEEL_EVENT(self), 0);
158     WebCore::WheelEvent* item = WebKit::core(self);
159     glong result = item->wheelDelta();
160     return result;
161 }