From 6f4e30f8b6eb4785fccd50183606d0d1f9a7b8e8 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 16 Jun 2024 18:17:01 +0200 Subject: [PATCH] [ecmascript] placeholder for CSSStyleDeclaration.getPropertyValue It returns undefined. --- src/ecmascript/mujs/css.c | 10 ++++++++++ src/ecmascript/quickjs/css.c | 12 ++++++++++++ src/ecmascript/spidermonkey/css.cpp | 15 +++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/src/ecmascript/mujs/css.c b/src/ecmascript/mujs/css.c index 3ebf552ce..343062f3b 100644 --- a/src/ecmascript/mujs/css.c +++ b/src/ecmascript/mujs/css.c @@ -40,6 +40,15 @@ mjs_push_CSSStyleDeclaration_item2(js_State *J, int idx) js_pushstring(J, "0"); // fake } +static void +mjs_CSSStyleDeclaration_getPropertyValue(js_State *J) +{ +#ifdef ECMASCRIPT_DEBUG + fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); +#endif + js_pushundefined(J); // fake +} + static void mjs_CSSStyleDeclaration_item(js_State *J) { @@ -104,6 +113,7 @@ mjs_push_CSSStyleDeclaration(js_State *J, void *node) js_newarray(J); { js_newuserdata(J, "CSSStyleDeclaration", node, mjs_CSSStyleDeclaration_finalizer); + addmethod(J, "getPropertyValue", mjs_CSSStyleDeclaration_getPropertyValue, 1); addmethod(J, "item", mjs_CSSStyleDeclaration_item, 1); addmethod(J, "namedItem", mjs_CSSStyleDeclaration_namedItem, 1); addmethod(J, "toString", mjs_CSSStyleDeclaration_toString, 0); diff --git a/src/ecmascript/quickjs/css.c b/src/ecmascript/quickjs/css.c index a44c40804..46a8f0fa9 100644 --- a/src/ecmascript/quickjs/css.c +++ b/src/ecmascript/quickjs/css.c @@ -58,6 +58,17 @@ js_CSSStyleDeclaration_get_property_length(JSContext *ctx, JSValueConst this_val return JS_NewInt32(ctx, 3); // fake } +static JSValue +js_CSSStyleDeclaration_getPropertyValue(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) +{ +#ifdef ECMASCRIPT_DEBUG + fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); +#endif + REF_JS(this_val); + + return JS_UNDEFINED; +} + static JSValue js_CSSStyleDeclaration_item2(JSContext *ctx, JSValueConst this_val, int idx) { @@ -133,6 +144,7 @@ js_CSSStyleDeclaration_toString(JSContext *ctx, JSValueConst this_val, int argc, static const JSCFunctionListEntry js_CSSStyleDeclaration_proto_funcs[] = { JS_CGETSET_DEF("length", js_CSSStyleDeclaration_get_property_length, NULL), + JS_CFUNC_DEF("getPropertyValue", 1, js_CSSStyleDeclaration_getPropertyValue), JS_CFUNC_DEF("item", 1, js_CSSStyleDeclaration_item), JS_CFUNC_DEF("namedItem", 1, js_CSSStyleDeclaration_namedItem), JS_CFUNC_DEF("toString", 0, js_CSSStyleDeclaration_toString) diff --git a/src/ecmascript/spidermonkey/css.cpp b/src/ecmascript/spidermonkey/css.cpp index a5588df92..e7b4ab3c5 100644 --- a/src/ecmascript/spidermonkey/css.cpp +++ b/src/ecmascript/spidermonkey/css.cpp @@ -54,6 +54,7 @@ static bool CSSStyleDeclaration_item(JSContext *ctx, unsigned int argc, JS::Value *rval); +static bool CSSStyleDeclaration_getPropertyValue(JSContext *ctx, unsigned int argc, JS::Value *rval); static bool CSSStyleDeclaration_namedItem(JSContext *ctx, unsigned int argc, JS::Value *rval); static bool CSSStyleDeclaration_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::MutableHandleValue hvp); static bool CSSStyleDeclaration_namedItem2(JSContext *ctx, JS::HandleObject hobj, char *str, JS::MutableHandleValue hvp); @@ -85,6 +86,7 @@ JSClass CSSStyleDeclaration_class = { }; static const spidermonkeyFunctionSpec CSSStyleDeclaration_funcs[] = { + { "getPropertyValue", CSSStyleDeclaration_getPropertyValue, 1 }, { "item", CSSStyleDeclaration_item, 1 }, { "namedItem", CSSStyleDeclaration_namedItem, 1 }, { NULL } @@ -120,6 +122,18 @@ CSSStyleDeclaration_get_property_length(JSContext *ctx, unsigned int argc, JS::V return true; } +static bool +CSSStyleDeclaration_getPropertyValue(JSContext *ctx, unsigned int argc, JS::Value *vp) +{ +#ifdef ECMASCRIPT_DEBUG + fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); +#endif + JS::CallArgs args = CallArgsFromVp(argc, vp); + args.rval().setUndefined(); + + return true; +} + static bool CSSStyleDeclaration_item(JSContext *ctx, unsigned int argc, JS::Value *vp) { @@ -138,6 +152,7 @@ CSSStyleDeclaration_item(JSContext *ctx, unsigned int argc, JS::Value *vp) return ret; } + static bool CSSStyleDeclaration_namedItem(JSContext *ctx, unsigned int argc, JS::Value *vp) {