| 148 | } |
| 149 | |
| 150 | GJS_JSAPI_RETURN_CONVENTION |
| 151 | static bool getDeviceOffset_func(JSContext* cx, unsigned argc, JS::Value* vp) { |
| 152 | GJS_GET_THIS(cx, argc, vp, args, obj); |
| 153 | |
| 154 | if (argc > 0) { |
| 155 | gjs_throw(cx, "Surface.getDeviceOffset() takes no arguments"); |
| 156 | return false; |
| 157 | } |
| 158 | |
| 159 | cairo_surface_t* surface = CairoSurface::for_js(cx, obj); |
| 160 | if (!surface) |
| 161 | return false; |
| 162 | |
| 163 | double x_offset, y_offset; |
| 164 | cairo_surface_get_device_offset(surface, &x_offset, &y_offset); |
| 165 | // cannot error |
| 166 | |
| 167 | JS::RootedValueArray<2> elements(cx); |
| 168 | elements[0].setNumber(JS::CanonicalizeNaN(x_offset)); |
| 169 | elements[1].setNumber(JS::CanonicalizeNaN(y_offset)); |
| 170 | JS::RootedObject retval(cx, JS::NewArrayObject(cx, elements)); |
| 171 | if (!retval) |
| 172 | return false; |
| 173 | |
| 174 | args.rval().setObject(*retval); |
| 175 | return true; |
| 176 | } |
| 177 | |
| 178 | GJS_JSAPI_RETURN_CONVENTION |
| 179 | static bool setDeviceScale_func(JSContext* cx, unsigned argc, JS::Value* vp) { |
nothing calls this directly
no test coverage detected