NetSurf
Functions
browser_history.c File Reference

Browser history tree implementation. More...

#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "utils/log.h"
#include "utils/utils.h"
#include "netsurf/layout.h"
#include "netsurf/content.h"
#include "netsurf/window.h"
#include "netsurf/browser_window.h"
#include "content/hlcache.h"
#include "content/urldb.h"
#include "netsurf/bitmap.h"
#include "utils/corestrings.h"
#include "desktop/gui_internal.h"
#include "desktop/browser_private.h"
#include "desktop/local_history_private.h"
#include "desktop/browser_history.h"
Include dependency graph for browser_history.c:

Go to the source code of this file.

Functions

static struct history_entrybrowser_window_history__clone_entry (struct history *history, struct history_entry *entry)
 Clone a history entry. More...
 
static void browser_window_history__free_entry (struct history_entry *entry)
 Free an entry in the tree recursively. More...
 
static int browser_window_history__layout_subtree (struct history *history, struct history_entry *entry, int x, int y)
 Recursively position a subtree. More...
 
static void browser_window_history__layout (struct history *history)
 Compute node positions. More...
 
static bool browser_window_history__enumerate_entry (const struct browser_window *bw, const struct history_entry *entry, browser_window_history_enumerate_cb cb, void *ud)
 Enumerate subentries in history See also history_enumerate() More...
 
nserror browser_window_history_create (struct browser_window *bw)
 Create a new history tree for a browser window window. More...
 
nserror browser_window_history_clone (const struct browser_window *existing, struct browser_window *clone)
 Clone a bw's history tree for new bw. More...
 
nserror browser_window_history_add (struct browser_window *bw, struct hlcache_handle *content, lwc_string *frag_id)
 Insert a url into the history tree. More...
 
nserror browser_window_history_update (struct browser_window *bw, struct hlcache_handle *content)
 Update the thumbnail and scroll offsets for the current entry. More...
 
nserror browser_window_history_get_scroll (struct browser_window *bw, float *sx, float *sy)
 Retrieve the stored scroll offsets for the current history entry. More...
 
void browser_window_history_destroy (struct browser_window *bw)
 Free a history structure. More...
 
nserror browser_window_history_back (struct browser_window *bw, bool new_window)
 Go back in the history. More...
 
nserror browser_window_history_forward (struct browser_window *bw, bool new_window)
 Go forward in the history. More...
 
bool browser_window_history_back_available (struct browser_window *bw)
 Check whether it is pssible to go back in the history. More...
 
bool browser_window_history_forward_available (struct browser_window *bw)
 Check whether it is pssible to go forwards in the history. More...
 
nserror browser_window_history_get_thumbnail (struct browser_window *bw, struct bitmap **bitmap_out)
 Get the thumbnail bitmap for the current history entry. More...
 
nserror browser_window_history_go (struct browser_window *bw, struct history_entry *entry, bool new_window)
 Navigate to specified history entry, optionally in new window. More...
 
void browser_window_history_enumerate_forward (const struct browser_window *bw, browser_window_history_enumerate_cb cb, void *user_data)
 Enumerate all entries that will be reached by the 'forward' button. More...
 
void browser_window_history_enumerate_back (const struct browser_window *bw, browser_window_history_enumerate_cb cb, void *user_data)
 Enumerate all entries that will be reached by the 'back' button. More...
 
void browser_window_history_enumerate (const struct browser_window *bw, browser_window_history_enumerate_cb cb, void *user_data)
 Enumerate all entries in the history. More...
 
nsurlbrowser_window_history_entry_get_url (const struct history_entry *entry)
 Returns the URL to a history entry. More...
 
const char * browser_window_history_entry_get_fragment_id (const struct history_entry *entry)
 Returns the URL to a history entry. More...
 
const char * browser_window_history_entry_get_title (const struct history_entry *entry)
 Returns the title of a history entry. More...
 

Detailed Description

Browser history tree implementation.

Definition in file browser_history.c.

Function Documentation

◆ browser_window_history__clone_entry()

static struct history_entry * browser_window_history__clone_entry ( struct history history,
struct history_entry entry 
)
static

Clone a history entry.

Parameters
historyopaque history structure, as returned by history_create()
entryentry to clone
Returns
A cloned history entry or NULL on error

Definition at line 55 of file browser_history.c.

References history_entry::back, history_page::bitmap, netsurf_table::bitmap, BITMAP_OPAQUE, browser_window_history__clone_entry(), gui_bitmap_table::create, history::current, gui_bitmap_table::destroy, history_entry::forward, history_entry::forward_last, history_entry::forward_pref, history_page::frag_id, gui_bitmap_table::get_buffer, gui_bitmap_table::get_height, gui_bitmap_table::get_rowstride, guit, LOCAL_HISTORY_HEIGHT, LOCAL_HISTORY_WIDTH, history_entry::next, nsurl_ref(), nsurl_unref(), history_entry::page, history_page::title, and history_page::url.

Referenced by browser_window_history__clone_entry(), and browser_window_history_clone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser_window_history__enumerate_entry()

static bool browser_window_history__enumerate_entry ( const struct browser_window bw,
const struct history_entry entry,
browser_window_history_enumerate_cb  cb,
void *  ud 
)
static

Enumerate subentries in history See also history_enumerate()

Parameters
bwThe browser window to enumerate history of
entryentry to start enumeration at
cbcallback function
udcontext pointer passed to cb
Returns
true to continue enumeration, false to cancel

Definition at line 268 of file browser_history.c.

References browser_window_history__enumerate_entry(), history_entry::forward, LOCAL_HISTORY_HEIGHT, LOCAL_HISTORY_WIDTH, history_entry::next, history_entry::x, and history_entry::y.

Referenced by browser_window_history__enumerate_entry(), and browser_window_history_enumerate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser_window_history__free_entry()

static void browser_window_history__free_entry ( struct history_entry entry)
static

Free an entry in the tree recursively.

Definition at line 168 of file browser_history.c.

References history_page::bitmap, netsurf_table::bitmap, browser_window_history__free_entry(), gui_bitmap_table::destroy, history_entry::forward, history_page::frag_id, guit, history_entry::next, nsurl_unref(), history_entry::page, history_page::title, and history_page::url.

Referenced by browser_window_history__free_entry(), and browser_window_history_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser_window_history__layout()

static void browser_window_history__layout ( struct history history)
static

Compute node positions.

Parameters
historyhistory to layout

Each node's x and y are filled in.

Definition at line 236 of file browser_history.c.

References browser_window_history__layout_subtree(), history::height, LOCAL_HISTORY_BOTTOM_MARGIN, LOCAL_HISTORY_RIGHT_MARGIN, history::start, and history::width.

Referenced by browser_window_history_add().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser_window_history__layout_subtree()

static int browser_window_history__layout_subtree ( struct history history,
struct history_entry entry,
int  x,
int  y 
)
static

Recursively position a subtree.

Parameters
historyhistory being laid out
entrysubtree to position
xx position for entry
ysmallest available y
Returns
greatest y used by subtree

Definition at line 197 of file browser_history.c.

References browser_window_history__layout_subtree(), history_entry::forward, LOCAL_HISTORY_BOTTOM_MARGIN, LOCAL_HISTORY_HEIGHT, LOCAL_HISTORY_RIGHT_MARGIN, LOCAL_HISTORY_WIDTH, history_entry::next, history::width, history_entry::x, and history_entry::y.

Referenced by browser_window_history__layout(), and browser_window_history__layout_subtree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser_window_history_add()

nserror browser_window_history_add ( struct browser_window bw,
struct hlcache_handle content,
lwc_string *  frag_id 
)

Insert a url into the history tree.

Parameters
bwbrowser window with history object
contentcontent to add to history
frag_idfragment identifier, or NULL.
Returns
NSERROR_OK or error code on faliure.

The page is added after the current entry and becomes current.

Definition at line 352 of file browser_history.c.

References history_entry::back, history_page::bitmap, netsurf_table::bitmap, BITMAP_CLEAR, BITMAP_OPAQUE, browser_window_history__layout(), history_entry::children, content_get_title(), gui_bitmap_table::create, history::current, history_entry::forward, history_entry::forward_last, history_entry::forward_pref, history_page::frag_id, guit, browser_window::history, hlcache_handle_get_url(), LOCAL_HISTORY_HEIGHT, LOCAL_HISTORY_WIDTH, history_entry::next, NSERROR_NOMEM, NSERROR_OK, NSLOG, nsurl_access(), nsurl_ref(), history_entry::page, gui_bitmap_table::render, history_page::scroll_x, history_page::scroll_y, history::start, history_page::title, and history_page::url.

Referenced by browser_window_content_ready(), and browser_window_navigate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser_window_history_back()

nserror browser_window_history_back ( struct browser_window bw,
bool  new_window 
)

Go back in the history.

Parameters
bwA browser window to navigate the history in.
new_windowwhether to open in new window.
Returns
NSERROR_OK or error code on faliure.

Definition at line 518 of file browser_history.c.

References history_entry::back, browser_window__reload_current_parameters(), browser_window_history_go(), browser_window_navigate(), BW_NAVIGATE_HISTORY, history::current, browser_window::current_parameters, browser_window::history, browser_window::internal_nav, NSERROR_BAD_PARAMETER, and browser_fetch_parameters::url.

Referenced by ami_gui_history(), back_button_clicked_cb(), fb_leftarrow_click(), nsbeos_scaffolding_dispatch_event(), nsws_window_command(), ro_gui_window_menu_select(), ro_gui_window_toolbar_click(), and toolbar_back_click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser_window_history_back_available()

bool browser_window_history_back_available ( struct browser_window bw)

Check whether it is pssible to go back in the history.

Parameters
bwA browser window to check the history navigation in.
Returns
true if the history can go back, false otherwise

Definition at line 562 of file browser_history.c.

References history_entry::back, history::current, and browser_window::history.

Referenced by back_button_clicked_cb(), browser_window_back_available(), forward_button_clicked_cb(), nsbeos_scaffolding_dispatch_event(), nsbeos_window_update_back_forward(), nsgtk_toolbar_throbber(), nsws_window_command(), nsws_window_update_forward_back(), and scaffolding_update_context().

Here is the caller graph for this function:

◆ browser_window_history_clone()

nserror browser_window_history_clone ( const struct browser_window existing,
struct browser_window clone 
)

Clone a bw's history tree for new bw.

Parameters
existingbrowser window with history to clone.
clonebrowser window to make cloned history for.
Returns
NSERROR_OK or appropriate error otherwise

Definition at line 317 of file browser_history.c.

References browser_window_history__clone_entry(), browser_window_history_create(), browser_window_history_destroy(), browser_window::history, NSERROR_NOMEM, NSERROR_OK, NSLOG, and history::start.

Referenced by browser_window_initialise_common().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser_window_history_create()

nserror browser_window_history_create ( struct browser_window bw)

Create a new history tree for a browser window window.

Parameters
bwbrowser window to create history for.
Returns
NSERROR_OK or appropriate error otherwise

Definition at line 296 of file browser_history.c.

References history::height, browser_window::history, LOCAL_HISTORY_BOTTOM_MARGIN, LOCAL_HISTORY_RIGHT_MARGIN, NSERROR_NOMEM, NSERROR_OK, and history::width.

Referenced by browser_window_history_clone(), and browser_window_initialise_common().

Here is the caller graph for this function:

◆ browser_window_history_destroy()

void browser_window_history_destroy ( struct browser_window bw)

Free a history structure.

Parameters
bwThe browser window to destroy the history within.

Definition at line 502 of file browser_history.c.

References browser_window_history__free_entry(), browser_window::history, and history::start.

Referenced by browser_window_destroy_internal(), and browser_window_history_clone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser_window_history_entry_get_fragment_id()

const char * browser_window_history_entry_get_fragment_id ( const struct history_entry entry)

Returns the URL to a history entry.

Parameters
entrythe history entry to retrieve the fragment id from
Returns
the fragment id

Definition at line 700 of file browser_history.c.

References history_page::frag_id, and history_entry::page.

◆ browser_window_history_entry_get_title()

const char * browser_window_history_entry_get_title ( const struct history_entry entry)

Returns the title of a history entry.

Parameters
entryThe history entry to retrieve the title from
Returns
the title

Definition at line 708 of file browser_history.c.

References history_entry::page, and history_page::title.

◆ browser_window_history_entry_get_url()

nsurl * browser_window_history_entry_get_url ( const struct history_entry entry)

Returns the URL to a history entry.

Parameters
entrythe history entry to retrieve the URL from
Returns
A referenced nsurl URL

Definition at line 693 of file browser_history.c.

References nsurl_ref(), history_entry::page, and history_page::url.

Here is the call graph for this function:

◆ browser_window_history_enumerate()

void browser_window_history_enumerate ( const struct browser_window bw,
browser_window_history_enumerate_cb  cb,
void *  user_data 
)

Enumerate all entries in the history.

Do not change the history while it is being enumerated.

Parameters
bwThe browser window to enumerate history of
cbcallback function
user_datacontext pointer passed to cb

Definition at line 682 of file browser_history.c.

References browser_window_history__enumerate_entry(), browser_window::history, and history::start.

Here is the call graph for this function:

◆ browser_window_history_enumerate_back()

void browser_window_history_enumerate_back ( const struct browser_window bw,
browser_window_history_enumerate_cb  cb,
void *  user_data 
)

Enumerate all entries that will be reached by the 'back' button.

Parameters
bwThe browser window to enumerate history of
cbThe callback function
user_dataData passed to the callback

Definition at line 664 of file browser_history.c.

References history_entry::back, history::current, browser_window::history, LOCAL_HISTORY_HEIGHT, LOCAL_HISTORY_WIDTH, history_entry::x, and history_entry::y.

◆ browser_window_history_enumerate_forward()

void browser_window_history_enumerate_forward ( const struct browser_window bw,
browser_window_history_enumerate_cb  cb,
void *  user_data 
)

Enumerate all entries that will be reached by the 'forward' button.

Parameters
bwThe browser window to enumerate history of
cbThe callback function
user_dataData passed to the callback

Definition at line 645 of file browser_history.c.

References history::current, history_entry::forward_pref, browser_window::history, LOCAL_HISTORY_HEIGHT, LOCAL_HISTORY_WIDTH, history_entry::x, and history_entry::y.

◆ browser_window_history_forward()

nserror browser_window_history_forward ( struct browser_window bw,
bool  new_window 
)

Go forward in the history.

Parameters
bwA browser window to navigate the history in.
new_windowwhether to open in new window.
Returns
NSERROR_OK or error code on faliure.

Definition at line 549 of file browser_history.c.

References browser_window_history_go(), history::current, history_entry::forward_pref, browser_window::history, and NSERROR_BAD_PARAMETER.

Referenced by ami_gui_history(), fb_rightarrow_click(), forward_button_clicked_cb(), nsbeos_scaffolding_dispatch_event(), nsws_window_command(), ro_gui_window_menu_select(), ro_gui_window_toolbar_click(), and toolbar_forward_click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser_window_history_forward_available()

bool browser_window_history_forward_available ( struct browser_window bw)

Check whether it is pssible to go forwards in the history.

Parameters
bwA browser window to check the history navigation in.
Returns
true if the history can go forwards, false otherwise

Definition at line 570 of file browser_history.c.

References history::current, history_entry::forward_pref, and browser_window::history.

Referenced by back_button_clicked_cb(), browser_window_forward_available(), forward_button_clicked_cb(), nsbeos_scaffolding_dispatch_event(), nsbeos_window_update_back_forward(), nsgtk_toolbar_throbber(), nsws_window_command(), nsws_window_update_forward_back(), and scaffolding_update_context().

Here is the caller graph for this function:

◆ browser_window_history_get_scroll()

nserror browser_window_history_get_scroll ( struct browser_window bw,
float *  sx,
float *  sy 
)

Retrieve the stored scroll offsets for the current history entry.

Parameters
bwThe browser window to retrieve scroll offsets for.
sxPointer to a float for the X scroll offset
syPointer to a float for the Y scroll offset
Returns
NSERROR_OK or error code on failure.

Definition at line 482 of file browser_history.c.

References history::current, browser_window::history, NSERROR_INVALID, NSERROR_OK, history_entry::page, history_page::scroll_x, and history_page::scroll_y.

Referenced by browser_window_content_done().

Here is the caller graph for this function:

◆ browser_window_history_get_thumbnail()

nserror browser_window_history_get_thumbnail ( struct browser_window bw,
struct bitmap **  bitmap_out 
)

Get the thumbnail bitmap for the current history entry.

Parameters
bwThe browser window
bitmapThe bitmat for the current history entry.
Returns
NSERROR_OK or error code on faliure.

Definition at line 578 of file browser_history.c.

References history_page::bitmap, bitmap(), content_get_bitmap(), history::current, browser_window::current_content, browser_window::history, NSERROR_INVALID, NSERROR_OK, and history_entry::page.

Referenced by ami_gui_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser_window_history_go()

nserror browser_window_history_go ( struct browser_window bw,
struct history_entry entry,
bool  new_window 
)

Navigate to specified history entry, optionally in new window.

Parameters
bwbrowser window
entryentry to open
new_windowopen entry in new window
Returns
NSERROR_OK or error code on faliure.

Definition at line 599 of file browser_history.c.

References browser_window_create(), browser_window_history_update(), browser_window_navigate(), BW_CREATE_CLONE, BW_NAVIGATE_NO_TERMINAL_HISTORY_UPDATE, history::current, browser_window::current_content, history_page::frag_id, browser_window::history, NSERROR_OK, nsurl_ref(), nsurl_refragment(), nsurl_unref(), history_entry::page, and history_page::url.

Referenced by browser_window_history_back(), browser_window_history_forward(), local_history_keypress(), and local_history_mouse_action().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser_window_history_update()

nserror browser_window_history_update ( struct browser_window bw,
struct hlcache_handle content 
)

Update the thumbnail and scroll offsets for the current entry.

Parameters
bwThe browser window to update the history within.
contentcontent for current entry
Returns
NSERROR_OK or error code on faliure.

Definition at line 427 of file browser_history.c.

References history_page::bitmap, netsurf_table::bitmap, content_get_height(), content_get_title(), content_get_width(), history::current, gui_window_table::get_scroll, guit, browser_window::history, NSERROR_INVALID, NSERROR_NOMEM, NSERROR_OK, NSLOG, history_entry::page, gui_bitmap_table::render, history_page::scroll_x, history_page::scroll_y, history_page::title, history_page::url, browser_window::window, and netsurf_table::window.

Referenced by browser_window_content_done(), browser_window_history_go(), browser_window_navigate(), and frag_scroll().

Here is the call graph for this function:
Here is the caller graph for this function: