diff options
-rwxr-xr-x | amiga/gui.c | 2 | ||||
-rw-r--r-- | desktop/browser.c | 54 | ||||
-rw-r--r-- | desktop/browser.h | 10 | ||||
-rw-r--r-- | desktop/history_core.c | 39 | ||||
-rw-r--r-- | desktop/history_core.h | 2 | ||||
-rw-r--r-- | gtk/gtk_scaffolding.c | 7 | ||||
-rw-r--r-- | gtk/gtk_window.c | 21 | ||||
-rw-r--r-- | gtk/gtk_window.h | 1 | ||||
-rw-r--r-- | riscos/window.c | 2 |
9 files changed, 33 insertions, 105 deletions
diff --git a/amiga/gui.c b/amiga/gui.c index 3e977ee57..b9f2272cc 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -1367,7 +1367,7 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw) GetAttr(SPACE_AreaBox,gwin->gadgets[GID_BROWSER],(ULONG *)&bbox); p96RectFill(gwin->win->RPort,bbox->Left,bbox->Top,bbox->Width+bbox->Left,bbox->Height+bbox->Top,0xffffffff); - browser_window_update(gwin->bw); + browser_window_update(gwin->bw,false); gui_window_set_scroll(gwin->bw->window,gwin->bw->window->scrollx,gwin->bw->window->scrolly); diff --git a/desktop/browser.c b/desktop/browser.c index 605b44f25..55d069db2 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -139,11 +139,11 @@ static void browser_window_scroll_box(struct browser_window *bw, struct browser_window *browser_window_create(const char *url, struct browser_window *clone, - const char *referer, bool add_to_history, bool new_tab) + const char *referer, bool history_add, bool new_tab) { struct browser_window *bw; - assert(clone || add_to_history); + assert(clone || history_add); if ((bw = calloc(1, sizeof *bw)) == NULL) { warn_user("NoMemory", 0); @@ -165,7 +165,7 @@ struct browser_window *browser_window_create(const char *url, return NULL; } if (url) - browser_window_go(bw, url, referer, add_to_history); + browser_window_go(bw, url, referer, history_add); return bw; } @@ -208,11 +208,11 @@ void browser_window_initialise_common(struct browser_window *bw, */ void browser_window_go(struct browser_window *bw, const char *url, - const char *referer, bool add_to_history) + const char *referer, bool history_add) { /* All fetches passing through here are verifiable * (i.e are the result of user action) */ - browser_window_go_post(bw, url, 0, 0, add_to_history, referer, + browser_window_go_post(bw, url, 0, 0, history_add, referer, false, true, referer); } @@ -244,11 +244,11 @@ void browser_window_download(struct browser_window *bw, const char *url, */ void browser_window_go_unverifiable(struct browser_window *bw, - const char *url, const char *referer, bool add_to_history) + const char *url, const char *referer, bool history_add) { /* All fetches passing through here are unverifiable * (i.e are not the result of user action) */ - browser_window_go_post(bw, url, 0, 0, add_to_history, referer, + browser_window_go_post(bw, url, 0, 0, history_add, referer, false, false, referer); } @@ -349,7 +349,7 @@ void browser_window_go_post(struct browser_window *bw, const char *url, if (add_to_history) history_add(bw->history, bw->current_content, bw->frag_id); - browser_window_update(bw); + browser_window_update(bw, false); if (bw->current_content) { browser_window_refresh_url_bar(bw, bw->current_content->url, @@ -367,7 +367,7 @@ void browser_window_go_post(struct browser_window *bw, const char *url, LOG(("Loading '%s' width %i, height %i", url2, width, height)); browser_window_set_status(bw, messages_get("Loading")); - bw->add_to_history = add_to_history; + bw->history_add = add_to_history; c = fetchcache(url2, browser_window_callback, (intptr_t) bw, 0, width, height, false, post_urlenc, post_multipart, verifiable, download); @@ -448,12 +448,12 @@ void browser_window_callback(content_msg msg, struct content *c, bw->current_content->url, bw->frag_id); } - browser_window_update(bw); + browser_window_update(bw, false); content_open(c, bw, 0, 0, 0, 0); browser_window_set_status(bw, c->status_message); /* history */ - if (bw->add_to_history && bw->history) { + if (bw->history_add && bw->history) { history_add(bw->history, c, bw->frag_id); if (urldb_add_url(c->url)) { urldb_set_url_title(c->url, @@ -487,7 +487,7 @@ void browser_window_callback(content_msg msg, struct content *c, case CONTENT_MSG_DONE: assert(bw->current_content == c); - browser_window_update(bw); + browser_window_update(bw, false); browser_window_set_status(bw, c->status_message); browser_window_stop_throbber(bw); history_update(bw->history, c); @@ -537,7 +537,7 @@ void browser_window_callback(content_msg msg, struct content *c, } if (bw->move_callback) bw->move_callback(bw, bw->caret_p); - browser_window_update(bw); + browser_window_update(bw, false); break; case CONTENT_MSG_REDRAW: @@ -669,7 +669,7 @@ void browser_window_convert_to_download(struct browser_window *bw) void browser_window_refresh(void *p) { struct browser_window *bw = p; - bool add_to_history = true; + bool history_add = true; assert(bw->current_content && (bw->current_content->status == CONTENT_STATUS_READY || @@ -687,7 +687,7 @@ void browser_window_refresh(void *p) (bw->current_content->refresh) && (!strcmp(bw->current_content->url, bw->current_content->refresh))) - add_to_history = false; + history_add = false; /* Treat an (almost) immediate refresh in a top-level browser window as * if it were an HTTP redirect, and thus make the resulting fetch @@ -698,10 +698,10 @@ void browser_window_refresh(void *p) */ if (bw->refresh_interval <= 100 && bw->parent == NULL) { browser_window_go(bw, bw->current_content->refresh, - bw->current_content->url, add_to_history); + bw->current_content->url, history_add); } else { browser_window_go_unverifiable(bw, bw->current_content->refresh, - bw->current_content->url, add_to_history); + bw->current_content->url, history_add); } } @@ -770,10 +770,11 @@ bool browser_window_check_throbber(struct browser_window *bw) * \param scroll_to_top move view to top of page */ -void browser_window_update(struct browser_window *bw) +void browser_window_update(struct browser_window *bw, + bool scroll_to_top) { struct box *pos; - int x, y, sx, sy; + int x, y; if (!bw->current_content) return; @@ -785,21 +786,18 @@ void browser_window_update(struct browser_window *bw) gui_window_update_extent(bw->window); - if (!history_get_current_scroll(bw->history, &sx, &sy)) - sx = -1; + if (scroll_to_top) + gui_window_set_scroll(bw->window, 0, 0); - /* if the page was scrolled before return to that position */ - if (sx != -1) { - gui_window_set_scroll(bw->window, sx, sy); + /** \todo don't do this if the user has scrolled */ /* if frag_id exists, then try to scroll to it */ - } else if (bw->frag_id && bw->current_content->type == CONTENT_HTML) { + if (bw->frag_id && bw->current_content->type == CONTENT_HTML) { if ((pos = box_find_by_id(bw->current_content->data.html.layout, bw->frag_id)) != 0) { box_coords(pos, &x, &y); gui_window_set_scroll(bw->window, x, y); } - } else - gui_window_set_scroll(bw->window, 0, 0); + } gui_window_redraw_window(bw->window); } @@ -1071,7 +1069,7 @@ void browser_window_set_scale_internal(struct browser_window *bw, float scale) c = bw->current_content; if (c) { if (!content_can_reformat(c)) { - browser_window_update(bw); + browser_window_update(bw, false); } else { bw->reformat_pending = true; browser_reformat_pending = true; diff --git a/desktop/browser.h b/desktop/browser.h index 54e4c69cc..37c643520 100644 --- a/desktop/browser.h +++ b/desktop/browser.h @@ -80,7 +80,7 @@ struct browser_window { /** Busy indicator is active. */ bool throbbing; /** Add loading_content to the window history when it loads. */ - bool add_to_history; + bool history_add; /** Fragment identifier for current_content. */ char *frag_id; @@ -214,16 +214,16 @@ extern bool browser_reformat_pending; struct browser_window * browser_window_create(const char *url, struct browser_window *clone, const char *referrer, - bool add_to_history, bool new_tab); + bool history_add, bool new_tab); void browser_window_initialise_common(struct browser_window *bw, struct browser_window *clone); void browser_window_go(struct browser_window *bw, const char *url, - const char *referrer, bool add_to_history); + const char *referrer, bool history_add); void browser_window_go_unverifiable(struct browser_window *bw, - const char *url, const char *referrer, bool add_to_history); + const char *url, const char *referrer, bool history_add); void browser_window_download(struct browser_window *bw, const char *url, const char *referrer); -void browser_window_update(struct browser_window *bw); +void browser_window_update(struct browser_window *bw, bool scroll_to_top); void browser_window_stop(struct browser_window *bw); void browser_window_reload(struct browser_window *bw, bool all); void browser_window_destroy(struct browser_window *bw); diff --git a/desktop/history_core.c b/desktop/history_core.c index 433889bea..d6feb69be 100644 --- a/desktop/history_core.c +++ b/desktop/history_core.c @@ -29,7 +29,6 @@ #include "content/content.h" #include "content/urldb.h" #include "css/css.h" -#include "desktop/browser.h" #include "desktop/gui.h" #include "desktop/history_core.h" #include "desktop/plotters.h" @@ -64,8 +63,6 @@ struct history_entry { int x; /**< Position of node. */ int y; /**< Position of node. */ struct bitmap *bitmap; /**< Thumbnail bitmap, or 0. */ - int sx; /**< X scroll offset. */ - int sy; /**< Y scroll offset. */ }; /** History tree for a window. */ @@ -262,8 +259,6 @@ void history_add(struct history *history, struct content *content, entry->forward = entry->forward_pref = entry->forward_last = 0; entry->children = 0; entry->bitmap = 0; - entry->sx = -1; - entry->sy = -1; if (history->current) { if (history->current->forward_last) history->current->forward_last->next = entry; @@ -760,37 +755,3 @@ struct history_entry *history_find_position(struct history_entry *entry, return 0; } - -/** - * Save in the history the scroll offsets of the current page - * \param history history with the page - * \param sx x offset to be set - * \param sy y offset to be set - */ - -void history_set_current_scroll(struct history *history, int sx, int sy) -{ - if (!history || !history->current) - return; - - history->current->sx = sx; - history->current->sy = sy; -} - -/** - * Load from the history the scroll offsets of the current page - * \param history history with the page - * \param sx updated to x offset - * \param sy updated to y offset - * \return true on success - */ - -bool history_get_current_scroll(struct history *history, int *sx, int *sy) -{ - if (!history || !history->current) - return false; - - *sx = history->current->sx; - *sy = history->current->sy; - return true; -} diff --git a/desktop/history_core.h b/desktop/history_core.h index 4abb94ce8..46de18848 100644 --- a/desktop/history_core.h +++ b/desktop/history_core.h @@ -46,7 +46,5 @@ bool history_redraw_rectangle(struct history *history, bool history_click(struct browser_window *bw, struct history *history, int x, int y, bool new_window); const char *history_position_url(struct history *history, int x, int y); -void history_set_current_scroll(struct history *history, int sx, int sy); -bool history_get_current_scroll(struct history *history, int *sx, int *sy); #endif diff --git a/gtk/gtk_scaffolding.c b/gtk/gtk_scaffolding.c index 9d2b69111..abf42eda4 100644 --- a/gtk/gtk_scaffolding.c +++ b/gtk/gtk_scaffolding.c @@ -1069,12 +1069,6 @@ MENUHANDLER(local_history) { struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g; - /* if entries of the same url but different frag_ids have been added - * the history needs redrawing (what is done in the throbber code in - * other cases) - */ - nsgtk_window_update_back_forward(gw); - gtk_widget_show(GTK_WIDGET(gw->history_window->window)); gdk_window_raise(GTK_WIDGET(gw->history_window->window)->window); @@ -1160,7 +1154,6 @@ gboolean nsgtk_history_button_press_event(GtkWidget *widget, history_click(bw, bw->history, event->x, event->y, false); - nsgtk_window_update_back_forward(bw->window->scaffold); return TRUE; } diff --git a/gtk/gtk_window.c b/gtk/gtk_window.c index 7ab698e44..1784f5926 100644 --- a/gtk/gtk_window.c +++ b/gtk/gtk_window.c @@ -20,7 +20,6 @@ #include <inttypes.h> #include "gtk/gtk_window.h" #include "desktop/browser.h" -#include "desktop/history_core.h" #include "desktop/options.h" #include "desktop/textinput.h" #include "desktop/selection.h" @@ -53,7 +52,6 @@ static gboolean nsgtk_window_keypress_event(GtkWidget *, GdkEventKey *, gpointer); static gboolean nsgtk_window_size_allocate_event(GtkWidget *, GtkAllocation *, gpointer); -static void nsgtk_window_scrolled(GtkAdjustment *, gpointer); /* Other useful bits */ static void nsgtk_redraw_caret(struct gui_window *g); @@ -87,8 +85,6 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, { struct gui_window *g; /**< what we're creating to return */ GtkPolicyType scrollpolicy; - GtkAdjustment *vadj; - GtkAdjustment *hadj; g = malloc(sizeof(*g)); if (!g) { @@ -144,9 +140,6 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, GTK_SHADOW_NONE); g->viewport = GTK_VIEWPORT(gtk_bin_get_child(GTK_BIN(g->scrolledwindow))); g->tab = NULL; - - vadj = gtk_viewport_get_vadjustment(g->viewport); - hadj = gtk_viewport_get_hadjustment(g->viewport); if (bw->parent != NULL) /* Attach ourselves into our parent at the right point */ @@ -232,8 +225,6 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, nsgtk_window_keypress_event, g); CONNECT(g->viewport, "size_allocate", nsgtk_window_size_allocate_event, g); - CONNECT(vadj, "value-changed", nsgtk_window_scrolled, g); - CONNECT(hadj, "value-changed", nsgtk_window_scrolled, g); return g; } @@ -591,16 +582,6 @@ gboolean nsgtk_window_size_allocate_event(GtkWidget *widget, return TRUE; } -void nsgtk_window_scrolled(GtkAdjustment *ga, gpointer data) -{ - struct gui_window *g = data; - int sx, sy; - - if (!g->setting_scroll) { - gui_window_get_scroll(g->bw->window, &sx, &sy); - history_set_current_scroll(g->bw->history, sx, sy); - } -} void nsgtk_reflow_all_windows(void) { @@ -737,10 +718,8 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy) if (y > (vupper - vpage)) y = vupper - vpage; - g->setting_scroll = true; gtk_adjustment_set_value(vadj, y); gtk_adjustment_set_value(hadj, x); - g->setting_scroll = false; } diff --git a/gtk/gtk_window.h b/gtk/gtk_window.h index ba81ad171..0f99549a7 100644 --- a/gtk/gtk_window.h +++ b/gtk/gtk_window.h @@ -34,7 +34,6 @@ struct gui_window { int caretx, carety, careth; gui_pointer_shape current_pointer; int last_x, last_y; - bool setting_scroll; /* Within GTK, a gui_window is a scrolled window * with a viewport inside diff --git a/riscos/window.c b/riscos/window.c index a4a0e3e2e..5bcecf19a 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -2539,7 +2539,7 @@ bool ro_gui_window_keypress(wimp_key *key) browser_window_set_scale(g->bw, scale, true); // g->reformat_pending = true; // if ((content) && (content->type != CONTENT_HTML)) -// browser_window_update(g->bw); +// browser_window_update(g->bw, false); // browser_reformat_pending = true; } return true; |