1
0
Fork 0

Revert "Fix some issues with js."

This reverts commit 6322d2936a.
This commit is contained in:
Witold Filipczyk 2019-04-21 12:26:27 +02:00
parent 6322d2936a
commit 8d7112c27d
16 changed files with 226 additions and 294 deletions

View File

@ -88,6 +88,7 @@ jsid_to_string(JSContext *ctx, jsid *id)
}
#define ELINKS_CAST_PROP_PARAMS JSObject *obj = (hobj); \
jsval vp = hvp; \
jsval vp2 = (hvp); \
jsval *vp = &vp2;
#endif

View File

@ -85,11 +85,9 @@ document_get_property_cookie(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
strncpy(cookiestr, cookies->source, 1024);
done_string(cookies);
string_to_jsval(ctx, &vp, cookiestr);
hvp.set(vp);
string_to_jsval(ctx, vp, cookiestr);
} else {
string_to_jsval(ctx, &vp, "");
hvp.set(vp);
string_to_jsval(ctx, vp, "");
}
return JS_TRUE;
@ -115,7 +113,7 @@ document_set_property_cookie(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
vs = JS_GetInstancePrivate(ctx, parent_win,
&window_class, NULL);
set_cookie(vs->uri, jsval_to_string(ctx, &vp));
set_cookie(vs->uri, jsval_to_string(ctx, vp));
return JS_TRUE;
}
@ -137,7 +135,7 @@ document_get_property_location(JSContext *ctx, JSHandleObject hobj, JSHandleId h
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
if_assert_failed return JS_FALSE;
JS_GetProperty(ctx, parent_win, "location", &vp);
JS_GetProperty(ctx, parent_win, "location", vp);
return JS_TRUE;
}
@ -164,7 +162,7 @@ document_set_property_location(JSContext *ctx, JSHandleObject hobj, JSHandleId h
vs = JS_GetInstancePrivate(ctx, parent_win,
&window_class, NULL);
doc_view = vs->doc_view;
location_goto(doc_view, jsval_to_string(ctx, &vp));
location_goto(doc_view, jsval_to_string(ctx, vp));
return JS_TRUE;
}
@ -198,26 +196,22 @@ document_get_property_referrer(JSContext *ctx, JSHandleObject hobj, JSHandleId h
switch (get_opt_int("protocol.http.referer.policy", NULL)) {
case REFERER_NONE:
/* oh well */
undef_to_jsval(ctx, &vp);
hvp.set(vp);
undef_to_jsval(ctx, vp);
break;
case REFERER_FAKE:
string_to_jsval(ctx, &vp, get_opt_str("protocol.http.referer.fake", NULL));
hvp.set(vp);
string_to_jsval(ctx, vp, get_opt_str("protocol.http.referer.fake", NULL));
break;
case REFERER_TRUE:
/* XXX: Encode as in add_url_to_httset_prop_string(&prop, ) ? --pasky */
if (ses->referrer) {
astring_to_jsval(ctx, &vp, get_uri_string(ses->referrer, URI_HTTP_REFERRER));
hvp.set(vp);
astring_to_jsval(ctx, vp, get_uri_string(ses->referrer, URI_HTTP_REFERRER));
}
break;
case REFERER_SAME_URL:
astring_to_jsval(ctx, &vp, get_uri_string(document->uri, URI_HTTP_REFERRER));
hvp.set(vp);
astring_to_jsval(ctx, vp, get_uri_string(document->uri, URI_HTTP_REFERRER));
break;
}
@ -247,8 +241,7 @@ document_get_property_title(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
&window_class, NULL);
doc_view = vs->doc_view;
document = doc_view->document;
string_to_jsval(ctx, &vp, document->title);
hvp.set(vp);
string_to_jsval(ctx, vp, document->title);
return JS_TRUE;
}
@ -277,7 +270,7 @@ document_set_property_title(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
&window_class, NULL);
doc_view = vs->doc_view;
document = doc_view->document;
mem_free_set(&document->title, stracpy(jsval_to_string(ctx, &vp)));
mem_free_set(&document->title, stracpy(jsval_to_string(ctx, vp)));
print_screen_status(doc_view->session);
return JS_TRUE;
@ -305,8 +298,7 @@ document_get_property_url(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, J
&window_class, NULL);
doc_view = vs->doc_view;
document = doc_view->document;
astring_to_jsval(ctx, &vp, get_uri_string(document->uri, URI_ORIGINAL));
hvp.set(vp);
astring_to_jsval(ctx, vp, get_uri_string(document->uri, URI_ORIGINAL));
return JS_TRUE;
}
@ -333,7 +325,7 @@ document_set_property_url(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, J
vs = JS_GetInstancePrivate(ctx, parent_win,
&window_class, NULL);
doc_view = vs->doc_view;
location_goto(doc_view, jsval_to_string(ctx, &vp));
location_goto(doc_view, jsval_to_string(ctx, vp));
return JS_TRUE;
}
@ -386,8 +378,7 @@ document_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMut
if (!form->name || c_strcasecmp(string, form->name))
continue;
object_to_jsval(ctx, &vp, get_form_object(ctx, obj, find_form_view(doc_view, form)));
hvp.set(vp);
object_to_jsval(ctx, vp, get_form_object(ctx, obj, find_form_view(doc_view, form)));
break;
}

View File

@ -142,20 +142,16 @@ input_get_property_accessKey(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
/* Hiddens have no link. */
if (linknum >= 0) link = &document->links[linknum];
undef_to_jsval(ctx, &vp);
hvp.set(vp);
undef_to_jsval(ctx, vp);
if (!link) return JS_TRUE;
if (!link->accesskey) {
vp = JS_GetEmptyStringValue(ctx);
hvp.set(vp);
*vp = JS_GetEmptyStringValue(ctx);
} else {
keystr = unicode_to_jsstring(ctx, link->accesskey);
if (keystr) {
vp = STRING_TO_JSVAL(keystr);
hvp.set(vp);
}
if (keystr)
*vp = STRING_TO_JSVAL(keystr);
else
return JS_FALSE;
}
@ -209,7 +205,7 @@ input_set_property_accessKey(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
/* Hiddens have no link. */
if (linknum >= 0) link = &document->links[linknum];
accesskey = jsval_to_accesskey(ctx, &vp);
accesskey = jsval_to_accesskey(ctx, vp);
if (accesskey == UCS_NO_CHAR)
return JS_FALSE;
@ -262,8 +258,7 @@ input_get_property_alt(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMu
assert(fc);
assert(fc->form && fs);
string_to_jsval(ctx, &vp, fc->alt);
hvp.set(vp);
string_to_jsval(ctx, vp, fc->alt);
return JS_TRUE;
}
@ -308,7 +303,7 @@ input_set_property_alt(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBo
assert(fc);
assert(fc->form && fs);
mem_free_set(&fc->alt, stracpy(jsval_to_string(ctx, &vp)));
mem_free_set(&fc->alt, stracpy(jsval_to_string(ctx, vp)));
return JS_TRUE;
}
@ -329,8 +324,7 @@ input_get_property_checked(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
fs = input_get_form_state(ctx, obj);
if (!fs) return JS_FALSE; /* detached */
boolean_to_jsval(ctx, &vp, fs->state);
hvp.set(vp);
boolean_to_jsval(ctx, vp, fs->state);
return JS_TRUE;
}
@ -377,7 +371,7 @@ input_set_property_checked(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if (fc->type != FC_CHECKBOX && fc->type != FC_RADIO)
return JS_TRUE;
fs->state = jsval_to_boolean(ctx, &vp);
fs->state = jsval_to_boolean(ctx, vp);
return JS_TRUE;
}
@ -425,8 +419,7 @@ input_get_property_defaultChecked(JSContext *ctx, JSHandleObject hobj, JSHandleI
assert(fc);
assert(fc->form && fs);
boolean_to_jsval(ctx, &vp, fc->default_state);
hvp.set(vp);
boolean_to_jsval(ctx, vp, fc->default_state);
return JS_TRUE;
}
@ -475,8 +468,7 @@ input_get_property_defaultValue(JSContext *ctx, JSHandleObject hobj, JSHandleId
assert(fc->form && fs);
/* FIXME (bug 805): convert from the charset of the document */
string_to_jsval(ctx, &vp, fc->default_value);
hvp.set(vp);
string_to_jsval(ctx, vp, fc->default_value);
return JS_TRUE;
}
@ -525,8 +517,7 @@ input_get_property_disabled(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
assert(fc->form && fs);
/* FIXME: <input readonly disabled> --pasky */
boolean_to_jsval(ctx, &vp, fc->mode == FORM_MODE_DISABLED);
hvp.set(vp);
boolean_to_jsval(ctx, vp, fc->mode == FORM_MODE_DISABLED);
return JS_TRUE;
}
@ -572,7 +563,7 @@ input_set_property_disabled(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
assert(fc->form && fs);
/* FIXME: <input readonly disabled> --pasky */
fc->mode = (jsval_to_boolean(ctx, &vp) ? FORM_MODE_DISABLED
fc->mode = (jsval_to_boolean(ctx, vp) ? FORM_MODE_DISABLED
: fc->mode == FORM_MODE_READONLY ? FORM_MODE_READONLY
: FORM_MODE_NORMAL);
@ -596,8 +587,7 @@ input_get_property_form(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSM
assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL));
if_assert_failed return JS_FALSE;
object_to_jsval(ctx, &vp, parent_form);
hvp.set(vp);
object_to_jsval(ctx, vp, parent_form);
return JS_TRUE;
}
@ -645,8 +635,7 @@ input_get_property_maxLength(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
assert(fc);
assert(fc->form && fs);
int_to_jsval(ctx, &vp, fc->maxlength);
hvp.set(vp);
int_to_jsval(ctx, vp, fc->maxlength);
return JS_TRUE;
}
@ -691,7 +680,7 @@ input_set_property_maxLength(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
assert(fc);
assert(fc->form && fs);
if (!JS_ValueToInt32(ctx, vp, &fc->maxlength))
if (!JS_ValueToInt32(ctx, *vp, &fc->maxlength))
return JS_FALSE;
return JS_TRUE;
@ -740,8 +729,7 @@ input_get_property_name(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSM
assert(fc);
assert(fc->form && fs);
string_to_jsval(ctx, &vp, fc->name);
hvp.set(vp);
string_to_jsval(ctx, vp, fc->name);
return JS_TRUE;
}
@ -787,7 +775,7 @@ input_set_property_name(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSB
assert(fc);
assert(fc->form && fs);
mem_free_set(&fc->name, stracpy(jsval_to_string(ctx, &vp)));
mem_free_set(&fc->name, stracpy(jsval_to_string(ctx, vp)));
return JS_TRUE;
}
@ -836,8 +824,7 @@ input_get_property_readonly(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
assert(fc->form && fs);
/* FIXME: <input readonly disabled> --pasky */
boolean_to_jsval(ctx, &vp, fc->mode == FORM_MODE_READONLY);
hvp.set(vp);
boolean_to_jsval(ctx, vp, fc->mode == FORM_MODE_READONLY);
return JS_TRUE;
}
@ -884,7 +871,7 @@ input_set_property_readonly(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
assert(fc->form && fs);
/* FIXME: <input readonly disabled> --pasky */
fc->mode = (jsval_to_boolean(ctx, &vp) ? FORM_MODE_READONLY
fc->mode = (jsval_to_boolean(ctx, vp) ? FORM_MODE_READONLY
: fc->mode == FORM_MODE_DISABLED ? FORM_MODE_DISABLED
: FORM_MODE_NORMAL);
@ -934,10 +921,9 @@ input_get_property_selectedIndex(JSContext *ctx, JSHandleObject hobj, JSHandleId
assert(fc);
assert(fc->form && fs);
undef_to_jsval(ctx, &vp);
undef_to_jsval(ctx, vp);
if (fc->type == FC_SELECT) int_to_jsval(ctx, &vp, fs->state);
hvp.set(vp);
if (fc->type == FC_SELECT) int_to_jsval(ctx, vp, fs->state);
return JS_TRUE;
}
@ -986,7 +972,7 @@ input_set_property_selectedIndex(JSContext *ctx, JSHandleObject hobj, JSHandleId
if (fc->type == FC_SELECT) {
int item;
if (!JS_ValueToInt32(ctx, vp, &item))
if (!JS_ValueToInt32(ctx, *vp, &item))
return JS_FALSE;
if (item >= 0 && item < fc->nvalues) {
@ -1041,8 +1027,7 @@ input_get_property_size(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSM
assert(fc);
assert(fc->form && fs);
int_to_jsval(ctx, &vp, fc->size);
hvp.set(vp);
int_to_jsval(ctx, vp, fc->size);
return JS_TRUE;
}
@ -1095,12 +1080,10 @@ input_get_property_src(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMu
/* Hiddens have no link. */
if (linknum >= 0) link = &document->links[linknum];
undef_to_jsval(ctx, &vp);
undef_to_jsval(ctx, vp);
if (link && link->where_img)
string_to_jsval(ctx, &vp, link->where_img);
hvp.set(vp);
string_to_jsval(ctx, vp, link->where_img);
return JS_TRUE;
}
@ -1152,7 +1135,7 @@ input_set_property_src(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBo
if (linknum >= 0) link = &document->links[linknum];
if (link) {
mem_free_set(&link->where_img, stracpy(jsval_to_string(ctx, &vp)));
mem_free_set(&link->where_img, stracpy(jsval_to_string(ctx, vp)));
}
return JS_TRUE;
@ -1207,13 +1190,11 @@ input_get_property_tabIndex(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
/* Hiddens have no link. */
if (linknum >= 0) link = &document->links[linknum];
undef_to_jsval(ctx, &vp);
undef_to_jsval(ctx, vp);
if (link)
/* FIXME: This is WRONG. --pasky */
int_to_jsval(ctx, &vp, link->number);
hvp.set(vp);
int_to_jsval(ctx, vp, link->number);
return JS_TRUE;
}
@ -1276,8 +1257,7 @@ input_get_property_type(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSM
case FC_SELECT: s = "select"; break;
default: INTERNAL("input_get_property() upon a non-input item."); break;
}
string_to_jsval(ctx, &vp, s);
hvp.set(vp);
string_to_jsval(ctx, vp, s);
return JS_TRUE;
}
@ -1297,8 +1277,7 @@ input_get_property_value(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
fs = input_get_form_state(ctx, obj);
if (!fs) return JS_FALSE; /* detached */
string_to_jsval(ctx, &vp, fs->value);
hvp.set(vp);
string_to_jsval(ctx, vp, fs->value);
return JS_TRUE;
}
@ -1344,7 +1323,7 @@ input_set_property_value(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
assert(fc->form && fs);
if (fc->type != FC_FILE) {
mem_free_set(&fs->value, stracpy(jsval_to_string(ctx, &vp)));
mem_free_set(&fs->value, stracpy(jsval_to_string(ctx, vp)));
if (fc->type == FC_TEXT || fc->type == FC_PASSWORD)
fs->state = strlen(fs->value);
}
@ -1459,8 +1438,7 @@ input_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutabl
/* Hiddens have no link. */
if (linknum >= 0) link = &document->links[linknum];
undef_to_jsval(ctx, &vp);
hvp.set(vp);
undef_to_jsval(ctx, vp);
switch (JSID_TO_INT(id)) {
case JSP_INPUT_ACCESSKEY:
@ -1470,57 +1448,57 @@ input_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutabl
if (!link) break;
if (!link->accesskey) {
vp = JS_GetEmptyStringValue(ctx);
*vp = JS_GetEmptyStringValue(ctx);
} else {
keystr = unicode_to_jsstring(ctx, link->accesskey);
if (keystr)
vp = STRING_TO_JSVAL(keystr);
*vp = STRING_TO_JSVAL(keystr);
else
return JS_FALSE;
}
break;
}
case JSP_INPUT_ALT:
string_to_jsval(ctx, &vp, fc->alt);
string_to_jsval(ctx, vp, fc->alt);
break;
case JSP_INPUT_CHECKED:
boolean_to_jsval(ctx, &vp, fs->state);
boolean_to_jsval(ctx, vp, fs->state);
break;
case JSP_INPUT_DEFAULT_CHECKED:
boolean_to_jsval(ctx, &vp, fc->default_state);
boolean_to_jsval(ctx, vp, fc->default_state);
break;
case JSP_INPUT_DEFAULT_VALUE:
/* FIXME (bug 805): convert from the charset of the document */
string_to_jsval(ctx, &vp, fc->default_value);
string_to_jsval(ctx, vp, fc->default_value);
break;
case JSP_INPUT_DISABLED:
/* FIXME: <input readonly disabled> --pasky */
boolean_to_jsval(ctx, &vp, fc->mode == FORM_MODE_DISABLED);
boolean_to_jsval(ctx, vp, fc->mode == FORM_MODE_DISABLED);
break;
case JSP_INPUT_FORM:
object_to_jsval(ctx, &vp, parent_form);
object_to_jsval(ctx, vp, parent_form);
break;
case JSP_INPUT_MAX_LENGTH:
int_to_jsval(ctx, &vp, fc->maxlength);
int_to_jsval(ctx, vp, fc->maxlength);
break;
case JSP_INPUT_NAME:
string_to_jsval(ctx, &vp, fc->name);
string_to_jsval(ctx, vp, fc->name);
break;
case JSP_INPUT_READONLY:
/* FIXME: <input readonly disabled> --pasky */
boolean_to_jsval(ctx, &vp, fc->mode == FORM_MODE_READONLY);
boolean_to_jsval(ctx, vp, fc->mode == FORM_MODE_READONLY);
break;
case JSP_INPUT_SIZE:
int_to_jsval(ctx, &vp, fc->size);
int_to_jsval(ctx, vp, fc->size);
break;
case JSP_INPUT_SRC:
if (link && link->where_img)
string_to_jsval(ctx, &vp, link->where_img);
string_to_jsval(ctx, vp, link->where_img);
break;
case JSP_INPUT_TABINDEX:
if (link)
/* FIXME: This is WRONG. --pasky */
int_to_jsval(ctx, &vp, link->number);
int_to_jsval(ctx, vp, link->number);
break;
case JSP_INPUT_TYPE:
{
@ -1540,15 +1518,15 @@ input_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutabl
case FC_SELECT: s = "select"; break;
default: INTERNAL("input_get_property() upon a non-input item."); break;
}
string_to_jsval(ctx, &vp, s);
string_to_jsval(ctx, vp, s);
break;
}
case JSP_INPUT_VALUE:
string_to_jsval(ctx, &vp, fs->value);
string_to_jsval(ctx, vp, fs->value);
break;
case JSP_INPUT_SELECTED_INDEX:
if (fc->type == FC_SELECT) int_to_jsval(ctx, &vp, fs->state);
if (fc->type == FC_SELECT) int_to_jsval(ctx, vp, fs->state);
break;
default:
/* Unrecognized integer property ID; someone is using
@ -1559,7 +1537,6 @@ input_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutabl
* @undef_to_jsval.) */
break;
}
hvp.set(vp);
return JS_TRUE;
}
@ -1618,48 +1595,48 @@ input_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBool s
switch (JSID_TO_INT(id)) {
case JSP_INPUT_ACCESSKEY:
accesskey = jsval_to_accesskey(ctx, &vp);
accesskey = jsval_to_accesskey(ctx, vp);
if (accesskey == UCS_NO_CHAR)
return JS_FALSE;
else if (link)
link->accesskey = accesskey;
break;
case JSP_INPUT_ALT:
mem_free_set(&fc->alt, stracpy(jsval_to_string(ctx, &vp)));
mem_free_set(&fc->alt, stracpy(jsval_to_string(ctx, vp)));
break;
case JSP_INPUT_CHECKED:
if (fc->type != FC_CHECKBOX && fc->type != FC_RADIO)
break;
fs->state = jsval_to_boolean(ctx, &vp);
fs->state = jsval_to_boolean(ctx, vp);
break;
case JSP_INPUT_DISABLED:
/* FIXME: <input readonly disabled> --pasky */
fc->mode = (jsval_to_boolean(ctx, &vp) ? FORM_MODE_DISABLED
fc->mode = (jsval_to_boolean(ctx, vp) ? FORM_MODE_DISABLED
: fc->mode == FORM_MODE_READONLY ? FORM_MODE_READONLY
: FORM_MODE_NORMAL);
break;
case JSP_INPUT_MAX_LENGTH:
if (!JS_ValueToInt32(ctx, vp, &fc->maxlength))
if (!JS_ValueToInt32(ctx, *vp, &fc->maxlength))
return JS_FALSE;
break;
case JSP_INPUT_NAME:
mem_free_set(&fc->name, stracpy(jsval_to_string(ctx, &vp)));
mem_free_set(&fc->name, stracpy(jsval_to_string(ctx, vp)));
break;
case JSP_INPUT_READONLY:
/* FIXME: <input readonly disabled> --pasky */
fc->mode = (jsval_to_boolean(ctx, &vp) ? FORM_MODE_READONLY
fc->mode = (jsval_to_boolean(ctx, vp) ? FORM_MODE_READONLY
: fc->mode == FORM_MODE_DISABLED ? FORM_MODE_DISABLED
: FORM_MODE_NORMAL);
break;
case JSP_INPUT_SRC:
if (link) {
mem_free_set(&link->where_img, stracpy(jsval_to_string(ctx, &vp)));
mem_free_set(&link->where_img, stracpy(jsval_to_string(ctx, vp)));
}
break;
case JSP_INPUT_VALUE:
if (fc->type == FC_FILE)
break; /* A huge security risk otherwise. */
mem_free_set(&fs->value, stracpy(jsval_to_string(ctx, &vp)));
mem_free_set(&fs->value, stracpy(jsval_to_string(ctx, vp)));
if (fc->type == FC_TEXT || fc->type == FC_PASSWORD)
fs->state = strlen(fs->value);
break;
@ -1667,7 +1644,7 @@ input_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBool s
if (fc->type == FC_SELECT) {
int item;
if (!JS_ValueToInt32(ctx, vp, &item))
if (!JS_ValueToInt32(ctx, *vp, &item))
return JS_FALSE;
if (item >= 0 && item < fc->nvalues) {
@ -2013,27 +1990,25 @@ form_elements_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if (JSID_IS_STRING(id)) {
JS_IdToValue(ctx, id, &idval);
form_elements_namedItem2(ctx, obj, 1, &idval, &vp);
hvp.set(vp);
form_elements_namedItem2(ctx, obj, 1, &idval, vp);
return JS_TRUE;
}
if (!JSID_IS_INT(id))
return JS_TRUE;
undef_to_jsval(ctx, &vp);
undef_to_jsval(ctx, vp);
switch (JSID_TO_INT(id)) {
case JSP_FORM_ELEMENTS_LENGTH:
int_to_jsval(ctx, &vp, list_size(&form->items));
int_to_jsval(ctx, vp, list_size(&form->items));
break;
default:
/* Array index. */
JS_IdToValue(ctx, id, &idval);
form_elements_item2(ctx, obj, 1, &idval, &vp);
form_elements_item2(ctx, obj, 1, &idval, vp);
break;
}
hvp.set(vp);
return JS_TRUE;
}
@ -2075,8 +2050,7 @@ form_elements_get_property_length(JSContext *ctx, JSHandleObject hobj, JSHandleI
if (!form_view) return JS_FALSE; /* detached */
form = find_form_by_form_view(document, form_view);
int_to_jsval(ctx, &vp, list_size(&form->items));
hvp.set(vp);
int_to_jsval(ctx, vp, list_size(&form->items));
return JS_TRUE;
}
@ -2349,27 +2323,26 @@ form_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutable
&& (!fc->name || c_strcasecmp(string, fc->name)))
continue;
undef_to_jsval(ctx, &vp);
undef_to_jsval(ctx, vp);
fs = find_form_state(doc_view, fc);
if (fs) {
fcobj = get_form_control_object(ctx, obj, fc->type, fs);
if (fcobj)
object_to_jsval(ctx, &vp, fcobj);
object_to_jsval(ctx, vp, fcobj);
}
break;
}
hvp.set(vp);
return JS_TRUE;
}
if (!JSID_IS_INT(id))
return JS_TRUE;
undef_to_jsval(ctx, &vp);
undef_to_jsval(ctx, vp);
switch (JSID_TO_INT(id)) {
case JSP_FORM_ACTION:
string_to_jsval(ctx, &vp, form->action);
string_to_jsval(ctx, vp, form->action);
break;
case JSP_FORM_ELEMENTS:
@ -2380,7 +2353,7 @@ form_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutable
JS_DefineProperties(ctx, jsform_elems, (JSPropertySpec *) form_elements_props);
spidermonkey_DefineFunctions(ctx, jsform_elems,
form_elements_funcs);
object_to_jsval(ctx, &vp, jsform_elems);
object_to_jsval(ctx, vp, jsform_elems);
/* SM will cache this property value for us so we create this
* just once per form. */
}
@ -2390,41 +2363,41 @@ form_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutable
switch (form->method) {
case FORM_METHOD_GET:
case FORM_METHOD_POST:
string_to_jsval(ctx, &vp, "application/x-www-form-urlencoded");
string_to_jsval(ctx, vp, "application/x-www-form-urlencoded");
break;
case FORM_METHOD_POST_MP:
string_to_jsval(ctx, &vp, "multipart/form-data");
string_to_jsval(ctx, vp, "multipart/form-data");
break;
case FORM_METHOD_POST_TEXT_PLAIN:
string_to_jsval(ctx, &vp, "text/plain");
string_to_jsval(ctx, vp, "text/plain");
break;
}
break;
case JSP_FORM_LENGTH:
int_to_jsval(ctx, &vp, list_size(&form->items));
int_to_jsval(ctx, vp, list_size(&form->items));
break;
case JSP_FORM_METHOD:
switch (form->method) {
case FORM_METHOD_GET:
string_to_jsval(ctx, &vp, "GET");
string_to_jsval(ctx, vp, "GET");
break;
case FORM_METHOD_POST:
case FORM_METHOD_POST_MP:
case FORM_METHOD_POST_TEXT_PLAIN:
string_to_jsval(ctx, &vp, "POST");
string_to_jsval(ctx, vp, "POST");
break;
}
break;
case JSP_FORM_NAME:
string_to_jsval(ctx, &vp, form->name);
string_to_jsval(ctx, vp, form->name);
break;
case JSP_FORM_TARGET:
string_to_jsval(ctx, &vp, form->target);
string_to_jsval(ctx, vp, form->target);
break;
default:
@ -2436,7 +2409,6 @@ form_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutable
* @undef_to_jsval.) */
break;
}
hvp.set(vp);
return JS_TRUE;
}
@ -2474,8 +2446,7 @@ form_get_property_action(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
form = find_form_by_form_view(doc_view->document, fv);
assert(form);
string_to_jsval(ctx, &vp, form->action);
hvp.set(vp);
string_to_jsval(ctx, vp, form->action);
return JS_TRUE;
}
@ -2514,7 +2485,7 @@ form_set_property_action(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
assert(form);
string = stracpy(jsval_to_string(ctx, &vp));
string = stracpy(jsval_to_string(ctx, vp));
if (form->action) {
ecmascript_set_action(&form->action, string);
} else {
@ -2547,10 +2518,9 @@ form_get_property_elements(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
JS_DefineProperties(ctx, jsform_elems, (JSPropertySpec *) form_elements_props);
spidermonkey_DefineFunctions(ctx, jsform_elems,
form_elements_funcs);
object_to_jsval(ctx, &vp, jsform_elems);
object_to_jsval(ctx, vp, jsform_elems);
/* SM will cache this property value for us so we create this
* just once per form. */
hvp.set(vp);
return JS_TRUE;
}
@ -2591,16 +2561,15 @@ form_get_property_encoding(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
switch (form->method) {
case FORM_METHOD_GET:
case FORM_METHOD_POST:
string_to_jsval(ctx, &vp, "application/x-www-form-urlencoded");
string_to_jsval(ctx, vp, "application/x-www-form-urlencoded");
break;
case FORM_METHOD_POST_MP:
string_to_jsval(ctx, &vp, "multipart/form-data");
string_to_jsval(ctx, vp, "multipart/form-data");
break;
case FORM_METHOD_POST_TEXT_PLAIN:
string_to_jsval(ctx, &vp, "text/plain");
string_to_jsval(ctx, vp, "text/plain");
break;
}
hvp.set(vp);
return JS_TRUE;
}
@ -2640,7 +2609,7 @@ form_set_property_encoding(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
assert(form);
string = jsval_to_string(ctx, &vp);
string = jsval_to_string(ctx, vp);
if (!c_strcasecmp(string, "application/x-www-form-urlencoded")) {
form->method = form->method == FORM_METHOD_GET ? FORM_METHOD_GET
: FORM_METHOD_POST;
@ -2686,8 +2655,7 @@ form_get_property_length(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
assert(form);
int_to_jsval(ctx, &vp, list_size(&form->items));
hvp.set(vp);
int_to_jsval(ctx, vp, list_size(&form->items));
return JS_TRUE;
}
@ -2727,16 +2695,15 @@ form_get_property_method(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
switch (form->method) {
case FORM_METHOD_GET:
string_to_jsval(ctx, &vp, "GET");
string_to_jsval(ctx, vp, "GET");
break;
case FORM_METHOD_POST:
case FORM_METHOD_POST_MP:
case FORM_METHOD_POST_TEXT_PLAIN:
string_to_jsval(ctx, &vp, "POST");
string_to_jsval(ctx, vp, "POST");
break;
}
hvp.set(vp);
return JS_TRUE;
}
@ -2776,7 +2743,7 @@ form_set_property_method(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
assert(form);
string = jsval_to_string(ctx, &vp);
string = jsval_to_string(ctx, vp);
if (!c_strcasecmp(string, "GET")) {
form->method = FORM_METHOD_GET;
} else if (!c_strcasecmp(string, "POST")) {
@ -2819,8 +2786,7 @@ form_get_property_name(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMu
assert(form);
string_to_jsval(ctx, &vp, form->name);
hvp.set(vp);
string_to_jsval(ctx, vp, form->name);
return JS_TRUE;
}
@ -2858,7 +2824,7 @@ form_set_property_name(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBo
form = find_form_by_form_view(doc_view->document, fv);
assert(form);
mem_free_set(&form->name, stracpy(jsval_to_string(ctx, &vp)));
mem_free_set(&form->name, stracpy(jsval_to_string(ctx, vp)));
return JS_TRUE;
}
@ -2895,8 +2861,7 @@ form_get_property_target(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
form = find_form_by_form_view(doc_view->document, fv);
assert(form);
string_to_jsval(ctx, &vp, form->target);
hvp.set(vp);
string_to_jsval(ctx, vp, form->target);
return JS_TRUE;
}
@ -2933,7 +2898,7 @@ form_set_property_target(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
form = find_form_by_form_view(doc_view->document, fv);
assert(form);
mem_free_set(&form->target, stracpy(jsval_to_string(ctx, &vp)));
mem_free_set(&form->target, stracpy(jsval_to_string(ctx, vp)));
return JS_TRUE;
}
@ -3195,16 +3160,14 @@ forms_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutabl
* we must leave *vp unchanged here, to avoid
* "TypeError: forms.namedItem is not a function". */
JS_IdToValue(ctx, id, &idval);
find_form_by_name(ctx, parent_doc, doc_view, idval, &vp);
hvp.set(vp);
find_form_by_name(ctx, parent_doc, doc_view, idval, vp);
return JS_TRUE;
}
}
/* Array index. */
JS_IdToValue(ctx, id, &idval);
forms_item2(ctx, obj, 1, &idval, &vp);
hvp.set(vp);
forms_item2(ctx, obj, 1, &idval, vp);
return JS_TRUE;
}
@ -3238,8 +3201,7 @@ forms_get_property_length(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, J
&window_class, NULL);
doc_view = vs->doc_view;
document = doc_view->document;
int_to_jsval(ctx, &vp, list_size(&document->forms));
hvp.set(vp);
int_to_jsval(ctx, vp, list_size(&document->forms));
return JS_TRUE;
}

View File

@ -173,8 +173,7 @@ location_get_property_href(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
vs = JS_GetInstancePrivate(ctx, parent_win,
&window_class, NULL);
astring_to_jsval(ctx, &vp, get_uri_string(vs->uri, URI_ORIGINAL));
hvp.set(vp);
astring_to_jsval(ctx, vp, get_uri_string(vs->uri, URI_ORIGINAL));
return JS_TRUE;
}
@ -199,7 +198,7 @@ location_set_property_href(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
vs = JS_GetInstancePrivate(ctx, parent_win,
&window_class, NULL);
doc_view = vs->doc_view;
location_goto(doc_view, jsval_to_string(ctx, &vp));
location_goto(doc_view, jsval_to_string(ctx, vp));
return JS_TRUE;
}

View File

@ -92,8 +92,7 @@ navigator_get_property_appCodeName(JSContext *ctx, JSHandleObject hobj, JSHandle
ELINKS_CAST_PROP_PARAMS
(void)obj;
string_to_jsval(ctx, &vp, "Mozilla"); /* More like a constant nowadays. */
hvp.set(vp);
string_to_jsval(ctx, vp, "Mozilla"); /* More like a constant nowadays. */
return JS_TRUE;
}
@ -104,8 +103,7 @@ navigator_get_property_appName(JSContext *ctx, JSHandleObject hobj, JSHandleId h
ELINKS_CAST_PROP_PARAMS
(void)obj;
string_to_jsval(ctx, &vp, "ELinks (roughly compatible with Netscape Navigator, Mozilla and Microsoft Internet Explorer)");
hvp.set(vp);
string_to_jsval(ctx, vp, "ELinks (roughly compatible with Netscape Navigator, Mozilla and Microsoft Internet Explorer)");
return JS_TRUE;
}
@ -116,8 +114,7 @@ navigator_get_property_appVersion(JSContext *ctx, JSHandleObject hobj, JSHandleI
ELINKS_CAST_PROP_PARAMS
(void)obj;
string_to_jsval(ctx, &vp, VERSION);
hvp.set(vp);
string_to_jsval(ctx, vp, VERSION);
return JS_TRUE;
}
@ -128,14 +125,12 @@ navigator_get_property_language(JSContext *ctx, JSHandleObject hobj, JSHandleId
ELINKS_CAST_PROP_PARAMS
(void)obj;
undef_to_jsval(ctx, &vp);
undef_to_jsval(ctx, vp);
#ifdef CONFIG_NLS
if (get_opt_bool("protocol.http.accept_ui_language", NULL))
string_to_jsval(ctx, &vp, language_to_iso639(current_language));
string_to_jsval(ctx, vp, language_to_iso639(current_language));
#endif
hvp.set(vp);
return JS_TRUE;
}
@ -145,8 +140,7 @@ navigator_get_property_platform(JSContext *ctx, JSHandleObject hobj, JSHandleId
ELINKS_CAST_PROP_PARAMS
(void)obj;
string_to_jsval(ctx, &vp, system_name);
hvp.set(vp);
string_to_jsval(ctx, vp, system_name);
return JS_TRUE;
}
@ -179,14 +173,12 @@ navigator_get_property_userAgent(JSContext *ctx, JSHandleObject hobj, JSHandleId
if (ustr) {
safe_strncpy(custr, ustr, 256);
mem_free(ustr);
string_to_jsval(ctx, &vp, custr);
hvp.set(vp);
string_to_jsval(ctx, vp, custr);
return JS_TRUE;
}
}
string_to_jsval(ctx, &vp, system_name);
hvp.set(vp);
string_to_jsval(ctx, vp, system_name);
return JS_TRUE;
}

View File

@ -106,7 +106,7 @@ unibar_get_property_visible(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
bar = JS_GetPrivate(obj); /* from @menubar_class or @statusbar_class */
#define unibar_fetch(bar) \
boolean_to_jsval(ctx, &vp, status->force_show_##bar##_bar >= 0 \
boolean_to_jsval(ctx, vp, status->force_show_##bar##_bar >= 0 \
? status->force_show_##bar##_bar \
: status->show_##bar##_bar)
switch (*bar) {
@ -117,11 +117,10 @@ unibar_get_property_visible(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
unibar_fetch(title);
break;
default:
boolean_to_jsval(ctx, &vp, 0);
boolean_to_jsval(ctx, vp, 0);
break;
}
#undef unibar_fetch
hvp.set(vp);
return JS_TRUE;
}
@ -155,10 +154,10 @@ unibar_set_property_visible(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
switch (*bar) {
case 's':
status->force_show_status_bar = jsval_to_boolean(ctx, &vp);
status->force_show_status_bar = jsval_to_boolean(ctx, vp);
break;
case 't':
status->force_show_title_bar = jsval_to_boolean(ctx, &vp);
status->force_show_title_bar = jsval_to_boolean(ctx, vp);
break;
default:
break;

View File

@ -153,8 +153,7 @@ window_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutab
/* TODO: Try other lookups (mainly element lookup) until
* something yields data. */
if (obj) {
object_to_jsval(ctx, &vp, obj);
hvp.set(vp);
object_to_jsval(ctx, vp, obj);
}
return JS_TRUE;
}
@ -162,20 +161,17 @@ window_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutab
if (!JSID_IS_INT(id))
return JS_TRUE;
undef_to_jsval(ctx, &vp);
hvp.set(vp);
undef_to_jsval(ctx, vp);
switch (JSID_TO_INT(id)) {
case JSP_WIN_CLOSED:
/* TODO: It will be a major PITA to implement this properly.
* Well, perhaps not so much if we introduce reference tracking
* for (struct session)? Still... --pasky */
boolean_to_jsval(ctx, &vp, 0);
hvp.set(vp);
boolean_to_jsval(ctx, vp, 0);
break;
case JSP_WIN_SELF:
object_to_jsval(ctx, &vp, obj);
hvp.set(vp);
object_to_jsval(ctx, vp, obj);
break;
case JSP_WIN_PARENT:
/* XXX: It would be nice if the following worked, yes.
@ -215,8 +211,7 @@ found_parent:
if (doc_view->vs.ecmascript_fragile)
ecmascript_reset_state(&doc_view->vs);
assert(doc_view->ecmascript);
object_to_jsval(ctx, &vp, JS_GetGlobalObject(doc_view->ecmascript->backend_data));
hvp.set(vp);
object_to_jsval(ctx, vp, JS_GetGlobalObject(doc_view->ecmascript->backend_data));
break;
}
#endif
@ -242,8 +237,7 @@ found_parent:
* let the script walk thru. That'd mean moving the check to
* other individual properties in this switch. */
if (compare_uri(vs->uri, top_view->vs->uri, URI_HOST))
object_to_jsval(ctx, &vp, newjsframe);
hvp.set(vp);
object_to_jsval(ctx, vp, newjsframe);
/* else */
/****X*X*X*** SECURITY VIOLATION! RED ALERT, SHIELDS UP! ***X*X*X****\
|* (Pasky was apparently looking at the Links2 JS code . ___ ^.^ *|
@ -455,8 +449,7 @@ window_get_property_closed(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if (!JS_InstanceOf(ctx, obj, &window_class, NULL))
return JS_FALSE;
boolean_to_jsval(ctx, &vp, 0);
hvp.set(vp);
boolean_to_jsval(ctx, vp, 0);
return JS_TRUE;
}
@ -483,8 +476,7 @@ window_get_property_parent(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
* INCORRECT but works for the most common cases of just two
* frames. Better something than nothing. */
undef_to_jsval(ctx, &vp);
hvp.set(vp);
undef_to_jsval(ctx, vp);
return JS_TRUE;
}
@ -500,8 +492,7 @@ window_get_property_self(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
if (!JS_InstanceOf(ctx, obj, &window_class, NULL))
return JS_FALSE;
object_to_jsval(ctx, &vp, obj);
hvp.set(vp);
object_to_jsval(ctx, vp, obj);
return JS_TRUE;
}
@ -517,8 +508,7 @@ window_get_property_status(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if (!JS_InstanceOf(ctx, obj, &window_class, NULL))
return JS_FALSE;
undef_to_jsval(ctx, &vp);
hvp.set(vp);
undef_to_jsval(ctx, vp);
return JS_TRUE;
}
@ -538,7 +528,7 @@ window_set_property_status(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
vs = JS_GetInstancePrivate(ctx, obj, &window_class, NULL);
mem_free_set(&vs->doc_view->session->status.window_status, stracpy(jsval_to_string(ctx, &vp)));
mem_free_set(&vs->doc_view->session->status.window_status, stracpy(jsval_to_string(ctx, vp)));
print_screen_status(vs->doc_view->session);
return JS_TRUE;
@ -564,8 +554,7 @@ window_get_property_top(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSM
doc_view = vs->doc_view;
top_view = doc_view->session->doc_view;
undef_to_jsval(ctx, &vp);
hvp.set(vp);
undef_to_jsval(ctx, vp);
assert(top_view && top_view->vs);
if (top_view->vs->ecmascript_fragile)
@ -581,8 +570,7 @@ window_get_property_top(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSM
* let the script walk thru. That'd mean moving the check to
* other individual properties in this switch. */
if (compare_uri(vs->uri, top_view->vs->uri, URI_HOST))
object_to_jsval(ctx, &vp, newjsframe);
hvp.set(vp);
object_to_jsval(ctx, vp, newjsframe);
/* else */
/****X*X*X*** SECURITY VIOLATION! RED ALERT, SHIELDS UP! ***X*X*X****\
|* (Pasky was apparently looking at the Links2 JS code . ___ ^.^ *|

View File

@ -174,7 +174,7 @@ action_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutab
JSObject *action_fn;
unsigned char *action_str;
vp = JSVAL_NULL;
*vp = JSVAL_NULL;
JS_IdToValue(ctx, id, &val);
action_str = JS_EncodeString(ctx, JS_ValueToString(ctx, val));
@ -183,7 +183,7 @@ action_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutab
action_fn = smjs_get_action_fn_object(action_str);
if (!action_fn) return JS_TRUE;
vp = OBJECT_TO_JSVAL(action_fn);
*vp = OBJECT_TO_JSVAL(action_fn);
return JS_TRUE;
}

View File

@ -183,7 +183,7 @@ bookmark_get_property_title(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if (!bookmark) return JS_FALSE;
return bookmark_string_to_jsval(ctx, bookmark->title, &vp);
return bookmark_string_to_jsval(ctx, bookmark->title, vp);
}
static JSBool
@ -207,7 +207,7 @@ bookmark_set_property_title(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if (!bookmark) return JS_FALSE;
if (!jsval_to_bookmark_string(ctx, vp, &title))
if (!jsval_to_bookmark_string(ctx, *vp, &title))
return JS_FALSE;
ok = update_bookmark(bookmark, get_cp_index("UTF-8"), title, url);
@ -234,7 +234,7 @@ bookmark_get_property_url(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, J
if (!bookmark) return JS_FALSE;
return bookmark_string_to_jsval(ctx, bookmark->url, &vp);
return bookmark_string_to_jsval(ctx, bookmark->url, vp);
}
static JSBool
@ -258,7 +258,7 @@ bookmark_set_property_url(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, J
if (!bookmark) return JS_FALSE;
if (!jsval_to_bookmark_string(ctx, vp, &url))
if (!jsval_to_bookmark_string(ctx, *vp, &url))
return JS_FALSE;
ok = update_bookmark(bookmark, get_cp_index("UTF-8"), title, url);
@ -285,7 +285,7 @@ bookmark_get_property_children(JSContext *ctx, JSHandleObject hobj, JSHandleId h
if (!bookmark) return