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 | #include "JSScrollIntoViewOptions.h" |
23 | |
24 | #include "JSDOMConvertEnumeration.h" |
25 | #include "JSScrollLogicalPosition.h" |
26 | #include <JavaScriptCore/JSCInlines.h> |
27 | |
28 | |
29 | namespace WebCore { |
30 | using namespace JSC; |
31 | |
32 | template<> ScrollIntoViewOptions convertDictionary<ScrollIntoViewOptions>(ExecState& state, JSValue value) |
33 | { |
34 | VM& vm = state.vm(); |
35 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
36 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
37 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
38 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
39 | throwTypeError(&state, throwScope); |
40 | return { }; |
41 | } |
42 | ScrollIntoViewOptions result; |
43 | JSValue blockValue; |
44 | if (isNullOrUndefined) |
45 | blockValue = jsUndefined(); |
46 | else { |
47 | blockValue = object->get(&state, Identifier::fromString(&state, "block" )); |
48 | RETURN_IF_EXCEPTION(throwScope, { }); |
49 | } |
50 | if (!blockValue.isUndefined()) { |
51 | result.blockPosition = convert<IDLEnumeration<ScrollLogicalPosition>>(state, blockValue); |
52 | RETURN_IF_EXCEPTION(throwScope, { }); |
53 | } else |
54 | result.blockPosition = ScrollLogicalPosition::Start; |
55 | JSValue inlineValue; |
56 | if (isNullOrUndefined) |
57 | inlineValue = jsUndefined(); |
58 | else { |
59 | inlineValue = object->get(&state, Identifier::fromString(&state, "inline" )); |
60 | RETURN_IF_EXCEPTION(throwScope, { }); |
61 | } |
62 | if (!inlineValue.isUndefined()) { |
63 | result.inlinePosition = convert<IDLEnumeration<ScrollLogicalPosition>>(state, inlineValue); |
64 | RETURN_IF_EXCEPTION(throwScope, { }); |
65 | } else |
66 | result.inlinePosition = ScrollLogicalPosition::Nearest; |
67 | return result; |
68 | } |
69 | |
70 | } // namespace WebCore |
71 | |