mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
Make html_top have a pointer type; use it to declare format and par_format
This commit is contained in:
parent
db11b6452f
commit
5808b4ae0c
@ -114,9 +114,9 @@ struct html_context {
|
||||
void *(*special_f)(struct html_context *, enum html_special_type, ...);
|
||||
};
|
||||
|
||||
#define format (((struct html_element *) html_context->stack.next)->attr)
|
||||
#define par_format (((struct html_element *) html_context->stack.next)->parattr)
|
||||
#define html_top (*(struct html_element *) html_context->stack.next)
|
||||
#define html_top ((struct html_element *) html_context->stack.next)
|
||||
#define format (html_top->attr)
|
||||
#define par_format (html_top->parattr)
|
||||
|
||||
#define html_is_preformatted() (format.style.attr & AT_PREFORMATTED)
|
||||
|
||||
|
@ -93,7 +93,7 @@ get_target(struct document_options *options, unsigned char *a)
|
||||
void
|
||||
ln_break(struct html_context *html_context, int n)
|
||||
{
|
||||
if (!n || html_top.invisible) return;
|
||||
if (!n || html_top->invisible) return;
|
||||
while (n > html_context->line_breax) {
|
||||
html_context->line_breax++;
|
||||
html_context->line_break_f(html_context);
|
||||
@ -108,7 +108,7 @@ put_chrs(struct html_context *html_context, unsigned char *start, int len)
|
||||
if (html_is_preformatted())
|
||||
html_context->putsp = HTML_SPACE_NORMAL;
|
||||
|
||||
if (!len || html_top.invisible)
|
||||
if (!len || html_top->invisible)
|
||||
return;
|
||||
|
||||
switch (html_context->putsp) {
|
||||
@ -258,8 +258,8 @@ html_focusable(struct html_context *html_context, unsigned char *a)
|
||||
void
|
||||
html_skip(struct html_context *html_context, unsigned char *a)
|
||||
{
|
||||
html_top.invisible = 1;
|
||||
html_top.type = ELEMENT_DONT_KILL;
|
||||
html_top->invisible = 1;
|
||||
html_top->type = ELEMENT_DONT_KILL;
|
||||
}
|
||||
|
||||
void
|
||||
@ -666,7 +666,7 @@ init_html_parser_state(struct html_context *html_context,
|
||||
struct html_element *element;
|
||||
|
||||
html_stack_dup(html_context, type);
|
||||
element = &html_top;
|
||||
element = html_top;
|
||||
|
||||
par_format.align = align;
|
||||
|
||||
@ -677,7 +677,7 @@ init_html_parser_state(struct html_context *html_context,
|
||||
par_format.list_level = 0;
|
||||
par_format.list_number = 0;
|
||||
par_format.dd_margin = 0;
|
||||
html_top.namelen = 0;
|
||||
html_top->namelen = 0;
|
||||
}
|
||||
|
||||
return element;
|
||||
@ -691,20 +691,20 @@ done_html_parser_state(struct html_context *html_context,
|
||||
{
|
||||
html_context->line_breax = 1;
|
||||
|
||||
while (&html_top != element) {
|
||||
kill_html_stack_item(html_context, &html_top);
|
||||
while (html_top != element) {
|
||||
kill_html_stack_item(html_context, html_top);
|
||||
#if 0
|
||||
/* I've preserved this bit to show an example of the Old Code
|
||||
* of the Mikulas days (I _HOPE_ it's by Mikulas, at least ;-).
|
||||
* I think this assert() can never fail, for one. --pasky */
|
||||
assertm(&html_top && (void *) &html_top != (void *) &html_stack,
|
||||
assertm(html_top && (void *) html_top != (void *) &html_stack,
|
||||
"html stack trashed");
|
||||
if_assert_failed break;
|
||||
#endif
|
||||
}
|
||||
|
||||
html_top.type = ELEMENT_KILLABLE;
|
||||
kill_html_stack_item(html_context, &html_top);
|
||||
html_top->type = ELEMENT_KILLABLE;
|
||||
kill_html_stack_item(html_context, html_top);
|
||||
|
||||
}
|
||||
|
||||
@ -777,12 +777,12 @@ init_html_parser(struct uri *uri, struct document_options *options,
|
||||
|
||||
par_format.bgcolor = options->default_bg;
|
||||
|
||||
html_top.invisible = 0;
|
||||
html_top.name = NULL;
|
||||
html_top.namelen = 0;
|
||||
html_top.options = NULL;
|
||||
html_top.linebreak = 1;
|
||||
html_top.type = ELEMENT_DONT_KILL;
|
||||
html_top->invisible = 0;
|
||||
html_top->name = NULL;
|
||||
html_top->namelen = 0;
|
||||
html_top->options = NULL;
|
||||
html_top->linebreak = 1;
|
||||
html_top->type = ELEMENT_DONT_KILL;
|
||||
|
||||
html_context->has_link_lines = 0;
|
||||
html_context->table_level = 0;
|
||||
|
@ -254,7 +254,7 @@ html_input_format(struct html_context *html_context, unsigned char *a,
|
||||
case FC_HIDDEN:
|
||||
INTERNAL("bad control type");
|
||||
}
|
||||
kill_html_stack_item(html_context, &html_top);
|
||||
kill_html_stack_item(html_context, html_top);
|
||||
put_chrs(html_context, " ", 1);
|
||||
}
|
||||
|
||||
@ -498,7 +498,7 @@ end_parse:
|
||||
for (i = 0; i < max_width; i++)
|
||||
put_chrs(html_context, "_", 1);
|
||||
|
||||
kill_html_stack_item(html_context, &html_top);
|
||||
kill_html_stack_item(html_context, html_top);
|
||||
put_chrs(html_context, "]", 1);
|
||||
html_context->special_f(html_context, SP_CONTROL, fc);
|
||||
}
|
||||
@ -513,7 +513,7 @@ do_html_select_multiple(struct html_context *html_context, unsigned char *a,
|
||||
|
||||
if (!al) return;
|
||||
html_focusable(html_context, a);
|
||||
html_top.type = ELEMENT_DONT_KILL;
|
||||
html_top->type = ELEMENT_DONT_KILL;
|
||||
mem_free_set(&format.select, al);
|
||||
format.select_disabled = has_attr(a, "disabled", html_context->options)
|
||||
? FORM_MODE_DISABLED
|
||||
@ -603,7 +603,7 @@ end_parse:
|
||||
format.form = fc;
|
||||
format.style.attr |= AT_BOLD;
|
||||
put_chrs(html_context, "[ ]", 3);
|
||||
kill_html_stack_item(html_context, &html_top);
|
||||
kill_html_stack_item(html_context, html_top);
|
||||
put_chrs(html_context, " ", 1);
|
||||
html_context->special_f(html_context, SP_CONTROL, fc);
|
||||
}
|
||||
@ -709,7 +709,7 @@ pp:
|
||||
ln_break(html_context, 1);
|
||||
}
|
||||
|
||||
kill_html_stack_item(html_context, &html_top);
|
||||
kill_html_stack_item(html_context, html_top);
|
||||
if (rows > 1)
|
||||
ln_break(html_context, 1);
|
||||
else
|
||||
|
@ -141,7 +141,7 @@ html_apply_canvas_bgcolor(struct html_context *html_context)
|
||||
/* If there are any CSS twaks regarding bgcolor, make sure we will get
|
||||
* it _and_ prefer it over bgcolor attribute. */
|
||||
if (html_context->options->css_enable)
|
||||
css_apply(html_context, &html_top, &html_context->css_styles,
|
||||
css_apply(html_context, html_top, &html_context->css_styles,
|
||||
&html_context->stack);
|
||||
#endif
|
||||
|
||||
@ -195,7 +195,7 @@ html_script(struct html_context *html_context, unsigned char *a,
|
||||
mem_free(type);
|
||||
not_processed:
|
||||
/* Permit nested scripts and retreat. */
|
||||
html_top.invisible++;
|
||||
html_top->invisible++;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -403,8 +403,8 @@ void
|
||||
html_title(struct html_context *html_context, unsigned char *a,
|
||||
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
|
||||
{
|
||||
html_top.invisible = 1;
|
||||
html_top.type = ELEMENT_WEAK;
|
||||
html_top->invisible = 1;
|
||||
html_top->type = ELEMENT_WEAK;
|
||||
}
|
||||
|
||||
void
|
||||
@ -586,7 +586,7 @@ html_hr(struct html_context *html_context, unsigned char *a,
|
||||
}
|
||||
html_context->special_f(html_context, SP_NOWRAP, 0);
|
||||
ln_break(html_context, 2);
|
||||
kill_html_stack_item(html_context, &html_top);
|
||||
kill_html_stack_item(html_context, html_top);
|
||||
}
|
||||
|
||||
void
|
||||
@ -690,7 +690,7 @@ html_ul(struct html_context *html_context, unsigned char *a,
|
||||
int_upper_bound(&par_format.leftmargin, par_format.width / 2);
|
||||
|
||||
par_format.align = ALIGN_LEFT;
|
||||
html_top.type = ELEMENT_DONT_KILL;
|
||||
html_top->type = ELEMENT_DONT_KILL;
|
||||
}
|
||||
|
||||
void
|
||||
@ -725,7 +725,7 @@ html_ol(struct html_context *html_context, unsigned char *a,
|
||||
int_upper_bound(&par_format.leftmargin, par_format.width / 2);
|
||||
|
||||
par_format.align = ALIGN_LEFT;
|
||||
html_top.type = ELEMENT_DONT_KILL;
|
||||
html_top->type = ELEMENT_DONT_KILL;
|
||||
}
|
||||
|
||||
static struct {
|
||||
@ -873,10 +873,10 @@ html_dl(struct html_context *html_context, unsigned char *a,
|
||||
par_format.list_number = 0;
|
||||
par_format.align = ALIGN_LEFT;
|
||||
par_format.dd_margin = par_format.leftmargin;
|
||||
html_top.type = ELEMENT_DONT_KILL;
|
||||
html_top->type = ELEMENT_DONT_KILL;
|
||||
if (!(par_format.flags & P_COMPACT)) {
|
||||
ln_break(html_context, 2);
|
||||
html_top.linebreak = 2;
|
||||
html_top->linebreak = 2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -948,14 +948,14 @@ html_frame(struct html_context *html_context, unsigned char *a,
|
||||
}
|
||||
if (!name) return;
|
||||
|
||||
if (!html_context->options->frames || !html_top.frameset) {
|
||||
if (!html_context->options->frames || !html_top->frameset) {
|
||||
html_focusable(html_context, a);
|
||||
put_link_line("Frame: ", name, url, "", html_context);
|
||||
|
||||
} else {
|
||||
if (html_context->special_f(html_context, SP_USED, NULL)) {
|
||||
html_context->special_f(html_context, SP_FRAME,
|
||||
html_top.frameset, name, url);
|
||||
html_top->frameset, name, url);
|
||||
}
|
||||
}
|
||||
|
||||
@ -997,12 +997,12 @@ html_frameset(struct html_context *html_context, unsigned char *a,
|
||||
}
|
||||
}
|
||||
|
||||
if (!html_top.frameset) {
|
||||
if (!html_top->frameset) {
|
||||
width = html_context->options->box.width;
|
||||
height = html_context->options->box.height;
|
||||
html_context->options->needs_height = 1;
|
||||
} else {
|
||||
struct frameset_desc *frameset_desc = html_top.frameset;
|
||||
struct frameset_desc *frameset_desc = html_top->frameset;
|
||||
int offset;
|
||||
|
||||
if (frameset_desc->box.y >= frameset_desc->box.height)
|
||||
@ -1020,9 +1020,9 @@ html_frameset(struct html_context *html_context, unsigned char *a,
|
||||
parse_frame_widths(rows, height, HTML_FRAME_CHAR_HEIGHT,
|
||||
&fp.height, &fp.y);
|
||||
|
||||
fp.parent = html_top.frameset;
|
||||
fp.parent = html_top->frameset;
|
||||
if (fp.x && fp.y) {
|
||||
html_top.frameset = html_context->special_f(html_context, SP_FRAMESET, &fp);
|
||||
html_top->frameset = html_context->special_f(html_context, SP_FRAMESET, &fp);
|
||||
}
|
||||
mem_free_if(fp.width);
|
||||
mem_free_if(fp.height);
|
||||
|
@ -67,20 +67,20 @@ html_a(struct html_context *html_context, unsigned char *a,
|
||||
#ifdef CONFIG_GLOBHIST
|
||||
} else if (get_global_history_item(format.link)) {
|
||||
format.style.fg = format.vlink;
|
||||
html_top.pseudo_class &= ~ELEMENT_LINK;
|
||||
html_top.pseudo_class |= ELEMENT_VISITED;
|
||||
html_top->pseudo_class &= ~ELEMENT_LINK;
|
||||
html_top->pseudo_class |= ELEMENT_VISITED;
|
||||
#endif
|
||||
#ifdef CONFIG_BOOKMARKS
|
||||
} else if (get_bookmark(format.link)) {
|
||||
format.style.fg = format.bookmark_link;
|
||||
html_top.pseudo_class &= ~ELEMENT_VISITED;
|
||||
html_top->pseudo_class &= ~ELEMENT_VISITED;
|
||||
/* XXX: Really set ELEMENT_LINK? --pasky */
|
||||
html_top.pseudo_class |= ELEMENT_LINK;
|
||||
html_top->pseudo_class |= ELEMENT_LINK;
|
||||
#endif
|
||||
} else {
|
||||
format.style.fg = format.clink;
|
||||
html_top.pseudo_class &= ~ELEMENT_VISITED;
|
||||
html_top.pseudo_class |= ELEMENT_LINK;
|
||||
html_top->pseudo_class &= ~ELEMENT_VISITED;
|
||||
html_top->pseudo_class |= ELEMENT_LINK;
|
||||
}
|
||||
|
||||
mem_free_set(&format.title,
|
||||
@ -89,7 +89,7 @@ html_a(struct html_context *html_context, unsigned char *a,
|
||||
html_focusable(html_context, a);
|
||||
|
||||
} else {
|
||||
kill_html_stack_item(html_context, &html_top);
|
||||
kill_html_stack_item(html_context, html_top);
|
||||
}
|
||||
|
||||
set_fragment_identifier(html_context, a, "name");
|
||||
@ -269,7 +269,7 @@ html_img_do(unsigned char *a, unsigned char *object_src,
|
||||
* If not, just exit now. */
|
||||
if (!options->images && !format.link) {
|
||||
mem_free_if(src);
|
||||
if (usemap) kill_html_stack_item(html_context, &html_top);
|
||||
if (usemap) kill_html_stack_item(html_context, html_top);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -332,7 +332,7 @@ html_img_do(unsigned char *a, unsigned char *object_src,
|
||||
|
||||
put_image_label(a, label, html_context);
|
||||
|
||||
if (ismap) kill_html_stack_item(html_context, &html_top);
|
||||
if (ismap) kill_html_stack_item(html_context, html_top);
|
||||
mem_free_set(&format.image, NULL);
|
||||
mem_free_set(&format.title, NULL);
|
||||
}
|
||||
@ -341,7 +341,7 @@ html_img_do(unsigned char *a, unsigned char *object_src,
|
||||
}
|
||||
|
||||
mem_free_if(src);
|
||||
if (usemap) kill_html_stack_item(html_context, &html_top);
|
||||
if (usemap) kill_html_stack_item(html_context, html_top);
|
||||
}
|
||||
|
||||
void
|
||||
@ -369,7 +369,7 @@ put_link_line(unsigned char *prefix, unsigned char *linkname,
|
||||
format.style.fg = format.clink;
|
||||
put_chrs(html_context, linkname, strlen(linkname));
|
||||
ln_break(html_context, 1);
|
||||
kill_html_stack_item(html_context, &html_top);
|
||||
kill_html_stack_item(html_context, html_top);
|
||||
}
|
||||
|
||||
|
||||
|
@ -714,7 +714,7 @@ next_break:
|
||||
|
||||
element:
|
||||
endingtag = *name == '/'; name += endingtag; namelen -= endingtag;
|
||||
if (!endingtag && html_context->putsp == HTML_SPACE_ADD && !html_top.invisible)
|
||||
if (!endingtag && html_context->putsp == HTML_SPACE_ADD && !html_top->invisible)
|
||||
put_chrs(html_context, " ", 1);
|
||||
put_chrs(html_context, base_pos, html - base_pos);
|
||||
if (!html_is_preformatted() && !endingtag && html_context->putsp == HTML_SPACE_NORMAL) {
|
||||
@ -766,14 +766,14 @@ start_element(struct element_info *ei,
|
||||
struct css_selector *selector = NULL;
|
||||
#endif
|
||||
|
||||
if (html_top.type == ELEMENT_WEAK) {
|
||||
kill_html_stack_item(html_context, &html_top);
|
||||
if (html_top->type == ELEMENT_WEAK) {
|
||||
kill_html_stack_item(html_context, html_top);
|
||||
}
|
||||
|
||||
/* We try to process nested <script> if we didn't process the parent
|
||||
* one. */
|
||||
if (html_top.invisible
|
||||
&& (ei->func != html_script || html_top.invisible < 2)) {
|
||||
if (html_top->invisible
|
||||
&& (ei->func != html_script || html_top->invisible < 2)) {
|
||||
ELEMENT_RENDER_PROLOGUE
|
||||
return html;
|
||||
}
|
||||
@ -819,10 +819,10 @@ start_element(struct element_info *ei,
|
||||
|
||||
if (ei->type != ELEMENT_TYPE_NON_PAIRABLE) {
|
||||
html_stack_dup(html_context, ELEMENT_KILLABLE);
|
||||
html_top.name = name;
|
||||
html_top.namelen = namelen;
|
||||
html_top.options = attr;
|
||||
html_top.linebreak = ei->linebreak;
|
||||
html_top->name = name;
|
||||
html_top->namelen = namelen;
|
||||
html_top->options = attr;
|
||||
html_top->linebreak = ei->linebreak;
|
||||
|
||||
#ifdef CONFIG_ECMASCRIPT
|
||||
if (has_attr(attr, "onClick", html_context->options)) {
|
||||
@ -830,7 +830,7 @@ start_element(struct element_info *ei,
|
||||
mem_free_set(&format.link, stracpy("javascript:void(0);"));
|
||||
mem_free_set(&format.target, stracpy(html_context->base_target));
|
||||
format.style.fg = format.clink;
|
||||
html_top.pseudo_class = ELEMENT_LINK;
|
||||
html_top->pseudo_class = ELEMENT_LINK;
|
||||
mem_free_set(&format.title, stracpy("onClick placeholder"));
|
||||
/* Er. I know. Well, double html_focusable()s shouldn't
|
||||
* really hurt. */
|
||||
@ -840,7 +840,7 @@ start_element(struct element_info *ei,
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CSS
|
||||
if (html_top.options && html_context->options->css_enable) {
|
||||
if (html_top->options && html_context->options->css_enable) {
|
||||
/* XXX: We should apply CSS otherwise as well, but that'll need
|
||||
* some deeper changes in order to have options filled etc.
|
||||
* Probably just applying CSS from more places, since we
|
||||
@ -852,12 +852,12 @@ start_element(struct element_info *ei,
|
||||
/* FIXME: The caching of the CSS selector is broken, since t can
|
||||
* lead to wrong styles being applied to following elements, so
|
||||
* disabled for now. */
|
||||
selector = get_css_selector_for_element(html_context, &html_top,
|
||||
selector = get_css_selector_for_element(html_context, html_top,
|
||||
&html_context->css_styles,
|
||||
&html_context->stack);
|
||||
|
||||
if (selector) {
|
||||
apply_css_selector_style(html_context, &html_top, selector);
|
||||
apply_css_selector_style(html_context, html_top, selector);
|
||||
done_css_selector(selector);
|
||||
}
|
||||
}
|
||||
@ -868,14 +868,14 @@ start_element(struct element_info *ei,
|
||||
ELEMENT_RENDER_PROLOGUE
|
||||
if (ei->func) ei->func(html_context, attr, html, eof, &html);
|
||||
#ifdef CONFIG_CSS
|
||||
if (selector && html_top.options) {
|
||||
if (selector && html_top->options) {
|
||||
/* Call it now to override default colors of the elements. */
|
||||
selector = get_css_selector_for_element(html_context, &html_top,
|
||||
selector = get_css_selector_for_element(html_context, html_top,
|
||||
&html_context->css_styles,
|
||||
&html_context->stack);
|
||||
|
||||
if (selector) {
|
||||
apply_css_selector_style(html_context, &html_top, selector);
|
||||
apply_css_selector_style(html_context, html_top, selector);
|
||||
done_css_selector(selector);
|
||||
}
|
||||
}
|
||||
@ -909,7 +909,7 @@ end_element(struct element_info *ei,
|
||||
|
||||
/* Apply background color from the <HTML> element. (bug 696) */
|
||||
if (ei->func == html_html
|
||||
&& html_top.type >= ELEMENT_KILLABLE
|
||||
&& html_top->type >= ELEMENT_KILLABLE
|
||||
&& !html_context->was_body_background)
|
||||
html_apply_canvas_bgcolor(html_context);
|
||||
|
||||
|
@ -60,7 +60,7 @@ search_html_stack(struct html_context *html_context, unsigned char *name)
|
||||
#endif
|
||||
|
||||
foreach (element, html_context->stack) {
|
||||
if (element == &html_top)
|
||||
if (element == html_top)
|
||||
continue; /* skip the top element */
|
||||
if (strlcasecmp(element->name, element->namelen, name, namelen))
|
||||
continue;
|
||||
@ -189,7 +189,7 @@ kill_element(struct html_context *html_context, int ls, struct html_element *e)
|
||||
void
|
||||
kill_html_stack_until(struct html_context *html_context, int ls, ...)
|
||||
{
|
||||
struct html_element *e = &html_top;
|
||||
struct html_element *e = html_top;
|
||||
|
||||
if (ls) e = e->next;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user