1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

bug 1009: id variables renamed, added document_id to the document.

cached->id => cached->cache_id
document->id => document->cache_id
onload_snippets_owner => onload_snippets_document_id
Added the distinct document->document_id.
Always reset ecmascript when a document changes for example a next chunk
of it is loaded.
This commit is contained in:
Witold Filipczyk 2008-04-20 22:25:10 +02:00 committed by Kalle Olavi Niemitalo
parent 10caf7a4bc
commit 232c07aa7f
8 changed files with 19 additions and 15 deletions

6
src/cache/cache.c vendored
View File

@ -150,7 +150,7 @@ get_cache_entry(struct uri *uri)
cached->valid = 1;
init_list(cached->frag);
cached->id = id_counter++;
cached->cache_id = id_counter++;
object_nolock(cached, "cache_entry"); /* Debugging purpose. */
cached->box_item = add_listbox_leaf(&cache_browser, NULL, cached);
@ -385,7 +385,7 @@ add_fragment(struct cache_entry *cached, off_t offset,
/* id marks each entry, and change each time it's modified,
* used in HTML renderer. */
cached->id = id_counter++;
cached->cache_id = id_counter++;
/* Possibly insert the new data in the middle of existing fragment. */
foreach (f, cached->frag) {
@ -639,7 +639,7 @@ delete_entry_content(struct cache_entry *cached)
del_from_list(f);
frag_free(f);
}
cached->id = id_counter++;
cached->cache_id = id_counter++;
cached->length = 0;
cached->incomplete = 1;

2
src/cache/cache.h vendored
View File

@ -42,7 +42,7 @@ struct cache_entry {
unsigned char *ssl_info; /* SSL ciphers used during transfer */
unsigned char *encoding_info; /* Encoding used during transfer */
unsigned int id; /* Change each time entry is modified. */
unsigned int cache_id; /* Change each time entry is modified. */
time_t seconds; /* Access time. Used by 'If-Modified-Since' */

2
src/cache/dialogs.c vendored
View File

@ -146,7 +146,7 @@ get_cache_entry_info(struct listbox_item *item, struct terminal *term)
#ifdef CONFIG_DEBUG
add_format_to_string(&msg, "\n%s: %d", "Refcount", get_object_refcount(cached));
add_format_to_string(&msg, "\n%s: %u", _("ID", term), cached->id);
add_format_to_string(&msg, "\n%s: %u", _("ID", term), cached->cache_id);
if (cached->head && *cached->head) {
add_format_to_string(&msg, "\n%s:\n\n%s", _("Header", term),

View File

@ -33,6 +33,7 @@
#include "util/string.h"
#include "viewer/text/link.h"
static int document_init_counter = 0;
static INIT_LIST_OF(struct document, format_cache);
@ -46,7 +47,7 @@ init_document(struct cache_entry *cached, struct document_options *options)
document->uri = get_uri_reference(cached->uri);
object_lock(cached);
document->id = cached->id;
document->cache_id = cached->cache_id;
document->cached = cached;
init_list(document->forms);
@ -55,6 +56,7 @@ init_document(struct cache_entry *cached, struct document_options *options)
#ifdef CONFIG_ECMASCRIPT
init_list(document->onload_snippets);
document->document_id = ++document_init_counter;
#endif
#ifdef CONFIG_COMBINE
@ -214,7 +216,7 @@ get_document_css_magic(struct document *document)
foreach_uri (uri, index, &document->css_imports) {
struct cache_entry *cached = find_in_cache(uri);
if (cached) css_magic += cached->id + cached->data_size;
if (cached) css_magic += cached->cache_id + cached->data_size;
}
return css_magic;
@ -256,7 +258,7 @@ get_cached_document(struct cache_entry *cached, struct document_options *options
continue;
if (options->no_cache
|| cached->id != document->id
|| cached->cache_id != document->cache_id
|| !check_document_css_magic(document)) {
if (!is_object_used(document)) {
done_document(document);
@ -289,7 +291,7 @@ shrink_format_cache(int whole)
/* Destroy obsolete renderer documents which are already
* out-of-sync. */
if (document->cached->id == document->id)
if (document->cached->cache_id == document->cache_id)
continue;
done_document(document);

View File

@ -166,6 +166,7 @@ struct document {
struct uri_list ecmascript_imports;
/** used by setTimeout */
timer_id_T timeout;
unsigned int document_id;
#endif
#ifdef CONFIG_CSS
/** @todo FIXME: We should externally maybe using cache_entry store the
@ -210,7 +211,7 @@ struct document {
/* Positions of the last base character.*/
int comb_x, comb_y;
#endif
unsigned int id; /**< Used to check cache entries. */
unsigned int cache_id; /**< Used to check cache entries. */
int cp;
int width, height; /**< size of document */

View File

@ -383,11 +383,12 @@ render_document(struct view_state *vs, struct document_view *doc_view,
* XXX: What happens if a document is still loading in the
* other tab when we press ^L here? */
if (vs->ecmascript_fragile
|| (vs->ecmascript && vs->ecmascript->onload_snippets_owner
&& document->id != vs->ecmascript->onload_snippets_owner))
|| (vs->ecmascript
&& vs->ecmascript->onload_snippets_document_id
&& document->document_id != vs->ecmascript->onload_snippets_document_id))
ecmascript_reset_state(vs);
assert(vs->ecmascript);
vs->ecmascript->onload_snippets_owner = document->id;
vs->ecmascript->onload_snippets_document_id = document->document_id;
/* Passing of the onload_snippets pointers gives *_snippets()
* some feeling of universality, shall we ever get any other

View File

@ -50,7 +50,7 @@ struct ecmascript_interpreter {
* ecmascript_fragile, but it can happen i.e. when the urrent document
* is reloaded in another tab and then you just cause the current tab
* to redraw. */
unsigned int onload_snippets_owner;
unsigned int onload_snippets_document_id;
};
/* Why is the interpreter bound to {struct view_state} instead of {struct

View File

@ -67,7 +67,7 @@ check_document_fragment(struct session *ses, struct document_view *doc_view)
struct cache_entry *cached = document->cached;
assert(cached);
if (cached->incomplete || cached->id != document->id) {
if (cached->incomplete || cached->cache_id != document->cache_id) {
done_string(&fragment);
return -2;
}