From cf64f0f4bb6db65eb35928f5c27830c78a043123 Mon Sep 17 00:00:00 2001 From: Kevin Bracey <kbracey@gitlab.riscosopen.org> Date: Thu, 24 Jul 1997 16:12:13 +0000 Subject: [PATCH] Updated code to extract attributes from BODY tag, including event info. --- c/Fetch | 33 +++++++++++++++++++-------------- c/Images | 2 +- h/Global | 5 +++++ h/Images | 2 +- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/c/Fetch b/c/Fetch index ad35a1f..d0bddda 100644 --- a/c/Fetch +++ b/c/Fetch @@ -616,24 +616,23 @@ void fetch_preprocess_token(browser_data * b, HStream * tptr) } } - if (tptr->style & IMG) + if (tptr->tag == BODY) { - /* A background image. */ + /* The BODY tag. All sorts of exciting stuff in here... */ - if (tptr->src) + if (HtmlBODYbackground(tptr)) { /* If there's a URL for the image, ask the image library for it */ /* and remember the image number in the browser_data structure */ - image_new_image(b, tptr->src, tptr, 2); + image_new_image(b, HtmlBODYbackground(tptr), tptr, 2); } - /* In the case of a background, the maxlen field in the HStream structure */ - /* is used to hold a 24-bit background colour, or '-1' for 'default'. */ + /* Get the 24-bit background colour, if any. */ - if (tptr->maxlen != (unsigned int) - 1) + if (HtmlBODYbgcolour(tptr) != NULL_COLOUR) { - b->backgroundcol = tptr->maxlen; + b->backgroundcol = HtmlBODYbgcolour(tptr); #ifdef TRACE if (tl & (1u<<6)) Printf("fetch_preprocess_token: Background colour set to %d\n", b->backgroundcol); @@ -648,13 +647,16 @@ void fetch_preprocess_token(browser_data * b, HStream * tptr) browser_update_bottom(b, 0); } - /* In a manner similar to the background colour handling above, */ - /* the 'size', 'rows' and 'cols' fields of the HStream struct */ - /* are used to hold colour information. */ + /* Get the rest of the colour info out. */ - if ((tptr->size) != (unsigned int) -1) b->textcol = tptr->size; - if ((tptr->rows) != (unsigned int) -1) b->linkcol = tptr->rows; - if ((tptr->cols) != (unsigned int) -1) b->usedcol = tptr->cols; + if (HtmlBODYtext(tptr) != NULL_COLOUR) b->textcol = HtmlBODYtext(tptr); + if (HtmlBODYlink(tptr) != NULL_COLOUR) b->linkcol = HtmlBODYlink(tptr); + if (HtmlBODYvlink(tptr) != NULL_COLOUR) b->usedcol = HtmlBODYvlink(tptr); + if (HtmlBODYalink(tptr) != NULL_COLOUR) b->follcol = HtmlBODYalink(tptr); + + /* Also pull out the onload and onunload scripts. */ + if (HtmlBODYonload(tptr)) b->onload = HtmlBODYonload(tptr); + if (HtmlBODYonunload(tptr)) b->onunload = HtmlBODYonunload(tptr); } /* Closure of long else to see if the HStream structure represented */ @@ -1022,6 +1024,9 @@ void fetch_fetcher(browser_data * b) b->follcol = choices.col_foll; /* Following link default colour */ b->selecol = choices.col_sele; /* Selected (highlighted) link colour */ + b->onload = NULL; /* <BODY onload> attribute */ + b->onunload = NULL; /* <BODY onunload> attribute */ + /* Ensure the nesting level and filling frame counters are reset */ b->nesting_level = 0; diff --git a/c/Images b/c/Images index f5fc740..ee4c9f7 100644 --- a/c/Images +++ b/c/Images @@ -730,7 +730,7 @@ void image_abort_fetches(browser_data * b) /* sprite for fast plotting. */ /*************************************************/ -_kernel_oserror * image_new_image(browser_data * b, char * url, HStream * token, int background) +_kernel_oserror * image_new_image(browser_data * b, const char * url, HStream * token, int background) { int size, ok, ulen, xref; HStream * tp; diff --git a/h/Global b/h/Global index 40639ef..ef709e8 100644 --- a/h/Global +++ b/h/Global @@ -262,6 +262,11 @@ typedef struct browser_data bistate_type bistate; /* Type of a bistate button, if one is present. */ int bistate_state; /* Current state of the bistate button. */ + /* JavaScript support */ + + const char * onload; /* The onLoad attribute specified in the BODY start tag. */ + const char * onunload; /* The onUnload attribute specified in the BODY start tag. */ + /* General page display information */ int backgroundcol; /* Background colour. */ diff --git a/h/Images b/h/Images index d9c2ef6..59b81d0 100644 --- a/h/Images +++ b/h/Images @@ -75,7 +75,7 @@ typedef struct image_info /* Function prototypes */ -_kernel_oserror * image_new_image (browser_data * b, char * url, HStream * token, int background); +_kernel_oserror * image_new_image (browser_data * b, const char * url, HStream * token, int background); void image_abort_fetches (browser_data * b); _kernel_oserror * image_process_null (browser_data * b); _kernel_oserror * image_discard (browser_data * b); -- GitLab