summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-02-08 22:43:54 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2014-02-08 22:43:54 +0000
commit3d7cd77982d79ff798a92ebe7f3c0b2a52042cdf (patch)
tree43fb131d4c23d6d9f177c135291c4ad8ea102953
parent2cd2e5b0541e7067c908e88f446b7cc56095253b (diff)
downloadnetsurf-3d7cd77982d79ff798a92ebe7f3c0b2a52042cdf.tar.gz
netsurf-3d7cd77982d79ff798a92ebe7f3c0b2a52042cdf.tar.bz2
Simplify local history interface.
-rw-r--r--amiga/context_menu.c2
-rw-r--r--amiga/gui.c4
-rwxr-xr-xamiga/history_local.c4
-rw-r--r--atari/toolbar.c4
-rw-r--r--beos/scaffolding.cpp4
-rw-r--r--cocoa/BrowserViewController.m6
-rw-r--r--cocoa/HistoryView.m2
-rw-r--r--desktop/browser.c4
-rw-r--r--desktop/local_history.c36
-rw-r--r--desktop/local_history.h30
-rw-r--r--framebuffer/gui.c4
-rw-r--r--framebuffer/localhistory.c2
-rw-r--r--gtk/scaffolding.c7
-rw-r--r--riscos/history.c2
-rw-r--r--riscos/window.c72
-rw-r--r--windows/gui.c4
-rw-r--r--windows/localhistory.c3
17 files changed, 67 insertions, 123 deletions
diff --git a/amiga/context_menu.c b/amiga/context_menu.c
index c0c47ac6b..a1ce624e5 100644
--- a/amiga/context_menu.c
+++ b/amiga/context_menu.c
@@ -916,7 +916,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
}
else
{
- history_go(gwin->bw, gwin->bw->history,
+ history_go(gwin->bw->history,
(struct history_entry *)userdata, false);
}
break;
diff --git a/amiga/gui.c b/amiga/gui.c
index 74aece866..3f937a6f2 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1064,12 +1064,12 @@ void ami_gui_history(struct gui_window_2 *gwin, bool back)
if(back == true)
{
if(browser_window_back_available(gwin->bw))
- history_back(gwin->bw, gwin->bw->history);
+ history_back(gwin->bw->history, false);
}
else
{
if(browser_window_forward_available(gwin->bw))
- history_forward(gwin->bw, gwin->bw->history);
+ history_forward(gwin->bw->history, false);
}
ami_update_buttons(gwin);
diff --git a/amiga/history_local.c b/amiga/history_local.c
index b5aba3825..3eda8874b 100755
--- a/amiga/history_local.c
+++ b/amiga/history_local.c
@@ -210,13 +210,13 @@ bool ami_history_click(struct history_window *hw,uint16 code)
switch(code)
{
case SELECTUP:
- history_click(hw->bw,history_current,x,y,false);
+ history_click(history_current,x,y,false);
ami_history_redraw(hw);
ami_schedule_redraw(hw->bw->window->shared, true);
break;
case MIDDLEUP:
- history_click(hw->bw,history_current,x,y,true);
+ history_click(history_current,x,y,true);
ami_history_redraw(hw);
break;
diff --git a/atari/toolbar.c b/atari/toolbar.c
index f40c07a65..9a49fbfea 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -948,7 +948,7 @@ void toolbar_back_click(struct s_toolbar *tb)
assert(bw != NULL);
if( history_back_available(bw->history) )
- history_back(bw, bw->history);
+ history_back(bw->history, false);
}
void toolbar_reload_click(struct s_toolbar *tb)
@@ -975,7 +975,7 @@ void toolbar_forward_click(struct s_toolbar *tb)
assert(bw != NULL);
if (history_forward_available(bw->history))
- history_forward(bw, bw->history);
+ history_forward(bw->history, false);
}
void toolbar_home_click(struct s_toolbar *tb)
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index c673f19a5..0a362ce62 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -976,7 +976,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
case 'back':
if (!history_back_available(bw->history))
break;
- history_back(bw, bw->history);
+ history_back(bw->history, false);
nsbeos_window_update_back_forward(scaffold);
break;
case B_NETPOSITIVE_FORWARD:
@@ -984,7 +984,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
case 'forw':
if (!history_forward_available(bw->history))
break;
- history_forward(bw, bw->history);
+ history_forward(bw->history, false);
nsbeos_window_update_back_forward(scaffold);
break;
case B_NETPOSITIVE_STOP:
diff --git a/cocoa/BrowserViewController.m b/cocoa/BrowserViewController.m
index 5cc3d4c20..7c77b7c7f 100644
--- a/cocoa/BrowserViewController.m
+++ b/cocoa/BrowserViewController.m
@@ -118,7 +118,7 @@
- (IBAction) goBack: (id) sender;
{
if (browser && history_back_available( browser->history )) {
- history_back(browser, browser->history);
+ history_back(browser->history, false);
[self updateBackForward];
}
}
@@ -126,7 +126,7 @@
- (IBAction) goForward: (id) sender;
{
if (browser && history_forward_available( browser->history )) {
- history_forward(browser, browser->history);
+ history_forward(browser->history, false);
[self updateBackForward];
}
}
@@ -316,7 +316,7 @@ static bool history_add_menu_item_cb( const struct history *history, int x0, int
- (IBAction) historyItemSelected: (id) sender;
{
struct history_entry *entry = [[sender representedObject] pointerValue];
- history_go( browser, browser->history, entry, false );
+ history_go( browser->history, entry, false );
[self updateBackForward];
}
diff --git a/cocoa/HistoryView.m b/cocoa/HistoryView.m
index 45f7facbf..c7181650b 100644
--- a/cocoa/HistoryView.m
+++ b/cocoa/HistoryView.m
@@ -72,7 +72,7 @@
{
const NSPoint location = [self convertPoint: [theEvent locationInWindow] fromView: nil];
const bool newWindow = [theEvent modifierFlags] & NSCommandKeyMask;
- if (history_click( browser, browser->history,
+ if (history_click( browser->history,
cocoa_pt_to_px( location.x ), cocoa_pt_to_px( location.y ),
newWindow )) {
[browserView setHistoryVisible: NO];
diff --git a/desktop/browser.c b/desktop/browser.c
index 428c0775b..4fdfce52d 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -764,9 +764,9 @@ void browser_window_initialise_common(struct browser_window *bw,
assert(bw);
if (!clone)
- bw->history = history_create();
+ bw->history = history_create(bw);
else
- bw->history = history_clone(clone->history);
+ bw->history = history_clone(clone->history, bw);
/* window characteristics */
bw->refresh_interval = -1;
diff --git a/desktop/local_history.c b/desktop/local_history.c
index 9829f51b6..b26f266d6 100644
--- a/desktop/local_history.c
+++ b/desktop/local_history.c
@@ -78,6 +78,8 @@ struct history {
int width;
/** Height of layout. */
int height;
+ /** Browser window that local history belongs to */
+ struct browser_window *bw;
};
static struct history_entry *history_clone_entry(struct history *history,
@@ -102,7 +104,7 @@ static bool history_enumerate_entry(const struct history *history,
* \return pointer to an opaque history structure, 0 on failure.
*/
-struct history *history_create(void)
+struct history *history_create(struct browser_window *bw)
{
struct history *history;
@@ -113,6 +115,7 @@ struct history *history_create(void)
}
history->width = RIGHT_MARGIN / 2;
history->height = BOTTOM_MARGIN / 2;
+ history->bw = bw;
return history;
}
@@ -125,12 +128,13 @@ struct history *history_create(void)
* \return pointer to an opaque history structure, 0 on failure.
*/
-struct history *history_clone(struct history *history)
+struct history *history_clone(struct history *history,
+ struct browser_window *bw)
{
struct history *new_history;
if (!history->start)
- return history_create();
+ return history_create(bw);
new_history = malloc(sizeof *history);
if (!new_history)
@@ -370,13 +374,14 @@ void history_free_entry(struct history_entry *entry)
*
* \param bw browser window
* \param history history of the window
+ * \param new_window whether to open in new window
*/
-void history_back(struct browser_window *bw, struct history *history)
+void history_back(struct history *history, bool new_window)
{
if (!history || !history->current || !history->current->back)
return;
- history_go(bw, history, history->current->back, false);
+ history_go(history, history->current->back, new_window);
}
@@ -385,13 +390,14 @@ void history_back(struct browser_window *bw, struct history *history)
*
* \param bw browser window
* \param history history of the window
+ * \param new_window whether to open in new window
*/
-void history_forward(struct browser_window *bw, struct history *history)
+void history_forward(struct history *history, bool new_window)
{
if (!history || !history->current || !history->current->forward_pref)
return;
- history_go(bw, history, history->current->forward_pref, false);
+ history_go(history, history->current->forward_pref, new_window);
}
@@ -422,9 +428,7 @@ bool history_forward_available(struct history *history)
/* Documented in local_history.h */
-void history_go(struct browser_window *bw,
- struct history *history,
- struct history_entry *entry,
+void history_go(struct history *history, struct history_entry *entry,
bool new_window)
{
nsurl *url;
@@ -452,14 +456,11 @@ void history_go(struct browser_window *bw,
history->current = entry;
browser_window_create(BROWSER_WINDOW_VERIFIABLE,
- url,
- NULL,
- bw,
- NULL);
+ url, NULL, history->bw, NULL);
history->current = current;
} else {
history->current = entry;
- browser_window_navigate(bw, url, NULL,
+ browser_window_navigate(history->bw, url, NULL,
BROWSER_WINDOW_VERIFIABLE, NULL, NULL, NULL);
}
@@ -702,8 +703,7 @@ bool history_redraw_entry(struct history *history,
* \return true if action was taken, false if click was not on an entry
*/
-bool history_click(struct browser_window *bw, struct history *history,
- int x, int y, bool new_window)
+bool history_click(struct history *history, int x, int y, bool new_window)
{
struct history_entry *entry;
@@ -713,7 +713,7 @@ bool history_click(struct browser_window *bw, struct history *history,
if (entry == history->current)
return false;
- history_go(bw, history, entry, new_window);
+ history_go(history, entry, new_window);
return true;
}
diff --git a/desktop/local_history.h b/desktop/local_history.h
index c4faa8532..b3e177b28 100644
--- a/desktop/local_history.h
+++ b/desktop/local_history.h
@@ -32,14 +32,15 @@ struct browser_window;
struct history_entry;
struct redraw_context;
-struct history *history_create(void);
-struct history *history_clone(struct history *history);
+struct history *history_create(struct browser_window *bw);
+struct history *history_clone(struct history *history,
+ struct browser_window *bw);
void history_add(struct history *history, struct hlcache_handle *content,
lwc_string *frag_id);
void history_update(struct history *history, struct hlcache_handle *content);
void history_destroy(struct history *history);
-void history_back(struct browser_window *bw, struct history *history);
-void history_forward(struct browser_window *bw, struct history *history);
+void history_back(struct history *history, bool new_window);
+void history_forward(struct history *history, bool new_window);
bool history_back_available(struct history *history);
bool history_forward_available(struct history *history);
void history_size(struct history *history, int *width, int *height);
@@ -47,8 +48,7 @@ bool history_redraw(struct history *history, const struct redraw_context *ctx);
bool history_redraw_rectangle(struct history *history,
int x0, int y0, int x1, int y1, int x, int y,
const struct redraw_context *ctx);
-bool history_click(struct browser_window *bw, struct history *history,
- int x, int y, bool new_window);
+bool history_click(struct history *history, int x, int y, bool new_window);
const char *history_position_url(struct history *history, int x, int y);
/**
@@ -59,9 +59,10 @@ const char *history_position_url(struct history *history, int x, int y);
* \param entry Current history entry
* \return true to continue enumeration, false to cancel enumeration
*/
-typedef bool (*history_enumerate_cb)(const struct history *history, int x0, int y0,
- int x1, int y1,
- const struct history_entry *entry, void *user_data);
+typedef bool (*history_enumerate_cb)(const struct history *history,
+ int x0, int y0,
+ int x1, int y1,
+ const struct history_entry *entry, void *user_data);
/**
* Enumerate all entries in the history.
@@ -71,7 +72,8 @@ typedef bool (*history_enumerate_cb)(const struct history *history, int x0, int
* \param cb callback function
* \param user_data context pointer passed to cb
*/
-void history_enumerate(const struct history *history, history_enumerate_cb cb, void *user_data);
+void history_enumerate(const struct history *history,
+ history_enumerate_cb cb, void *user_data);
/**
* Enumerate all entries that will be reached by the 'forward' button
@@ -81,7 +83,7 @@ void history_enumerate(const struct history *history, history_enumerate_cb cb, v
* \param user_data Data passed to the callback
*/
void history_enumerate_forward( struct history *history,
- history_enumerate_cb cb, void *user_data );
+ history_enumerate_cb cb, void *user_data);
/**
* Enumerate all entries that will be reached by the 'back' button
@@ -91,7 +93,7 @@ void history_enumerate_forward( struct history *history,
* \param user_data Data passed to the callback
*/
void history_enumerate_back( struct history *history,
- history_enumerate_cb cb, void *user_data );
+ history_enumerate_cb cb, void *user_data);
/**
* Returns the URL to a history entry
@@ -125,7 +127,7 @@ const char *history_entry_get_title(const struct history_entry *entry);
* \param entry entry to open
* \param new_window open entry in new window
*/
-void history_go(struct browser_window *bw, struct history *history,
- struct history_entry *entry, bool new_window);
+void history_go(struct history *history, struct history_entry *entry,
+ bool new_window);
#endif
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index b9fbdfa7b..2cceba9c5 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -989,7 +989,7 @@ fb_leftarrow_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
return 0;
if (history_back_available(bw->history))
- history_back(bw, bw->history);
+ history_back(bw->history, false);
fb_update_back_forward(gw);
@@ -1007,7 +1007,7 @@ fb_rightarrow_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
return 0;
if (history_forward_available(bw->history))
- history_forward(bw, bw->history);
+ history_forward(bw->history, false);
fb_update_back_forward(gw);
return 1;
diff --git a/framebuffer/localhistory.c b/framebuffer/localhistory.c
index d4820980f..bb2736dd9 100644
--- a/framebuffer/localhistory.c
+++ b/framebuffer/localhistory.c
@@ -97,7 +97,7 @@ localhistory_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
if (cbi->event->type != NSFB_EVENT_KEY_UP)
return 0;
- history_click(glh->bw, glh->bw->history, cbi->x, cbi->y, false);
+ history_click(glh->bw->history, cbi->x, cbi->y, false);
fbtk_set_mapping(glh->window, false);
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 615526b68..c4ea674d8 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -1422,7 +1422,7 @@ MULTIHANDLER(back)
nsgtk_search_set_forward_state(true, bw);
nsgtk_search_set_back_state(true, bw);
- history_back(bw, bw->history);
+ history_back(bw->history, false);
nsgtk_window_update_back_forward(g);
return TRUE;
@@ -1442,7 +1442,7 @@ MULTIHANDLER(forward)
nsgtk_search_set_forward_state(true, bw);
nsgtk_search_set_back_state(true, bw);
- history_forward(bw, bw->history);
+ history_forward(bw->history, false);
nsgtk_window_update_back_forward(g);
return TRUE;
@@ -1741,8 +1741,7 @@ static gboolean nsgtk_history_button_press_event(GtkWidget *widget,
LOG(("X=%g, Y=%g", event->x, event->y));
- history_click(bw, bw->history,
- event->x, event->y, false);
+ history_click(bw->history, event->x, event->y, false);
return TRUE;
}
diff --git a/riscos/history.c b/riscos/history.c
index a4aedc6b5..959f4ce38 100644
--- a/riscos/history.c
+++ b/riscos/history.c
@@ -348,7 +348,7 @@ bool ro_gui_history_click(wimp_pointer *pointer)
x = (pointer->pos.x - (state.visible.x0 - state.xscroll)) / 2;
y = -(pointer->pos.y - (state.visible.y1 - state.yscroll)) / 2;
- history_click(history_bw, history_current, x, y,
+ history_click(history_current, x, y,
pointer->buttons == wimp_CLICK_ADJUST);
return true;
diff --git a/riscos/window.c b/riscos/window.c
index 83fa1eed9..37a5e7b1d 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -135,8 +135,6 @@ static bool ro_gui_window_navigate_up(struct gui_window *g, const char *url);
static void ro_gui_window_action_home(struct gui_window *g);
static void ro_gui_window_action_new_window(struct gui_window *g);
static void ro_gui_window_action_local_history(struct gui_window *g);
-static void ro_gui_window_action_navigate_back_new(struct gui_window *g);
-static void ro_gui_window_action_navigate_forward_new(struct gui_window *g);
static void ro_gui_window_action_save(struct gui_window *g,
gui_save_type save_type);
static void ro_gui_window_action_search(struct gui_window *g);
@@ -2944,11 +2942,11 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
break;
case BROWSER_NAVIGATE_BACK:
if (bw != NULL && bw->history != NULL)
- history_back(bw, bw->history);
+ history_back(bw->history, false);
break;
case BROWSER_NAVIGATE_FORWARD:
if (bw != NULL && bw->history != NULL)
- history_forward(bw, bw->history);
+ history_forward(bw->history, false);
break;
case BROWSER_NAVIGATE_UP:
if (bw != NULL && h != NULL)
@@ -3642,20 +3640,22 @@ void ro_gui_window_toolbar_click(void *data,
switch (action.button) {
case TOOLBAR_BUTTON_BACK:
if (g->bw != NULL && g->bw->history != NULL)
- history_back(g->bw, g->bw->history);
+ history_back(g->bw->history, false);
break;
case TOOLBAR_BUTTON_BACK_NEW:
- ro_gui_window_action_navigate_back_new(g);
+ if (g->bw != NULL && g->bw->history != NULL)
+ history_back(g->bw->history, true);
break;
case TOOLBAR_BUTTON_FORWARD:
if (g->bw != NULL && g->bw->history != NULL)
- history_forward(g->bw, g->bw->history);
+ history_forward(g->bw->history, false);
break;
case TOOLBAR_BUTTON_FORWARD_NEW:
- ro_gui_window_action_navigate_forward_new(g);
+ if (g->bw != NULL && g->bw->history != NULL)
+ history_forward(g->bw->history, true);
break;
case TOOLBAR_BUTTON_STOP:
@@ -4099,62 +4099,6 @@ void ro_gui_window_action_home(struct gui_window *g)
/**
- * Navigate back from a browser window into a new window.
- *
- * \param *g The browser window to act on.
- */
-
-void ro_gui_window_action_navigate_back_new(struct gui_window *g)
-{
- struct browser_window *new_bw;
- nserror error;
-
- if (g == NULL || g->bw == NULL)
- return;
-
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE,
- NULL,
- NULL,
- g->bw,
- &new_bw);
-
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- } else {
- history_back(new_bw, new_bw->history);
- }
-}
-
-
-/**
- * Navigate forward from a browser window into a new window.
- *
- * \param *g The browser window to act on.
- */
-
-void ro_gui_window_action_navigate_forward_new(struct gui_window *g)
-{
- struct browser_window *new_bw;
- nserror error;
-
- if (g == NULL || g->bw == NULL)
- return;
-
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE,
- NULL,
- NULL,
- g->bw,
- &new_bw);
-
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- } else {
- history_forward(new_bw, new_bw->history);
- }
-}
-
-
-/**
* Open a new browser window.
*
* \param *g The browser window to act on.
diff --git a/windows/gui.c b/windows/gui.c
index 6ac4f6155..ee8b4ed1f 100644
--- a/windows/gui.c
+++ b/windows/gui.c
@@ -853,7 +853,7 @@ nsws_window_command(HWND hwnd,
case IDM_NAV_BACK:
if ((gw->bw != NULL) &&
(history_back_available(gw->bw->history))) {
- history_back(gw->bw, gw->bw->history);
+ history_back(gw->bw->history, false);
}
nsws_window_update_forward_back(gw);
break;
@@ -861,7 +861,7 @@ nsws_window_command(HWND hwnd,
case IDM_NAV_FORWARD:
if ((gw->bw != NULL) &&
(history_forward_available(gw->bw->history))) {
- history_forward(gw->bw, gw->bw->history);
+ history_forward(gw->bw->history, false);
}
nsws_window_update_forward_back(gw);
break;
diff --git a/windows/localhistory.c b/windows/localhistory.c
index 0b298719f..d2be2c377 100644
--- a/windows/localhistory.c
+++ b/windows/localhistory.c
@@ -167,8 +167,7 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
- if (history_click(gw->bw,
- gw->bw->history,
+ if (history_click(gw->bw->history,
gw->localhistory->hscroll + x,
gw->localhistory->vscroll + y,
false)) {