Simplify browser_window_refresh_url_bar.
Reduces front end need to access bw internals.
This commit is contained in:
parent
41d7084356
commit
cf84e557fa
|
@ -2690,8 +2690,7 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw)
|
|||
gwin->bw->window->scrollx, gwin->bw->window->scrolly);
|
||||
gwin->redraw_scroll = false;
|
||||
|
||||
browser_window_refresh_url_bar(gwin->bw,
|
||||
hlcache_handle_get_url(gwin->bw->current_content), gwin->bw->frag_id);
|
||||
browser_window_refresh_url_bar(gwin->bw);
|
||||
|
||||
ami_gui_update_hotlist_button(gwin);
|
||||
}
|
||||
|
|
|
@ -1175,9 +1175,7 @@ static nserror browser_window_callback(hlcache_handle *c,
|
|||
browser_window_convert_to_download(bw, event->data.download);
|
||||
|
||||
if (bw->current_content != NULL) {
|
||||
browser_window_refresh_url_bar(bw,
|
||||
hlcache_handle_get_url(bw->current_content),
|
||||
bw->frag_id);
|
||||
browser_window_refresh_url_bar(bw);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1227,9 +1225,7 @@ static nserror browser_window_callback(hlcache_handle *c,
|
|||
if (bw->window != NULL) {
|
||||
guit->window->new_content(bw->window);
|
||||
|
||||
browser_window_refresh_url_bar(bw,
|
||||
hlcache_handle_get_url(bw->current_content),
|
||||
bw->frag_id);
|
||||
browser_window_refresh_url_bar(bw);
|
||||
}
|
||||
|
||||
/* new content; set scroll_to_top */
|
||||
|
@ -1697,6 +1693,70 @@ void browser_window_destroy(struct browser_window *bw)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update URL bar for a given browser window to given URL
|
||||
*
|
||||
* \param bw Browser window to update URL bar for.
|
||||
* \param url URL for content displayed by bw including any fragment.
|
||||
*/
|
||||
|
||||
static inline void browser_window_refresh_url_bar_internal(
|
||||
struct browser_window *bw, nsurl *url)
|
||||
{
|
||||
assert(bw);
|
||||
assert(url);
|
||||
|
||||
if (bw->parent != NULL) {
|
||||
/* Not root window; don't set a URL in GUI URL bar */
|
||||
return;
|
||||
}
|
||||
|
||||
guit->window->set_url(bw->window, nsurl_access(url));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update URL bar for a given browser window to bw's content's URL
|
||||
*
|
||||
* \param bw Browser window to update URL bar for.
|
||||
*/
|
||||
|
||||
void browser_window_refresh_url_bar(struct browser_window *bw)
|
||||
{
|
||||
assert(bw);
|
||||
|
||||
if (bw->parent != NULL) {
|
||||
/* Not root window; don't set a URL in GUI URL bar */
|
||||
return;
|
||||
}
|
||||
|
||||
if (bw->current_content == NULL) {
|
||||
/* TODO: set "about:blank"? */
|
||||
return;
|
||||
}
|
||||
|
||||
if (bw->frag_id == NULL) {
|
||||
browser_window_refresh_url_bar_internal(bw,
|
||||
hlcache_handle_get_url(bw->current_content));
|
||||
} else {
|
||||
nsurl *display_url;
|
||||
nserror error;
|
||||
|
||||
/* Combine URL and Fragment */
|
||||
error = nsurl_refragment(
|
||||
hlcache_handle_get_url(bw->current_content),
|
||||
bw->frag_id, &display_url);
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user("NoMemory", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
browser_window_refresh_url_bar_internal(bw, display_url);
|
||||
nsurl_unref(display_url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* exported interface documented in desktop/browser.h */
|
||||
nserror browser_window_navigate(struct browser_window *bw,
|
||||
nsurl *url,
|
||||
|
@ -1807,10 +1867,7 @@ nserror browser_window_navigate(struct browser_window *bw,
|
|||
browser_window_update(bw, false);
|
||||
|
||||
if (bw->current_content != NULL) {
|
||||
browser_window_refresh_url_bar(bw,
|
||||
hlcache_handle_get_url(
|
||||
bw->current_content),
|
||||
bw->frag_id);
|
||||
browser_window_refresh_url_bar(bw);
|
||||
}
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
@ -1842,7 +1899,7 @@ nserror browser_window_navigate(struct browser_window *bw,
|
|||
case NSERROR_OK:
|
||||
bw->loading_content = c;
|
||||
browser_window_start_throbber(bw);
|
||||
browser_window_refresh_url_bar(bw, url, NULL);
|
||||
browser_window_refresh_url_bar_internal(bw, url);
|
||||
break;
|
||||
|
||||
case NSERROR_NO_FETCH_HANDLER: /* no handler for this type */
|
||||
|
@ -2074,9 +2131,7 @@ void browser_window_stop(struct browser_window *bw)
|
|||
}
|
||||
|
||||
if (bw->current_content != NULL) {
|
||||
browser_window_refresh_url_bar(bw,
|
||||
hlcache_handle_get_url(bw->current_content),
|
||||
bw->frag_id);
|
||||
browser_window_refresh_url_bar(bw);
|
||||
}
|
||||
|
||||
browser_window_stop_throbber(bw);
|
||||
|
@ -2314,46 +2369,6 @@ float browser_window_get_scale(struct browser_window *bw)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update URL bar for a given browser window to given URL
|
||||
*
|
||||
* \param bw Browser window to update URL bar for.
|
||||
* \param url URL for content displayed by bw, excluding any fragment.
|
||||
* \param frag Additional fragment. May be NULL if none.
|
||||
*/
|
||||
|
||||
void browser_window_refresh_url_bar(struct browser_window *bw, nsurl *url,
|
||||
lwc_string *frag)
|
||||
{
|
||||
assert(bw);
|
||||
assert(url);
|
||||
|
||||
if (bw->parent != NULL) {
|
||||
/* Not root window; don't set a URL in GUI URL bar */
|
||||
return;
|
||||
}
|
||||
|
||||
if (frag == NULL) {
|
||||
/* With no fragment, we may as well pass url straight through
|
||||
* saving a malloc, copy, free cycle.
|
||||
*/
|
||||
guit->window->set_url(bw->window, nsurl_access(url));
|
||||
} else {
|
||||
nsurl *display_url;
|
||||
nserror error;
|
||||
|
||||
error = nsurl_refragment(url, frag, &display_url);
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user("NoMemory", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
guit->window->set_url(bw->window, nsurl_access(display_url));
|
||||
nsurl_unref(display_url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void browser_window_find_target_internal(struct browser_window *bw,
|
||||
const char *target, int depth, struct browser_window *page,
|
||||
int *rdepth, struct browser_window **bw_target)
|
||||
|
|
|
@ -177,8 +177,7 @@ bool browser_window_drop_file_at_point(struct browser_window *bw,
|
|||
void browser_window_set_gadget_filename(struct browser_window *bw,
|
||||
struct form_control *gadget, const char *fn);
|
||||
|
||||
void browser_window_refresh_url_bar(struct browser_window *bw, nsurl *url,
|
||||
lwc_string *frag);
|
||||
void browser_window_refresh_url_bar(struct browser_window *bw);
|
||||
|
||||
void browser_window_mouse_click(struct browser_window *bw,
|
||||
browser_mouse_state mouse, int x, int y);
|
||||
|
|
|
@ -303,11 +303,7 @@ static void nsgtk_window_update_back_forward(struct gtk_scaffolding *g)
|
|||
nsgtk_scaffolding_set_sensitivity(g);
|
||||
|
||||
/* update the url bar, particularly necessary when tabbing */
|
||||
if (bw->current_content != NULL &&
|
||||
hlcache_handle_get_url(bw->current_content) != NULL)
|
||||
browser_window_refresh_url_bar(bw,
|
||||
hlcache_handle_get_url(bw->current_content),
|
||||
bw->frag_id);
|
||||
browser_window_refresh_url_bar(bw);
|
||||
|
||||
/* update the local history window, as well as queuing a redraw
|
||||
* for it.
|
||||
|
|
|
@ -429,14 +429,7 @@ void nsgtk_toolbar_close(nsgtk_scaffolding *g)
|
|||
current_content) != NULL))
|
||||
browser_window_refresh_url_bar(
|
||||
nsgtk_get_browser_window(
|
||||
nsgtk_scaffolding_top_level(list)),
|
||||
hlcache_handle_get_url(
|
||||
nsgtk_get_browser_window(
|
||||
nsgtk_scaffolding_top_level(list))->
|
||||
current_content),
|
||||
nsgtk_get_browser_window(
|
||||
nsgtk_scaffolding_top_level(list))->
|
||||
frag_id);
|
||||
nsgtk_scaffolding_top_level(list)));
|
||||
|
||||
if (list != g)
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(
|
||||
|
|
Loading…
Reference in New Issue