mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 04:56:50 +03:00
Add core function to navigate to URL parent.
This commit is contained in:
parent
7a6faf4199
commit
7519993fd7
@ -1973,6 +1973,41 @@ nserror browser_window_navigate(struct browser_window *bw,
|
||||
}
|
||||
|
||||
|
||||
/* Exported interface, documented in browser.h */
|
||||
nserror browser_window_navigate_up(struct browser_window *bw, bool new_window)
|
||||
{
|
||||
nsurl *current, *parent;
|
||||
nserror err;
|
||||
|
||||
if (bw == NULL)
|
||||
return NSERROR_BAD_PARAMETER;
|
||||
|
||||
current = browser_window_get_url(bw);
|
||||
|
||||
err = nsurl_parent(current, &parent);
|
||||
if (err != NSERROR_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (nsurl_compare(current, parent, NSURL_COMPLETE) == true) {
|
||||
/* Can't go up to parent from here */
|
||||
nsurl_unref(parent);
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
if (new_window) {
|
||||
err = browser_window_create(BW_CREATE_CLONE,
|
||||
parent, NULL, bw, NULL);
|
||||
} else {
|
||||
err = browser_window_navigate(bw, parent, NULL,
|
||||
BW_NAVIGATE_HISTORY, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
nsurl_unref(parent);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/* Exported interface, documented in browser.h */
|
||||
nsurl* browser_window_get_url(struct browser_window *bw)
|
||||
{
|
||||
|
@ -151,6 +151,14 @@ nserror browser_window_navigate(struct browser_window *bw,
|
||||
struct fetch_multipart_data *post_multipart,
|
||||
struct hlcache_handle *parent);
|
||||
|
||||
/**
|
||||
* Navigate to a browser_window's parent URL.
|
||||
*
|
||||
* \param bw browser window
|
||||
* \param new_window whether to open parent in a new window, or existing
|
||||
*/
|
||||
nserror browser_window_navigate_up(struct browser_window *bw, bool new_window);
|
||||
|
||||
/**
|
||||
* Get a browser window's URL.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user