mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-15 15:19:19 +03:00
correctly handle location
This commit is contained in:
parent
40076ea422
commit
99f93da0f3
@ -79,7 +79,7 @@
|
||||
jsapi_property_##name##_set(cx, obj, jsval jsapi_id, vp)
|
||||
|
||||
/* native property return value */
|
||||
#define JSAPI_PROP_RVAL(cx, vp) (vp)
|
||||
#define JSAPI_PROP_RVAL(cx, vp) (*(vp))
|
||||
|
||||
/* native property getter return value */
|
||||
#define JSAPI_PROP_SET_RVAL(cx, vp, v) (*(vp) = (v))
|
||||
|
@ -43,6 +43,9 @@ binding document {
|
||||
*/
|
||||
private "dom_document *" node;
|
||||
private "struct html_content *" htmlc;
|
||||
|
||||
/** location instantiated on first use */
|
||||
property unshared location;
|
||||
}
|
||||
|
||||
api finalise %{
|
||||
@ -53,6 +56,19 @@ api finalise %{
|
||||
}
|
||||
%}
|
||||
|
||||
getter location %{
|
||||
if (!JSVAL_IS_VOID(JSAPI_PROP_RVAL(cx,vp))) {
|
||||
/* already created - return it */
|
||||
return JS_TRUE;
|
||||
}
|
||||
jsret = jsapi_new_Location(cx,
|
||||
NULL,
|
||||
NULL,
|
||||
private->htmlc->bw,
|
||||
llcache_handle_get_url(private->htmlc->base.llcache));
|
||||
%}
|
||||
|
||||
|
||||
getter cookie %{
|
||||
char *cookie_str;
|
||||
cookie_str = urldb_get_cookie(llcache_handle_get_url(private->htmlc->base.llcache), false);
|
||||
|
@ -42,7 +42,6 @@ binding window {
|
||||
internal "JSObject *" document;
|
||||
internal "JSObject *" navigator;
|
||||
internal "JSObject *" console;
|
||||
internal "JSObject *" location;
|
||||
|
||||
property unshared type EventHandler;
|
||||
}
|
||||
@ -58,9 +57,6 @@ api mark %{
|
||||
if (private->console != NULL) {
|
||||
JSAPI_GCMARK(private->console);
|
||||
}
|
||||
if (private->location != NULL) {
|
||||
JSAPI_GCMARK(private->location);
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
@ -180,13 +176,6 @@ api new %{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
private->location = jsapi_new_Location(cx, NULL, newobject, bw,
|
||||
llcache_handle_get_url(private->htmlc->base.llcache));
|
||||
if (private->location == NULL) {
|
||||
free(private);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
private->console = jsapi_new_Console(cx, NULL, newobject);
|
||||
if (private->console == NULL) {
|
||||
free(private);
|
||||
@ -210,14 +199,6 @@ operation prompt %{
|
||||
warn_user(message, NULL);
|
||||
%}
|
||||
|
||||
getter window %{
|
||||
jsret = obj;
|
||||
%}
|
||||
|
||||
getter self %{
|
||||
jsret = obj;
|
||||
%}
|
||||
|
||||
/* boolean dispatchEvent(Event event); */
|
||||
operation dispatchEvent %{
|
||||
/* this implementation is unique to the window object as it is
|
||||
@ -254,6 +235,20 @@ operation dispatchEvent %{
|
||||
}
|
||||
%}
|
||||
|
||||
getter location %{
|
||||
jsval loc;
|
||||
JS_GetProperty(cx, private->document, "location", &loc);
|
||||
jsret = JSVAL_TO_OBJECT(loc);
|
||||
%}
|
||||
|
||||
getter window %{
|
||||
jsret = obj;
|
||||
%}
|
||||
|
||||
getter self %{
|
||||
jsret = obj;
|
||||
%}
|
||||
|
||||
getter EventHandler %{
|
||||
/* this implementation is unique to the window object as it is
|
||||
* not a dom node.
|
||||
|
Loading…
Reference in New Issue
Block a user