1 | /* |
2 | This file is part of the WebKit open source project. |
3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #include "config.h" |
22 | |
23 | #if ENABLE(GEOLOCATION) |
24 | |
25 | #include "JSPositionErrorCallback.h" |
26 | |
27 | #include "JSDOMConvertInterface.h" |
28 | #include "JSDOMExceptionHandling.h" |
29 | #include "JSDOMGlobalObject.h" |
30 | #include "JSPositionError.h" |
31 | #include "ScriptExecutionContext.h" |
32 | |
33 | |
34 | namespace WebCore { |
35 | using namespace JSC; |
36 | |
37 | JSPositionErrorCallback::JSPositionErrorCallback(JSObject* callback, JSDOMGlobalObject* globalObject) |
38 | : PositionErrorCallback(globalObject->scriptExecutionContext()) |
39 | , m_data(new JSCallbackDataStrong(callback, globalObject, this)) |
40 | { |
41 | } |
42 | |
43 | JSPositionErrorCallback::~JSPositionErrorCallback() |
44 | { |
45 | ScriptExecutionContext* context = scriptExecutionContext(); |
46 | // When the context is destroyed, all tasks with a reference to a callback |
47 | // should be deleted. So if the context is 0, we are on the context thread. |
48 | if (!context || context->isContextThread()) |
49 | delete m_data; |
50 | else |
51 | context->postTask(DeleteCallbackDataTask(m_data)); |
52 | #ifndef NDEBUG |
53 | m_data = nullptr; |
54 | #endif |
55 | } |
56 | |
57 | CallbackResult<typename IDLVoid::ImplementationType> JSPositionErrorCallback::handleEvent(typename IDLInterface<PositionError>::ParameterType error) |
58 | { |
59 | if (!canInvokeCallback()) |
60 | return CallbackResultType::UnableToExecute; |
61 | |
62 | Ref<JSPositionErrorCallback> protectedThis(*this); |
63 | |
64 | auto& globalObject = *m_data->globalObject(); |
65 | auto& vm = globalObject.vm(); |
66 | |
67 | JSLockHolder lock(vm); |
68 | auto& state = *globalObject.globalExec(); |
69 | JSValue thisValue = jsUndefined(); |
70 | MarkedArgumentBuffer args; |
71 | args.append(toJS<IDLInterface<PositionError>>(state, globalObject, error)); |
72 | ASSERT(!args.hasOverflowed()); |
73 | |
74 | NakedPtr<JSC::Exception> returnedException; |
75 | m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException); |
76 | if (returnedException) { |
77 | reportException(&state, returnedException); |
78 | return CallbackResultType::ExceptionThrown; |
79 | } |
80 | |
81 | return { }; |
82 | } |
83 | |
84 | JSC::JSValue toJS(PositionErrorCallback& impl) |
85 | { |
86 | if (!static_cast<JSPositionErrorCallback&>(impl).callbackData()) |
87 | return jsNull(); |
88 | |
89 | return static_cast<JSPositionErrorCallback&>(impl).callbackData()->callback(); |
90 | } |
91 | |
92 | } // namespace WebCore |
93 | |
94 | #endif // ENABLE(GEOLOCATION) |
95 | |