diff options
author | Vincent Sanders <vince@netsurf-browser.org> | 2012-11-21 18:51:44 +0000 |
---|---|---|
committer | Vincent Sanders <vince@netsurf-browser.org> | 2012-11-21 18:51:44 +0000 |
commit | c2cd36fda86b9bdfbb36cc340e35cfbc6609fd32 (patch) | |
tree | bee67eb54a0560bef43ea640253dcabbdd226665 /javascript/jsapi/location.bnd | |
parent | a159a4a79b1facc77ae41983e9f96f8117f07f21 (diff) | |
download | netsurf-c2cd36fda86b9bdfbb36cc340e35cfbc6609fd32.tar.gz netsurf-c2cd36fda86b9bdfbb36cc340e35cfbc6609fd32.tar.bz2 |
improve location interface implementation
Diffstat (limited to 'javascript/jsapi/location.bnd')
-rw-r--r-- | javascript/jsapi/location.bnd | 95 |
1 files changed, 93 insertions, 2 deletions
diff --git a/javascript/jsapi/location.bnd b/javascript/jsapi/location.bnd index db7a247bc..e91094f2d 100644 --- a/javascript/jsapi/location.bnd +++ b/javascript/jsapi/location.bnd @@ -8,8 +8,6 @@ * http://www.opensource.org/licenses/mit-license */ -#include "dom.bnd" - webidlfile "html.idl"; hdrcomment "Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>"; @@ -35,8 +33,101 @@ binding location { interface Location; /* Web IDL interface to generate */ private "struct browser_window *" bw; + private "nsurl *" url; } operation reload %{ browser_window_reload(private->bw, false); %} + + +getter href %{ + char *url_s = NULL; + size_t url_l; + nsurl_get(private->url, NSURL_COMPLETE, &url_s, &url_l); + if (url_s != NULL) { + jsret = JS_NewStringCopyN(cx, url_s, url_l); + free(url_s); + } +%} + +getter protocol %{ + lwc_string *component; + component = nsurl_get_component(private->url, NSURL_SCHEME); + if (component != NULL) { + jsret = JS_NewStringCopyN(cx, + lwc_string_data(component), + lwc_string_length(component)); + dom_string_unref(component); + } +%} + +getter host %{ + lwc_string *component; + component = nsurl_get_component(private->url, NSURL_HOST); + if (component != NULL) { + jsret = JS_NewStringCopyN(cx, + lwc_string_data(component), + lwc_string_length(component)); + dom_string_unref(component); + } +%} + +getter hostname %{ + lwc_string *component; + component = nsurl_get_component(private->url, NSURL_HOST); + if (component != NULL) { + jsret = JS_NewStringCopyN(cx, + lwc_string_data(component), + lwc_string_length(component)); + dom_string_unref(component); + } + +%} + +getter port %{ + lwc_string *component; + component = nsurl_get_component(private->url, NSURL_PORT); + if (component != NULL) { + jsret = JS_NewStringCopyN(cx, + lwc_string_data(component), + lwc_string_length(component)); + dom_string_unref(component); + } + +%} + +getter pathname %{ + lwc_string *component; + component = nsurl_get_component(private->url, NSURL_PATH); + if (component != NULL) { + jsret = JS_NewStringCopyN(cx, + lwc_string_data(component), + lwc_string_length(component)); + dom_string_unref(component); + } + +%} + +getter search %{ + lwc_string *component; + component = nsurl_get_component(private->url, NSURL_QUERY); + if (component != NULL) { + jsret = JS_NewStringCopyN(cx, + lwc_string_data(component), + lwc_string_length(component)); + dom_string_unref(component); + } + +%} + +getter hash %{ + lwc_string *component; + component = nsurl_get_component(private->url, NSURL_FRAGMENT); + if (component != NULL) { + jsret = JS_NewStringCopyN(cx, + lwc_string_data(component), + lwc_string_length(component)); + dom_string_unref(component); + } +%} |