netsurf: branch master updated. release/3.0-309-g8d3a89b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/8d3a89b62db7ee14df788...
...commit http://git.netsurf-browser.org/netsurf.git/commit/8d3a89b62db7ee14df788f1...
...tree http://git.netsurf-browser.org/netsurf.git/tree/8d3a89b62db7ee14df788f1ea...
The branch, master has been updated
via 8d3a89b62db7ee14df788f1ea06a8beb1b283471 (commit)
from 3a0bda977136f0764d5da15c1d727b6de63fa6c5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=8d3a89b62db7ee14df7...
commit 8d3a89b62db7ee14df788f1ea06a8beb1b283471
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Don't attempt to vertical-align objects for now, as our current bodged vertical-align implementation can do more harm than good.
diff --git a/render/layout.c b/render/layout.c
index fd518d9..14d06ee 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -2911,8 +2911,7 @@ bool layout_line(struct box *first, int *width, int *y,
if ((d->type == BOX_INLINE && d->inline_end) ||
d->type == BOX_BR ||
d->type == BOX_TEXT ||
- d->type == BOX_INLINE_END ||
- d->object != NULL) {
+ d->type == BOX_INLINE_END) {
css_fixed value = 0;
css_unit unit = CSS_UNIT_PX;
switch (css_computed_vertical_align(d->style, &value,
-----------------------------------------------------------------------
Summary of changes:
render/layout.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/render/layout.c b/render/layout.c
index fd518d9..14d06ee 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -2911,8 +2911,7 @@ bool layout_line(struct box *first, int *width, int *y,
if ((d->type == BOX_INLINE && d->inline_end) ||
d->type == BOX_BR ||
d->type == BOX_TEXT ||
- d->type == BOX_INLINE_END ||
- d->object != NULL) {
+ d->type == BOX_INLINE_END) {
css_fixed value = 0;
css_unit unit = CSS_UNIT_PX;
switch (css_computed_vertical_align(d->style, &value,
--
NetSurf Browser
9 years, 10 months
netsurf: branch master updated. release/3.0-308-g3a0bda9
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/3a0bda977136f0764d5da...
...commit http://git.netsurf-browser.org/netsurf.git/commit/3a0bda977136f0764d5da15...
...tree http://git.netsurf-browser.org/netsurf.git/tree/3a0bda977136f0764d5da15c1...
The branch, master has been updated
via 3a0bda977136f0764d5da15c1d727b6de63fa6c5 (commit)
from 90231bd4b1b7b6fdb0650b4015d94db12e99d7ad (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=3a0bda977136f0764d5...
commit 3a0bda977136f0764d5da15c1d727b6de63fa6c5
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Move local history over to nsurl.
diff --git a/desktop/browser.c b/desktop/browser.c
index 4df48e4..aa7da1f 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -941,9 +941,7 @@ nserror browser_window_navigate(struct browser_window *bw,
if ((flags & BROWSER_WINDOW_HISTORY) != 0) {
history_add(bw->history,
- bw->current_content,
- bw->frag_id == NULL ? NULL :
- lwc_string_data(bw->frag_id));
+ bw->current_content, bw->frag_id);
}
browser_window_update(bw, false);
@@ -1285,8 +1283,7 @@ nserror browser_window_callback(hlcache_handle *c,
if (bw->history_add && bw->history) {
nsurl *url = hlcache_handle_get_url(c);
- history_add(bw->history, c, bw->frag_id == NULL ? NULL :
- lwc_string_data(bw->frag_id));
+ history_add(bw->history, c, bw->frag_id);
if (urldb_add_url(url)) {
urldb_set_url_title(url, content_get_title(c));
urldb_update_url_visit_data(url);
diff --git a/desktop/local_history.c b/desktop/local_history.c
index 7b5ecc7..d4f9519 100644
--- a/desktop/local_history.c
+++ b/desktop/local_history.c
@@ -38,7 +38,7 @@
#include "image/bitmap.h"
#include "render/font.h"
#include "utils/log.h"
-#include "utils/url.h"
+#include "utils/nsurl.h"
#include "utils/utils.h"
@@ -48,8 +48,8 @@
#define BOTTOM_MARGIN 30
struct history_page {
- char *url; /**< Page URL, never 0. */
- char *frag_id; /** Fragment identifier, or 0. */
+ nsurl *url; /**< Page URL, never 0. */
+ lwc_string *frag_id; /** Fragment identifier, or 0. */
char *title; /**< Page title, never 0. */
};
@@ -175,15 +175,16 @@ struct history_entry *history_clone_entry(struct history *history,
if (!new_entry)
return 0;
memcpy(new_entry, entry, sizeof *entry);
- new_entry->page.url = strdup(entry->page.url);
+ new_entry->page.url = nsurl_ref(entry->page.url);
if (entry->page.frag_id)
- new_entry->page.frag_id = strdup(entry->page.frag_id);
+ new_entry->page.frag_id = lwc_string_ref(entry->page.frag_id);
new_entry->page.title = strdup(entry->page.title);
if (!new_entry->page.url || !new_entry->page.title ||
((entry->page.frag_id) && (!new_entry->page.frag_id))) {
- free(new_entry->page.url);
+ nsurl_unref(new_entry->page.url);
+ if (new_entry->page.frag_id)
+ lwc_string_unref(new_entry->page.frag_id);
free(new_entry->page.title);
- free(new_entry->page.frag_id);
free(new_entry);
return 0;
}
@@ -218,21 +219,18 @@ struct history_entry *history_clone_entry(struct history *history,
*
* \param history opaque history structure, as returned by history_create()
* \param content content to add to history
- * \param frag_id fragment identifier
+ * \param frag_id fragment identifier, or NULL.
*
* The page is added after the current entry and becomes current.
*/
void history_add(struct history *history, hlcache_handle *content,
- const char *frag_id)
+ lwc_string *frag_id)
{
struct history_entry *entry;
nsurl *nsurl = hlcache_handle_get_url(content);
- char *url;
char *title;
struct bitmap *bitmap;
- nserror error;
- size_t url_len;
assert(history);
assert(content);
@@ -242,24 +240,16 @@ void history_add(struct history *history, hlcache_handle *content,
if (entry == NULL)
return;
- /* TODO: use a nsurl? */
- error = nsurl_get(nsurl, NSURL_WITH_FRAGMENT, &url, &url_len);
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- free(entry);
- return;
- }
-
title = strdup(content_get_title(content));
if (title == NULL) {
warn_user("NoMemory", 0);
- free(url);
free(entry);
return;
}
- entry->page.url = url;
- entry->page.frag_id = frag_id ? strdup(frag_id) : 0;
+ entry->page.url = nsurl_ref(nsurl);
+ entry->page.frag_id = frag_id ? lwc_string_ref(frag_id) : 0;
+
entry->page.title = title;
entry->back = history->current;
entry->next = 0;
@@ -358,9 +348,9 @@ void history_free_entry(struct history_entry *entry)
return;
history_free_entry(entry->forward);
history_free_entry(entry->next);
- free(entry->page.url);
+ nsurl_unref(entry->page.url);
if (entry->page.frag_id)
- free(entry->page.frag_id);
+ lwc_string_unref(entry->page.frag_id);
free(entry->page.title);
free(entry);
}
@@ -428,7 +418,6 @@ void history_go(struct browser_window *bw,
struct history_entry *entry,
bool new_window)
{
- char *full_url;
nsurl *url;
struct history_entry *current;
nserror error;
@@ -438,24 +427,15 @@ void history_go(struct browser_window *bw,
// entry->page.url, entry->page.title, entry->page.frag_id));
if (entry->page.frag_id) {
- full_url = malloc(strlen(entry->page.url) +
- strlen(entry->page.frag_id) + 5);
- if (full_url == NULL) {
+ error = nsurl_refragment(entry->page.url,
+ entry->page.frag_id, &url);
+
+ if (error != NSERROR_OK) {
warn_user("NoMemory", 0);
return;
}
- sprintf(full_url, "%s#%s", entry->page.url, entry->page.frag_id);
-
- error = nsurl_create(full_url, &url);
- free(full_url);
} else {
- error = nsurl_create(entry->page.url, &url);
- }
-
-
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return;
+ url = nsurl_ref(entry->page.url);
}
if (new_window) {
@@ -747,7 +727,7 @@ const char *history_position_url(struct history *history, int x, int y)
if (!entry)
return 0;
- return entry->page.url;
+ return nsurl_access(entry->page.url);
}
@@ -848,13 +828,13 @@ static bool history_enumerate_entry(const struct history *history,
/* Documented in local_history.h */
const char *history_entry_get_url(const struct history_entry *entry)
{
- return entry->page.url;
+ return nsurl_access(entry->page.url);
}
/* Documented in local_history.h */
const char *history_entry_get_fragment_id(const struct history_entry *entry)
{
- return entry->page.frag_id;
+ return (entry->page.frag_id) ? lwc_string_data(entry->page.frag_id) : 0;
}
/* Documented in local_history.h */
diff --git a/desktop/local_history.h b/desktop/local_history.h
index 76f39a7..c4faa85 100644
--- a/desktop/local_history.h
+++ b/desktop/local_history.h
@@ -24,6 +24,7 @@
#define _NETSURF_DESKTOP_HISTORY_H_
#include <stdbool.h>
+#include <libwapcaplet/libwapcaplet.h>
struct hlcache_handle;
struct history;
@@ -34,7 +35,7 @@ struct redraw_context;
struct history *history_create(void);
struct history *history_clone(struct history *history);
void history_add(struct history *history, struct hlcache_handle *content,
- const char *frag_id);
+ 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);
-----------------------------------------------------------------------
Summary of changes:
desktop/browser.c | 7 +---
desktop/local_history.c | 66 ++++++++++++++++------------------------------
desktop/local_history.h | 3 +-
3 files changed, 27 insertions(+), 49 deletions(-)
diff --git a/desktop/browser.c b/desktop/browser.c
index 4df48e4..aa7da1f 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -941,9 +941,7 @@ nserror browser_window_navigate(struct browser_window *bw,
if ((flags & BROWSER_WINDOW_HISTORY) != 0) {
history_add(bw->history,
- bw->current_content,
- bw->frag_id == NULL ? NULL :
- lwc_string_data(bw->frag_id));
+ bw->current_content, bw->frag_id);
}
browser_window_update(bw, false);
@@ -1285,8 +1283,7 @@ nserror browser_window_callback(hlcache_handle *c,
if (bw->history_add && bw->history) {
nsurl *url = hlcache_handle_get_url(c);
- history_add(bw->history, c, bw->frag_id == NULL ? NULL :
- lwc_string_data(bw->frag_id));
+ history_add(bw->history, c, bw->frag_id);
if (urldb_add_url(url)) {
urldb_set_url_title(url, content_get_title(c));
urldb_update_url_visit_data(url);
diff --git a/desktop/local_history.c b/desktop/local_history.c
index 7b5ecc7..d4f9519 100644
--- a/desktop/local_history.c
+++ b/desktop/local_history.c
@@ -38,7 +38,7 @@
#include "image/bitmap.h"
#include "render/font.h"
#include "utils/log.h"
-#include "utils/url.h"
+#include "utils/nsurl.h"
#include "utils/utils.h"
@@ -48,8 +48,8 @@
#define BOTTOM_MARGIN 30
struct history_page {
- char *url; /**< Page URL, never 0. */
- char *frag_id; /** Fragment identifier, or 0. */
+ nsurl *url; /**< Page URL, never 0. */
+ lwc_string *frag_id; /** Fragment identifier, or 0. */
char *title; /**< Page title, never 0. */
};
@@ -175,15 +175,16 @@ struct history_entry *history_clone_entry(struct history *history,
if (!new_entry)
return 0;
memcpy(new_entry, entry, sizeof *entry);
- new_entry->page.url = strdup(entry->page.url);
+ new_entry->page.url = nsurl_ref(entry->page.url);
if (entry->page.frag_id)
- new_entry->page.frag_id = strdup(entry->page.frag_id);
+ new_entry->page.frag_id = lwc_string_ref(entry->page.frag_id);
new_entry->page.title = strdup(entry->page.title);
if (!new_entry->page.url || !new_entry->page.title ||
((entry->page.frag_id) && (!new_entry->page.frag_id))) {
- free(new_entry->page.url);
+ nsurl_unref(new_entry->page.url);
+ if (new_entry->page.frag_id)
+ lwc_string_unref(new_entry->page.frag_id);
free(new_entry->page.title);
- free(new_entry->page.frag_id);
free(new_entry);
return 0;
}
@@ -218,21 +219,18 @@ struct history_entry *history_clone_entry(struct history *history,
*
* \param history opaque history structure, as returned by history_create()
* \param content content to add to history
- * \param frag_id fragment identifier
+ * \param frag_id fragment identifier, or NULL.
*
* The page is added after the current entry and becomes current.
*/
void history_add(struct history *history, hlcache_handle *content,
- const char *frag_id)
+ lwc_string *frag_id)
{
struct history_entry *entry;
nsurl *nsurl = hlcache_handle_get_url(content);
- char *url;
char *title;
struct bitmap *bitmap;
- nserror error;
- size_t url_len;
assert(history);
assert(content);
@@ -242,24 +240,16 @@ void history_add(struct history *history, hlcache_handle *content,
if (entry == NULL)
return;
- /* TODO: use a nsurl? */
- error = nsurl_get(nsurl, NSURL_WITH_FRAGMENT, &url, &url_len);
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- free(entry);
- return;
- }
-
title = strdup(content_get_title(content));
if (title == NULL) {
warn_user("NoMemory", 0);
- free(url);
free(entry);
return;
}
- entry->page.url = url;
- entry->page.frag_id = frag_id ? strdup(frag_id) : 0;
+ entry->page.url = nsurl_ref(nsurl);
+ entry->page.frag_id = frag_id ? lwc_string_ref(frag_id) : 0;
+
entry->page.title = title;
entry->back = history->current;
entry->next = 0;
@@ -358,9 +348,9 @@ void history_free_entry(struct history_entry *entry)
return;
history_free_entry(entry->forward);
history_free_entry(entry->next);
- free(entry->page.url);
+ nsurl_unref(entry->page.url);
if (entry->page.frag_id)
- free(entry->page.frag_id);
+ lwc_string_unref(entry->page.frag_id);
free(entry->page.title);
free(entry);
}
@@ -428,7 +418,6 @@ void history_go(struct browser_window *bw,
struct history_entry *entry,
bool new_window)
{
- char *full_url;
nsurl *url;
struct history_entry *current;
nserror error;
@@ -438,24 +427,15 @@ void history_go(struct browser_window *bw,
// entry->page.url, entry->page.title, entry->page.frag_id));
if (entry->page.frag_id) {
- full_url = malloc(strlen(entry->page.url) +
- strlen(entry->page.frag_id) + 5);
- if (full_url == NULL) {
+ error = nsurl_refragment(entry->page.url,
+ entry->page.frag_id, &url);
+
+ if (error != NSERROR_OK) {
warn_user("NoMemory", 0);
return;
}
- sprintf(full_url, "%s#%s", entry->page.url, entry->page.frag_id);
-
- error = nsurl_create(full_url, &url);
- free(full_url);
} else {
- error = nsurl_create(entry->page.url, &url);
- }
-
-
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return;
+ url = nsurl_ref(entry->page.url);
}
if (new_window) {
@@ -747,7 +727,7 @@ const char *history_position_url(struct history *history, int x, int y)
if (!entry)
return 0;
- return entry->page.url;
+ return nsurl_access(entry->page.url);
}
@@ -848,13 +828,13 @@ static bool history_enumerate_entry(const struct history *history,
/* Documented in local_history.h */
const char *history_entry_get_url(const struct history_entry *entry)
{
- return entry->page.url;
+ return nsurl_access(entry->page.url);
}
/* Documented in local_history.h */
const char *history_entry_get_fragment_id(const struct history_entry *entry)
{
- return entry->page.frag_id;
+ return (entry->page.frag_id) ? lwc_string_data(entry->page.frag_id) : 0;
}
/* Documented in local_history.h */
diff --git a/desktop/local_history.h b/desktop/local_history.h
index 76f39a7..c4faa85 100644
--- a/desktop/local_history.h
+++ b/desktop/local_history.h
@@ -24,6 +24,7 @@
#define _NETSURF_DESKTOP_HISTORY_H_
#include <stdbool.h>
+#include <libwapcaplet/libwapcaplet.h>
struct hlcache_handle;
struct history;
@@ -34,7 +35,7 @@ struct redraw_context;
struct history *history_create(void);
struct history *history_clone(struct history *history);
void history_add(struct history *history, struct hlcache_handle *content,
- const char *frag_id);
+ 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);
--
NetSurf Browser
9 years, 10 months
netsurf: branch master updated. release/3.0-307-g90231bd
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/90231bd4b1b7b6fdb0650...
...commit http://git.netsurf-browser.org/netsurf.git/commit/90231bd4b1b7b6fdb0650b4...
...tree http://git.netsurf-browser.org/netsurf.git/tree/90231bd4b1b7b6fdb0650b401...
The branch, master has been updated
via 90231bd4b1b7b6fdb0650b4015d94db12e99d7ad (commit)
from 3f45e535397b45a60c696aa68565aca4d76b1f2e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=90231bd4b1b7b6fdb06...
commit 90231bd4b1b7b6fdb0650b4015d94db12e99d7ad
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Force root element box type to BOX_BLOCK.
diff --git a/render/box_construct.c b/render/box_construct.c
index 03e87e8..37a8702 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -944,6 +944,10 @@ bool box_construct_element(struct box_construct_ctx *ctx,
* inline container as if they were not absolutely positioned.
* Layout expects and handles this. */
box->type = box_map[CSS_DISPLAY_INLINE_BLOCK];
+ } else if (props.node_is_root) {
+ /* Special case for root element: force it to BLOCK, or the
+ * rest of the layout will break. */
+ box->type = BOX_BLOCK;
} else {
/* Normal mapping */
box->type = box_map[css_computed_display(box->style,
@@ -972,8 +976,9 @@ bool box_construct_element(struct box_construct_ctx *ctx,
return false;
}
- if (box->type == BOX_NONE || css_computed_display(box->style,
- props.node_is_root) == CSS_DISPLAY_NONE) {
+ if (box->type == BOX_NONE || (css_computed_display(box->style,
+ props.node_is_root) == CSS_DISPLAY_NONE &&
+ props.node_is_root == false)) {
css_select_results_destroy(styles);
box->styles = NULL;
box->style = NULL;
-----------------------------------------------------------------------
Summary of changes:
render/box_construct.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/render/box_construct.c b/render/box_construct.c
index 03e87e8..37a8702 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -944,6 +944,10 @@ bool box_construct_element(struct box_construct_ctx *ctx,
* inline container as if they were not absolutely positioned.
* Layout expects and handles this. */
box->type = box_map[CSS_DISPLAY_INLINE_BLOCK];
+ } else if (props.node_is_root) {
+ /* Special case for root element: force it to BLOCK, or the
+ * rest of the layout will break. */
+ box->type = BOX_BLOCK;
} else {
/* Normal mapping */
box->type = box_map[css_computed_display(box->style,
@@ -972,8 +976,9 @@ bool box_construct_element(struct box_construct_ctx *ctx,
return false;
}
- if (box->type == BOX_NONE || css_computed_display(box->style,
- props.node_is_root) == CSS_DISPLAY_NONE) {
+ if (box->type == BOX_NONE || (css_computed_display(box->style,
+ props.node_is_root) == CSS_DISPLAY_NONE &&
+ props.node_is_root == false)) {
css_select_results_destroy(styles);
box->styles = NULL;
box->style = NULL;
--
NetSurf Browser
9 years, 10 months
netsurf: branch master updated. release/3.0-306-g3f45e53
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/3f45e535397b45a60c696...
...commit http://git.netsurf-browser.org/netsurf.git/commit/3f45e535397b45a60c696aa...
...tree http://git.netsurf-browser.org/netsurf.git/tree/3f45e535397b45a60c696aa68...
The branch, master has been updated
via 3f45e535397b45a60c696aa68565aca4d76b1f2e (commit)
from ed557f090a60a1c96dae9bc3319990d589bc60ec (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=3f45e535397b45a60c6...
commit 3f45e535397b45a60c696aa68565aca4d76b1f2e
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
s/history_core/local_history/
diff --git a/amiga/context_menu.c b/amiga/context_menu.c
index 839b603..be52865 100644
--- a/amiga/context_menu.c
+++ b/amiga/context_menu.c
@@ -40,7 +40,7 @@
#include "amiga/tree.h"
#include "amiga/utf8.h"
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/hotlist.h"
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
diff --git a/amiga/gui.c b/amiga/gui.c
index a5cac9d..bbc4268 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -20,7 +20,7 @@
#include "content/urldb.h"
#include "css/utils.h"
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/mouse.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
diff --git a/amiga/history_local.c b/amiga/history_local.c
index 3c8b6e1..5203276 100755
--- a/amiga/history_local.c
+++ b/amiga/history_local.c
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "amiga/os3support.h"
#include "amiga/object.h"
diff --git a/atari/download.c b/atari/download.c
index 407be06..e4a45e8 100755
--- a/atari/download.c
+++ b/atari/download.c
@@ -28,7 +28,7 @@
#include "content/urldb.h"
#include "content/fetch.h"
#include "desktop/gui.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
#include "desktop/save_complete.h"
diff --git a/atari/gui.c b/atari/gui.c
index 5b0df84..df205aa 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -35,7 +35,7 @@
#include "content/fetchers/resource.h"
#include "css/utils.h"
#include "desktop/gui.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "desktop/netsurf.h"
#include "desktop/401login.h"
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 28e3271..2344219 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -38,7 +38,7 @@
#include "utils/log.h"
#include "desktop/gui.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "desktop/browser.h"
#include "desktop/browser_private.h"
diff --git a/atari/statusbar.c b/atari/statusbar.c
index 9f26d7b..3bf186c 100755
--- a/atari/statusbar.c
+++ b/atari/statusbar.c
@@ -29,7 +29,7 @@
#include "utils/log.h"
#include "desktop/gui.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "desktop/browser.h"
#include "desktop/mouse.h"
diff --git a/atari/toolbar.c b/atari/toolbar.c
index 79be31b..e190c96 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -29,7 +29,7 @@
#include "utils/log.h"
#include "desktop/gui.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "desktop/browser.h"
#include "desktop/browser_private.h"
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index fe40b0c..7834db4 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -52,7 +52,7 @@
extern "C" {
#include "content/content.h"
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/gui.h"
#include "desktop/netsurf.h"
#include "desktop/plotters.h"
diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m
index c472fd7..ca5808c 100644
--- a/cocoa/BrowserView.m
+++ b/cocoa/BrowserView.m
@@ -24,7 +24,7 @@
#import "cocoa/BrowserWindowController.h"
#import "desktop/browser_private.h"
-#import "desktop/history_core.h"
+#import "desktop/local_history.h"
#import "desktop/plotters.h"
#import "desktop/textinput.h"
#import "utils/nsoption.h"
diff --git a/cocoa/BrowserViewController.m b/cocoa/BrowserViewController.m
index 4952f52..77ee57b 100644
--- a/cocoa/BrowserViewController.m
+++ b/cocoa/BrowserViewController.m
@@ -21,7 +21,7 @@
#import "cocoa/BrowserWindowController.h"
#import "desktop/browser_private.h"
-#import "desktop/history_core.h"
+#import "desktop/local_history.h"
#import "desktop/textinput.h"
#import "utils/nsoption.h"
diff --git a/cocoa/HistoryView.m b/cocoa/HistoryView.m
index 31a8e24..45f7fac 100644
--- a/cocoa/HistoryView.m
+++ b/cocoa/HistoryView.m
@@ -24,7 +24,7 @@
#import "cocoa/BrowserView.h"
#import "desktop/browser_private.h"
-#import "desktop/history_core.h"
+#import "desktop/local_history.h"
#import "desktop/plotters.h"
@implementation HistoryView
diff --git a/cocoa/NetSurf.xcodeproj/project.pbxproj b/cocoa/NetSurf.xcodeproj/project.pbxproj
index eacc80a..ca0bed6 100644
--- a/cocoa/NetSurf.xcodeproj/project.pbxproj
+++ b/cocoa/NetSurf.xcodeproj/project.pbxproj
@@ -47,8 +47,8 @@
260F1F8B12D620E800D9B07F /* frames.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = frames.c; sourceTree = "<group>"; };
260F1F8C12D620E800D9B07F /* frames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = frames.h; sourceTree = "<group>"; };
260F1F8D12D620E800D9B07F /* gui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gui.h; sourceTree = "<group>"; };
- 260F1F8E12D620E800D9B07F /* history_core.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = history_core.c; sourceTree = "<group>"; };
- 260F1F8F12D620E800D9B07F /* history_core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = history_core.h; sourceTree = "<group>"; };
+ 260F1F8E12D620E800D9B07F /* local_history.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = local_history.c; sourceTree = "<group>"; };
+ 260F1F8F12D620E800D9B07F /* local_history.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = local_history.h; sourceTree = "<group>"; };
260F1F9012D620E800D9B07F /* history_global_core.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = history_global_core.c; sourceTree = "<group>"; };
260F1F9112D620E800D9B07F /* history_global_core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = history_global_core.h; sourceTree = "<group>"; };
260F1F9212D620E800D9B07F /* hotlist.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hotlist.c; sourceTree = "<group>"; };
@@ -404,8 +404,8 @@
260F1F8B12D620E800D9B07F /* frames.c */,
260F1F8C12D620E800D9B07F /* frames.h */,
260F1F8D12D620E800D9B07F /* gui.h */,
- 260F1F8E12D620E800D9B07F /* history_core.c */,
- 260F1F8F12D620E800D9B07F /* history_core.h */,
+ 260F1F8E12D620E800D9B07F /* local_history.c */,
+ 260F1F8F12D620E800D9B07F /* local_history.h */,
260F1F9012D620E800D9B07F /* history_global_core.c */,
260F1F9112D620E800D9B07F /* history_global_core.h */,
260F1F9212D620E800D9B07F /* hotlist.c */,
diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m
index 333cbe2..33e3bfa 100644
--- a/cocoa/NetsurfApp.m
+++ b/cocoa/NetsurfApp.m
@@ -26,7 +26,7 @@
#import "content/fetch.h"
#import "css/utils.h"
#import "desktop/gui.h"
-#import "desktop/history_core.h"
+#import "desktop/local_history.h"
#import "desktop/mouse.h"
#import "desktop/netsurf.h"
#import "utils/nsoption.h"
diff --git a/desktop/Makefile b/desktop/Makefile
index f787fd2..ded75aa 100644
--- a/desktop/Makefile
+++ b/desktop/Makefile
@@ -12,7 +12,7 @@ desktop/version.c: testament utils/testament.h
# S_BROWSER are sources related to full browsers but are common
# between RISC OS, GTK, BeOS and AmigaOS builds
-S_BROWSER := browser.c download.c frames.c history_core.c netsurf.c \
+S_BROWSER := browser.c download.c frames.c local_history.c netsurf.c \
save_complete.c save_text.c selection.c textinput.c
S_BROWSER := $(addprefix desktop/,$(S_BROWSER))
diff --git a/desktop/browser.c b/desktop/browser.c
index b7ec989..4df48e4 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -45,7 +45,7 @@
#include "desktop/browser_private.h"
#include "desktop/download.h"
#include "desktop/frames.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/hotlist.h"
#include "desktop/gui.h"
#include "desktop/knockout.h"
diff --git a/desktop/frames.c b/desktop/frames.c
index dcc66df..3f7613f 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -32,7 +32,7 @@
#include "content/hlcache.h"
#include "desktop/browser_private.h"
#include "desktop/frames.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/gui.h"
#include "desktop/scrollbar.h"
#include "desktop/selection.h"
diff --git a/desktop/history_core.c b/desktop/history_core.c
deleted file mode 100644
index bc933c0..0000000
--- a/desktop/history_core.c
+++ /dev/null
@@ -1,864 +0,0 @@
-/*
- * Copyright 2006 James Bursa <bursa(a)users.sourceforge.net>
- * Copyright 2005 Richard Wilson <info(a)tinct.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Browser history tree (implementation).
- */
-
-#include <assert.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include "content/content.h"
-#include "content/hlcache.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"
-#include "desktop/thumbnail.h"
-#include "image/bitmap.h"
-#include "render/font.h"
-#include "utils/log.h"
-#include "utils/url.h"
-#include "utils/utils.h"
-
-
-#define WIDTH 100
-#define HEIGHT 86
-#define RIGHT_MARGIN 50
-#define BOTTOM_MARGIN 30
-
-struct history_page {
- char *url; /**< Page URL, never 0. */
- char *frag_id; /** Fragment identifier, or 0. */
- char *title; /**< Page title, never 0. */
-};
-
-/** A node in the history tree. */
-struct history_entry {
- struct history_page page;
- struct history_entry *back; /**< Parent. */
- struct history_entry *next; /**< Next sibling. */
- struct history_entry *forward; /**< First child. */
- struct history_entry *forward_pref; /**< Child in direction of
- current entry. */
- struct history_entry *forward_last; /**< Last child. */
- unsigned int children; /**< Number of children. */
- int x; /**< Position of node. */
- int y; /**< Position of node. */
- struct bitmap *bitmap; /**< Thumbnail bitmap, or 0. */
-};
-
-/** History tree for a window. */
-struct history {
- /** First page in tree (page that window opened with). */
- struct history_entry *start;
- /** Current position in tree. */
- struct history_entry *current;
- /** Width of layout. */
- int width;
- /** Height of layout. */
- int height;
-};
-
-static struct history_entry *history_clone_entry(struct history *history,
- struct history_entry *entry);
-static void history_free_entry(struct history_entry *entry);
-static void history_layout(struct history *history);
-static int history_layout_subtree(struct history *history,
- struct history_entry *entry, int x, int y, bool shuffle);
-static bool history_redraw_entry(struct history *history,
- struct history_entry *entry,
- int x0, int y0, int x1, int y1,
- int x, int y, bool clip, const struct redraw_context *ctx);
-static struct history_entry *history_find_position(struct history_entry *entry,
- int x, int y);
-static bool history_enumerate_entry(const struct history *history,
- const struct history_entry *entry, history_enumerate_cb cb, void *ud);
-
-
-/**
- * Create a new history tree for a window.
- *
- * \return pointer to an opaque history structure, 0 on failure.
- */
-
-struct history *history_create(void)
-{
- struct history *history;
-
- history = calloc(1, sizeof *history);
- if (!history) {
- warn_user("NoMemory", 0);
- return 0;
- }
- history->width = RIGHT_MARGIN / 2;
- history->height = BOTTOM_MARGIN / 2;
- return history;
-}
-
-
-/**
- * Clone a history tree
- *
- * \param history opaque history structure, as returned by history_create()
- *
- * \return pointer to an opaque history structure, 0 on failure.
- */
-
-struct history *history_clone(struct history *history)
-{
- struct history *new_history;
-
- if (!history->start)
- return history_create();
-
- new_history = malloc(sizeof *history);
- if (!new_history)
- return 0;
- memcpy(new_history, history, sizeof *history);
-
- new_history->start = history_clone_entry(new_history,
- new_history->start);
- if (!history->start) {
- LOG(("Insufficient memory to clone history"));
- warn_user("NoMemory", 0);
- history_destroy(new_history);
- return 0;
- }
-
- return new_history;
-}
-
-
-/**
- * Clone a history entry
- *
- * \param history opaque history structure, as returned by history_create()
- * \param start entry to clone
- *
- * \return a cloned history entry, or 0 on error
- */
-
-struct history_entry *history_clone_entry(struct history *history,
- struct history_entry *entry)
-{
- struct history_entry *child;
- struct history_entry *new_child;
- struct history_entry *prev = NULL;
- struct history_entry *new_entry;
-
- assert(entry->page.url);
- assert(entry->page.title);
-
- /* clone the entry */
- new_entry = malloc(sizeof *entry);
- if (!new_entry)
- return 0;
- memcpy(new_entry, entry, sizeof *entry);
- new_entry->page.url = strdup(entry->page.url);
- if (entry->page.frag_id)
- new_entry->page.frag_id = strdup(entry->page.frag_id);
- new_entry->page.title = strdup(entry->page.title);
- if (!new_entry->page.url || !new_entry->page.title ||
- ((entry->page.frag_id) && (!new_entry->page.frag_id))) {
- free(new_entry->page.url);
- free(new_entry->page.title);
- free(new_entry->page.frag_id);
- free(new_entry);
- return 0;
- }
-
- /* update references */
- if (history->current == entry)
- history->current = new_entry;
-
- /* recurse for all children */
- for (child = new_entry->forward; child; child = child->next) {
- new_child = history_clone_entry(history, child);
- if (new_child)
- new_child->back = new_entry;
- if (prev)
- prev->next = new_child;
- if (new_entry->forward == child)
- new_entry->forward = new_child;
- if (new_entry->forward_pref == child)
- new_entry->forward_pref = new_child;
- if (new_entry->forward_last == child)
- new_entry->forward_last = new_child;
- if (!new_child)
- return 0;
- prev = new_child;
- }
- return new_entry;
-}
-
-
-/**
- * Insert a url into the history tree.
- *
- * \param history opaque history structure, as returned by history_create()
- * \param content content to add to history
- * \param frag_id fragment identifier
- *
- * The page is added after the current entry and becomes current.
- */
-
-void history_add(struct history *history, hlcache_handle *content,
- const char *frag_id)
-{
- struct history_entry *entry;
- nsurl *nsurl = hlcache_handle_get_url(content);
- char *url;
- char *title;
- struct bitmap *bitmap;
- nserror error;
- size_t url_len;
-
- assert(history);
- assert(content);
-
- /* allocate space */
- entry = malloc(sizeof *entry);
- if (entry == NULL)
- return;
-
- /* TODO: use a nsurl? */
- error = nsurl_get(nsurl, NSURL_WITH_FRAGMENT, &url, &url_len);
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- free(entry);
- return;
- }
-
- title = strdup(content_get_title(content));
- if (title == NULL) {
- warn_user("NoMemory", 0);
- free(url);
- free(entry);
- return;
- }
-
- entry->page.url = url;
- entry->page.frag_id = frag_id ? strdup(frag_id) : 0;
- entry->page.title = title;
- entry->back = history->current;
- entry->next = 0;
- entry->forward = entry->forward_pref = entry->forward_last = 0;
- entry->children = 0;
- entry->bitmap = 0;
- if (history->current) {
- if (history->current->forward_last)
- history->current->forward_last->next = entry;
- else
- history->current->forward = entry;
- history->current->forward_pref = entry;
- history->current->forward_last = entry;
- history->current->children++;
- } else {
- history->start = entry;
- }
- history->current = entry;
-
- /* if we have a thumbnail, don't update until the page has finished
- * loading */
- bitmap = urldb_get_thumbnail(nsurl);
- if (!bitmap) {
- bitmap = bitmap_create(WIDTH, HEIGHT,
- BITMAP_NEW | BITMAP_CLEAR_MEMORY |
- BITMAP_OPAQUE);
- if (!bitmap) {
- warn_user("NoMemory", 0);
- return;
- }
- if (thumbnail_create(content, bitmap, nsurl) == false) {
- /* Thumbnailing failed. Ignore it silently */
- bitmap_destroy(bitmap);
- bitmap = NULL;
- }
- }
- entry->bitmap = bitmap;
-
- history_layout(history);
-}
-
-
-/**
- * Update the thumbnail for the current entry.
- *
- * \param history opaque history structure, as returned by history_create()
- * \param content content for current entry
- */
-
-void history_update(struct history *history, hlcache_handle *content)
-{
- char *title;
-
- if (!history || !history->current || !history->current->bitmap)
- return;
-
- assert(history->current->page.url);
- assert(history->current->page.title);
-
- title = strdup(content_get_title(content));
- if (!title) {
- warn_user("NoMemory", 0);
- return;
- }
-
- assert(title);
- free(history->current->page.title);
- history->current->page.title = title;
-
- thumbnail_create(content, history->current->bitmap, NULL);
-}
-
-
-/**
- * Free a history structure.
- *
- * \param history opaque history structure, as returned by history_create()
- */
-
-void history_destroy(struct history *history)
-{
- if (!history)
- return;
- history_free_entry(history->start);
- free(history);
-}
-
-
-/**
- * Free an entry in the tree recursively.
- */
-
-void history_free_entry(struct history_entry *entry)
-{
- if (!entry)
- return;
- history_free_entry(entry->forward);
- history_free_entry(entry->next);
- free(entry->page.url);
- if (entry->page.frag_id)
- free(entry->page.frag_id);
- free(entry->page.title);
- free(entry);
-}
-
-
-/**
- * Go back in the history.
- *
- * \param bw browser window
- * \param history history of the window
- */
-
-void history_back(struct browser_window *bw, struct history *history)
-{
- if (!history || !history->current || !history->current->back)
- return;
- history_go(bw, history, history->current->back, false);
-}
-
-
-/**
- * Go forward in the history.
- *
- * \param bw browser window
- * \param history history of the window
- */
-
-void history_forward(struct browser_window *bw, struct history *history)
-{
- if (!history || !history->current || !history->current->forward_pref)
- return;
- history_go(bw, history, history->current->forward_pref, false);
-}
-
-
-/**
- * Check whether it is pssible to go back in the history.
- *
- * \param history history of the window
- * \return true if the history can go back, false otherwise
- */
-
-bool history_back_available(struct history *history)
-{
- return (history && history->current && history->current->back);
-}
-
-
-/**
- * Check whether it is pssible to go forwards in the history.
- *
- * \param history history of the window
- * \return true if the history can go forwards, false otherwise
- */
-
-bool history_forward_available(struct history *history)
-{
- return (history && history->current && history->current->forward_pref);
-}
-
-
-/* Documented in history_core.h */
-void history_go(struct browser_window *bw,
- struct history *history,
- struct history_entry *entry,
- bool new_window)
-{
- char *full_url;
- nsurl *url;
- struct history_entry *current;
- nserror error;
-
-// LOG(("%p %p %p", bw, history, entry));
-// LOG(("%s %s %s",
-// entry->page.url, entry->page.title, entry->page.frag_id));
-
- if (entry->page.frag_id) {
- full_url = malloc(strlen(entry->page.url) +
- strlen(entry->page.frag_id) + 5);
- if (full_url == NULL) {
- warn_user("NoMemory", 0);
- return;
- }
- sprintf(full_url, "%s#%s", entry->page.url, entry->page.frag_id);
-
- error = nsurl_create(full_url, &url);
- free(full_url);
- } else {
- error = nsurl_create(entry->page.url, &url);
- }
-
-
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return;
- }
-
- if (new_window) {
- current = history->current;
- history->current = entry;
-
- browser_window_create(BROWSER_WINDOW_VERIFIABLE,
- url,
- NULL,
- bw,
- NULL);
- history->current = current;
- } else {
- history->current = entry;
- browser_window_navigate(bw, url, NULL,
- BROWSER_WINDOW_VERIFIABLE, NULL, NULL, NULL);
- }
-
- nsurl_unref(url);
-}
-
-
-/**
- * Compute node positions.
- *
- * \param history history to layout
- *
- * Each node's x and y are filled in.
- */
-
-void history_layout(struct history *history)
-{
- time_t t = time(0);
- struct tm *tp = localtime(&t);
- bool shuffle = tp->tm_mon == 3 && tp->tm_mday == 1;
-
- if (!history)
- return;
-
- history->width = 0;
- if (history->start)
- history->height = history_layout_subtree(history,
- history->start, RIGHT_MARGIN / 2, BOTTOM_MARGIN / 2,
- shuffle);
- else
- history->height = 0;
- if (shuffle) {
- history->width = 600 + WIDTH;
- history->height = 400 + HEIGHT;
- }
- history->width += RIGHT_MARGIN / 2;
- history->height += BOTTOM_MARGIN / 2;
-}
-
-
-/**
- * Recursively position a subtree.
- *
- * \param history history being laid out
- * \param entry subtree to position
- * \param x x position for entry
- * \param y smallest available y
- * \param shuffle shuffle layout
- * \return greatest y used by subtree
- */
-
-int history_layout_subtree(struct history *history,
- struct history_entry *entry, int x, int y, bool shuffle)
-{
- struct history_entry *child;
- int y1 = y;
-
- if (history->width < x + WIDTH)
- history->width = x + WIDTH;
-
- if (!entry->forward) {
- entry->x = x;
- entry->y = y;
- if (shuffle) {
- entry->x = rand() % 600;
- entry->y = rand() % 400;
- }
- return y + HEIGHT;
- }
-
- /* layout child subtrees below each other */
- for (child = entry->forward; child; child = child->next) {
- y1 = history_layout_subtree(history, child,
- x + WIDTH + RIGHT_MARGIN, y1, shuffle);
- if (child->next)
- y1 += BOTTOM_MARGIN;
- }
-
- /* place ourselves in the middle */
- entry->x = x;
- entry->y = (y + y1) / 2 - HEIGHT / 2;
- if (shuffle) {
- entry->x = rand() % 600;
- entry->y = rand() % 400;
- }
-
- return y1;
-}
-
-
-/**
- * Get the dimensions of a history.
- *
- * \param history history to measure
- * \param width updated to width
- * \param height updated to height
- */
-
-void history_size(struct history *history, int *width, int *height)
-{
- *width = history->width;
- *height = history->height;
-}
-
-
-/**
- * Redraw a history.
- *
- * \param history history to render
- * \param ctx current redraw context
- */
-
-bool history_redraw(struct history *history, const struct redraw_context *ctx)
-{
- if (!history->start)
- return true;
- return history_redraw_entry(history, history->start, 0, 0, 0, 0, 0, 0,
- false, ctx);
-}
-
-/**
- * Redraw part of a history.
- *
- * \param history history to render
- * \param x0 left X co-ordinate of redraw area
- * \param y0 top Y co-ordinate of redraw area
- * \param x1 right X co-ordinate of redraw area
- * \param y1 lower Y co-ordinate of redraw area
- * \param x start X co-ordinate on plot canvas
- * \param y start Y co-ordinate on plot canvas
- * \param ctx current redraw context
- */
-
-bool history_redraw_rectangle(struct history *history,
- int x0, int y0, int x1, int y1,
- int x, int y, const struct redraw_context *ctx)
-{
- if (!history->start)
- return true;
- return history_redraw_entry(history, history->start,
- x0, y0, x1, y1, x, y, true, ctx);
-}
-
-/**
- * Recursively redraw a history_entry.
- *
- * \param history history containing the entry
- * \param history_entry entry to render
- * \param ctx current redraw context
- */
-
-bool history_redraw_entry(struct history *history,
- struct history_entry *entry,
- int x0, int y0, int x1, int y1,
- int x, int y, bool clip, const struct redraw_context *ctx)
-{
- const struct plotter_table *plot = ctx->plot;
- size_t char_offset;
- int actual_x;
- struct history_entry *child;
- colour c = entry == history->current ? HISTORY_COLOUR_SELECTED : HISTORY_COLOUR_FOREGROUND;
- int tailsize = 5;
- int xoffset = x - x0;
- int yoffset = y - y0;
- plot_style_t pstyle_history_rect = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = c,
- .stroke_width = entry == history->current ? 3 : 1,
- };
- plot_font_style_t fstyle = *plot_style_font;
-
- if (clip) {
- struct rect rect;
- rect.x0 = x0 + xoffset;
- rect.y0 = y0 + yoffset;
- rect.x1 = x1 + xoffset;
- rect.y1 = y1 + yoffset;
- if(!plot->clip(&rect))
- return false;
- }
-
- if (!plot->bitmap(entry->x + xoffset, entry->y + yoffset, WIDTH, HEIGHT,
- entry->bitmap, 0xffffff, 0))
- return false;
- if (!plot->rectangle(entry->x - 1 + xoffset,
- entry->y - 1 + yoffset,
- entry->x + xoffset + WIDTH,
- entry->y + yoffset + HEIGHT,
- &pstyle_history_rect))
- return false;
-
- if (!nsfont.font_position_in_string(plot_style_font, entry->page.title,
- strlen(entry->page.title), WIDTH,
- &char_offset, &actual_x))
- return false;
-
- fstyle.background = HISTORY_COLOUR_BACKGROUND;
- fstyle.foreground = c;
- fstyle.weight = entry == history->current ? 900 : 400;
-
- if (!plot->text(entry->x + xoffset, entry->y + HEIGHT + 12 + yoffset,
- entry->page.title, char_offset, &fstyle))
- return false;
-
- for (child = entry->forward; child; child = child->next) {
- if (!plot->line(entry->x + WIDTH + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
- return false;
- if (!plot->line(entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- child->x - tailsize +xoffset,
- child->y + HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
- return false;
- if (!plot->line(child->x - tailsize + xoffset,
- child->y + HEIGHT / 2 + yoffset,
- child->x + xoffset, child->y + HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
- return false;
- if (!history_redraw_entry(history, child, x0, y0, x1, y1, x, y,
- clip, ctx))
- return false;
- }
-
- return true;
-}
-
-
-/**
- * Handle a mouse click in a history.
- *
- * \param bw browser window containing history
- * \param history history that was clicked in
- * \param x click coordinate
- * \param y click coordinate
- * \param new_window open a new window instead of using bw
- * \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)
-{
- struct history_entry *entry;
-
- entry = history_find_position(history->start, x, y);
- if (!entry)
- return false;
- if (entry == history->current)
- return false;
-
- history_go(bw, history, entry, new_window);
-
- return true;
-}
-
-
-/**
- * Determine the URL of the entry at a position.
- *
- * \param history history to search
- * \param x coordinate
- * \param y coordinate
- * \return URL, or 0 if no entry at (x, y)
- */
-
-const char *history_position_url(struct history *history, int x, int y)
-{
- struct history_entry *entry;
-
- entry = history_find_position(history->start, x, y);
- if (!entry)
- return 0;
-
- return entry->page.url;
-}
-
-
-/**
- * Find the history entry at a position.
- *
- * \param entry entry to search from
- * \param x coordinate
- * \param y coordinate
- * \return an entry if found, 0 if none
- */
-
-struct history_entry *history_find_position(struct history_entry *entry,
- int x, int y)
-{
- struct history_entry *child;
- struct history_entry *found;
-
- if (!entry)
- return 0;
-
- if (entry->x <= x && x <= entry->x + WIDTH &&
- entry->y <= y && y <= entry->y + HEIGHT)
- return entry;
-
- for (child = entry->forward; child; child = child->next) {
- found = history_find_position(child, x, y);
- if (found)
- return found;
- }
-
- return 0;
-}
-
-/* Documented in history_core.h */
-void history_enumerate_forward(struct history *history,
- history_enumerate_cb cb, void *user_data)
-{
- struct history_entry *entry;
-
- if (history == NULL || history->current == NULL) return;
-
- for (entry = history->current->forward_pref; entry != NULL; entry = entry->forward_pref) {
- if (!cb(history, entry->x, entry->y, entry->x + WIDTH,
- entry->y + HEIGHT, entry, user_data))
- break;
- }
-}
-
-/* Documented in history_core.h */
-void history_enumerate_back(struct history *history,
- history_enumerate_cb cb, void *user_data)
-{
- struct history_entry *entry;
-
- if (history == NULL || history->current == NULL) return;
-
- for (entry = history->current->back; entry != NULL; entry = entry->back) {
- if (!cb(history, entry->x, entry->y, entry->x + WIDTH,
- entry->y + HEIGHT, entry, user_data))
- break;
- }
-}
-
-/* Documented in history_core.h */
-void history_enumerate(const struct history *history, history_enumerate_cb cb,
- void *user_data)
-{
- history_enumerate_entry(history, history->start, cb, user_data);
-}
-
-/**
- * Enumerate subentries in history
- * See also history_enumerate()
- *
- * \param history history to enumerate
- * \param entry entry to start enumeration at
- * \param cb callback function
- * \param ud context pointer passed to cb
- * \return true to continue enumeration, false to cancel
- */
-static bool history_enumerate_entry(const struct history *history,
- const struct history_entry *entry, history_enumerate_cb cb, void *ud)
-{
- const struct history_entry *child;
-
- if (!cb(history, entry->x, entry->y, entry->x + WIDTH, entry->y + HEIGHT,
- entry, ud)) return false;
-
- for (child = entry->forward; child; child = child->next) {
- if (!history_enumerate_entry(history, child, cb, ud))
- return false;
- }
-
- return true;
-}
-
-/* Documented in history_core.h */
-const char *history_entry_get_url(const struct history_entry *entry)
-{
- return entry->page.url;
-}
-
-/* Documented in history_core.h */
-const char *history_entry_get_fragment_id(const struct history_entry *entry)
-{
- return entry->page.frag_id;
-}
-
-/* Documented in history_core.h */
-const char *history_entry_get_title(const struct history_entry *entry)
-{
- return entry->page.title;
-}
diff --git a/desktop/history_core.h b/desktop/history_core.h
deleted file mode 100644
index 76f39a7..0000000
--- a/desktop/history_core.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2006 James Bursa <bursa(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Browser history tree (interface).
- */
-
-#ifndef _NETSURF_DESKTOP_HISTORY_H_
-#define _NETSURF_DESKTOP_HISTORY_H_
-
-#include <stdbool.h>
-
-struct hlcache_handle;
-struct history;
-struct browser_window;
-struct history_entry;
-struct redraw_context;
-
-struct history *history_create(void);
-struct history *history_clone(struct history *history);
-void history_add(struct history *history, struct hlcache_handle *content,
- const char *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);
-bool history_back_available(struct history *history);
-bool history_forward_available(struct history *history);
-void history_size(struct history *history, int *width, int *height);
-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);
-const char *history_position_url(struct history *history, int x, int y);
-
-/**
- * Callback function type for history enumeration
- *
- * \param history history being enumerated
- * \param x0, y0, x1, y1 Coordinates of entry in history tree view
- * \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);
-
-/**
- * Enumerate all entries in the history.
- * Do not change the history while it is being enumerated.
- *
- * \param history history to enumerate
- * \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);
-
-/**
- * Enumerate all entries that will be reached by the 'forward' button
- *
- * \param history The history object to enumerate in
- * \param cb The callback function
- * \param user_data Data passed to the callback
- */
-void history_enumerate_forward( struct history *history,
- history_enumerate_cb cb, void *user_data );
-
-/**
- * Enumerate all entries that will be reached by the 'back' button
- *
- * \param history The history object to enumerate in
- * \param cb The callback function
- * \param user_data Data passed to the callback
- */
-void history_enumerate_back( struct history *history,
- history_enumerate_cb cb, void *user_data );
-
-/**
- * Returns the URL to a history entry
- *
- * \param entry the history entry to retrieve the URL from
- * \return the URL
- */
-const char *history_entry_get_url(const struct history_entry *entry);
-
-/**
- * Returns the URL to a history entry
- *
- * \param entry the history entry to retrieve the fragment id from
- * \return the fragment id
- */
-const char *history_entry_get_fragment_id(const struct history_entry *entry);
-
-/**
- * Returns the title of a history entry
- *
- * \param entry the history entry to retrieve the title from
- * \return the title
- */
-const char *history_entry_get_title(const struct history_entry *entry);
-
-/**
- * Open a history entry in the specified browser window
- *
- * \param bw browser window
- * \param history history containing 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);
-
-#endif
diff --git a/desktop/local_history.c b/desktop/local_history.c
new file mode 100644
index 0000000..7b5ecc7
--- /dev/null
+++ b/desktop/local_history.c
@@ -0,0 +1,864 @@
+/*
+ * Copyright 2006 James Bursa <bursa(a)users.sourceforge.net>
+ * Copyright 2005 Richard Wilson <info(a)tinct.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Browser history tree (implementation).
+ */
+
+#include <assert.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "content/content.h"
+#include "content/hlcache.h"
+#include "content/urldb.h"
+#include "css/css.h"
+#include "desktop/browser.h"
+#include "desktop/gui.h"
+#include "desktop/local_history.h"
+#include "desktop/plotters.h"
+#include "desktop/thumbnail.h"
+#include "image/bitmap.h"
+#include "render/font.h"
+#include "utils/log.h"
+#include "utils/url.h"
+#include "utils/utils.h"
+
+
+#define WIDTH 100
+#define HEIGHT 86
+#define RIGHT_MARGIN 50
+#define BOTTOM_MARGIN 30
+
+struct history_page {
+ char *url; /**< Page URL, never 0. */
+ char *frag_id; /** Fragment identifier, or 0. */
+ char *title; /**< Page title, never 0. */
+};
+
+/** A node in the history tree. */
+struct history_entry {
+ struct history_page page;
+ struct history_entry *back; /**< Parent. */
+ struct history_entry *next; /**< Next sibling. */
+ struct history_entry *forward; /**< First child. */
+ struct history_entry *forward_pref; /**< Child in direction of
+ current entry. */
+ struct history_entry *forward_last; /**< Last child. */
+ unsigned int children; /**< Number of children. */
+ int x; /**< Position of node. */
+ int y; /**< Position of node. */
+ struct bitmap *bitmap; /**< Thumbnail bitmap, or 0. */
+};
+
+/** History tree for a window. */
+struct history {
+ /** First page in tree (page that window opened with). */
+ struct history_entry *start;
+ /** Current position in tree. */
+ struct history_entry *current;
+ /** Width of layout. */
+ int width;
+ /** Height of layout. */
+ int height;
+};
+
+static struct history_entry *history_clone_entry(struct history *history,
+ struct history_entry *entry);
+static void history_free_entry(struct history_entry *entry);
+static void history_layout(struct history *history);
+static int history_layout_subtree(struct history *history,
+ struct history_entry *entry, int x, int y, bool shuffle);
+static bool history_redraw_entry(struct history *history,
+ struct history_entry *entry,
+ int x0, int y0, int x1, int y1,
+ int x, int y, bool clip, const struct redraw_context *ctx);
+static struct history_entry *history_find_position(struct history_entry *entry,
+ int x, int y);
+static bool history_enumerate_entry(const struct history *history,
+ const struct history_entry *entry, history_enumerate_cb cb, void *ud);
+
+
+/**
+ * Create a new history tree for a window.
+ *
+ * \return pointer to an opaque history structure, 0 on failure.
+ */
+
+struct history *history_create(void)
+{
+ struct history *history;
+
+ history = calloc(1, sizeof *history);
+ if (!history) {
+ warn_user("NoMemory", 0);
+ return 0;
+ }
+ history->width = RIGHT_MARGIN / 2;
+ history->height = BOTTOM_MARGIN / 2;
+ return history;
+}
+
+
+/**
+ * Clone a history tree
+ *
+ * \param history opaque history structure, as returned by history_create()
+ *
+ * \return pointer to an opaque history structure, 0 on failure.
+ */
+
+struct history *history_clone(struct history *history)
+{
+ struct history *new_history;
+
+ if (!history->start)
+ return history_create();
+
+ new_history = malloc(sizeof *history);
+ if (!new_history)
+ return 0;
+ memcpy(new_history, history, sizeof *history);
+
+ new_history->start = history_clone_entry(new_history,
+ new_history->start);
+ if (!history->start) {
+ LOG(("Insufficient memory to clone history"));
+ warn_user("NoMemory", 0);
+ history_destroy(new_history);
+ return 0;
+ }
+
+ return new_history;
+}
+
+
+/**
+ * Clone a history entry
+ *
+ * \param history opaque history structure, as returned by history_create()
+ * \param start entry to clone
+ *
+ * \return a cloned history entry, or 0 on error
+ */
+
+struct history_entry *history_clone_entry(struct history *history,
+ struct history_entry *entry)
+{
+ struct history_entry *child;
+ struct history_entry *new_child;
+ struct history_entry *prev = NULL;
+ struct history_entry *new_entry;
+
+ assert(entry->page.url);
+ assert(entry->page.title);
+
+ /* clone the entry */
+ new_entry = malloc(sizeof *entry);
+ if (!new_entry)
+ return 0;
+ memcpy(new_entry, entry, sizeof *entry);
+ new_entry->page.url = strdup(entry->page.url);
+ if (entry->page.frag_id)
+ new_entry->page.frag_id = strdup(entry->page.frag_id);
+ new_entry->page.title = strdup(entry->page.title);
+ if (!new_entry->page.url || !new_entry->page.title ||
+ ((entry->page.frag_id) && (!new_entry->page.frag_id))) {
+ free(new_entry->page.url);
+ free(new_entry->page.title);
+ free(new_entry->page.frag_id);
+ free(new_entry);
+ return 0;
+ }
+
+ /* update references */
+ if (history->current == entry)
+ history->current = new_entry;
+
+ /* recurse for all children */
+ for (child = new_entry->forward; child; child = child->next) {
+ new_child = history_clone_entry(history, child);
+ if (new_child)
+ new_child->back = new_entry;
+ if (prev)
+ prev->next = new_child;
+ if (new_entry->forward == child)
+ new_entry->forward = new_child;
+ if (new_entry->forward_pref == child)
+ new_entry->forward_pref = new_child;
+ if (new_entry->forward_last == child)
+ new_entry->forward_last = new_child;
+ if (!new_child)
+ return 0;
+ prev = new_child;
+ }
+ return new_entry;
+}
+
+
+/**
+ * Insert a url into the history tree.
+ *
+ * \param history opaque history structure, as returned by history_create()
+ * \param content content to add to history
+ * \param frag_id fragment identifier
+ *
+ * The page is added after the current entry and becomes current.
+ */
+
+void history_add(struct history *history, hlcache_handle *content,
+ const char *frag_id)
+{
+ struct history_entry *entry;
+ nsurl *nsurl = hlcache_handle_get_url(content);
+ char *url;
+ char *title;
+ struct bitmap *bitmap;
+ nserror error;
+ size_t url_len;
+
+ assert(history);
+ assert(content);
+
+ /* allocate space */
+ entry = malloc(sizeof *entry);
+ if (entry == NULL)
+ return;
+
+ /* TODO: use a nsurl? */
+ error = nsurl_get(nsurl, NSURL_WITH_FRAGMENT, &url, &url_len);
+ if (error != NSERROR_OK) {
+ warn_user("NoMemory", 0);
+ free(entry);
+ return;
+ }
+
+ title = strdup(content_get_title(content));
+ if (title == NULL) {
+ warn_user("NoMemory", 0);
+ free(url);
+ free(entry);
+ return;
+ }
+
+ entry->page.url = url;
+ entry->page.frag_id = frag_id ? strdup(frag_id) : 0;
+ entry->page.title = title;
+ entry->back = history->current;
+ entry->next = 0;
+ entry->forward = entry->forward_pref = entry->forward_last = 0;
+ entry->children = 0;
+ entry->bitmap = 0;
+ if (history->current) {
+ if (history->current->forward_last)
+ history->current->forward_last->next = entry;
+ else
+ history->current->forward = entry;
+ history->current->forward_pref = entry;
+ history->current->forward_last = entry;
+ history->current->children++;
+ } else {
+ history->start = entry;
+ }
+ history->current = entry;
+
+ /* if we have a thumbnail, don't update until the page has finished
+ * loading */
+ bitmap = urldb_get_thumbnail(nsurl);
+ if (!bitmap) {
+ bitmap = bitmap_create(WIDTH, HEIGHT,
+ BITMAP_NEW | BITMAP_CLEAR_MEMORY |
+ BITMAP_OPAQUE);
+ if (!bitmap) {
+ warn_user("NoMemory", 0);
+ return;
+ }
+ if (thumbnail_create(content, bitmap, nsurl) == false) {
+ /* Thumbnailing failed. Ignore it silently */
+ bitmap_destroy(bitmap);
+ bitmap = NULL;
+ }
+ }
+ entry->bitmap = bitmap;
+
+ history_layout(history);
+}
+
+
+/**
+ * Update the thumbnail for the current entry.
+ *
+ * \param history opaque history structure, as returned by history_create()
+ * \param content content for current entry
+ */
+
+void history_update(struct history *history, hlcache_handle *content)
+{
+ char *title;
+
+ if (!history || !history->current || !history->current->bitmap)
+ return;
+
+ assert(history->current->page.url);
+ assert(history->current->page.title);
+
+ title = strdup(content_get_title(content));
+ if (!title) {
+ warn_user("NoMemory", 0);
+ return;
+ }
+
+ assert(title);
+ free(history->current->page.title);
+ history->current->page.title = title;
+
+ thumbnail_create(content, history->current->bitmap, NULL);
+}
+
+
+/**
+ * Free a history structure.
+ *
+ * \param history opaque history structure, as returned by history_create()
+ */
+
+void history_destroy(struct history *history)
+{
+ if (!history)
+ return;
+ history_free_entry(history->start);
+ free(history);
+}
+
+
+/**
+ * Free an entry in the tree recursively.
+ */
+
+void history_free_entry(struct history_entry *entry)
+{
+ if (!entry)
+ return;
+ history_free_entry(entry->forward);
+ history_free_entry(entry->next);
+ free(entry->page.url);
+ if (entry->page.frag_id)
+ free(entry->page.frag_id);
+ free(entry->page.title);
+ free(entry);
+}
+
+
+/**
+ * Go back in the history.
+ *
+ * \param bw browser window
+ * \param history history of the window
+ */
+
+void history_back(struct browser_window *bw, struct history *history)
+{
+ if (!history || !history->current || !history->current->back)
+ return;
+ history_go(bw, history, history->current->back, false);
+}
+
+
+/**
+ * Go forward in the history.
+ *
+ * \param bw browser window
+ * \param history history of the window
+ */
+
+void history_forward(struct browser_window *bw, struct history *history)
+{
+ if (!history || !history->current || !history->current->forward_pref)
+ return;
+ history_go(bw, history, history->current->forward_pref, false);
+}
+
+
+/**
+ * Check whether it is pssible to go back in the history.
+ *
+ * \param history history of the window
+ * \return true if the history can go back, false otherwise
+ */
+
+bool history_back_available(struct history *history)
+{
+ return (history && history->current && history->current->back);
+}
+
+
+/**
+ * Check whether it is pssible to go forwards in the history.
+ *
+ * \param history history of the window
+ * \return true if the history can go forwards, false otherwise
+ */
+
+bool history_forward_available(struct history *history)
+{
+ return (history && history->current && history->current->forward_pref);
+}
+
+
+/* Documented in local_history.h */
+void history_go(struct browser_window *bw,
+ struct history *history,
+ struct history_entry *entry,
+ bool new_window)
+{
+ char *full_url;
+ nsurl *url;
+ struct history_entry *current;
+ nserror error;
+
+// LOG(("%p %p %p", bw, history, entry));
+// LOG(("%s %s %s",
+// entry->page.url, entry->page.title, entry->page.frag_id));
+
+ if (entry->page.frag_id) {
+ full_url = malloc(strlen(entry->page.url) +
+ strlen(entry->page.frag_id) + 5);
+ if (full_url == NULL) {
+ warn_user("NoMemory", 0);
+ return;
+ }
+ sprintf(full_url, "%s#%s", entry->page.url, entry->page.frag_id);
+
+ error = nsurl_create(full_url, &url);
+ free(full_url);
+ } else {
+ error = nsurl_create(entry->page.url, &url);
+ }
+
+
+ if (error != NSERROR_OK) {
+ warn_user("NoMemory", 0);
+ return;
+ }
+
+ if (new_window) {
+ current = history->current;
+ history->current = entry;
+
+ browser_window_create(BROWSER_WINDOW_VERIFIABLE,
+ url,
+ NULL,
+ bw,
+ NULL);
+ history->current = current;
+ } else {
+ history->current = entry;
+ browser_window_navigate(bw, url, NULL,
+ BROWSER_WINDOW_VERIFIABLE, NULL, NULL, NULL);
+ }
+
+ nsurl_unref(url);
+}
+
+
+/**
+ * Compute node positions.
+ *
+ * \param history history to layout
+ *
+ * Each node's x and y are filled in.
+ */
+
+void history_layout(struct history *history)
+{
+ time_t t = time(0);
+ struct tm *tp = localtime(&t);
+ bool shuffle = tp->tm_mon == 3 && tp->tm_mday == 1;
+
+ if (!history)
+ return;
+
+ history->width = 0;
+ if (history->start)
+ history->height = history_layout_subtree(history,
+ history->start, RIGHT_MARGIN / 2, BOTTOM_MARGIN / 2,
+ shuffle);
+ else
+ history->height = 0;
+ if (shuffle) {
+ history->width = 600 + WIDTH;
+ history->height = 400 + HEIGHT;
+ }
+ history->width += RIGHT_MARGIN / 2;
+ history->height += BOTTOM_MARGIN / 2;
+}
+
+
+/**
+ * Recursively position a subtree.
+ *
+ * \param history history being laid out
+ * \param entry subtree to position
+ * \param x x position for entry
+ * \param y smallest available y
+ * \param shuffle shuffle layout
+ * \return greatest y used by subtree
+ */
+
+int history_layout_subtree(struct history *history,
+ struct history_entry *entry, int x, int y, bool shuffle)
+{
+ struct history_entry *child;
+ int y1 = y;
+
+ if (history->width < x + WIDTH)
+ history->width = x + WIDTH;
+
+ if (!entry->forward) {
+ entry->x = x;
+ entry->y = y;
+ if (shuffle) {
+ entry->x = rand() % 600;
+ entry->y = rand() % 400;
+ }
+ return y + HEIGHT;
+ }
+
+ /* layout child subtrees below each other */
+ for (child = entry->forward; child; child = child->next) {
+ y1 = history_layout_subtree(history, child,
+ x + WIDTH + RIGHT_MARGIN, y1, shuffle);
+ if (child->next)
+ y1 += BOTTOM_MARGIN;
+ }
+
+ /* place ourselves in the middle */
+ entry->x = x;
+ entry->y = (y + y1) / 2 - HEIGHT / 2;
+ if (shuffle) {
+ entry->x = rand() % 600;
+ entry->y = rand() % 400;
+ }
+
+ return y1;
+}
+
+
+/**
+ * Get the dimensions of a history.
+ *
+ * \param history history to measure
+ * \param width updated to width
+ * \param height updated to height
+ */
+
+void history_size(struct history *history, int *width, int *height)
+{
+ *width = history->width;
+ *height = history->height;
+}
+
+
+/**
+ * Redraw a history.
+ *
+ * \param history history to render
+ * \param ctx current redraw context
+ */
+
+bool history_redraw(struct history *history, const struct redraw_context *ctx)
+{
+ if (!history->start)
+ return true;
+ return history_redraw_entry(history, history->start, 0, 0, 0, 0, 0, 0,
+ false, ctx);
+}
+
+/**
+ * Redraw part of a history.
+ *
+ * \param history history to render
+ * \param x0 left X co-ordinate of redraw area
+ * \param y0 top Y co-ordinate of redraw area
+ * \param x1 right X co-ordinate of redraw area
+ * \param y1 lower Y co-ordinate of redraw area
+ * \param x start X co-ordinate on plot canvas
+ * \param y start Y co-ordinate on plot canvas
+ * \param ctx current redraw context
+ */
+
+bool history_redraw_rectangle(struct history *history,
+ int x0, int y0, int x1, int y1,
+ int x, int y, const struct redraw_context *ctx)
+{
+ if (!history->start)
+ return true;
+ return history_redraw_entry(history, history->start,
+ x0, y0, x1, y1, x, y, true, ctx);
+}
+
+/**
+ * Recursively redraw a history_entry.
+ *
+ * \param history history containing the entry
+ * \param history_entry entry to render
+ * \param ctx current redraw context
+ */
+
+bool history_redraw_entry(struct history *history,
+ struct history_entry *entry,
+ int x0, int y0, int x1, int y1,
+ int x, int y, bool clip, const struct redraw_context *ctx)
+{
+ const struct plotter_table *plot = ctx->plot;
+ size_t char_offset;
+ int actual_x;
+ struct history_entry *child;
+ colour c = entry == history->current ? HISTORY_COLOUR_SELECTED : HISTORY_COLOUR_FOREGROUND;
+ int tailsize = 5;
+ int xoffset = x - x0;
+ int yoffset = y - y0;
+ plot_style_t pstyle_history_rect = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = c,
+ .stroke_width = entry == history->current ? 3 : 1,
+ };
+ plot_font_style_t fstyle = *plot_style_font;
+
+ if (clip) {
+ struct rect rect;
+ rect.x0 = x0 + xoffset;
+ rect.y0 = y0 + yoffset;
+ rect.x1 = x1 + xoffset;
+ rect.y1 = y1 + yoffset;
+ if(!plot->clip(&rect))
+ return false;
+ }
+
+ if (!plot->bitmap(entry->x + xoffset, entry->y + yoffset, WIDTH, HEIGHT,
+ entry->bitmap, 0xffffff, 0))
+ return false;
+ if (!plot->rectangle(entry->x - 1 + xoffset,
+ entry->y - 1 + yoffset,
+ entry->x + xoffset + WIDTH,
+ entry->y + yoffset + HEIGHT,
+ &pstyle_history_rect))
+ return false;
+
+ if (!nsfont.font_position_in_string(plot_style_font, entry->page.title,
+ strlen(entry->page.title), WIDTH,
+ &char_offset, &actual_x))
+ return false;
+
+ fstyle.background = HISTORY_COLOUR_BACKGROUND;
+ fstyle.foreground = c;
+ fstyle.weight = entry == history->current ? 900 : 400;
+
+ if (!plot->text(entry->x + xoffset, entry->y + HEIGHT + 12 + yoffset,
+ entry->page.title, char_offset, &fstyle))
+ return false;
+
+ for (child = entry->forward; child; child = child->next) {
+ if (!plot->line(entry->x + WIDTH + xoffset,
+ entry->y + HEIGHT / 2 + yoffset,
+ entry->x + WIDTH + tailsize + xoffset,
+ entry->y + HEIGHT / 2 + yoffset,
+ plot_style_stroke_history))
+ return false;
+ if (!plot->line(entry->x + WIDTH + tailsize + xoffset,
+ entry->y + HEIGHT / 2 + yoffset,
+ child->x - tailsize +xoffset,
+ child->y + HEIGHT / 2 + yoffset,
+ plot_style_stroke_history))
+ return false;
+ if (!plot->line(child->x - tailsize + xoffset,
+ child->y + HEIGHT / 2 + yoffset,
+ child->x + xoffset, child->y + HEIGHT / 2 + yoffset,
+ plot_style_stroke_history))
+ return false;
+ if (!history_redraw_entry(history, child, x0, y0, x1, y1, x, y,
+ clip, ctx))
+ return false;
+ }
+
+ return true;
+}
+
+
+/**
+ * Handle a mouse click in a history.
+ *
+ * \param bw browser window containing history
+ * \param history history that was clicked in
+ * \param x click coordinate
+ * \param y click coordinate
+ * \param new_window open a new window instead of using bw
+ * \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)
+{
+ struct history_entry *entry;
+
+ entry = history_find_position(history->start, x, y);
+ if (!entry)
+ return false;
+ if (entry == history->current)
+ return false;
+
+ history_go(bw, history, entry, new_window);
+
+ return true;
+}
+
+
+/**
+ * Determine the URL of the entry at a position.
+ *
+ * \param history history to search
+ * \param x coordinate
+ * \param y coordinate
+ * \return URL, or 0 if no entry at (x, y)
+ */
+
+const char *history_position_url(struct history *history, int x, int y)
+{
+ struct history_entry *entry;
+
+ entry = history_find_position(history->start, x, y);
+ if (!entry)
+ return 0;
+
+ return entry->page.url;
+}
+
+
+/**
+ * Find the history entry at a position.
+ *
+ * \param entry entry to search from
+ * \param x coordinate
+ * \param y coordinate
+ * \return an entry if found, 0 if none
+ */
+
+struct history_entry *history_find_position(struct history_entry *entry,
+ int x, int y)
+{
+ struct history_entry *child;
+ struct history_entry *found;
+
+ if (!entry)
+ return 0;
+
+ if (entry->x <= x && x <= entry->x + WIDTH &&
+ entry->y <= y && y <= entry->y + HEIGHT)
+ return entry;
+
+ for (child = entry->forward; child; child = child->next) {
+ found = history_find_position(child, x, y);
+ if (found)
+ return found;
+ }
+
+ return 0;
+}
+
+/* Documented in local_history.h */
+void history_enumerate_forward(struct history *history,
+ history_enumerate_cb cb, void *user_data)
+{
+ struct history_entry *entry;
+
+ if (history == NULL || history->current == NULL) return;
+
+ for (entry = history->current->forward_pref; entry != NULL; entry = entry->forward_pref) {
+ if (!cb(history, entry->x, entry->y, entry->x + WIDTH,
+ entry->y + HEIGHT, entry, user_data))
+ break;
+ }
+}
+
+/* Documented in local_history.h */
+void history_enumerate_back(struct history *history,
+ history_enumerate_cb cb, void *user_data)
+{
+ struct history_entry *entry;
+
+ if (history == NULL || history->current == NULL) return;
+
+ for (entry = history->current->back; entry != NULL; entry = entry->back) {
+ if (!cb(history, entry->x, entry->y, entry->x + WIDTH,
+ entry->y + HEIGHT, entry, user_data))
+ break;
+ }
+}
+
+/* Documented in local_history.h */
+void history_enumerate(const struct history *history, history_enumerate_cb cb,
+ void *user_data)
+{
+ history_enumerate_entry(history, history->start, cb, user_data);
+}
+
+/**
+ * Enumerate subentries in history
+ * See also history_enumerate()
+ *
+ * \param history history to enumerate
+ * \param entry entry to start enumeration at
+ * \param cb callback function
+ * \param ud context pointer passed to cb
+ * \return true to continue enumeration, false to cancel
+ */
+static bool history_enumerate_entry(const struct history *history,
+ const struct history_entry *entry, history_enumerate_cb cb, void *ud)
+{
+ const struct history_entry *child;
+
+ if (!cb(history, entry->x, entry->y, entry->x + WIDTH, entry->y + HEIGHT,
+ entry, ud)) return false;
+
+ for (child = entry->forward; child; child = child->next) {
+ if (!history_enumerate_entry(history, child, cb, ud))
+ return false;
+ }
+
+ return true;
+}
+
+/* Documented in local_history.h */
+const char *history_entry_get_url(const struct history_entry *entry)
+{
+ return entry->page.url;
+}
+
+/* Documented in local_history.h */
+const char *history_entry_get_fragment_id(const struct history_entry *entry)
+{
+ return entry->page.frag_id;
+}
+
+/* Documented in local_history.h */
+const char *history_entry_get_title(const struct history_entry *entry)
+{
+ return entry->page.title;
+}
diff --git a/desktop/local_history.h b/desktop/local_history.h
new file mode 100644
index 0000000..76f39a7
--- /dev/null
+++ b/desktop/local_history.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2006 James Bursa <bursa(a)users.sourceforge.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Browser history tree (interface).
+ */
+
+#ifndef _NETSURF_DESKTOP_HISTORY_H_
+#define _NETSURF_DESKTOP_HISTORY_H_
+
+#include <stdbool.h>
+
+struct hlcache_handle;
+struct history;
+struct browser_window;
+struct history_entry;
+struct redraw_context;
+
+struct history *history_create(void);
+struct history *history_clone(struct history *history);
+void history_add(struct history *history, struct hlcache_handle *content,
+ const char *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);
+bool history_back_available(struct history *history);
+bool history_forward_available(struct history *history);
+void history_size(struct history *history, int *width, int *height);
+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);
+const char *history_position_url(struct history *history, int x, int y);
+
+/**
+ * Callback function type for history enumeration
+ *
+ * \param history history being enumerated
+ * \param x0, y0, x1, y1 Coordinates of entry in history tree view
+ * \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);
+
+/**
+ * Enumerate all entries in the history.
+ * Do not change the history while it is being enumerated.
+ *
+ * \param history history to enumerate
+ * \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);
+
+/**
+ * Enumerate all entries that will be reached by the 'forward' button
+ *
+ * \param history The history object to enumerate in
+ * \param cb The callback function
+ * \param user_data Data passed to the callback
+ */
+void history_enumerate_forward( struct history *history,
+ history_enumerate_cb cb, void *user_data );
+
+/**
+ * Enumerate all entries that will be reached by the 'back' button
+ *
+ * \param history The history object to enumerate in
+ * \param cb The callback function
+ * \param user_data Data passed to the callback
+ */
+void history_enumerate_back( struct history *history,
+ history_enumerate_cb cb, void *user_data );
+
+/**
+ * Returns the URL to a history entry
+ *
+ * \param entry the history entry to retrieve the URL from
+ * \return the URL
+ */
+const char *history_entry_get_url(const struct history_entry *entry);
+
+/**
+ * Returns the URL to a history entry
+ *
+ * \param entry the history entry to retrieve the fragment id from
+ * \return the fragment id
+ */
+const char *history_entry_get_fragment_id(const struct history_entry *entry);
+
+/**
+ * Returns the title of a history entry
+ *
+ * \param entry the history entry to retrieve the title from
+ * \return the title
+ */
+const char *history_entry_get_title(const struct history_entry *entry);
+
+/**
+ * Open a history entry in the specified browser window
+ *
+ * \param bw browser window
+ * \param history history containing 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);
+
+#endif
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index d9e78d7..c9adf6c 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -56,7 +56,7 @@
#include "framebuffer/font.h"
#include "content/urldb.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "content/fetch.h"
#define NSFB_TOOLBAR_DEFAULT_LAYOUT "blfsrutc"
diff --git a/framebuffer/localhistory.c b/framebuffer/localhistory.c
index e23dd1f..d482098 100644
--- a/framebuffer/localhistory.c
+++ b/framebuffer/localhistory.c
@@ -52,7 +52,7 @@
#include "framebuffer/font.h"
#include "content/urldb.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "content/fetch.h"
static int
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index b10fb69..c073698 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -33,7 +33,7 @@
#include "content/hlcache.h"
#include "css/utils.h"
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/hotlist.h"
#include "desktop/gui.h"
#include "desktop/netsurf.h"
diff --git a/riscos/history.c b/riscos/history.c
index 65ae847..be81e1a 100644
--- a/riscos/history.c
+++ b/riscos/history.c
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include "oslib/wimp.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "riscos/dialog.h"
#include "desktop/browser_private.h"
diff --git a/riscos/menus.c b/riscos/menus.c
index aaec8cf..337ca48 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -38,7 +38,7 @@
#include "desktop/browser.h"
#include "desktop/gui.h"
#include "desktop/history_global_core.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/hotlist.h"
#include "desktop/netsurf.h"
#include "desktop/textinput.h"
diff --git a/riscos/window.c b/riscos/window.c
index 772a0d1..8e0f0a0 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -49,7 +49,7 @@
#include "desktop/cookies.h"
#include "desktop/scrollbar.h"
#include "desktop/frames.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/hotlist.h"
#include "desktop/mouse.h"
#include "desktop/plotters.h"
diff --git a/windows/gui.c b/windows/gui.c
index f8d57fd..767f681 100644
--- a/windows/gui.c
+++ b/windows/gui.c
@@ -33,7 +33,7 @@
#include "content/fetch.h"
#include "css/utils.h"
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/mouse.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
diff --git a/windows/localhistory.c b/windows/localhistory.c
index f58ab81..0b29871 100644
--- a/windows/localhistory.c
+++ b/windows/localhistory.c
@@ -23,7 +23,7 @@
#include <commctrl.h>
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "utils/utils.h"
#include "utils/log.h"
-----------------------------------------------------------------------
Summary of changes:
amiga/context_menu.c | 2 +-
amiga/gui.c | 2 +-
amiga/history_local.c | 2 +-
atari/download.c | 2 +-
atari/gui.c | 2 +-
atari/rootwin.c | 2 +-
atari/statusbar.c | 2 +-
atari/toolbar.c | 2 +-
beos/scaffolding.cpp | 2 +-
cocoa/BrowserView.m | 2 +-
cocoa/BrowserViewController.m | 2 +-
cocoa/HistoryView.m | 2 +-
cocoa/NetSurf.xcodeproj/project.pbxproj | 8 ++++----
cocoa/NetsurfApp.m | 2 +-
desktop/Makefile | 2 +-
desktop/browser.c | 2 +-
desktop/frames.c | 2 +-
desktop/{history_core.c => local_history.c} | 16 ++++++++--------
desktop/{history_core.h => local_history.h} | 0
framebuffer/gui.c | 2 +-
framebuffer/localhistory.c | 2 +-
gtk/scaffolding.c | 2 +-
riscos/history.c | 2 +-
riscos/menus.c | 2 +-
riscos/window.c | 2 +-
windows/gui.c | 2 +-
windows/localhistory.c | 2 +-
27 files changed, 36 insertions(+), 36 deletions(-)
rename desktop/{history_core.c => local_history.c} (98%)
rename desktop/{history_core.h => local_history.h} (100%)
diff --git a/amiga/context_menu.c b/amiga/context_menu.c
index 839b603..be52865 100644
--- a/amiga/context_menu.c
+++ b/amiga/context_menu.c
@@ -40,7 +40,7 @@
#include "amiga/tree.h"
#include "amiga/utf8.h"
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/hotlist.h"
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
diff --git a/amiga/gui.c b/amiga/gui.c
index a5cac9d..bbc4268 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -20,7 +20,7 @@
#include "content/urldb.h"
#include "css/utils.h"
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/mouse.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
diff --git a/amiga/history_local.c b/amiga/history_local.c
index 3c8b6e1..5203276 100755
--- a/amiga/history_local.c
+++ b/amiga/history_local.c
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "amiga/os3support.h"
#include "amiga/object.h"
diff --git a/atari/download.c b/atari/download.c
index 407be06..e4a45e8 100755
--- a/atari/download.c
+++ b/atari/download.c
@@ -28,7 +28,7 @@
#include "content/urldb.h"
#include "content/fetch.h"
#include "desktop/gui.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
#include "desktop/save_complete.h"
diff --git a/atari/gui.c b/atari/gui.c
index 5b0df84..df205aa 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -35,7 +35,7 @@
#include "content/fetchers/resource.h"
#include "css/utils.h"
#include "desktop/gui.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "desktop/netsurf.h"
#include "desktop/401login.h"
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 28e3271..2344219 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -38,7 +38,7 @@
#include "utils/log.h"
#include "desktop/gui.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "desktop/browser.h"
#include "desktop/browser_private.h"
diff --git a/atari/statusbar.c b/atari/statusbar.c
index 9f26d7b..3bf186c 100755
--- a/atari/statusbar.c
+++ b/atari/statusbar.c
@@ -29,7 +29,7 @@
#include "utils/log.h"
#include "desktop/gui.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "desktop/browser.h"
#include "desktop/mouse.h"
diff --git a/atari/toolbar.c b/atari/toolbar.c
index 79be31b..e190c96 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -29,7 +29,7 @@
#include "utils/log.h"
#include "desktop/gui.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "desktop/browser.h"
#include "desktop/browser_private.h"
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index fe40b0c..7834db4 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -52,7 +52,7 @@
extern "C" {
#include "content/content.h"
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/gui.h"
#include "desktop/netsurf.h"
#include "desktop/plotters.h"
diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m
index c472fd7..ca5808c 100644
--- a/cocoa/BrowserView.m
+++ b/cocoa/BrowserView.m
@@ -24,7 +24,7 @@
#import "cocoa/BrowserWindowController.h"
#import "desktop/browser_private.h"
-#import "desktop/history_core.h"
+#import "desktop/local_history.h"
#import "desktop/plotters.h"
#import "desktop/textinput.h"
#import "utils/nsoption.h"
diff --git a/cocoa/BrowserViewController.m b/cocoa/BrowserViewController.m
index 4952f52..77ee57b 100644
--- a/cocoa/BrowserViewController.m
+++ b/cocoa/BrowserViewController.m
@@ -21,7 +21,7 @@
#import "cocoa/BrowserWindowController.h"
#import "desktop/browser_private.h"
-#import "desktop/history_core.h"
+#import "desktop/local_history.h"
#import "desktop/textinput.h"
#import "utils/nsoption.h"
diff --git a/cocoa/HistoryView.m b/cocoa/HistoryView.m
index 31a8e24..45f7fac 100644
--- a/cocoa/HistoryView.m
+++ b/cocoa/HistoryView.m
@@ -24,7 +24,7 @@
#import "cocoa/BrowserView.h"
#import "desktop/browser_private.h"
-#import "desktop/history_core.h"
+#import "desktop/local_history.h"
#import "desktop/plotters.h"
@implementation HistoryView
diff --git a/cocoa/NetSurf.xcodeproj/project.pbxproj b/cocoa/NetSurf.xcodeproj/project.pbxproj
index eacc80a..ca0bed6 100644
--- a/cocoa/NetSurf.xcodeproj/project.pbxproj
+++ b/cocoa/NetSurf.xcodeproj/project.pbxproj
@@ -47,8 +47,8 @@
260F1F8B12D620E800D9B07F /* frames.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = frames.c; sourceTree = "<group>"; };
260F1F8C12D620E800D9B07F /* frames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = frames.h; sourceTree = "<group>"; };
260F1F8D12D620E800D9B07F /* gui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gui.h; sourceTree = "<group>"; };
- 260F1F8E12D620E800D9B07F /* history_core.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = history_core.c; sourceTree = "<group>"; };
- 260F1F8F12D620E800D9B07F /* history_core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = history_core.h; sourceTree = "<group>"; };
+ 260F1F8E12D620E800D9B07F /* local_history.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = local_history.c; sourceTree = "<group>"; };
+ 260F1F8F12D620E800D9B07F /* local_history.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = local_history.h; sourceTree = "<group>"; };
260F1F9012D620E800D9B07F /* history_global_core.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = history_global_core.c; sourceTree = "<group>"; };
260F1F9112D620E800D9B07F /* history_global_core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = history_global_core.h; sourceTree = "<group>"; };
260F1F9212D620E800D9B07F /* hotlist.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hotlist.c; sourceTree = "<group>"; };
@@ -404,8 +404,8 @@
260F1F8B12D620E800D9B07F /* frames.c */,
260F1F8C12D620E800D9B07F /* frames.h */,
260F1F8D12D620E800D9B07F /* gui.h */,
- 260F1F8E12D620E800D9B07F /* history_core.c */,
- 260F1F8F12D620E800D9B07F /* history_core.h */,
+ 260F1F8E12D620E800D9B07F /* local_history.c */,
+ 260F1F8F12D620E800D9B07F /* local_history.h */,
260F1F9012D620E800D9B07F /* history_global_core.c */,
260F1F9112D620E800D9B07F /* history_global_core.h */,
260F1F9212D620E800D9B07F /* hotlist.c */,
diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m
index 333cbe2..33e3bfa 100644
--- a/cocoa/NetsurfApp.m
+++ b/cocoa/NetsurfApp.m
@@ -26,7 +26,7 @@
#import "content/fetch.h"
#import "css/utils.h"
#import "desktop/gui.h"
-#import "desktop/history_core.h"
+#import "desktop/local_history.h"
#import "desktop/mouse.h"
#import "desktop/netsurf.h"
#import "utils/nsoption.h"
diff --git a/desktop/Makefile b/desktop/Makefile
index f787fd2..ded75aa 100644
--- a/desktop/Makefile
+++ b/desktop/Makefile
@@ -12,7 +12,7 @@ desktop/version.c: testament utils/testament.h
# S_BROWSER are sources related to full browsers but are common
# between RISC OS, GTK, BeOS and AmigaOS builds
-S_BROWSER := browser.c download.c frames.c history_core.c netsurf.c \
+S_BROWSER := browser.c download.c frames.c local_history.c netsurf.c \
save_complete.c save_text.c selection.c textinput.c
S_BROWSER := $(addprefix desktop/,$(S_BROWSER))
diff --git a/desktop/browser.c b/desktop/browser.c
index b7ec989..4df48e4 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -45,7 +45,7 @@
#include "desktop/browser_private.h"
#include "desktop/download.h"
#include "desktop/frames.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/hotlist.h"
#include "desktop/gui.h"
#include "desktop/knockout.h"
diff --git a/desktop/frames.c b/desktop/frames.c
index dcc66df..3f7613f 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -32,7 +32,7 @@
#include "content/hlcache.h"
#include "desktop/browser_private.h"
#include "desktop/frames.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/gui.h"
#include "desktop/scrollbar.h"
#include "desktop/selection.h"
diff --git a/desktop/history_core.c b/desktop/local_history.c
similarity index 98%
rename from desktop/history_core.c
rename to desktop/local_history.c
index bc933c0..7b5ecc7 100644
--- a/desktop/history_core.c
+++ b/desktop/local_history.c
@@ -32,7 +32,7 @@
#include "css/css.h"
#include "desktop/browser.h"
#include "desktop/gui.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "desktop/thumbnail.h"
#include "image/bitmap.h"
@@ -422,7 +422,7 @@ bool history_forward_available(struct history *history)
}
-/* Documented in history_core.h */
+/* Documented in local_history.h */
void history_go(struct browser_window *bw,
struct history *history,
struct history_entry *entry,
@@ -782,7 +782,7 @@ struct history_entry *history_find_position(struct history_entry *entry,
return 0;
}
-/* Documented in history_core.h */
+/* Documented in local_history.h */
void history_enumerate_forward(struct history *history,
history_enumerate_cb cb, void *user_data)
{
@@ -797,7 +797,7 @@ void history_enumerate_forward(struct history *history,
}
}
-/* Documented in history_core.h */
+/* Documented in local_history.h */
void history_enumerate_back(struct history *history,
history_enumerate_cb cb, void *user_data)
{
@@ -812,7 +812,7 @@ void history_enumerate_back(struct history *history,
}
}
-/* Documented in history_core.h */
+/* Documented in local_history.h */
void history_enumerate(const struct history *history, history_enumerate_cb cb,
void *user_data)
{
@@ -845,19 +845,19 @@ static bool history_enumerate_entry(const struct history *history,
return true;
}
-/* Documented in history_core.h */
+/* Documented in local_history.h */
const char *history_entry_get_url(const struct history_entry *entry)
{
return entry->page.url;
}
-/* Documented in history_core.h */
+/* Documented in local_history.h */
const char *history_entry_get_fragment_id(const struct history_entry *entry)
{
return entry->page.frag_id;
}
-/* Documented in history_core.h */
+/* Documented in local_history.h */
const char *history_entry_get_title(const struct history_entry *entry)
{
return entry->page.title;
diff --git a/desktop/history_core.h b/desktop/local_history.h
similarity index 100%
rename from desktop/history_core.h
rename to desktop/local_history.h
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index d9e78d7..c9adf6c 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -56,7 +56,7 @@
#include "framebuffer/font.h"
#include "content/urldb.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "content/fetch.h"
#define NSFB_TOOLBAR_DEFAULT_LAYOUT "blfsrutc"
diff --git a/framebuffer/localhistory.c b/framebuffer/localhistory.c
index e23dd1f..d482098 100644
--- a/framebuffer/localhistory.c
+++ b/framebuffer/localhistory.c
@@ -52,7 +52,7 @@
#include "framebuffer/font.h"
#include "content/urldb.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "content/fetch.h"
static int
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index b10fb69..c073698 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -33,7 +33,7 @@
#include "content/hlcache.h"
#include "css/utils.h"
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/hotlist.h"
#include "desktop/gui.h"
#include "desktop/netsurf.h"
diff --git a/riscos/history.c b/riscos/history.c
index 65ae847..be81e1a 100644
--- a/riscos/history.c
+++ b/riscos/history.c
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include "oslib/wimp.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "riscos/dialog.h"
#include "desktop/browser_private.h"
diff --git a/riscos/menus.c b/riscos/menus.c
index aaec8cf..337ca48 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -38,7 +38,7 @@
#include "desktop/browser.h"
#include "desktop/gui.h"
#include "desktop/history_global_core.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/hotlist.h"
#include "desktop/netsurf.h"
#include "desktop/textinput.h"
diff --git a/riscos/window.c b/riscos/window.c
index 772a0d1..8e0f0a0 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -49,7 +49,7 @@
#include "desktop/cookies.h"
#include "desktop/scrollbar.h"
#include "desktop/frames.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/hotlist.h"
#include "desktop/mouse.h"
#include "desktop/plotters.h"
diff --git a/windows/gui.c b/windows/gui.c
index f8d57fd..767f681 100644
--- a/windows/gui.c
+++ b/windows/gui.c
@@ -33,7 +33,7 @@
#include "content/fetch.h"
#include "css/utils.h"
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/mouse.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
diff --git a/windows/localhistory.c b/windows/localhistory.c
index f58ab81..0b29871 100644
--- a/windows/localhistory.c
+++ b/windows/localhistory.c
@@ -23,7 +23,7 @@
#include <commctrl.h>
#include "desktop/browser_private.h"
-#include "desktop/history_core.h"
+#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "utils/utils.h"
#include "utils/log.h"
--
NetSurf Browser
9 years, 10 months
netsurf: branch master updated. release/3.0-305-ged557f0
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/ed557f090a60a1c96dae9...
...commit http://git.netsurf-browser.org/netsurf.git/commit/ed557f090a60a1c96dae9bc...
...tree http://git.netsurf-browser.org/netsurf.git/tree/ed557f090a60a1c96dae9bc33...
The branch, master has been updated
via ed557f090a60a1c96dae9bc3319990d589bc60ec (commit)
from 0df23dda20d830f55f3237a5bb2c61b9a409b691 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ed557f090a60a1c96da...
commit ed557f090a60a1c96dae9bc3319990d589bc60ec
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Cursor down moves to next after noncontinuous selections.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 88f9cc0..c15c9ee 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1528,6 +1528,7 @@ struct treeview_nav_state {
treeview_node *next;
treeview_node *last;
int n_selected;
+ int prev_n_selected;
};
/** Treewalk node callback for handling mouse action. */
static nserror treeview_node_nav_cb(treeview_node *node, void *ctx,
@@ -1548,8 +1549,9 @@ static nserror treeview_node_nav_cb(treeview_node *node, void *ctx,
if (ns->n_selected == 0) {
ns->prev = node;
- } else if (ns->next == NULL) {
+ } else if (ns->prev_n_selected < ns->n_selected) {
ns->next = node;
+ ns->prev_n_selected = ns->n_selected;
}
}
ns->last = node;
@@ -1576,7 +1578,8 @@ static bool treeview_keyboard_navigation(treeview *tree, uint32_t key,
.curr = NULL,
.next = NULL,
.last = NULL,
- .n_selected = 0
+ .n_selected = 0,
+ .prev_n_selected = 0
};
bool redraw = false;
-----------------------------------------------------------------------
Summary of changes:
desktop/treeview.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 88f9cc0..c15c9ee 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1528,6 +1528,7 @@ struct treeview_nav_state {
treeview_node *next;
treeview_node *last;
int n_selected;
+ int prev_n_selected;
};
/** Treewalk node callback for handling mouse action. */
static nserror treeview_node_nav_cb(treeview_node *node, void *ctx,
@@ -1548,8 +1549,9 @@ static nserror treeview_node_nav_cb(treeview_node *node, void *ctx,
if (ns->n_selected == 0) {
ns->prev = node;
- } else if (ns->next == NULL) {
+ } else if (ns->prev_n_selected < ns->n_selected) {
ns->next = node;
+ ns->prev_n_selected = ns->n_selected;
}
}
ns->last = node;
@@ -1576,7 +1578,8 @@ static bool treeview_keyboard_navigation(treeview *tree, uint32_t key,
.curr = NULL,
.next = NULL,
.last = NULL,
- .n_selected = 0
+ .n_selected = 0,
+ .prev_n_selected = 0
};
bool redraw = false;
--
NetSurf Browser
9 years, 10 months
netsurf: branch master updated. release/3.0-304-g0df23dd
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/0df23dda20d830f55f323...
...commit http://git.netsurf-browser.org/netsurf.git/commit/0df23dda20d830f55f3237a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/0df23dda20d830f55f3237a5b...
The branch, master has been updated
via 0df23dda20d830f55f3237a5bb2c61b9a409b691 (commit)
from 11eed50de4064ad84e1693acb0abbf0599cbe30f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=0df23dda20d830f55f3...
commit 0df23dda20d830f55f3237a5bb2c61b9a409b691
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Cursor right toggles expansion.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 8dbfce5..88f9cc0 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1607,14 +1607,24 @@ static bool treeview_keyboard_navigation(treeview *tree, uint32_t key,
break;
case KEY_RIGHT:
- if (ns.curr != NULL &&
- ns.curr->children != NULL) {
- /* Step to first child */
+ if (ns.curr != NULL) {
if (!(ns.curr->flags & TREE_NODE_EXPANDED)) {
- /* Need to expand node */
+ /* Toggle node to expanded */
treeview_node_expand(tree, ns.curr);
+ if (ns.curr->children != NULL) {
+ /* Step to first child */
+ ns.curr->children->flags |=
+ TREE_NODE_SELECTED;
+ } else {
+ /* Retain current node selection */
+ ns.curr->flags |= TREE_NODE_SELECTED;
+ }
+ } else {
+ /* Toggle node to contracted */
+ treeview_node_contract(tree, ns.curr);
+ /* Retain current node selection */
+ ns.curr->flags |= TREE_NODE_SELECTED;
}
- ns.curr->children->flags |= TREE_NODE_SELECTED;
} else if (ns.curr != NULL) {
/* Retain current node selection */
-----------------------------------------------------------------------
Summary of changes:
desktop/treeview.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 8dbfce5..88f9cc0 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1607,14 +1607,24 @@ static bool treeview_keyboard_navigation(treeview *tree, uint32_t key,
break;
case KEY_RIGHT:
- if (ns.curr != NULL &&
- ns.curr->children != NULL) {
- /* Step to first child */
+ if (ns.curr != NULL) {
if (!(ns.curr->flags & TREE_NODE_EXPANDED)) {
- /* Need to expand node */
+ /* Toggle node to expanded */
treeview_node_expand(tree, ns.curr);
+ if (ns.curr->children != NULL) {
+ /* Step to first child */
+ ns.curr->children->flags |=
+ TREE_NODE_SELECTED;
+ } else {
+ /* Retain current node selection */
+ ns.curr->flags |= TREE_NODE_SELECTED;
+ }
+ } else {
+ /* Toggle node to contracted */
+ treeview_node_contract(tree, ns.curr);
+ /* Retain current node selection */
+ ns.curr->flags |= TREE_NODE_SELECTED;
}
- ns.curr->children->flags |= TREE_NODE_SELECTED;
} else if (ns.curr != NULL) {
/* Retain current node selection */
--
NetSurf Browser
9 years, 10 months
netsurf: branch master updated. release/3.0-303-g11eed50
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/11eed50de4064ad84e169...
...commit http://git.netsurf-browser.org/netsurf.git/commit/11eed50de4064ad84e1693a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/11eed50de4064ad84e1693acb...
The branch, master has been updated
via 11eed50de4064ad84e1693acb0abbf0599cbe30f (commit)
from 541bc8e283d078dfc1433e94a38012a2b1f86373 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=11eed50de4064ad84e1...
commit 11eed50de4064ad84e1693acb0abbf0599cbe30f
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
A couple of tidyups.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 4a87e86..8dbfce5 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1556,7 +1556,17 @@ static nserror treeview_node_nav_cb(treeview_node *node, void *ctx,
return NSERROR_OK;
}
-/* Exported interface, documented in treeview.h */
+/**
+ * Handle keyboard navigation.
+ *
+ * \param tree Treeview object to launch selected nodes in
+ * \param key The ucs4 character codepoint
+ * \param rect Updated to redraw rectangle
+ * \return true if treeview needs redraw, false otherwise
+ *
+ * Note: Selected entries are launched.
+ * Entries that are descendants of selected folders are also launched.
+ */
static bool treeview_keyboard_navigation(treeview *tree, uint32_t key,
struct rect *rect)
{
@@ -1651,38 +1661,38 @@ bool treeview_keypress(treeview *tree, uint32_t key)
assert(tree != NULL);
switch (key) {
- case KEY_SELECT_ALL:
- redraw = treeview_select_all(tree, &r);
- break;
- case KEY_COPY_SELECTION:
- /* TODO: Copy selection as text */
- break;
- case KEY_DELETE_LEFT:
- case KEY_DELETE_RIGHT:
- redraw = treeview_delete_selection(tree, &r);
-
- if (tree->flags & TREEVIEW_DEL_EMPTY_DIRS) {
- /* Delete any empty nodes */
- err = treeview_delete_empty_nodes(tree);
- r.y0 = 0;
- }
- break;
- case KEY_CR:
- case KEY_NL:
- err = treeview_launch_selection(tree);
- break;
- case KEY_ESCAPE:
- case KEY_CLEAR_SELECTION:
- redraw = treeview_clear_selection(tree, &r);
- break;
- case KEY_LEFT:
- case KEY_RIGHT:
- case KEY_UP:
- case KEY_DOWN:
- redraw = treeview_keyboard_navigation(tree, key, &r);
- break;
- default:
- return false;
+ case KEY_SELECT_ALL:
+ redraw = treeview_select_all(tree, &r);
+ break;
+ case KEY_COPY_SELECTION:
+ /* TODO: Copy selection as text */
+ break;
+ case KEY_DELETE_LEFT:
+ case KEY_DELETE_RIGHT:
+ redraw = treeview_delete_selection(tree, &r);
+
+ if (tree->flags & TREEVIEW_DEL_EMPTY_DIRS) {
+ /* Delete any empty nodes */
+ err = treeview_delete_empty_nodes(tree);
+ r.y0 = 0;
+ }
+ break;
+ case KEY_CR:
+ case KEY_NL:
+ err = treeview_launch_selection(tree);
+ break;
+ case KEY_ESCAPE:
+ case KEY_CLEAR_SELECTION:
+ redraw = treeview_clear_selection(tree, &r);
+ break;
+ case KEY_LEFT:
+ case KEY_RIGHT:
+ case KEY_UP:
+ case KEY_DOWN:
+ redraw = treeview_keyboard_navigation(tree, key, &r);
+ break;
+ default:
+ return false;
}
if (redraw) {
-----------------------------------------------------------------------
Summary of changes:
desktop/treeview.c | 76 +++++++++++++++++++++++++++++----------------------
1 files changed, 43 insertions(+), 33 deletions(-)
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 4a87e86..8dbfce5 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1556,7 +1556,17 @@ static nserror treeview_node_nav_cb(treeview_node *node, void *ctx,
return NSERROR_OK;
}
-/* Exported interface, documented in treeview.h */
+/**
+ * Handle keyboard navigation.
+ *
+ * \param tree Treeview object to launch selected nodes in
+ * \param key The ucs4 character codepoint
+ * \param rect Updated to redraw rectangle
+ * \return true if treeview needs redraw, false otherwise
+ *
+ * Note: Selected entries are launched.
+ * Entries that are descendants of selected folders are also launched.
+ */
static bool treeview_keyboard_navigation(treeview *tree, uint32_t key,
struct rect *rect)
{
@@ -1651,38 +1661,38 @@ bool treeview_keypress(treeview *tree, uint32_t key)
assert(tree != NULL);
switch (key) {
- case KEY_SELECT_ALL:
- redraw = treeview_select_all(tree, &r);
- break;
- case KEY_COPY_SELECTION:
- /* TODO: Copy selection as text */
- break;
- case KEY_DELETE_LEFT:
- case KEY_DELETE_RIGHT:
- redraw = treeview_delete_selection(tree, &r);
-
- if (tree->flags & TREEVIEW_DEL_EMPTY_DIRS) {
- /* Delete any empty nodes */
- err = treeview_delete_empty_nodes(tree);
- r.y0 = 0;
- }
- break;
- case KEY_CR:
- case KEY_NL:
- err = treeview_launch_selection(tree);
- break;
- case KEY_ESCAPE:
- case KEY_CLEAR_SELECTION:
- redraw = treeview_clear_selection(tree, &r);
- break;
- case KEY_LEFT:
- case KEY_RIGHT:
- case KEY_UP:
- case KEY_DOWN:
- redraw = treeview_keyboard_navigation(tree, key, &r);
- break;
- default:
- return false;
+ case KEY_SELECT_ALL:
+ redraw = treeview_select_all(tree, &r);
+ break;
+ case KEY_COPY_SELECTION:
+ /* TODO: Copy selection as text */
+ break;
+ case KEY_DELETE_LEFT:
+ case KEY_DELETE_RIGHT:
+ redraw = treeview_delete_selection(tree, &r);
+
+ if (tree->flags & TREEVIEW_DEL_EMPTY_DIRS) {
+ /* Delete any empty nodes */
+ err = treeview_delete_empty_nodes(tree);
+ r.y0 = 0;
+ }
+ break;
+ case KEY_CR:
+ case KEY_NL:
+ err = treeview_launch_selection(tree);
+ break;
+ case KEY_ESCAPE:
+ case KEY_CLEAR_SELECTION:
+ redraw = treeview_clear_selection(tree, &r);
+ break;
+ case KEY_LEFT:
+ case KEY_RIGHT:
+ case KEY_UP:
+ case KEY_DOWN:
+ redraw = treeview_keyboard_navigation(tree, key, &r);
+ break;
+ default:
+ return false;
}
if (redraw) {
--
NetSurf Browser
9 years, 10 months
netsurf: branch master updated. release/3.0-302-g541bc8e
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/541bc8e283d078dfc1433...
...commit http://git.netsurf-browser.org/netsurf.git/commit/541bc8e283d078dfc1433e9...
...tree http://git.netsurf-browser.org/netsurf.git/tree/541bc8e283d078dfc1433e94a...
The branch, master has been updated
via 541bc8e283d078dfc1433e94a38012a2b1f86373 (commit)
from e9401de768fa2a3c37bc3f13a06bb3bc32c8dc4c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=541bc8e283d078dfc14...
commit 541bc8e283d078dfc1433e94a38012a2b1f86373
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Initial keyboard navigation support.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 1e3ea1e..4a87e86 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1521,6 +1521,126 @@ static nserror treeview_launch_selection(treeview *tree)
}
+struct treeview_nav_state {
+ treeview *tree;
+ treeview_node *prev;
+ treeview_node *curr;
+ treeview_node *next;
+ treeview_node *last;
+ int n_selected;
+};
+/** Treewalk node callback for handling mouse action. */
+static nserror treeview_node_nav_cb(treeview_node *node, void *ctx,
+ bool *skip_children, bool *end)
+{
+ struct treeview_nav_state *ns = ctx;
+
+ if (node == ns->tree->root)
+ return NSERROR_OK;
+
+ if (node->flags & TREE_NODE_SELECTED) {
+ ns->n_selected++;
+ if (ns->curr == NULL) {
+ ns->curr = node;
+ }
+
+ } else {
+ if (ns->n_selected == 0) {
+ ns->prev = node;
+
+ } else if (ns->next == NULL) {
+ ns->next = node;
+ }
+ }
+ ns->last = node;
+
+ return NSERROR_OK;
+}
+/* Exported interface, documented in treeview.h */
+static bool treeview_keyboard_navigation(treeview *tree, uint32_t key,
+ struct rect *rect)
+{
+ struct treeview_nav_state ns = {
+ .tree = tree,
+ .prev = NULL,
+ .curr = NULL,
+ .next = NULL,
+ .last = NULL,
+ .n_selected = 0
+ };
+ bool redraw = false;
+
+ /* Fill out the nav. state struct, by examining the current selection
+ * state */
+ treeview_walk_internal(tree->root, false, NULL,
+ treeview_node_nav_cb, &ns);
+ if (ns.next == NULL)
+ ns.next = tree->root->children;
+ if (ns.prev == NULL)
+ ns.prev = ns.last;
+
+ /* Clear any existing selection */
+ redraw = treeview_clear_selection(tree, rect);
+
+ switch (key) {
+ case KEY_LEFT:
+ if (ns.curr != NULL &&
+ ns.curr->parent != NULL &&
+ ns.curr->parent->type != TREE_NODE_ROOT) {
+ /* Step to parent */
+ ns.curr->parent->flags |= TREE_NODE_SELECTED;
+
+ } else if (ns.curr != NULL && tree->root->children != NULL) {
+ /* Select first node in tree */
+ tree->root->children->flags |= TREE_NODE_SELECTED;
+ }
+ break;
+
+ case KEY_RIGHT:
+ if (ns.curr != NULL &&
+ ns.curr->children != NULL) {
+ /* Step to first child */
+ if (!(ns.curr->flags & TREE_NODE_EXPANDED)) {
+ /* Need to expand node */
+ treeview_node_expand(tree, ns.curr);
+ }
+ ns.curr->children->flags |= TREE_NODE_SELECTED;
+
+ } else if (ns.curr != NULL) {
+ /* Retain current node selection */
+ ns.curr->flags |= TREE_NODE_SELECTED;
+ }
+ break;
+
+ case KEY_UP:
+ if (ns.prev != NULL) {
+ /* Step to previous node */
+ ns.prev->flags |= TREE_NODE_SELECTED;
+ }
+ break;
+
+ case KEY_DOWN:
+ if (ns.next != NULL) {
+ /* Step to next node */
+ ns.next->flags |= TREE_NODE_SELECTED;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ /* TODO: Deal with redraw area properly */
+ rect->x0 = 0;
+ rect->y0 = 0;
+ rect->x1 = REDRAW_MAX;
+ rect->y1 = tree->root->height;
+ redraw = true;
+
+ return redraw;
+}
+
+
/* Exported interface, documented in treeview.h */
bool treeview_keypress(treeview *tree, uint32_t key)
{
@@ -1555,14 +1675,11 @@ bool treeview_keypress(treeview *tree, uint32_t key)
case KEY_CLEAR_SELECTION:
redraw = treeview_clear_selection(tree, &r);
break;
- /* TODO: Trivial keyboard navigation */
case KEY_LEFT:
- break;
case KEY_RIGHT:
- break;
case KEY_UP:
- break;
case KEY_DOWN:
+ redraw = treeview_keyboard_navigation(tree, key, &r);
break;
default:
return false;
@@ -1575,6 +1692,7 @@ bool treeview_keypress(treeview *tree, uint32_t key)
return true;
}
+
struct treeview_mouse_action {
treeview *tree;
browser_mouse_state mouse;
-----------------------------------------------------------------------
Summary of changes:
desktop/treeview.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 122 insertions(+), 4 deletions(-)
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 1e3ea1e..4a87e86 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1521,6 +1521,126 @@ static nserror treeview_launch_selection(treeview *tree)
}
+struct treeview_nav_state {
+ treeview *tree;
+ treeview_node *prev;
+ treeview_node *curr;
+ treeview_node *next;
+ treeview_node *last;
+ int n_selected;
+};
+/** Treewalk node callback for handling mouse action. */
+static nserror treeview_node_nav_cb(treeview_node *node, void *ctx,
+ bool *skip_children, bool *end)
+{
+ struct treeview_nav_state *ns = ctx;
+
+ if (node == ns->tree->root)
+ return NSERROR_OK;
+
+ if (node->flags & TREE_NODE_SELECTED) {
+ ns->n_selected++;
+ if (ns->curr == NULL) {
+ ns->curr = node;
+ }
+
+ } else {
+ if (ns->n_selected == 0) {
+ ns->prev = node;
+
+ } else if (ns->next == NULL) {
+ ns->next = node;
+ }
+ }
+ ns->last = node;
+
+ return NSERROR_OK;
+}
+/* Exported interface, documented in treeview.h */
+static bool treeview_keyboard_navigation(treeview *tree, uint32_t key,
+ struct rect *rect)
+{
+ struct treeview_nav_state ns = {
+ .tree = tree,
+ .prev = NULL,
+ .curr = NULL,
+ .next = NULL,
+ .last = NULL,
+ .n_selected = 0
+ };
+ bool redraw = false;
+
+ /* Fill out the nav. state struct, by examining the current selection
+ * state */
+ treeview_walk_internal(tree->root, false, NULL,
+ treeview_node_nav_cb, &ns);
+ if (ns.next == NULL)
+ ns.next = tree->root->children;
+ if (ns.prev == NULL)
+ ns.prev = ns.last;
+
+ /* Clear any existing selection */
+ redraw = treeview_clear_selection(tree, rect);
+
+ switch (key) {
+ case KEY_LEFT:
+ if (ns.curr != NULL &&
+ ns.curr->parent != NULL &&
+ ns.curr->parent->type != TREE_NODE_ROOT) {
+ /* Step to parent */
+ ns.curr->parent->flags |= TREE_NODE_SELECTED;
+
+ } else if (ns.curr != NULL && tree->root->children != NULL) {
+ /* Select first node in tree */
+ tree->root->children->flags |= TREE_NODE_SELECTED;
+ }
+ break;
+
+ case KEY_RIGHT:
+ if (ns.curr != NULL &&
+ ns.curr->children != NULL) {
+ /* Step to first child */
+ if (!(ns.curr->flags & TREE_NODE_EXPANDED)) {
+ /* Need to expand node */
+ treeview_node_expand(tree, ns.curr);
+ }
+ ns.curr->children->flags |= TREE_NODE_SELECTED;
+
+ } else if (ns.curr != NULL) {
+ /* Retain current node selection */
+ ns.curr->flags |= TREE_NODE_SELECTED;
+ }
+ break;
+
+ case KEY_UP:
+ if (ns.prev != NULL) {
+ /* Step to previous node */
+ ns.prev->flags |= TREE_NODE_SELECTED;
+ }
+ break;
+
+ case KEY_DOWN:
+ if (ns.next != NULL) {
+ /* Step to next node */
+ ns.next->flags |= TREE_NODE_SELECTED;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ /* TODO: Deal with redraw area properly */
+ rect->x0 = 0;
+ rect->y0 = 0;
+ rect->x1 = REDRAW_MAX;
+ rect->y1 = tree->root->height;
+ redraw = true;
+
+ return redraw;
+}
+
+
/* Exported interface, documented in treeview.h */
bool treeview_keypress(treeview *tree, uint32_t key)
{
@@ -1555,14 +1675,11 @@ bool treeview_keypress(treeview *tree, uint32_t key)
case KEY_CLEAR_SELECTION:
redraw = treeview_clear_selection(tree, &r);
break;
- /* TODO: Trivial keyboard navigation */
case KEY_LEFT:
- break;
case KEY_RIGHT:
- break;
case KEY_UP:
- break;
case KEY_DOWN:
+ redraw = treeview_keyboard_navigation(tree, key, &r);
break;
default:
return false;
@@ -1575,6 +1692,7 @@ bool treeview_keypress(treeview *tree, uint32_t key)
return true;
}
+
struct treeview_mouse_action {
treeview *tree;
browser_mouse_state mouse;
--
NetSurf Browser
9 years, 10 months
netsurf: branch master updated. release/3.0-301-ge9401de
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/e9401de768fa2a3c37bc3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/e9401de768fa2a3c37bc3f1...
...tree http://git.netsurf-browser.org/netsurf.git/tree/e9401de768fa2a3c37bc3f13a...
The branch, master has been updated
via e9401de768fa2a3c37bc3f13a06bb3bc32c8dc4c (commit)
from 81a1506c5c3a5b1581c3f16350a64ce58e695c09 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e9401de768fa2a3c37b...
commit e9401de768fa2a3c37bc3f13a06bb3bc32c8dc4c
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Move mix_colour macro out of treeview for other stuff to use.
diff --git a/desktop/plot_style.h b/desktop/plot_style.h
index f965a25..71243a9 100644
--- a/desktop/plot_style.h
+++ b/desktop/plot_style.h
@@ -66,6 +66,14 @@
(((c0 & 0xff0000) * 28) >> 24)) > \
(0xff / 2)) ? 0x000000 : 0xffffff)
+/* Mix two colours according to the proportion given by p, where 0 <= p <= 255
+ * p = 0 gives result ==> c1, p = 255 gives result ==> c0 */
+#define mix_colour(c0, c1, p) \
+ ((((((c1 & 0xff00ff) * (255 - p)) + \
+ ((c0 & 0xff00ff) * ( p)) ) >> 8) & 0xff00ff) | \
+ (((((c1 & 0x00ff00) * (255 - p)) + \
+ ((c0 & 0x00ff00) * ( p)) ) >> 8) & 0x00ff00))
+
/* get a bitmap pixel (image/bitmap.h) into a plot colour */
#define pixel_to_colour(b) \
b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 3895832..1e3ea1e 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1903,19 +1903,6 @@ void treeview_mouse_action(treeview *tree,
}
-
-/* Mix two colours according to the proportion given by p.
- * Where 0 <= p <= 255
- * p=0 gives result ==> c1
- * p=255 gives result ==> c0
- */
-#define mix_colour(c0, c1, p) \
- ((((((c1 & 0xff00ff) * (255 - p)) + \
- ((c0 & 0xff00ff) * ( p)) ) >> 8) & 0xff00ff) | \
- (((((c1 & 0x00ff00) * (255 - p)) + \
- ((c0 & 0x00ff00) * ( p)) ) >> 8) & 0x00ff00))
-
-
/**
* Initialise the plot styles from CSS system colour values.
*/
-----------------------------------------------------------------------
Summary of changes:
desktop/plot_style.h | 8 ++++++++
desktop/treeview.c | 13 -------------
2 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/desktop/plot_style.h b/desktop/plot_style.h
index f965a25..71243a9 100644
--- a/desktop/plot_style.h
+++ b/desktop/plot_style.h
@@ -66,6 +66,14 @@
(((c0 & 0xff0000) * 28) >> 24)) > \
(0xff / 2)) ? 0x000000 : 0xffffff)
+/* Mix two colours according to the proportion given by p, where 0 <= p <= 255
+ * p = 0 gives result ==> c1, p = 255 gives result ==> c0 */
+#define mix_colour(c0, c1, p) \
+ ((((((c1 & 0xff00ff) * (255 - p)) + \
+ ((c0 & 0xff00ff) * ( p)) ) >> 8) & 0xff00ff) | \
+ (((((c1 & 0x00ff00) * (255 - p)) + \
+ ((c0 & 0x00ff00) * ( p)) ) >> 8) & 0x00ff00))
+
/* get a bitmap pixel (image/bitmap.h) into a plot colour */
#define pixel_to_colour(b) \
b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 3895832..1e3ea1e 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1903,19 +1903,6 @@ void treeview_mouse_action(treeview *tree,
}
-
-/* Mix two colours according to the proportion given by p.
- * Where 0 <= p <= 255
- * p=0 gives result ==> c1
- * p=255 gives result ==> c0
- */
-#define mix_colour(c0, c1, p) \
- ((((((c1 & 0xff00ff) * (255 - p)) + \
- ((c0 & 0xff00ff) * ( p)) ) >> 8) & 0xff00ff) | \
- (((((c1 & 0x00ff00) * (255 - p)) + \
- ((c0 & 0x00ff00) * ( p)) ) >> 8) & 0x00ff00))
-
-
/**
* Initialise the plot styles from CSS system colour values.
*/
--
NetSurf Browser
9 years, 10 months
netsurf: branch master updated. release/3.0-300-g81a1506
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/81a1506c5c3a5b1581c3f...
...commit http://git.netsurf-browser.org/netsurf.git/commit/81a1506c5c3a5b1581c3f16...
...tree http://git.netsurf-browser.org/netsurf.git/tree/81a1506c5c3a5b1581c3f1635...
The branch, master has been updated
via 81a1506c5c3a5b1581c3f16350a64ce58e695c09 (commit)
from e8f2297d0fcfef6edfd024c838436b9c218d8aa9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=81a1506c5c3a5b1581c...
commit 81a1506c5c3a5b1581c3f16350a64ce58e695c09
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Launch selection launches entries within contracted folders.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index ead92ec..3895832 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1515,7 +1515,7 @@ static nserror treeview_launch_selection(treeview *tree)
lw.selected_depth = 0;
lw.tree = tree;
- return treeview_walk_internal(tree->root, false,
+ return treeview_walk_internal(tree->root, true,
treeview_node_launch_walk_bwd_cb,
treeview_node_launch_walk_fwd_cb, &lw);
}
-----------------------------------------------------------------------
Summary of changes:
desktop/treeview.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/desktop/treeview.c b/desktop/treeview.c
index ead92ec..3895832 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1515,7 +1515,7 @@ static nserror treeview_launch_selection(treeview *tree)
lw.selected_depth = 0;
lw.tree = tree;
- return treeview_walk_internal(tree->root, false,
+ return treeview_walk_internal(tree->root, true,
treeview_node_launch_walk_bwd_cb,
treeview_node_launch_walk_fwd_cb, &lw);
}
--
NetSurf Browser
9 years, 10 months