NetSurf
|
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"
Go to the source code of this file.
Functions | |
static struct history_entry * | browser_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... | |
nsurl * | browser_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... | |
Browser history tree implementation.
Definition in file browser_history.c.
|
static |
Clone a history entry.
history | opaque history structure, as returned by history_create() |
entry | entry to clone |
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().
|
static |
Enumerate subentries in history See also history_enumerate()
bw | The browser window to enumerate history of |
entry | entry to start enumeration at |
cb | callback function |
ud | context pointer passed to cb |
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().
|
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().
|
static |
Compute node positions.
history | history 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().
|
static |
Recursively position a subtree.
history | history being laid out |
entry | subtree to position |
x | x position for entry |
y | smallest available y |
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().
nserror browser_window_history_add | ( | struct browser_window * | bw, |
struct hlcache_handle * | content, | ||
lwc_string * | frag_id | ||
) |
Insert a url into the history tree.
bw | browser window with history object |
content | content to add to history |
frag_id | fragment identifier, or NULL. |
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().
nserror browser_window_history_back | ( | struct browser_window * | bw, |
bool | new_window | ||
) |
Go back in the history.
bw | A browser window to navigate the history in. |
new_window | whether to open in new window. |
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().
bool browser_window_history_back_available | ( | struct browser_window * | bw | ) |
Check whether it is pssible to go back in the history.
bw | A browser window to check the history navigation in. |
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().
nserror browser_window_history_clone | ( | const struct browser_window * | existing, |
struct browser_window * | clone | ||
) |
Clone a bw's history tree for new bw.
existing | browser window with history to clone. |
clone | browser window to make cloned history for. |
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().
nserror browser_window_history_create | ( | struct browser_window * | bw | ) |
Create a new history tree for a browser window window.
bw | browser window to create history for. |
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().
void browser_window_history_destroy | ( | struct browser_window * | bw | ) |
Free a history structure.
bw | The 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().
const char * browser_window_history_entry_get_fragment_id | ( | const struct history_entry * | entry | ) |
Returns the URL to a history entry.
entry | the history entry to retrieve the fragment id from |
Definition at line 700 of file browser_history.c.
References history_page::frag_id, and history_entry::page.
const char * browser_window_history_entry_get_title | ( | const struct history_entry * | entry | ) |
Returns the title of a history entry.
entry | The history entry to retrieve the title from |
Definition at line 708 of file browser_history.c.
References history_entry::page, and history_page::title.
nsurl * browser_window_history_entry_get_url | ( | const struct history_entry * | entry | ) |
Returns the URL to a history entry.
entry | the history entry to retrieve the URL from |
Definition at line 693 of file browser_history.c.
References nsurl_ref(), history_entry::page, and history_page::url.
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.
bw | The browser window to enumerate history of |
cb | callback function |
user_data | context 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.
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.
bw | The browser window to enumerate history of |
cb | The callback function |
user_data | Data 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.
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.
bw | The browser window to enumerate history of |
cb | The callback function |
user_data | Data 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.
nserror browser_window_history_forward | ( | struct browser_window * | bw, |
bool | new_window | ||
) |
Go forward in the history.
bw | A browser window to navigate the history in. |
new_window | whether to open in new window. |
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().
bool browser_window_history_forward_available | ( | struct browser_window * | bw | ) |
Check whether it is pssible to go forwards in the history.
bw | A browser window to check the history navigation in. |
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().
nserror browser_window_history_get_scroll | ( | struct browser_window * | bw, |
float * | sx, | ||
float * | sy | ||
) |
Retrieve the stored scroll offsets for the current history entry.
bw | The browser window to retrieve scroll offsets for. |
sx | Pointer to a float for the X scroll offset |
sy | Pointer to a float for the Y scroll offset |
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().
nserror browser_window_history_get_thumbnail | ( | struct browser_window * | bw, |
struct bitmap ** | bitmap_out | ||
) |
Get the thumbnail bitmap for the current history entry.
bw | The browser window |
bitmap | The bitmat for the current history entry. |
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().
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.
bw | browser window |
entry | entry to open |
new_window | open entry in new window |
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().
nserror browser_window_history_update | ( | struct browser_window * | bw, |
struct hlcache_handle * | content | ||
) |
Update the thumbnail and scroll offsets for the current entry.
bw | The browser window to update the history within. |
content | content for current entry |
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().