| 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 "JSDOMRectInit.h" |
| 23 | |
| 24 | #include "JSDOMConvertNumbers.h" |
| 25 | #include <JavaScriptCore/JSCInlines.h> |
| 26 | |
| 27 | |
| 28 | namespace WebCore { |
| 29 | using namespace JSC; |
| 30 | |
| 31 | template<> DOMRectInit convertDictionary<DOMRectInit>(ExecState& state, JSValue value) |
| 32 | { |
| 33 | VM& vm = state.vm(); |
| 34 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 35 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 36 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 37 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 38 | throwTypeError(&state, throwScope); |
| 39 | return { }; |
| 40 | } |
| 41 | DOMRectInit result; |
| 42 | JSValue heightValue; |
| 43 | if (isNullOrUndefined) |
| 44 | heightValue = jsUndefined(); |
| 45 | else { |
| 46 | heightValue = object->get(&state, Identifier::fromString(&state, "height" )); |
| 47 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 48 | } |
| 49 | if (!heightValue.isUndefined()) { |
| 50 | result.height = convert<IDLUnrestrictedDouble>(state, heightValue); |
| 51 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 52 | } else |
| 53 | result.height = 0; |
| 54 | JSValue widthValue; |
| 55 | if (isNullOrUndefined) |
| 56 | widthValue = jsUndefined(); |
| 57 | else { |
| 58 | widthValue = object->get(&state, Identifier::fromString(&state, "width" )); |
| 59 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 60 | } |
| 61 | if (!widthValue.isUndefined()) { |
| 62 | result.width = convert<IDLUnrestrictedDouble>(state, widthValue); |
| 63 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 64 | } else |
| 65 | result.width = 0; |
| 66 | JSValue xValue; |
| 67 | if (isNullOrUndefined) |
| 68 | xValue = jsUndefined(); |
| 69 | else { |
| 70 | xValue = object->get(&state, Identifier::fromString(&state, "x" )); |
| 71 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 72 | } |
| 73 | if (!xValue.isUndefined()) { |
| 74 | result.x = convert<IDLUnrestrictedDouble>(state, xValue); |
| 75 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 76 | } else |
| 77 | result.x = 0; |
| 78 | JSValue yValue; |
| 79 | if (isNullOrUndefined) |
| 80 | yValue = jsUndefined(); |
| 81 | else { |
| 82 | yValue = object->get(&state, Identifier::fromString(&state, "y" )); |
| 83 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 84 | } |
| 85 | if (!yValue.isUndefined()) { |
| 86 | result.y = convert<IDLUnrestrictedDouble>(state, yValue); |
| 87 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 88 | } else |
| 89 | result.y = 0; |
| 90 | return result; |
| 91 | } |
| 92 | |
| 93 | } // namespace WebCore |
| 94 | |