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(CSS_PAINTING_API)
24
25#include "JSCSSPaintCallback.h"
26
27#include "JSCSSPaintSize.h"
28#include "JSDOMConvertAny.h"
29#include "JSDOMConvertInterface.h"
30#include "JSDOMConvertSequences.h"
31#include "JSDOMConvertStrings.h"
32#include "JSDOMExceptionHandling.h"
33#include "JSDOMGlobalObject.h"
34#include "JSPaintRenderingContext2D.h"
35#include "JSStylePropertyMapReadOnly.h"
36#include "ScriptExecutionContext.h"
37#include <JavaScriptCore/JSArray.h>
38
39
40namespace WebCore {
41using namespace JSC;
42
43JSCSSPaintCallback::JSCSSPaintCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
44 : CSSPaintCallback(globalObject->scriptExecutionContext())
45 , m_data(new JSCallbackDataStrong(callback, globalObject, this))
46{
47}
48
49JSCSSPaintCallback::~JSCSSPaintCallback()
50{
51 ScriptExecutionContext* context = scriptExecutionContext();
52 // When the context is destroyed, all tasks with a reference to a callback
53 // should be deleted. So if the context is 0, we are on the context thread.
54 if (!context || context->isContextThread())
55 delete m_data;
56 else
57 context->postTask(DeleteCallbackDataTask(m_data));
58#ifndef NDEBUG
59 m_data = nullptr;
60#endif
61}
62
63CallbackResult<typename IDLVoid::ImplementationType> JSCSSPaintCallback::handleEvent(typename IDLAny::ParameterType thisObject, typename IDLInterface<PaintRenderingContext2D>::ParameterType context, typename IDLInterface<CSSPaintSize>::ParameterType size, typename IDLInterface<StylePropertyMapReadOnly>::ParameterType styleMap, typename IDLSequence<IDLUSVString>::ParameterType arguments)
64{
65 if (!canInvokeCallback())
66 return CallbackResultType::UnableToExecute;
67
68 Ref<JSCSSPaintCallback> protectedThis(*this);
69
70 auto& globalObject = *m_data->globalObject();
71 auto& vm = globalObject.vm();
72
73 JSLockHolder lock(vm);
74 auto& state = *globalObject.globalExec();
75 JSValue thisValue = toJS<IDLAny>(thisObject);
76 MarkedArgumentBuffer args;
77 args.append(toJS<IDLInterface<PaintRenderingContext2D>>(state, globalObject, context));
78 args.append(toJS<IDLInterface<CSSPaintSize>>(state, globalObject, size));
79 args.append(toJS<IDLInterface<StylePropertyMapReadOnly>>(state, globalObject, styleMap));
80 args.append(toJS<IDLSequence<IDLUSVString>>(state, globalObject, arguments));
81 ASSERT(!args.hasOverflowed());
82
83 NakedPtr<JSC::Exception> returnedException;
84 m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
85 if (returnedException) {
86 reportException(&state, returnedException);
87 return CallbackResultType::ExceptionThrown;
88 }
89
90 return { };
91}
92
93JSC::JSValue toJS(CSSPaintCallback& impl)
94{
95 if (!static_cast<JSCSSPaintCallback&>(impl).callbackData())
96 return jsNull();
97
98 return static_cast<JSCSSPaintCallback&>(impl).callbackData()->callback();
99}
100
101} // namespace WebCore
102
103#endif // ENABLE(CSS_PAINTING_API)
104