mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-23 23:09:39 +03:00
fix docuemnt/window location to correctly navigate, fixes http://www.avaaz.org/ base page
This commit is contained in:
parent
7957cc59b1
commit
4ffa39177d
@ -76,8 +76,7 @@ getter location %{
|
||||
jsret = jsapi_new_Location(cx,
|
||||
NULL,
|
||||
NULL,
|
||||
llcache_handle_get_url(private->htmlc->base.llcache),
|
||||
private->htmlc);
|
||||
llcache_handle_get_url(private->htmlc->base.llcache));
|
||||
%}
|
||||
|
||||
getter URL %{
|
||||
|
@ -26,6 +26,8 @@ preamble %{
|
||||
|
||||
#include "location.h"
|
||||
|
||||
struct browser_window *jsapi_get_browser_window(JSContext *cx);
|
||||
|
||||
%}
|
||||
|
||||
binding location {
|
||||
@ -34,16 +36,50 @@ binding location {
|
||||
interface Location; /* Web IDL interface to generate */
|
||||
|
||||
private "nsurl *" url;
|
||||
private "struct html_content *" htmlc;
|
||||
|
||||
property unshared href;
|
||||
|
||||
}
|
||||
|
||||
operation reload %{
|
||||
browser_window_reload(private->htmlc->bw, false);
|
||||
struct browser_window *bw;
|
||||
bw = jsapi_get_browser_window(cx);
|
||||
if (bw != NULL) {
|
||||
browser_window_reload(bw, false);
|
||||
} else {
|
||||
JSLOG("failed to get browser context");
|
||||
}
|
||||
%}
|
||||
|
||||
/* void Location::assign(DOMString url); */
|
||||
operation assign %{
|
||||
nsurl *joined;
|
||||
struct browser_window *bw;
|
||||
|
||||
bw = jsapi_get_browser_window(cx);
|
||||
if (bw != NULL) {
|
||||
nsurl_join(private->url, url, &joined);
|
||||
browser_window_go(bw, nsurl_access(joined), NULL, true);
|
||||
nsurl_unref(joined);
|
||||
} else {
|
||||
JSLOG("failed to get browser context");
|
||||
}
|
||||
%}
|
||||
|
||||
/* void Location::replace(DOMString url); */
|
||||
operation replace %{
|
||||
nsurl *joined;
|
||||
struct browser_window *bw;
|
||||
|
||||
bw = jsapi_get_browser_window(cx);
|
||||
if (bw != NULL) {
|
||||
nsurl_join(private->url, url, &joined);
|
||||
browser_window_go(bw, nsurl_access(joined), NULL, false);
|
||||
nsurl_unref(joined);
|
||||
} else {
|
||||
JSLOG("failed to get browser context");
|
||||
}
|
||||
%}
|
||||
|
||||
getter href %{
|
||||
char *url_s = NULL;
|
||||
@ -65,13 +101,25 @@ setter href %{
|
||||
JSString *url_jsstr = NULL;
|
||||
int url_len = 0;
|
||||
char *url = NULL;
|
||||
struct browser_window *bw;
|
||||
nsurl *joined;
|
||||
|
||||
url_jsstr = JS_ValueToString(cx, *vp);
|
||||
if (url_jsstr != NULL) {
|
||||
JSString_to_char(url_jsstr, url, url_len);
|
||||
browser_window_go(private->htmlc->bw, url, NULL, false);
|
||||
bw = jsapi_get_browser_window(cx);
|
||||
|
||||
if (bw != NULL) {
|
||||
url_jsstr = JS_ValueToString(cx, *vp);
|
||||
if (url_jsstr != NULL) {
|
||||
JSString_to_char(url_jsstr, url, url_len);
|
||||
|
||||
nsurl_join(private->url, url, &joined);
|
||||
|
||||
browser_window_go(bw, nsurl_access(joined), NULL, false);
|
||||
nsurl_unref(joined);
|
||||
} else {
|
||||
JSLOG("failed to convert string value");
|
||||
}
|
||||
} else {
|
||||
JSLOG("failed to convert string value");
|
||||
JSLOG("failed to get browser context");
|
||||
}
|
||||
%}
|
||||
|
||||
|
@ -40,6 +40,27 @@ preamble %{
|
||||
#include "window.h"
|
||||
#include "location.h"
|
||||
|
||||
struct browser_window *jsapi_get_browser_window(JSContext *cx);
|
||||
|
||||
%}
|
||||
|
||||
prologue %{
|
||||
|
||||
struct browser_window *jsapi_get_browser_window(JSContext *cx)
|
||||
{
|
||||
struct jsclass_private *private;
|
||||
|
||||
private = JS_GetInstancePrivate(cx,
|
||||
JS_GetGlobalObject(cx),
|
||||
&JSClass_Window,
|
||||
NULL);
|
||||
if (private != NULL) {
|
||||
return private->bw;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
binding window {
|
||||
|
Loading…
Reference in New Issue
Block a user