diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-09-20 18:58:19 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-09-20 18:58:19 +0100 |
commit | 2c36eb4e217cf2528c8cb6d120fb9a662f212376 (patch) | |
tree | a6a5c4cc7b809703b7f42b520a40de567ab63f6f /desktop/browser.c | |
parent | d3493b138f38c9e26da24fcffb3ef8b813e3ca4e (diff) | |
download | netsurf-2c36eb4e217cf2528c8cb6d120fb9a662f212376.tar.gz netsurf-2c36eb4e217cf2528c8cb6d120fb9a662f212376.tar.bz2 |
Add concept of browser scroll offset saving in local history
Diffstat (limited to 'desktop/browser.c')
-rw-r--r-- | desktop/browser.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/desktop/browser.c b/desktop/browser.c index 6cadc54ac..c8768b949 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -887,7 +887,7 @@ nserror browser_window_create(enum browser_window_create_flags flags, } if (url != NULL) { - enum browser_window_nav_flags nav_flags = BW_NAVIGATE_NONE; + enum browser_window_nav_flags nav_flags = BW_NAVIGATE_NO_TERMINAL_HISTORY_UPDATE; if (flags & BW_CREATE_UNVERIFIABLE) nav_flags |= BW_NAVIGATE_UNVERIFIABLE; if (flags & BW_CREATE_HISTORY) @@ -1355,6 +1355,7 @@ browser_window_callback(hlcache_handle *c, { struct browser_window *bw = pw; nserror res = NSERROR_OK; + float sx, sy; switch (event->type) { case CONTENT_MSG_DOWNLOAD: @@ -1485,6 +1486,19 @@ browser_window_callback(hlcache_handle *c, browser_window_stop_throbber(bw); browser_window_update_favicon(c, bw, NULL); + if (browser_window_history_get_scroll(bw, &sx, &sy) == NSERROR_OK) { + int scrollx = (int)((float)content_get_width(bw->current_content) * sx); + int scrolly = (int)((float)content_get_height(bw->current_content) * sy); + struct rect rect; + rect.x0 = rect.x1 = scrollx; + rect.y0 = rect.y1 = scrolly; + if (browser_window_set_scroll(bw, &rect) != NSERROR_OK) { + NSLOG(netsurf, WARNING, + "Unable to set browser scroll offsets to %d by %d", + scrollx, scrolly); + } + } + browser_window_history_update(bw, c); hotlist_update_url(hlcache_handle_get_url(c)); @@ -2014,6 +2028,20 @@ browser_window_navigate(struct browser_window *bw, NSLOG(netsurf, INFO, "bw %p, url %s", bw, nsurl_access(url)); + /* If we're navigating and we have a history entry and a content + * then update the history entry before we navigate to save our + * current state. However since history navigation pre-moves + * the history state, we ensure that we only do this if we've not + * been suppressed. In the suppressed case, the history code + * updates the history itself before navigating. + */ + if (bw->current_content != NULL && + bw->history != NULL && + bw->history->current != NULL && + !(flags & BW_NAVIGATE_NO_TERMINAL_HISTORY_UPDATE)) { + browser_window_history_update(bw, bw->current_content); + } + /* don't allow massively nested framesets */ for (cur = bw; cur->parent; cur = cur->parent) { depth++; |