Start fixing for new cache.

svn path=/trunk/netsurf/; revision=10268
This commit is contained in:
Michael Drake 2010-04-07 12:45:18 +00:00
parent 20cb4a7a48
commit 4b54cca8b9

View File

@ -31,6 +31,8 @@
#include "oslib/osgbpb.h" #include "oslib/osgbpb.h"
#include "oslib/territory.h" #include "oslib/territory.h"
#include "oslib/wimp.h" #include "oslib/wimp.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h" #include "content/urldb.h"
#include "desktop/gui.h" #include "desktop/gui.h"
#include "desktop/history_core.h" #include "desktop/history_core.h"
@ -124,7 +126,7 @@ wimp_menu *current_menu;
/** Whether a menu is currently open */ /** Whether a menu is currently open */
bool current_menu_open = false; bool current_menu_open = false;
/** Object under menu, or 0 if no object. */ /** Object under menu, or 0 if no object. */
static struct content *current_menu_object = 0; static struct hlcache_handle *current_menu_object = 0;
/** URL of link under menu, or 0 if no link. */ /** URL of link under menu, or 0 if no link. */
static const char *current_menu_url = 0; static const char *current_menu_url = 0;
/** Menu of options for form select controls. */ /** Menu of options for form select controls. */
@ -495,19 +497,21 @@ void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w)
/* read the object under the pointer for a new gui_window menu */ /* read the object under the pointer for a new gui_window menu */
if ((!current_menu) && (menu == browser_menu)) { if ((!current_menu) && (menu == browser_menu)) {
hlcache_handle *c = g->bw->current_content;
g = ro_gui_window_lookup(w); g = ro_gui_window_lookup(w);
if (!ro_gui_window_to_window_pos(g, x, y, &pos)) if (!ro_gui_window_to_window_pos(g, x, y, &pos))
return; return;
current_menu_object = NULL; current_menu_object = NULL;
current_menu_url = NULL; current_menu_url = NULL;
if (g->bw->current_content) { if (c) {
switch (g->bw->current_content->type) { switch (content_get_type(c)) {
case CONTENT_HTML: { case CONTENT_HTML: {
struct box *box; struct box *box;
box = box_object_at_point(g->bw->current_content, pos.x, pos.y); box = box_object_at_point(c, pos.x, pos.y);
current_menu_object = box ? box->object : NULL; current_menu_object = box ? box->object : NULL;
box = box_href_at_point(g->bw->current_content, pos.x, pos.y); box = box_href_at_point(c, pos.x, pos.y);
current_menu_url = box ? box->href : NULL; current_menu_url = box ? box->href : NULL;
} }
break; break;
@ -515,7 +519,7 @@ void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w)
/* no object, no url */ /* no object, no url */
break; break;
default: default:
current_menu_object = g->bw->current_content; current_menu_object = c;
break; break;
} }
} }
@ -904,30 +908,31 @@ void ro_gui_prepare_navigate(struct gui_window *gui)
*/ */
void ro_gui_menu_prepare_pageinfo(struct gui_window *g) void ro_gui_menu_prepare_pageinfo(struct gui_window *g)
{ {
struct content *c = g->bw->current_content; struct hlcache_handle *h = g->bw->current_content;
char icon_buf[20] = "file_xxx"; char icon_buf[20] = "file_xxx";
char enc_buf[40]; char enc_buf[40];
char enc_token[10] = "Encoding0"; char enc_token[10] = "Encoding0";
const char *icon = icon_buf; const char *icon = icon_buf;
const char *title = "-"; const char *title, *url, *mime;
const char *url = "-";
const char *enc = "-"; const char *enc = "-";
const char *mime = "-";
assert(c); assert(h);
if (c->title) title = content_get_title(h);
title = c->title; if (title == NULL)
if (c->url) title = "-";
url = c->url; url = content_get_url(h);
if (c->mime_type) if (url == NULL)
mime = c->mime_type; url = "-";
mime = content_get_mime_type(h);
if (mime == NULL)
mime = "-";
sprintf(icon_buf, "file_%x", ro_content_filetype(c)); sprintf(icon_buf, "file_%x", ro_content_filetype(h));
if (!ro_gui_wimp_sprite_exists(icon_buf)) if (!ro_gui_wimp_sprite_exists(icon_buf))
sprintf(icon_buf, "file_xxx"); sprintf(icon_buf, "file_xxx");
if (c->type == CONTENT_HTML) { if (content_get_type(h) == CONTENT_HTML) {
if (c->data.html.encoding) { if (c->data.html.encoding) {
enc_token[8] = '0' + c->data.html.encoding_source; enc_token[8] = '0' + c->data.html.encoding_source;
snprintf(enc_buf, sizeof enc_buf, "%s (%s)", snprintf(enc_buf, sizeof enc_buf, "%s (%s)",