Commit a28afa84 authored by Kevin Bracey's avatar Kevin Bracey
Browse files

Modified to cope with withdrawal of #defines SELECT, INPUT etc.

Added right-align support.
parent 3f2cdce9
......@@ -1331,7 +1331,7 @@ static int browser_navigate_map(browser_data * b, int key)
if (tp && redraw_selected(b, tp) &&
(((tp->style & IMG) && (tp->type & TYPE_ISMAP)) ||
((tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_IMAGE)))
(tp->tagno == TAG_INPUT && HtmlINPUTtype(tp) == inputtype_IMAGE)))
{
int last_move = 4;
int last_key, start_key;
......@@ -1759,8 +1759,8 @@ int browser_pointer_check(int eventcode, WimpPollBlock * b, IdBlock * idb, brows
else mouse_set_pointer_shape(Mouse_Shape_Link);
}
else if (
tp &&
(tp->style & INPUT) &&
tp &&
tp->tagno == TAG_INPUT &&
HtmlINPUTtype(tp) == inputtype_IMAGE
)
mouse_set_pointer_shape(Mouse_Shape_Link);
......@@ -2109,7 +2109,7 @@ static HStream * browser_get_pointer_token_r(browser_data * b, reformat_cell * c
else if (
(tp->style & IMG) ||
(
(tp->style & INPUT) &&
tp->tagno == TAG_INPUT &&
HtmlINPUTtype(tp) == inputtype_IMAGE
)
)
......
......@@ -219,7 +219,7 @@ void * fetch_token_data_address(browser_data * b, HStream * token)
if (token->style & HR) return NULL;
if (token->style & IMG) return NULL;
if ((token->style & INPUT) && HtmlINPUTtype(token) == inputtype_IMAGE) return NULL;
if (token->tagno == TAG_INPUT && HtmlINPUTtype(token) == inputtype_IMAGE) return NULL;
/* Otherwise, return a pointer to the text */
......@@ -446,7 +446,7 @@ void fetch_preprocess_token(browser_data * b, HStream * tptr)
/* Deal with creating a new field as appropriate */
if (tptr->style & INPUT)
if (tptr->tagno == TAG_INPUT)
{
switch(HtmlINPUTtype(tptr))
{
......@@ -463,14 +463,14 @@ void fetch_preprocess_token(browser_data * b, HStream * tptr)
/* Handle text areas */
if ((tptr->style) & TEXTAREA)
if (tptr->tagno == TAG_TEXTAREA)
{
if (fetch_chkerror(b, form_new_field(b, tptr, form_textarea, tptr->text))) return;
}
/* Handle selection buttons */
if ((tptr->style) & SELECT)
if (tptr->tagno == TAG_SELECT)
{
if (fetch_chkerror(b, form_new_field(b, tptr, form_select, (char *) HtmlSELECToptions(tptr)))) return;
}
......
......@@ -1675,7 +1675,7 @@ static int form_input_box(browser_data * b, HStream * tp, BBox * box, int * lh,
/* the bounding box to account for the number of lines */
/* the area has. */
if (tp->style & TEXTAREA)
if (tp->tagno == TAG_TEXTAREA)
{
int r;
......@@ -2283,8 +2283,8 @@ static _kernel_oserror * form_start_textarea_edit(browser_data * b, HStream * tp
e = form_end_edit(b, 1, 0);
if (e) return e;
fe_single = !(tp->style & TEXTAREA);
fe_password = (tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_PASSWORD;
fe_single = tp->tagno != TAG_TEXTAREA;
fe_password = tp->tagno == TAG_INPUT && HtmlINPUTtype(tp) == inputtype_PASSWORD;
fe_browser = b;
fe_token = tp;
......@@ -4046,7 +4046,7 @@ static _kernel_oserror * form_cursor_y(int dir, int * used)
/* the new 'y' coordinate. The call returns the new index into */
/* whatever text the caret is in, into fe_index. */
if (tp->style & TEXTAREA) form_textarea_find_caret(p, fh, &fe_index, x, y);
if (tp->tagno == TAG_TEXTAREA) form_textarea_find_caret(p, fh, &fe_index, x, y);
/* If the index into the string hasn't changed, then the caret */
/* must have already been at the end of the text; in this */
......
......@@ -1679,9 +1679,9 @@ int handle_link_clicks(int eventcode, WimpPollBlock * b, IdBlock * idb, browser_
if (
(p->style & FORM) &&
(
(p->style & INPUT) ||
(p->style & TEXTAREA) ||
(p->style & SELECT)
(p->tagno == TAG_INPUT) ||
(p->tagno == TAG_TEXTAREA) ||
(p->tagno == TAG_SELECT)
)
)
{
......@@ -1689,7 +1689,7 @@ int handle_link_clicks(int eventcode, WimpPollBlock * b, IdBlock * idb, browser_
/* Get the offset into an IMAGE button type */
if ((p->style & INPUT) && HtmlINPUTtype(p) == inputtype_IMAGE && eventcode >= 0)
if (p->tagno == TAG_INPUT && HtmlINPUTtype(p) == inputtype_IMAGE && eventcode >= 0)
{
ChkError(image_return_click_offset(handle, p, &i, &x, &y));
}
......
......@@ -893,7 +893,7 @@ _kernel_oserror * image_new_image(browser_data * b, const char * url, HStream *
/* width and height fields according to any details in the */
/* HTML source. */
if (!background && !(tp->style & INPUT))
if (!background && tp->tagno != TAG_INPUT)
{
if (tp->cols > 0) idata[nimages].currw = tp->cols * 2;
if (tp->rows > 0) idata[nimages].currh = tp->rows * 2;
......
......@@ -172,7 +172,7 @@ int redraw_background_colour(browser_data * b,int foregroundcolour)
int redraw_token_colour(browser_data * b, HStream * t)
{
if (t->style & (INPUT | TEXTAREA | SELECT)) return 0;
if (t->tagno == TAG_INPUT || t->tagno == TAG_TEXTAREA || t->tagno == TAG_SELECT) return 0;
/* If the token represents a link, use different colours according */
/* to the state of that link (followed, unfollowed etc). */
......@@ -416,8 +416,8 @@ int redraw_start_x(browser_data * b, reformat_cell * cell, HStream * t, int line
/* else work out the centre alignment indentation. */
if ((t->style & CENTER) || ((t->type & TYPE_ALIGN_MASK) == TYPE_CENTRE)) align = 1;
if ((t->type & TYPE_ALIGN_MASK) == TYPE_RIGHT) align = 2;
if ((t->style & CENTER) || ((t->type & TYPE_ALIGN_MASK) == TYPE_CENTRE)) align = 1;
else if ((t->style & RIGHT) || (t->type & TYPE_ALIGN_MASK) == TYPE_RIGHT) align = 2;
if (align)
{
......@@ -1711,12 +1711,13 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
/* Deal with forms elements */
if (tp->style & (INPUT | TEXTAREA | SELECT))
if (tp->tagno == TAG_INPUT || tp->tagno == TAG_TEXTAREA || tp->tagno == TAG_SELECT)
{
/* A text-based element */
if (
(tp->style & (TEXTAREA | SELECT)) ||
tp->tagno == TAG_TEXTAREA ||
tp->tagno == TAG_SELECT ||
HtmlINPUTtype(tp) == inputtype_TEXT ||
HtmlINPUTtype(tp) == inputtype_PASSWORD
)
......@@ -1732,7 +1733,7 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
/* Set up the bounding box for a text area, with a minimum of 3 rows */
if (tp->style & TEXTAREA)
if (tp->tagno == TAG_TEXTAREA)
{
int r;
......@@ -1753,24 +1754,24 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
if (nocontent != tp)
{
redraw_input_field(b, tp, &box, redraw_token_colour(b, tp), !!(tp->style & SELECT));
redraw_input_field(b, tp, &box, redraw_token_colour(b, tp), tp->tagno == TAG_SELECT);
fm_set_font_colour(fh,
redraw_token_colour(b, tp),
(tp->style & SELECT) ? Redraw_Colour_BackGrey : Redraw_Colour_White);
(tp->tagno == TAG_SELECT) ? Redraw_Colour_BackGrey : Redraw_Colour_White);
form_textarea_redraw(b,
d->cdata[cn].t,
&box,
&r->redraw_area,
fh,
!!(tp->style & TEXTAREA),
(tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_PASSWORD);
tp->tagno == TAG_TEXTAREA,
tp->tagno == TAG_INPUT && HtmlINPUTtype(tp) == inputtype_PASSWORD);
}
/* If the element is a SELECT field, it needs a menu icon too */
if (tp->style & SELECT)
if (tp->tagno == TAG_SELECT)
{
int width, height, offset;
BBox icon;
......@@ -1984,7 +1985,7 @@ _kernel_oserror * redraw_draw_r(int toplevel, int xorg, int yorg, browser_data *
}
else if (redraw_selected(b, tp)) redraw_border_around_box(&box, b->selecol);
}
else if ((tp->style & INPUT) && redraw_selected(b, tp))
else if (tp->tagno == TAG_INPUT && redraw_selected(b, tp))
redraw_border_around_box(&box, b->selecol);
/* Redraw the image itself */
......
......@@ -184,7 +184,7 @@ _kernel_oserror * reformat_stop(browser_data * b)
static int reformat_istext(HStream * tp)
{
return (((tp->style) & (IMG | HR)) == 0 &&
!((tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_IMAGE));
!(tp->tagno == TAG_INPUT && HtmlINPUTtype(tp) == inputtype_IMAGE));
}
/*************************************************/
......@@ -302,17 +302,19 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned
/* Deal with forms: Text-based elements */
else if (w->tp->style & (INPUT | TEXTAREA | SELECT))
else if (w->tp->tagno == TAG_INPUT ||
w->tp->tagno == TAG_TEXTAREA ||
w->tp->tagno == TAG_SELECT)
{
if ( (w->tp->style & (TEXTAREA | SELECT) ||
if ( w->tp->tagno == TAG_TEXTAREA ||
w->tp->tagno == TAG_SELECT ||
HtmlINPUTtype(w->tp) == inputtype_TEXT ||
HtmlINPUTtype(w->tp) == inputtype_PASSWORD
)
)
{
int h, length, extra = 0;
if (w->tp->style & TEXTAREA)
if (w->tp->tagno == TAG_TEXTAREA)
{
/* Text areas */
......@@ -323,7 +325,7 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned
extra = 0;
}
else if (w->tp->style & SELECT)
else if (w->tp->tagno == TAG_SELECT)
{
/* SELECT elements (have pop-up menus) */
......@@ -1316,7 +1318,7 @@ static _kernel_oserror * reformat_check_height(int toplevel, browser_data * b, r
if (
(tp->style & IMG) ||
(
(tp->style & INPUT) &&
tp->tagno == TAG_INPUT &&
HtmlINPUTtype(tp) == inputtype_IMAGE
)
)
......@@ -1363,14 +1365,14 @@ static _kernel_oserror * reformat_check_height(int toplevel, browser_data * b, r
/* A few easy to work out forms elements */
else if ((tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_CHECKBOX)
else if (tp->tagno == TAG_INPUT && HtmlINPUTtype(tp) == inputtype_CHECKBOX)
{
read_sprite_size("fopton", NULL, &top);
top -= 8;
bot = 8;
}
else if ((tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_RADIO)
else if (tp->tagno == TAG_INPUT && HtmlINPUTtype(tp) == inputtype_RADIO)
{
read_sprite_size("fradioon", NULL, &top);
top -= 8;
......@@ -1527,7 +1529,7 @@ static _kernel_oserror * reformat_check_height(int toplevel, browser_data * b, r
/* Work out height of various forms elements */
if (tp->style & TEXTAREA)
if (tp->tagno == TAG_TEXTAREA)
{
/* Text areas, based on the number of rows */
......@@ -1538,7 +1540,7 @@ static _kernel_oserror * reformat_check_height(int toplevel, browser_data * b, r
top = (top + bot) * r + 12 - bot;
bot += 16;
}
else if (tp->style & SELECT)
else if (tp->tagno == TAG_SELECT)
{
/* Selection lists - a pop-up menu icon */
......@@ -1550,7 +1552,7 @@ static _kernel_oserror * reformat_check_height(int toplevel, browser_data * b, r
top += 8;
if (top + bot < h) top += h - top - bot;
}
else if (tp->style & INPUT)
else if (tp->tagno == TAG_INPUT)
{
/* General input types */
......@@ -2397,7 +2399,7 @@ static int reformat_reformatter_r(unsigned int flags, browser_data * b, reformat
/* region is next redrawn. */
if (tpCurr->style & IMG ||
((tpCurr->style & INPUT) && HtmlINPUTtype(tpCurr)==inputtype_IMAGE))
(tpCurr->tagno == TAG_INPUT && HtmlINPUTtype(tpCurr)==inputtype_IMAGE))
image_set_token_image_position(b, tpCurr, -1, -1);
/* If the image has a known width and height, the reformatter has */
......@@ -2803,7 +2805,7 @@ void reformat_change_text(browser_data * b, HStream * tp)
/* If we have ALT text for an image, strip off any preceeding */
/* spaces or [s, and any trailing spaces or ]s. */
else if (tp && tp->text && ((tp->style & IMG) || ((tp->style & INPUT) && HtmlINPUTtype(tp) == inputtype_IMAGE)))
else if (tp && tp->text && ((tp->style & IMG) || (tp->tagno == TAG_INPUT && HtmlINPUTtype(tp) == inputtype_IMAGE)))
{
char * start, * end;
char last;
......
......@@ -30,9 +30,10 @@
#define CanBeSelected(t) ( \
ISLINK(t) || \
((t)->style & (TEXTAREA | SELECT)) || \
(t)->tagno == TAG_TEXTAREA || \
(t)->tagno == TAG_SELECT || \
( \
((t)->style & INPUT) && \
((t)->tagno == TAG_INPUT) && \
(HtmlINPUTtype(t) != inputtype_HIDDEN) \
) \
)
......
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