Make the parasitic hack of the old tree code more robust. Now if the temp_treeview_test option is set, the global history and cookie manager will be replaced with their respective new implementations.
This commit is contained in:
parent
bb870de150
commit
2bd587add5
|
@ -101,6 +101,7 @@
|
||||||
#include "content/content.h"
|
#include "content/content.h"
|
||||||
#include "content/urldb.h"
|
#include "content/urldb.h"
|
||||||
#include "desktop/cookies_old.h"
|
#include "desktop/cookies_old.h"
|
||||||
|
#include "desktop/cookie_manager.h"
|
||||||
#include "utils/nsoption.h"
|
#include "utils/nsoption.h"
|
||||||
#include "utils/log.h"
|
#include "utils/log.h"
|
||||||
#include "utils/corestrings.h"
|
#include "utils/corestrings.h"
|
||||||
|
@ -2540,7 +2541,13 @@ char *urldb_get_cookie(nsurl *url, bool include_http_only)
|
||||||
version = c->version;
|
version = c->version;
|
||||||
|
|
||||||
c->last_used = now;
|
c->last_used = now;
|
||||||
cookies_schedule_update((struct cookie_data *)c);
|
|
||||||
|
if (nsoption_bool(temp_treeview_test) == false)
|
||||||
|
cookies_schedule_update(
|
||||||
|
(struct cookie_data *)c);
|
||||||
|
else
|
||||||
|
cookie_manager_add(
|
||||||
|
(struct cookie_data *)c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2575,7 +2582,13 @@ char *urldb_get_cookie(nsurl *url, bool include_http_only)
|
||||||
version = c->version;
|
version = c->version;
|
||||||
|
|
||||||
c->last_used = now;
|
c->last_used = now;
|
||||||
cookies_schedule_update((struct cookie_data *)c);
|
|
||||||
|
if (nsoption_bool(temp_treeview_test) == false)
|
||||||
|
cookies_schedule_update(
|
||||||
|
(struct cookie_data *)c);
|
||||||
|
else
|
||||||
|
cookie_manager_add(
|
||||||
|
(struct cookie_data *)c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2618,7 +2631,12 @@ char *urldb_get_cookie(nsurl *url, bool include_http_only)
|
||||||
version = c->version;
|
version = c->version;
|
||||||
|
|
||||||
c->last_used = now;
|
c->last_used = now;
|
||||||
cookies_schedule_update((struct cookie_data *)c);
|
|
||||||
|
if (nsoption_bool(temp_treeview_test) == false)
|
||||||
|
cookies_schedule_update(
|
||||||
|
(struct cookie_data *)c);
|
||||||
|
else
|
||||||
|
cookie_manager_add((struct cookie_data *)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2651,7 +2669,12 @@ char *urldb_get_cookie(nsurl *url, bool include_http_only)
|
||||||
version = c->version;
|
version = c->version;
|
||||||
|
|
||||||
c->last_used = now;
|
c->last_used = now;
|
||||||
cookies_schedule_update((struct cookie_data *)c);
|
|
||||||
|
if (nsoption_bool(temp_treeview_test) == false)
|
||||||
|
cookies_schedule_update(
|
||||||
|
(struct cookie_data *)c);
|
||||||
|
else
|
||||||
|
cookie_manager_add((struct cookie_data *)c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3406,7 +3429,11 @@ bool urldb_insert_cookie(struct cookie_internal_data *c, lwc_string *scheme,
|
||||||
else
|
else
|
||||||
p->cookies = d->next;
|
p->cookies = d->next;
|
||||||
|
|
||||||
|
if (nsoption_bool(temp_treeview_test) == false)
|
||||||
cookies_remove((struct cookie_data *)d);
|
cookies_remove((struct cookie_data *)d);
|
||||||
|
else
|
||||||
|
cookie_manager_remove((struct cookie_data *)d);
|
||||||
|
|
||||||
urldb_free_cookie(d);
|
urldb_free_cookie(d);
|
||||||
urldb_free_cookie(c);
|
urldb_free_cookie(c);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3422,10 +3449,17 @@ bool urldb_insert_cookie(struct cookie_internal_data *c, lwc_string *scheme,
|
||||||
else
|
else
|
||||||
p->cookies = c;
|
p->cookies = c;
|
||||||
|
|
||||||
|
if (nsoption_bool(temp_treeview_test) == false)
|
||||||
cookies_remove((struct cookie_data *)d);
|
cookies_remove((struct cookie_data *)d);
|
||||||
|
else
|
||||||
|
cookie_manager_remove((struct cookie_data *)d);
|
||||||
urldb_free_cookie(d);
|
urldb_free_cookie(d);
|
||||||
|
|
||||||
cookies_schedule_update((struct cookie_data *)c);
|
if (nsoption_bool(temp_treeview_test) == false)
|
||||||
|
cookies_schedule_update(
|
||||||
|
(struct cookie_data *)c);
|
||||||
|
else
|
||||||
|
cookie_manager_add((struct cookie_data *)c);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c->prev = p->cookies_end;
|
c->prev = p->cookies_end;
|
||||||
|
@ -3436,7 +3470,10 @@ bool urldb_insert_cookie(struct cookie_internal_data *c, lwc_string *scheme,
|
||||||
p->cookies = c;
|
p->cookies = c;
|
||||||
p->cookies_end = c;
|
p->cookies_end = c;
|
||||||
|
|
||||||
|
if (nsoption_bool(temp_treeview_test) == false)
|
||||||
cookies_schedule_update((struct cookie_data *)c);
|
cookies_schedule_update((struct cookie_data *)c);
|
||||||
|
else
|
||||||
|
cookie_manager_add((struct cookie_data *)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -392,7 +392,7 @@ bool cookies_initialise(struct tree *tree, const char* folder_icon_name, const c
|
||||||
*/
|
*/
|
||||||
unsigned int cookies_get_tree_flags(void)
|
unsigned int cookies_get_tree_flags(void)
|
||||||
{
|
{
|
||||||
return TREE_DELETE_EMPTY_DIRS;
|
return TREE_DELETE_EMPTY_DIRS | TREE_COOKIES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -297,7 +297,7 @@ bool history_global_initialise(struct tree *tree, const char* folder_icon_name)
|
||||||
*/
|
*/
|
||||||
unsigned int history_global_get_tree_flags(void)
|
unsigned int history_global_get_tree_flags(void)
|
||||||
{
|
{
|
||||||
return TREE_NO_FLAGS;
|
return TREE_NO_FLAGS | TREE_HISTORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ bool hotlist_initialise(struct tree *tree, const char *hotlist_path,
|
||||||
*/
|
*/
|
||||||
unsigned int hotlist_get_tree_flags(void)
|
unsigned int hotlist_get_tree_flags(void)
|
||||||
{
|
{
|
||||||
return TREE_MOVABLE;
|
return TREE_MOVABLE | TREE_HOTLIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ void sslcert_init(const char* icon_name)
|
||||||
*/
|
*/
|
||||||
unsigned int sslcert_get_tree_flags(void)
|
unsigned int sslcert_get_tree_flags(void)
|
||||||
{
|
{
|
||||||
return TREE_NO_DRAGS | TREE_NO_SELECT;
|
return TREE_NO_DRAGS | TREE_NO_SELECT | TREE_SSLCERT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -177,8 +177,11 @@ struct tree {
|
||||||
|
|
||||||
|
|
||||||
#include "desktop/treeview.h"
|
#include "desktop/treeview.h"
|
||||||
|
#include "desktop/cookie_manager.h"
|
||||||
#include "desktop/global_history.h"
|
#include "desktop/global_history.h"
|
||||||
|
|
||||||
|
int treeview_inits;
|
||||||
|
|
||||||
static void treeview_test_redraw_request(struct core_window *cw, struct rect r)
|
static void treeview_test_redraw_request(struct core_window *cw, struct rect r)
|
||||||
{
|
{
|
||||||
struct tree *tree = (struct tree *)cw;
|
struct tree *tree = (struct tree *)cw;
|
||||||
|
@ -238,10 +241,22 @@ static bool treeview_test_init(struct tree *tree)
|
||||||
if (nsoption_bool(temp_treeview_test) == false)
|
if (nsoption_bool(temp_treeview_test) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
treeview_inits++;
|
||||||
|
|
||||||
|
if (treeview_inits == 1)
|
||||||
treeview_init();
|
treeview_init();
|
||||||
|
|
||||||
|
if (tree->flags & TREE_COOKIES) {
|
||||||
|
err = cookie_manager_init(&cw_t, (struct core_window *)tree);
|
||||||
|
if (err != NSERROR_OK) {
|
||||||
|
warn_user("Couldn't init new cookie manager.", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tree->flags & TREE_HISTORY) {
|
||||||
err = global_history_init(&cw_t, (struct core_window *)tree);
|
err = global_history_init(&cw_t, (struct core_window *)tree);
|
||||||
if (err != NSERROR_OK) {
|
if (err != NSERROR_OK) {
|
||||||
warn_user("Duffed it.", 0);
|
warn_user("Couldn't init new global history.", 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -254,11 +269,22 @@ static bool treeview_test_fini(struct tree *tree)
|
||||||
if (nsoption_bool(temp_treeview_test) == false)
|
if (nsoption_bool(temp_treeview_test) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
err = global_history_fini();
|
if (tree->flags & TREE_COOKIES) {
|
||||||
treeview_fini();
|
err = cookie_manager_fini();
|
||||||
if (err != NSERROR_OK) {
|
if (err != NSERROR_OK) {
|
||||||
warn_user("Duffed it.", 0);
|
warn_user("Couldn't finalise cookie manager.", 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (tree->flags & TREE_HISTORY) {
|
||||||
|
err = global_history_fini();
|
||||||
|
if (err != NSERROR_OK) {
|
||||||
|
warn_user("Couldn't finalise cookie manager.", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (treeview_inits == 1)
|
||||||
|
treeview_fini();
|
||||||
|
treeview_inits--;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -277,10 +303,17 @@ static bool treeview_test_redraw(struct tree *tree, int x, int y,
|
||||||
clip.x1 = clip_x + clip_width;
|
clip.x1 = clip_x + clip_width;
|
||||||
clip.y1 = clip_y + clip_height;
|
clip.y1 = clip_y + clip_height;
|
||||||
|
|
||||||
global_history_redraw(x, y, &clip, ctx);
|
if (tree->flags & TREE_COOKIES) {
|
||||||
|
cookie_manager_redraw(x, y, &clip, ctx);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (tree->flags & TREE_HISTORY) {
|
||||||
|
global_history_redraw(x, y, &clip, ctx);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool treeview_test_mouse_action(struct tree *tree,
|
static bool treeview_test_mouse_action(struct tree *tree,
|
||||||
browser_mouse_state mouse, int x, int y)
|
browser_mouse_state mouse, int x, int y)
|
||||||
|
@ -288,20 +321,34 @@ static bool treeview_test_mouse_action(struct tree *tree,
|
||||||
if (nsoption_bool(temp_treeview_test) == false)
|
if (nsoption_bool(temp_treeview_test) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
global_history_mouse_action(mouse, x, y);
|
if (tree->flags & TREE_COOKIES) {
|
||||||
|
cookie_manager_mouse_action(mouse, x, y);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (tree->flags & TREE_HISTORY) {
|
||||||
|
global_history_mouse_action(mouse, x, y);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool treeview_test_keypress(struct tree *tree, uint32_t key)
|
static bool treeview_test_keypress(struct tree *tree, uint32_t key)
|
||||||
{
|
{
|
||||||
if (nsoption_bool(temp_treeview_test) == false)
|
if (nsoption_bool(temp_treeview_test) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
global_history_keypress(key);
|
if (tree->flags & TREE_COOKIES) {
|
||||||
|
cookie_manager_keypress(key);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (tree->flags & TREE_HISTORY) {
|
||||||
|
global_history_keypress(key);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -420,9 +467,7 @@ struct tree *tree_create(unsigned int flags,
|
||||||
|
|
||||||
tree_setup_colours();
|
tree_setup_colours();
|
||||||
|
|
||||||
if (flags == TREE_MOVABLE) {
|
|
||||||
treeview_test_init(tree);
|
treeview_test_init(tree);
|
||||||
}
|
|
||||||
|
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
@ -1267,9 +1312,7 @@ void tree_delete(struct tree *tree)
|
||||||
{
|
{
|
||||||
tree->redraw = false;
|
tree->redraw = false;
|
||||||
|
|
||||||
if (tree->flags == TREE_MOVABLE) {
|
|
||||||
treeview_test_fini(tree);
|
treeview_test_fini(tree);
|
||||||
}
|
|
||||||
|
|
||||||
if (tree->root->child != NULL)
|
if (tree->root->child != NULL)
|
||||||
tree_delete_node_internal(tree, tree->root->child, true);
|
tree_delete_node_internal(tree, tree->root->child, true);
|
||||||
|
@ -2196,12 +2239,10 @@ void tree_draw(struct tree *tree, int x, int y,
|
||||||
assert(tree != NULL);
|
assert(tree != NULL);
|
||||||
assert(tree->root != NULL);
|
assert(tree->root != NULL);
|
||||||
|
|
||||||
if (tree->flags == TREE_MOVABLE) {
|
|
||||||
if (treeview_test_redraw(tree, x, y, clip_x, clip_y,
|
if (treeview_test_redraw(tree, x, y, clip_x, clip_y,
|
||||||
clip_width, clip_height, ctx)) {
|
clip_width, clip_height, ctx)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Start knockout rendering if it's available for this plotter */
|
/* Start knockout rendering if it's available for this plotter */
|
||||||
if (ctx->plot->option_knockout)
|
if (ctx->plot->option_knockout)
|
||||||
|
@ -2567,11 +2608,9 @@ bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x,
|
||||||
assert(tree != NULL);
|
assert(tree != NULL);
|
||||||
assert(tree->root != NULL);
|
assert(tree->root != NULL);
|
||||||
|
|
||||||
if (tree->flags == TREE_MOVABLE) {
|
|
||||||
if (treeview_test_mouse_action(tree, mouse, x, y)) {
|
if (treeview_test_mouse_action(tree, mouse, x, y)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (tree->root->child == NULL)
|
if (tree->root->child == NULL)
|
||||||
return true;
|
return true;
|
||||||
|
@ -3026,11 +3065,9 @@ void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
|
||||||
*/
|
*/
|
||||||
bool tree_keypress(struct tree *tree, uint32_t key)
|
bool tree_keypress(struct tree *tree, uint32_t key)
|
||||||
{
|
{
|
||||||
if (tree->flags == TREE_MOVABLE) {
|
|
||||||
if (treeview_test_keypress(tree, key)) {
|
if (treeview_test_keypress(tree, key)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (tree->editing != NULL)
|
if (tree->editing != NULL)
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
|
|
@ -45,6 +45,11 @@ enum tree_flags {
|
||||||
* directory will be deleted
|
* directory will be deleted
|
||||||
* too.
|
* too.
|
||||||
*/
|
*/
|
||||||
|
/* The following are to aid transition to new treeviews */
|
||||||
|
TREE_HISTORY = 64,
|
||||||
|
TREE_COOKIES = 128,
|
||||||
|
TREE_SSLCERT = 256,
|
||||||
|
TREE_HOTLIST = 512
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A "flag" value to indicate the element data contains title
|
/** A "flag" value to indicate the element data contains title
|
||||||
|
|
Loading…
Reference in New Issue