Commit 6ff9e19e authored by Andrew Hodgkinson's avatar Andrew Hodgkinson
Browse files

Another intermediate version, rather more stable than the last I hope.

Lazy clearing of backgrounds - pages with the same background image or
colour won't be cleared to grey when going from one to the next anymore.

BODY element onLoad script attribute implemented properly (beyond the
Customer hackery).

Images use independent flex blocks for URL and transient fetch data;
greatly improved data throughput in image system as a result. Image
renumbering implemented - speeds up closing of pages / frames with
many images. Image xref is still rather slow though and images with
a 0 width or height specified in the HTML still cause an incorrectly
formatted page to appear.

Have, I think, fixed the "stops anti-aliasing" bug. Noticed that some
background images are not being processed as Fast (e.g. at the
Fibblesnork Lego Guide) - that old problem has reappeared, then.

Background images would cross reference when two pages had the same
background colour set in <body> elements but one was configured to use
document colours and one wasn't (so xref should not occur). Code was
looking at b->background_colour; corrected to call redraw_backcol(b).

Titles were added to the history according to the fetch URL not the
display URL, though the former is more likely to be in the history due
to the code execution order in the fetcher; changed to see whether this
improves upon the rather hit and miss addition of titles.

The 'about:' page now gets entered into the history (makes for much more
sensible behaviour if it is configured as a Home page, for example).
parent d78a1df8
......@@ -224,6 +224,35 @@ PlugInControl:asap
ClientPull:yes
SeeFetches:no
# Image garbage collection
# ========================
#
# CollectAfter - If 'yes', garbage collection occurs after a new page
# fetch is completed (free memory etc. permitting). This may
# mean higher transient memory requirements of course. If
# 'no', garbage collection occurs the moment a page is
# cleared ready for a new one to fetch. This will affect how
# high you might want to set UnusedImageLimit.
# FreeRAMLimit - If free memory falls below this amount when a new image is
# to be created, the garbage collection system is run to try
# and get more RAM. The amount is specified in kilobytes.
# Only as many images as need to be deleted to maintain the
# required free memory, are deleted. So, use 0 for unlimited
# (UnusedImageLimit becomes the only constraint).
# UnusedImageLimit - If the number of images a browser is holding ready for
# garbage collection exceeds the value given here, get rid
# of an unused image - so this number of unused images will
# be reached and thereafter maintained, since for each image
# created, one pending garbage collection is removed. Use
# zero to effectively disable image garbage collection;
# images from a current page are discard the moment that
# browser window goes to a new location. Use -1 for
# unlimited (FreeRAMLimit becomes the only constraint).
CollectAfter:yes
FreeRAMLimit:2097512
UnusedImageLimit:8
# Hotlist controls
# ================
#
......
......@@ -1266,12 +1266,15 @@ void fetch_preprocess_token(browser_data * b, HStream * tptr)
/* Try adding this title to the history, ignoring any errors */
history_add_title(browser_fetch_url(b), p);
history_add_title(browser_current_url(b), p);
}
}
if (tptr->tag == BODY)
{
int bg_set = 0;
int fg_set = 0;
/* The BODY tag. All sorts of exciting stuff in here... */
if (HtmlBODYbgcolour(tptr) != NULL_COLOUR)
......@@ -1292,6 +1295,8 @@ void fetch_preprocess_token(browser_data * b, HStream * tptr)
if (b->background_image < 0) b->antialias_colour = b->background_colour;
browser_update_bottom(b, 0);
bg_set = 1;
}
/* Background images */
......@@ -1302,19 +1307,31 @@ void fetch_preprocess_token(browser_data * b, HStream * tptr)
/* and remember the image number in the browser_data structure */
image_new_image(b, HtmlBODYbackground(tptr), tptr, 2, NULL);
b->antialias_colour = redraw_backcol(b); /* For the time being, at least */
bg_set = 1;
}
else
{
b->background_image = -1;
b->antialias_colour = redraw_backcol(b);
}
/* Get the rest of the colour info out */
if (HtmlBODYtext (tptr) != NULL_COLOUR) b->text_colour = HtmlBODYtext (tptr);
if (HtmlBODYlink (tptr) != NULL_COLOUR) b->link_colour = HtmlBODYlink (tptr);
if (HtmlBODYvlink(tptr) != NULL_COLOUR) b->used_colour = HtmlBODYvlink(tptr);
if (HtmlBODYalink(tptr) != NULL_COLOUR) b->followed_colour = HtmlBODYalink(tptr);
if (HtmlBODYtext (tptr) != NULL_COLOUR) fg_set = 1, b->text_colour = HtmlBODYtext (tptr);
if (HtmlBODYlink (tptr) != NULL_COLOUR) fg_set = 1, b->link_colour = HtmlBODYlink (tptr);
if (HtmlBODYvlink(tptr) != NULL_COLOUR) fg_set = 1, b->used_colour = HtmlBODYvlink(tptr);
if (HtmlBODYalink(tptr) != NULL_COLOUR) fg_set = 1, b->followed_colour = HtmlBODYalink(tptr);
/* Pull out the onload and onunload scripts */
if (HtmlBODYonload (tptr)) b->onload = HtmlBODYonload (tptr);
if (HtmlBODYonload(tptr)) b->onload = HtmlBODYonload(tptr);
else b->onload = bg_set ? "" : NULL;
if (HtmlBODYonunload(tptr)) b->onunload = HtmlBODYonunload(tptr);
else b->onunload = bg_set ? "" : NULL;
}
/* Deal with META... tags */
......@@ -1700,8 +1717,9 @@ void fetch_fetcher(browser_data * b)
/* Write to the global history */
if (
b->displayed == Display_Fetched_Page ||
b->displayed == Display_External_Image
b->displayed == Display_Fetched_Page ||
b->displayed == Display_External_Image ||
b->displayed == Display_About_Page
)
history_record(b, b->urlddata);
......@@ -1747,35 +1765,58 @@ void fetch_fetcher(browser_data * b)
b->final_token = NULL; /* Last HStream structure dealt with */
b->last_char = ' '; /* Last character dealt with */
b->background_colour = -1; /* Background colour, or -1 for default */
b->background_image = -1; /* Image no. of background image, 0=none */
b->text_colour = choices.text_colour; /* Body text default colour */
b->link_colour = choices.link_colour; /* Link text default colour */
b->used_colour = choices.used_colour; /* Followed link default colour */
b->antialias_colour = redraw_backcol(b); /* Colour to anti-alias to, or -1=none */
b->followed_colour = choices.followed_colour; /* Following link default colour */
b->selected_colour = choices.selected_colour; /* Selected (highlighted) link colour */
b->onload = NULL; /* <BODY onload> attribute */
b->onunload = NULL; /* <BODY onunload> attribute */
if (b->reloading || (b->onload == NULL && b->onunload == NULL))
{
b->background_colour = -1; /* Background colour, or -1 for default */
b->background_image = -1; /* Image no. of background image, 0=none */
b->antialias_colour = redraw_backcol(b); /* Colour to anti-alias to, or -1=none */
}
else
{
b->onload = NULL; /* <BODY onload> attribute */
b->onunload = NULL; /* <BODY onunload> attribute */
}
// Eeek! Needs doing, but not here. The SCRIPT callbacks would have gone off
// by now, so all of the functions just defined for this page are trashed;
// and trashed *after* the scripts have already run with the previous page's
// stuff visible. Fix me, fix me, fix me...
//
// /* For JavaScript, close down the old context for the window and */
// /* get a new one - we shouldn't be able to access things defined */
// /* in the previous page in this new page. */
//
// #ifdef JAVASCRIPT
//
// javascript_lose_context(b);
//
// if (fetch_chkerror(b, javascript_gain_context(b, b->ancestor))) return;
//
// #endif
/* If this was a History-based fetch, clear the flag */
b->from_history = 0;
b->from_history = 0;
/* Ensure the nesting level and filling frame counters are reset */
b->nesting_level = 0;
b->filling_frame = 0;
b->nesting_level = 0;
b->filling_frame = 0;
/* Allow scroll bars to be reset */
b->tools_lock = 1;
b->tools_lock = 1;
/* Cancel any pending automatic fetches */
if (b->meta_refresh_at) deregister_null_claimant(Wimp_ENull, (WimpEventHandler *) meta_check_refresh, b);
b->meta_refresh_at = 0;
b->meta_refresh_url = NULL;
......@@ -1829,6 +1870,10 @@ void fetch_fetcher(browser_data * b)
image_discard(b);
/* If forcing a reload, garbage collect immediately */
if (b->reloading) image_gc(b, 0, 1);
/* Flag that images need to be garbage collected later (as */
/* free memory drops down after the fetch), and call the */
/* garbage collector now since we may have exceeded the */
......@@ -1890,18 +1935,6 @@ void fetch_fetcher(browser_data * b)
toolbars_cancel_status(b, Toolbars_Status_Connecting);
toolbars_update_status(b, Toolbars_Status_Fetching);
// /* For JavaScript, close down the old context for the window and */
// /* get a new one - we shouldn't be able to access things defined */
// /* in the previous page in this new page. */
//
// #ifdef JAVASCRIPT
//
// javascript_lose_context(b);
//
// if (fetch_chkerror(b, javascript_gain_context(b, b->ancestor))) return;
//
// #endif
/* Since the new fetch is now official, update the current and previous */
/* page variables */
......@@ -2082,6 +2115,10 @@ _kernel_oserror * fetch_cancel(browser_data * b)
if (b->meta_refresh_at) deregister_null_claimant(Wimp_ENull, (WimpEventHandler *) meta_check_refresh, b);
b->meta_refresh_at = 0;
/* If an onLoad JavaScript specifier was present, cancel it too */
if (b->onload) b->onload = "";
/* If not fetching, exit here */
if (!fetch_fetching(b)) return NULL;
......
......@@ -2568,7 +2568,6 @@ browser_data * frames_find_target(browser_data * b, const char * target)
/* the relevant browser_data structure with */
/* frames_find_browser_from_index. */
/* */
/* */
/* Parameters: Pointer to a browser_data struct */
/* representing the parent (it and */
/* all its children are searched for */
......
This diff is collapsed.
......@@ -391,7 +391,6 @@
jsdocument_initialise_class(b);
jsdocument_define_document(b);
jsurl_define_location(b);
// JSObject *obj;
......@@ -1215,7 +1214,11 @@
case WIN_OPENER:
{
if (decoder->opener && !JSVAL_TO_OBJECT(*vp)) decoder->opener = NULL;
if (
decoder->opener &&
!JSVAL_TO_OBJECT(*vp)
)
decoder->opener = NULL;
}
break;
......
......@@ -114,6 +114,8 @@ _kernel_oserror * javascript_body_onload(browser_data * b)
if (tl & (1u<<24)) Printf("javascript_body_onload: Called\n");
#endif
if (!b->onload || !*b->onload) return NULL;
#ifdef CUSTOMER_SPECIAL
/* Only call customer_ functions if on the customer's site */
......@@ -125,7 +127,19 @@ _kernel_oserror * javascript_body_onload(browser_data * b)
#endif
b->onload = NULL;
/* This is a bit unusual as the Customer hack existed before any real */
/* JS support, hence the function itself being 'live' even in non JS */
/* builds. */
#ifdef JAVASCRIPT
e = javascript_process_script(b, b->onload);
#endif
/* Prevent multiple script executions... */
b->onload = "";
return e;
}
......
......@@ -2866,6 +2866,24 @@ static int reformat_reformatter_r(unsigned int flags, browser_data * b, reformat
if (!newchunks) bottom = y;
/* If this is the first line for a whole page, see if we should */
/* now clear the background colour and image */
if (!d->table && !d->nlines)
{
if (!b->onload && !b->onunload)
{
b->background_colour = -1; /* Background colour, or -1 for default */
b->background_image = -1; /* Image no. of background image, 0=none */
b->antialias_colour = redraw_backcol(b); /* Colour to anti-alias to, or -1=none */
browser_update_bottom(b, 0);
b->onload = "";
b->onunload = "";
}
}
/* Add the new line structure */
e = reformat_add_line(b, d);
......
......@@ -1025,3 +1025,51 @@ int tokenutils_within_distance(browser_data * b, HStream * t1, HStream * t2, int
return (check <= distance);
}
/*************************************************/
/* tokenutils_background_colour() */
/* */
/* See what background colour should be used for */
/* a body text token; deals with tables, going */
/* down through the structure until something */
/* with a background colour is found (just */
/* checking the immediate local table or cell is */
/* not good enough as a background colour from */
/* an outer level table as part of a nested set */
/* of cells may be what is showing through). */
/* */
/* Parameters: Pointer to a browser_data struct */
/* relevant to the token; */
/* */
/* Pointer to the HStream struct */
/* who's background colour should be */
/* returned. */
/* */
/* Returns: Background colour as BBGGRR00, */
/* or -1 if none was found (so you */
/* should use redraw_backcol() or */
/* any page background image). */
/*************************************************/
int tokenutils_background_colour(browser_data * b, HStream * t)
{
while (t && t->parent)
{
table_headdata * head = t->parent;
table_row * row = NULL;
table_stream * table = NULL;
if (head) row = head->parent;
if (row) table = row->parent;
if (table)
{
if (TD_HAS_BGCOL(head)) return TD_BGCOL(head);
if (TABLE_HAS_BGCOL(table)) return TABLE_BGCOL(table);
}
t = (HStream *) table;
}
return -1;
}
......@@ -1804,7 +1804,7 @@ void urlutils_set_displayed(browser_data * b, char * iurl)
}
/*************************************************/
/* Urlutils_check_protocols() */
/* urlutils_check_protocols() */
/* */
/* Checks a given URL to see if the fetch */
/* protocol it specifies can be handled. */
......
......@@ -531,9 +531,18 @@ _kernel_oserror * windows_create_browser(const char * url, browser_data * real_p
#ifdef JAVASCRIPT
/* Get an execution context for this window */
if (save_type == Windows_CreateBrowser_AsJSChild && real_parent)
{
/* Get an execution context using the parent */
RetError(javascript_gain_context(b, real_parent));
}
else
{
/* Get an execution context using any ancestor */
RetError(javascript_gain_context(b, b->ancestor));
RetError(javascript_gain_context(b, b->ancestor));
}
#endif
......@@ -1129,11 +1138,16 @@ int windows_open_browser(int eventcode, WimpPollBlock * b, IdBlock * idb, browse
}
else
{
b->open_window_request.visible_area.xmin = s.visible_area.xmin;
b->open_window_request.visible_area.xmax = s.visible_area.xmax;
int add, rmarg;
convert_to_os(choices.right_margin, &rmarg);
if (s.visible_area.xmax - s.visible_area.xmin > handle->display_extent) add = s.visible_area.xmax - s.visible_area.xmin;
else if (s.visible_area.xmax - s.visible_area.xmin < handle->display_extent) add = handle->display_extent + rmarg * 2; /* To give a reasonable right border gap */
else add = handle->display_extent;
w.xmin = s.visible_area.xmin;
w.xmax = s.visible_area.xmax;
w.xmin = b->open_window_request.visible_area.xmin = s.visible_area.xmin;
w.xmax = b->open_window_request.visible_area.xmax = s.visible_area.xmin + add;
}
b->open_window_request.visible_area.ymin = s.visible_area.ymin - o.outline.ymin + (shift ? 128 : 0);
......
......@@ -42,6 +42,18 @@
#define ImageDefaultOSSize_X 48
#define ImageDefaultOSSize_Y 48
/* The image_flex structure is used to hold flex anchors. It is */
/* attached to image_info (below) in a small malloc block; since */
/* image_info structs are held in a flex area they cannot hold */
/* the flex anchors directly. */
typedef struct image_flex
{
char * urldata;
void * fetchdata;
}
image_flex;
/* The image_info structure is used for the image handling code, */
/* where each image has associated data about its size, fetch */
/* status and so-on. */
......@@ -59,10 +71,7 @@ typedef struct image_info
int x; /* X position on the page for the owner */
int y; /* Y position on the page for the owner */
int dataoffset; /* Offset of image data within image data block */
int alloc; /* Total space allocated in flex block */
int ualloc; /* Space allocated to url in flex block */
int isize; /* Size of image storage used */
image_flex * flex; /* For URL data, fetch data etc. */
HStream * token; /* Token this image appears in - may be NULL (pending GC) */
time_t last_used; /* Time when the image was last used (for GC purposes) */
......@@ -73,6 +82,8 @@ typedef struct image_info
int bytesgot; /* Total bytes fetched for this image so far */
unsigned int deleted :1; /* Image is marked as deleted (so remove it from array ASAP!) */
unsigned int started :1; /* The fetch has started to happen */
unsigned int fetched :1; /* Flag indicating the image is fetched */
unsigned int delayed :1; /* Flag indicating the image is delayed (by delayimages option) */
......
......@@ -44,3 +44,5 @@ reformat_cell * tokenutils_find_cell (reformat_cell * cell, int depth,
void tokenutils_token_offset (browser_data * b, token_path * path, int * offset_x, int * offset_y);
reformat_cell * tokenutils_token_cell (browser_data * b, HStream * token);
int tokenutils_within_distance (browser_data * b, HStream * t1, HStream * t2, int distance);
int tokenutils_background_colour (browser_data * b, HStream * t);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment