mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-04 20:02:21 +03:00
143 lines
3.2 KiB
Plaintext
143 lines
3.2 KiB
Plaintext
/* Binding to generate Location interface
|
|
*
|
|
* Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
|
|
*
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
*
|
|
* Released under the terms of the MIT License,
|
|
* http://www.opensource.org/licenses/mit-license
|
|
*/
|
|
|
|
webidlfile "html.idl";
|
|
|
|
hdrcomment "Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>";
|
|
hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
|
|
hdrcomment "Released under the terms of the MIT License,";
|
|
hdrcomment " http://www.opensource.org/licenses/mit-license";
|
|
|
|
preamble %{
|
|
|
|
#include "desktop/browser.h"
|
|
|
|
#include "utils/config.h"
|
|
#include "utils/log.h"
|
|
|
|
#include "javascript/jsapi.h"
|
|
#include "javascript/jsapi/binding.h"
|
|
|
|
%}
|
|
|
|
binding location {
|
|
type js_libdom; /* the binding type */
|
|
|
|
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);
|
|
%}
|
|
|
|
|
|
getter href %{
|
|
char *url_s = NULL;
|
|
size_t url_l;
|
|
|
|
if (!JSVAL_IS_VOID(JSAPI_PROP_RVAL(cx,vp))) {
|
|
/* already created - return it */
|
|
return JS_TRUE;
|
|
}
|
|
|
|
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));
|
|
lwc_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));
|
|
lwc_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));
|
|
lwc_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));
|
|
lwc_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));
|
|
lwc_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));
|
|
lwc_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));
|
|
lwc_string_unref(component);
|
|
}
|
|
%}
|