159 "HTML warning: line %d, ",
161 va_start(argp, format);
172 const char *url_str,
const char *base_url,
176 MSG(
"a_Html_url_new: URL is NULL\n");
184 BUG_MSG(
"URL is not valid '%s'.", url_str);
190 const char *suffix = (n_ic) > 1 ?
"s" :
"";
192 if (n_ic == n_ic_spc) {
193 BUG_MSG(
"URL has %d illegal space%s ('%s').", n_ic, suffix, url_str);
194 }
else if (n_ic_spc == 0) {
195 BUG_MSG(
"URL has %d illegal byte%s in {00-1F, 7F-FF} range ('%s').",
196 n_ic, suffix, url_str);
198 BUG_MSG(
"URL has %d illegal byte%s: "
199 "%d space%s and %d in {00-1F, 7F-FF} range ('%s').",
201 n_ic_spc, n_ic_spc > 1 ?
"s" :
"", n_ic-n_ic_spc, url_str);
218 return (
void*)html->
dw;
241 for (
int i = 0; i < html->
forms->
size(); i++) {
242 if (html->
forms->
get(i) == v_form) {
296 snprintf(data, 64,
"?%d,%d", x, y);
309 html->
links->
set(nl, (*url) ? *url : NULL);
325 BUG_MSG(
"The align attribute is obsolete in HTML5.");
340 if (charattr[0] == 0)
345 style_attrs.textAlignChar =
' ';
347 style_attrs.textAlignChar = charattr[0];
350 style_attrs.textAlignChar =
'.';
369 BUG_MSG(
"The valign attribute is obsolete in HTML5.");
403 style = html->
style ();
410 HT2TB(html)->addWidget (textblock, style);
412 HT2TB(html)->addBreakOption (html->
style (),
false);
416 S_TOP(html)->textblock = html->
dw = textblock;
418 S_TOP(html)->hand_over_break =
true;
425 return HT2TB(html)->mustAddBreaks (html->
style ());
432 const char *content_type)
466 cssUrls =
new misc::SimpleVector <DilloUrl*> (1);
468 stack =
new misc::SimpleVector <DilloHtmlState> (16);
507 forms =
new misc::SimpleVector <DilloHtmlForm*> (1);
509 links =
new misc::SimpleVector <DilloUrl*> (64);
510 images =
new misc::SimpleVector <DilloHtmlImage*> (16);
537 _MSG(
"::~DilloHtml(this=%p)\n",
this);
583 _MSG(
"DilloHtml::write BufSize=%d Start_Ofs=%d\n", BufSize,
Start_Ofs);
615 for (i =
OldOfs; i < ofs; ++i)
616 if (p[i] ==
'\n' || (p[i] ==
'\r' && p[i+1] !=
'\n'))
676 _MSG(
"Html formNew: action=%s nform=%d\n", action, nf);
746 _MSG(
" Link LEAVE notify...\n");
749 _MSG(
" Link ENTER notify...\n");
772 linkurl = html->links->get(link);
773 const bool_t loaded_img = (html->images->get(img)->image == NULL);
775 html->page_url, linkurl);
798 if ((img != -1) && (html->images->get(img)->image)) {
802 DilloUrl *pattern = html->images->get(img)->url;
803 html->loadImages(pattern);
809 DilloUrl *url = html->links->get(link);
816 }
else if (event->
button == 2) {
829 _MSG(
" ->%s\n", w->getClassName());
831 ((
Textblock*)w)->changeLinkColor (link, html->visited_color);
860 case 146: ret =
'\'';
break;
862 case 148: ret =
'"';
break;
863 case 149: ret = 176;
break;
865 case 151: ret =
'-';
break;
866 default: ret = codepoint;
break;
876 bool_t is_attr,
int *entsize)
880 int n, codepoint = -1;
884 if (*s ==
'x' || *s ==
'X') {
885 if (isxdigit(*++s)) {
887 if (*s ==
'0' && s[1] ==
'x') {
891 codepoint = strtol(s, &s, 16);
894 }
else if (isdigit(*s)) {
895 codepoint = strtol(s, &s, 10);
907 BUG_MSG(
"Character reference '&#%s' lacks ';'.", tok);
920 if ((codepoint < 0x20 && codepoint !=
'\t' && codepoint !=
'\n' &&
921 codepoint !=
'\f') ||
922 (codepoint >= 0x7f && codepoint <= 0x9f) ||
923 (codepoint >= 0xd800 && codepoint <= 0xdfff) || codepoint > 0x10ffff ||
924 ((codepoint & 0xfffe) == 0xfffe) ||
926 codepoint > 0xffff)) {
932 BUG_MSG(
"Numeric character reference '&#%s' is not valid.", tok);
935 codepoint = (codepoint >= 145 && codepoint <= 151) ?
938 if (codepoint != -1) {
939 if (codepoint >= 128) {
943 buf[0] = (char) codepoint;
979 bool_t is_attr,
int *entsize)
984 const char *ret = NULL;
986 while (*++s && (isalnum(*s) || strchr(
":_.-", *s))) ;
992 BUG_MSG(
"Character reference '&%s' lacks ';'.", tok);
1019 BUG_MSG(
"Undefined character reference '&%s'.", tok);
1035 int toksize,
int *entsize,
bool_t is_attr)
1037 const char *ret = NULL;
1053 }
else if (isalpha(*tok)) {
1071 const char *esc_set =
"&";
1075 s = strcspn(token, esc_set);
1084 for (i = s; i < toksize; i++) {
1088 if (token[i] ==
'&' &&
1110 int i, breakCnt = 0;
1112 for (i = 0; i < spacesize; i++) {
1114 if (space[i] ==
'\r' || (space[i] ==
'\n' && !html->
PrevWasCR)) {
1121 if (breakCnt == 0) {
1136 if (
S_TOP(html)->display_none) {
1148 for (i = 0; i < spacesize; i++) {
1151 (space[i] ==
'\r' || (space[i] ==
'\n' && !html->
PrevWasCR))) {
1171 BUG_MSG(
"TAB character inside <pre>.");
1221 if (
S_TOP(html)->display_none)
1224 BUG_MSG(
"Content after </%s> tag.", i == 1 ?
"html" :
"body");
1250 for (start = i = 0; Pword[i]; start = i)
1251 if (isspace(Pword[i])) {
1252 while (Pword[++i] && isspace(Pword[i])) ;
1255 while (Pword[++i] && !isspace(Pword[i])) ;
1256 HT2TB(html)->addText(Pword + start, i - start, html->
wordStyle ());
1263 const char *word2, *beyond_word2;
1266 if (!memchr(word,
'&', size)) {
1269 beyond_word2 = word + size;
1274 for (i = j = 0; (Pword[i] = Pword[j]); ++i, ++j) {
1275 if (strchr(
" \t\f\n\r", Pword[i])) {
1276 if (i == 0 || (i > 0 && Pword[i-1] !=
' '))
1279 for (--i; Pword[j+1] && strchr(
" \t\f\n\r", Pword[j+1]); ++j)
1284 beyond_word2 = word2 + strlen(word2);
1286 for (start = i = 0; word2[i]; start = i) {
1289 if (isspace(word2[i])) {
1290 while (word2[++i] && isspace(word2[i])) ;
1297 HT2TB(html)->addText(word2 + start, i - start, html->
wordStyle ());
1302 }
while (word2[i] && !isspace(word2[i]) &&
1305 HT2TB(html)->addText(word2 + start, i - start, html->
wordStyle ());
1321 for (i = 0; i < tagsize && tagstr[i] !=
'\0'; i++) {
1326 if (i < tagsize && (isspace(tag[i]) || tag[i] ==
'>' || tag[i] ==
'/'))
1337 if (html->
dw !=
S_TOP(html)->textblock) {
1338 if (hand_over_break)
1340 HT2TB(html)->flush ();
1341 html->
dw =
S_TOP(html)->textblock;
1358 html->
dw =
S_TOP(html)->textblock;
1376 bool hand_over_break;
1379 hand_over_break =
S_TOP(html)->hand_over_break;
1400 v = strtod (attr, &end);
1443 if (*end && !isspace (*end)) {
1444 BUG_MSG(
"Garbage after length: '%s'.", attr);
1458 int32_t default_color)
1464 BUG_MSG(
"Color \"%s\" is not in \"#RRGGBB\" format.", str);
1478 bool valid = *val && !strchr(val,
' ');
1481 BUG_MSG(
"'%s' value \"%s\" must not be empty and must not contain "
1482 "spaces.", attrname, val);
1484 return valid ? 1 : 0;
1488 for (i = 0; val[i]; ++i)
1489 if (!
d_isascii(val[i]) || !(isalnum(val[i]) || strchr(
":_.-", val[i])))
1492 if (val[i] || !(
d_isascii(val[0]) && isalpha(val[0])))
1493 BUG_MSG(
"%s attribute value \"%s\" is not of the form "
1494 "'[A-Za-z][A-Za-z0-9:_.-]*'.", attrname, val);
1521 static const char HTML_SGML_sig [] =
"<!DOCTYPE HTML PUBLIC ";
1522 static const char HTML20 [] =
"-//IETF//DTD HTML";
1523 static const char HTML32 [] =
"-//W3C//DTD HTML 3.2";
1524 static const char HTML40 [] =
"-//W3C//DTD HTML 4.0";
1525 static const char HTML401 [] =
"-//W3C//DTD HTML 4.01";
1526 static const char HTML401_url[] =
"http://www.w3.org/TR/html4/";
1527 static const char XHTML1 [] =
"-//W3C//DTD XHTML 1.0";
1528 static const char XHTML1_url [] =
"http://www.w3.org/TR/xhtml1/DTD/";
1529 static const char XHTML11 [] =
"-//W3C//DTD XHTML 1.1";
1530 static const char XHTML11_url[] =
"http://www.w3.org/TR/xhtml11/DTD/";
1534 char *p, *ntag =
dStrndup(tag, tagsize);
1538 for (i = 0, p = ntag; *p; ++p) {
1540 for (ntag[i++] =
' '; isspace(p[1]); ++p) ;
1541 }
else if ((quote = *p) ==
'"' || *p ==
'\'') {
1542 for (ntag[i++] = *p++; (ntag[i] = *p) && ntag[i++] != quote; ++p) {
1543 if (*p ==
'\n' || *p ==
'\r')
1545 p += (p[0] ==
'\r' && p[1] ==
'\n') ? 1 : 0;
1555 _MSG(
"New: {%s}\n", ntag);
1558 BUG_MSG(
"Multiple DOCTYPE declarations.");
1561 if (i > strlen(HTML_SGML_sig) &&
1563 p = ntag + strlen(HTML_SGML_sig) + 1;
1564 if (!strncmp(p, HTML401, strlen(HTML401)) &&
1568 }
else if (!strncmp(p, XHTML1, strlen(XHTML1)) &&
1572 }
else if (!strncmp(p, XHTML11, strlen(XHTML11)) &&
1576 }
else if (!strncmp(p, HTML40, strlen(HTML40))) {
1579 }
else if (!strncmp(p, HTML32, strlen(HTML32))) {
1582 }
else if (!strncmp(p, HTML20, strlen(HTML20))) {
1589 "<!DOCTYPE html SYSTEM \"about:legacy-compat\">") ||
1591 "<!DOCTYPE html SYSTEM 'about:legacy-compat'>")) {
1597 BUG_MSG(
"DOCTYPE not recognized: ('%s').", ntag);
1616 BUG_MSG(
"<html> was already open.");
1626 _MSG(
"Html_tag_close_html: Num_HTML=%d\n", html->
Num_HTML);
1639 BUG_MSG(
"<head> must go before the BODY section.");
1647 BUG_MSG(
"<head> was already open.");
1650 BUG_MSG(
"<head> already finished -- ignoring.");
1667 BUG_MSG(
"<head> lacks <title>.");
1697 BUG_MSG(
"Redundant <title>.");
1699 BUG_MSG(
"<title> must be inside <head> -- ignoring.");
1713 if (!title || title[0] ==
'\0')
1745 const char *attrbuf;
1751 BUG_MSG(
"<style> requires type attribute.");
1784 const char *attrbuf;
1792 _MSG(
"Html_tag_open_body Num_BODY=%d\n", html->
Num_BODY);
1799 BUG_MSG(
"<body> was already open.");
1813 BUG_MSG(
"<body> bgcolor attribute is obsolete.");
1824 BUG_MSG(
"<body> text attribute is obsolete.");
1836 BUG_MSG(
"<body> link attribute is obsolete.");
1842 BUG_MSG(
"<body> vlink attribute is obsolete.");
1849 HT2LT(html)->setBgColor(bgColor);
1852 &bgPositionX, &bgPositionY);
1854 HT2LT(html)->setBgImage(bgImage, bgRepeat, bgAttachment, bgPositionX,
1890 _MSG(
"Html_tag_close_body: Num_BODY=%d\n", html->
Num_BODY);
1916 const char *attrbuf;
1941 const char *attrbuf;
1946 textblock =
HT2TB(html);
1985 const char *tag,
int tagsize)
2000 S_TOP(html)->parse_mode =
2017 const char *attrbuf;
2018 char *fontFamily = NULL;
2034 fontFamily =
dStrdup(attrbuf);
2047 const char *attrbuf;
2064 char *width_ptr, *height_ptr;
2065 const char *attrbuf;
2098 if (w < 0 || h < 0 ||
2103 width_ptr = height_ptr = NULL;
2104 MSG(
"a_Html_common_image_attrs: suspicious image size request %d x %d\n",
2136 const char *attrbuf;
2145 if (!alt_ptr || !*alt_ptr) {
2156 if (
HT2TB(html)->getBgColor())
2159 if (
HT2TB(html)->getFgColor())
2202 return ClientKey != 0;
2208 const char *attrbuf;
2214 space = strtol(attrbuf, NULL, 10);
2226 space = strtol(attrbuf, NULL, 10);
2238 border = strtol(attrbuf, NULL, 10);
2272 const char *attrbuf;
2292 HT2TB(html)->addBreakOption (html->
style (),
false);
2297 _MSG(
" Html_tag_open_img: server-side map (ISMAP)\n");
2299 usemap_url == NULL) {
2317 const char *attrbuf;
2331 BUG_MSG(
"<map> requires name attribute.");
2346 for (
int i = 0; i < html->
images->
size(); i++) {
2368 const char *tail = str;
2369 char *newtail = NULL;
2373 coord = strtol(tail, &newtail, 10);
2374 if (coord == 0 && newtail == tail)
2377 coords->
set(coords->
size() - 1, coord);
2378 while (isspace(*newtail))
2382 if (*newtail !=
',') {
2383 BUG_MSG(
"<area> coords must be integers separated by commas.");
2397 enum types {UNKNOWN, RECTANGLE, CIRCLE, POLYGON, BACKGROUND};
2401 const char *attrbuf;
2403 Shape *shape = NULL;
2406 BUG_MSG(
"<area> not inside <map>.");
2422 BUG_MSG(
"<area> unknown shape: '%s'.", attrbuf);
2425 if (type == RECTANGLE || type == CIRCLE || type == POLYGON) {
2429 if (type == RECTANGLE) {
2430 if (coords->
size() != 4)
2431 BUG_MSG(
"<area> rectangle must have four coordinate values.");
2432 if (coords->
size() >= 4)
2435 coords->
get(2) - coords->
get(0),
2436 coords->
get(3) - coords->
get(1));
2437 }
else if (type == CIRCLE) {
2438 if (coords->
size() != 3)
2439 BUG_MSG(
"<area> circle must have three coordinate values.");
2440 if (coords->
size() >= 3)
2443 }
else if (type == POLYGON) {
2446 if (coords->
size() % 2)
2447 BUG_MSG(
"<area> polygon with odd number of coordinates.");
2449 for (i = 0; i < (coords->
size() / 2); i++)
2455 if (shape != NULL || type == BACKGROUND) {
2462 if (type == BACKGROUND)
2476 const char *attrbuf;
2513 const char *attrbuf;
2516 MSG(
"<video> not handled when already inside a media element.\n");
2546 const char *attrbuf;
2549 MSG(
"<audio> not handled when already inside a media element.\n");
2578 const char *attrbuf;
2586 BUG_MSG(
"<source> requires src attribute.");
2624 const char *attrbuf;
2658 i = strcspn(Buf->
str,
"'\"");
2660 if ((ch ==
'"' || ch ==
'\'') &&
2661 (p2 = strchr(Buf->
str + i + 1 , ch))) {
2663 BUG_MSG(
"Link depends on javascript().");
2676 _MSG(
"Registering ANCHOR: %s\n", name);
2677 if (!
HT2TB(html)->addAnchor (name, html->
style ()))
2678 BUG_MSG(
"Anchor names must be unique within the document (\"%s\").",
2696 const char *attrbuf;
2748 if (!
id || strcmp(nameVal,
id)) {
2750 BUG_MSG(
"In <a>, id ('%s') and name ('%s') attributes differ.",
2773 const char *tag,
int tagsize)
2787 const char *U201C =
"\xe2\x80\x9c";
2799 const char *U201D =
"\xe2\x80\x9d";
2809 const char *attrbuf;
2828 BUG_MSG(
"<ul> type attribute is obsolete.");
2832 S_TOP(html)->list_number = 0;
2833 S_TOP(html)->ref_list_item = NULL;
2846 S_TOP(html)->list_number = 0;
2847 S_TOP(html)->ref_list_item = NULL;
2850 BUG_MSG(
"Obsolete list type; use <ul> instead.");
2875 const char *attrbuf;
2881 if (*attrbuf ==
'1')
2883 else if (*attrbuf ==
'a')
2885 else if (*attrbuf ==
'A')
2887 else if (*attrbuf ==
'i')
2889 else if (*attrbuf ==
'I')
2899 (n = (
int) strtol(attrbuf, NULL, 10)) < 0) {
2900 BUG_MSG(
"Illegal '-' character in START attribute; Starting from 0.");
2903 S_TOP(html)->list_number = n;
2904 S_TOP(html)->ref_list_item = NULL;
2914 const char *attrbuf;
2921 BUG_MSG(
"<li> outside <ul> or <ol>.");
2932 (*list_number = strtol(attrbuf, NULL, 10)) < 0) {
2933 BUG_MSG(
"Illegal negative list value attribute; Starting from 0.");
2954 const char *attrbuf;
2960 BUG_MSG(
"<hr> width attribute is obsolete.");
2968 size = strtol(attrbuf, NULL, 10);
2970 BUG_MSG(
"<hr> size attribute is obsolete.");
2978 BUG_MSG(
"<hr> noshade attribute is obsolete.");
3014 hruler =
new Ruler();
3016 HT2TB(html)->addWidget (hruler, html->
style ());
3074 const char *es_set[] = {
"img",
"object",
"applet",
"big",
"small",
"sub",
3075 "sup",
"font",
"basefont", NULL};
3076 static int ei_set[10], i;
3080 for (i = 0; es_set[i]; ++i)
3083 for (i = 0; ei_set[i]; ++i)
3084 if (tag_idx == ei_set[i])
3121 const char meta_template[] =
3122"<table width='100%%'><tr><td bgcolor='#ee0000'>Warning:</td>\n"
3123" <td bgcolor='#8899aa' width='100%%'>\n"
3124" This page uses the NON-STANDARD meta refresh tag.<br> The HTML 4.01 SPEC\n"
3125" (sec 7.4.4) recommends explicitly to avoid it.</td></tr>\n"
3126" <tr><td bgcolor='#a0a0a0' colspan='2'>The author wanted you to go\n"
3127" <a href='%s'>here</a>%s</td></tr></table><br>\n";
3129 const char *p, *equiv, *
charset, *content;
3130 char delay_str[64], *mr_url;
3141 BUG_MSG(
"This <meta> element must be inside the HEAD section.");
3151 if ((delay = strtol(content, NULL, 0))) {
3152 snprintf(delay_str, 64,
" after %d second%s.",
3153 delay, (delay > 1) ?
"s" :
"");
3155 sprintf(delay_str,
".");
3160 content = p + strlen(
"url=");
3161 else if ((p = strstr(content,
";")))
3162 content = p + strlen(
";");
3168 if (*content ==
'"' || *content ==
'\'') {
3169 if ((p = strchr(content + 1, *content)))
3170 mr_url =
dStrndup(content + 1, p - content - 1);
3172 mr_url =
dStrdup(content + 1);
3184 BUG_MSG(
"<meta> refresh: %s.",
3185 *mr_url ?
"redirection loop" :
"no target URL");
3186 }
else if (delay == 0) {
3191 "WARNING: local URL with META refresh. Aborting.");
3202 int o_InFlags = html->
InFlags;
3203 int o_TagSoup = html->
TagSoup;
3217 _MSG(
"Html_tag_open_meta: content={%s}\n", content);
3234 _MSG(
"Html_css_load_callback: Op=%d\n", Op);
3253 _MSG(
"Html_load_stylesheet: ");
3257 if (strncmp(
"@charset \"", data, 10) == 0) {
3258 char *endq = strchr(data+10,
'"');
3260 if (endq && (endq - data <= 51)) {
3301 const char *attrbuf;
3317 BUG_MSG(
"This <link> element must be inside the HEAD section.");
3339 _MSG(
" Html_tag_open_link(): addCssUrl %s\n",
URL_STR(url));
3350 const char *attrbuf;
3368 BUG_MSG(
"<base> URI is relative (it MUST be absolute).");
3373 BUG_MSG(
"<base> not inside HEAD section.");
3387 const char *attrbuf;
3405 const char *attrbuf;
3581#define NTAGS (sizeof(Tags)/sizeof(Tags[0]))
3584#if __cpp_static_assert
3586 "Mismatch between number of tags in Tags and HTML_NTAGS");
3602 return !strchr(
" >/\n\r\t", *p1);
3611 int low, high, mid, cond;
3616 while (low <= high) {
3617 mid = (low + high) / 2;
3638 int Flags =
Tags[cur_idx].Flags;
3639 if (old_idx ==
i_P || old_idx ==
i_DT) {
3641 return (!(Flags & 1));
3642 }
else if (old_idx ==
i_LI) {
3645 return (cur_idx ==
i_LI);
3646 }
else if (old_idx ==
i_TD || old_idx ==
i_TH) {
3649 return (cur_idx ==
i_TD || cur_idx ==
i_TH || cur_idx ==
i_TR);
3650 }
else if (old_idx ==
i_TR) {
3652 return (cur_idx ==
i_TR);
3653 }
else if (old_idx ==
i_DD) {
3655 return (cur_idx ==
i_DD || cur_idx ==
i_DT);
3678 int f =
InFlags, ni = new_idx, oi = -1;
3695 int new_idx,
int fi,
char op)
3697 int s_top, ni = new_idx;
3698 while ((s_top = html->
stack->
size() - 1) >= s_idx) {
3699 int toptag_idx =
S_TOP(html)->tag_idx;
3700 TagInfo toptag =
Tags[toptag_idx];
3704 if (toptag_idx != fi)
3705 BUG_MSG(
" Nesting cleanup - forcing close of open tag: <%s>.",
3707 }
else if (s_top == s_idx && op ==
'c') {
3709 }
else if (toptag.EndTag ==
'O') {
3711 }
else if ((!(toptag.Flags & 4) &&
3712 (
Tags[ni].Flags & 4 || !(
Tags[ni].Flags & 1))) ||
3713 (
Tags[ni].Flags & 1 && !(toptag.Flags & 2))) {
3717 "Bad nesting: <%s> can't contain <%s>. -- closing <%s>." :
3718 "<%s> needs to be closed before </%s>. -- closing <%s>.",
3719 toptag.name,
Tags[ni].name, toptag.name);
3722 "<%s> should have been closed before </%s>. -- closing <%s>.",
3723 toptag.name,
Tags[ni].name, toptag.name);
3725 _MSG(
"op(%c): %s s_top=%d s_idx=%d\n", op, toptag.name, s_top, s_idx);
3726 if (toptag_idx ==
i_BODY &&
3751 int s_top = html->
stack->
size() - 1, s_idx;
3753 for (s_idx = s_top; s_idx > 0; --s_idx) {
3761 BUG_MSG(
"Forbidden nesting: <%s> can't contain <%s>. -- closing "
3767 }
else if (
Tags[ti].EndTag ==
'O') {
3770 }
else if (!(
Tags[ni].Flags & 1) && !(
Tags[ti].Flags & 4)) {
3798 int stack_idx, tag_idx, matched = 0, expected = 0;
3799 TagInfo new_tag =
Tags[new_idx];
3803 while (--stack_idx) {
3805 if (tag_idx == new_idx) {
3809 }
else if (
Tags[tag_idx].EndTag ==
'O') {
3818 }
else if (
Tags[new_idx].Flags & 4 &&
3819 Tags[stack_idx].Flags & 3) {
3831 }
else if (expected) {
3832 BUG_MSG(
"Unexpected closing tag: </%s> -- expected </%s>.",
3833 new_tag.name,
Tags[tag_idx].name);
3835 BUG_MSG(
"Unexpected closing tag: </%s>.", new_tag.name);
3849 BUG_MSG(
"The required DOCTYPE declaration is missing. "
3850 "Handling as HTML4.");
3855 if (tag_idx != new_idx || IsCloseTag) {
3859 Tags[tag_idx].open (html, tag, strlen(tag));
3863 if (
Tags[new_idx].Flags & 16) {
3868 if (tag_idx != new_idx || IsCloseTag) {
3872 Tags[tag_idx].open (html, tag, strlen(tag));
3876 }
else if (
Tags[new_idx].Flags & 8) {
3885 if (tag_idx != new_idx || IsCloseTag) {
3889 Tags[tag_idx].open (html, tag, strlen(tag));
3899 const char *attrbuf;
3930 memset(lang, 0,
sizeof(lang));
3931 if (tagsize >= 14) {
3935 strncpy(lang, attrbuf, 2);
3937 if (!lang[0] && tagsize >= 10) {
3941 strncpy(lang, attrbuf, 2);
3953 static int indexes[9] = {-1};
3955 if (indexes[0] == -1) {
3966 for (
int i = 0; i < 9; i++) {
3967 if (indexes[i] == ni) {
3968 BUG_MSG(
"<%s> is obsolete in HTML5.",
Tags[ni].name);
4003 *ref_list_item = list_item;
4004 S_TOP(html)->textblock = html->
dw = list_item;
4026 char *start = tag + 1;
4027 int IsCloseTag = (*start ==
'/');
4041 _MSG(
"Html_process_tag: %s%s\n", IsCloseTag ?
"/" :
"",
Tags[ni].name);
4047 if (i == 1 || (i == 2 && ni !=
i_HTML))
4048 BUG_MSG(
"Content after </%s> tag.", i == 1 ?
"html" :
"body");
4056 ti =
S_TOP(html)->tag_idx;
4057 switch (IsCloseTag) {
4068 BUG_MSG(
"<pre> is not allowed to contain <%s>.",
Tags[ni].name);
4080 _MSG(
"Html_process_tag Open : %s\n",
Tags[ni].name);
4081 Tags[ni].open (html, tag, tagsize);
4083 if (!
S_TOP(html)->display_none) {
4095 S_TOP(html)->display_none =
true;
4105 if (
Tags[ni].content && !
S_TOP(html)->display_none) {
4106 Tags[ni].content (html, tag, tagsize);
4129 if (
Tags[ni].EndTag ==
'F')
4139 if (*start ==
'/' ||
4141 (tag[tagsize-2] ==
'/' &&
4142 (strchr(
" \"'", tag[tagsize-3]) ||
4143 (
size_t)tagsize == strlen(
Tags[ni].name) + 3))) {
4145 _MSG(
"Html_process_tag Close: %s\n",
Tags[ni].name);
4166 const char *attrname,
4167 int tag_parsing_flags)
4169 int i, entsize, Found = 0, delimiter = 0, attr_pos = 0;
4177 for (i = 1; i < tagsize; ++i) {
4180 if (isspace(tag[i]))
4182 else if (tag[i] ==
'=')
4187 if (!attrname[attr_pos] &&
4188 (tag[i] ==
'=' || isspace(tag[i]) || tag[i] ==
'>')) {
4192 }
else if (!tag[i]) {
4202 if (tag[i] ==
'=') {
4204 }
else if (!isspace(tag[i])) {
4211 if (!isspace(tag[i])) {
4212 delimiter = (tag[i] ==
'"' || tag[i] ==
'\'') ? tag[i] :
' ';
4213 i -= (delimiter ==
' ');
4219 if ((delimiter ==
' ' && isspace(tag[i])) || tag[i] == delimiter)
4223 if ((delimiter ==
' ' && (isspace(tag[i]) || tag[i] ==
'>')) ||
4224 tag[i] == delimiter) {
4226 }
else if (tag[i] ==
'&' &&
4238 }
else if (tag[i] ==
'\r' || tag[i] ==
'\t') {
4240 }
else if (tag[i] ==
'\n') {
4254 while (isspace(Buf->
str[0]))
4257 while (Buf->
len && isspace(Buf->
str[Buf->
len - 1]))
4260 return (Found) ? Buf->
str : NULL;
4269 const char *attrname)
4283 const char *attrname,
4317 char ch = 0, *p, *text;
4318 int token_start, buf_index;
4323 token_start = buf_index;
4327 if (
S_TOP(html)->parse_mode ==
4331 const char *tag =
Tags[
S_TOP(html)->tag_idx].name;
4332 buf_index += strcspn(buf + buf_index,
"<");
4333 if (buf_index + (
int)strlen(tag) + 3 >
bufsize) {
4335 }
else if (strncmp(buf + buf_index,
"</", 2) == 0 &&
4338 text =
dStrndup(buf + token_start, buf_index - token_start);
4341 token_start = buf_index;
4345 }
while (buf_index <
bufsize);
4351 if (isspace(buf[buf_index])) {
4353 while (++buf_index <
bufsize && isspace(buf[buf_index])) ;
4355 token_start = buf_index;
4357 }
else if (buf[buf_index] ==
'<' && (ch = buf[buf_index + 1]) &&
4358 (isalpha(ch) || strchr(
"/!?", ch)) ) {
4360 if (buf_index + 3 <
bufsize && !strncmp(buf + buf_index,
"<!--", 4)) {
4363 while ( (p = (
char*) memchr(buf + buf_index,
'>',
4365 buf_index = p - buf + 1;
4366 if (p[-1] ==
'-' && p[-2] ==
'-')
break;
4370 token_start = buf_index;
4377 while ( buf_index <
bufsize ) {
4379 buf_index += strcspn(buf + buf_index,
">\"'<");
4380 if ((ch = buf[buf_index]) ==
'>') {
4382 }
else if (ch ==
'"' || ch ==
'\'') {
4385 buf_index += strcspn(buf + buf_index,
4386 (ch ==
'"') ?
"\">" :
"'>");
4387 if (buf[buf_index] ==
'>') {
4390 int offset = buf_index + 1;
4391 offset += strcspn(buf + offset,
4392 (ch ==
'"') ?
"\"<" :
"'<");
4393 if (buf[offset] == ch || !buf[offset]) {
4396 BUG_MSG(
"Attribute lacks closing quote.");
4400 }
else if (ch ==
'<') {
4403 strcspn(buf+token_start+1,
" <\n\r\t"));
4404 BUG_MSG(
"<%s> lacks its closing '>'.", p);
4413 buf_index - token_start);
4414 token_start = buf_index;
4421 while (++buf_index <
bufsize) {
4422 buf_index += strcspn(buf + buf_index,
" <\n\r\t\f\v");
4423 if (buf[buf_index] ==
'<' && (ch = buf[buf_index + 1]) &&
4424 !isalpha(ch) && !strchr(
"/!?", ch))
4428 if (buf_index <
bufsize || Eof) {
4430 ch = buf[buf_index];
4433 buf_index - token_start);
4434 buf[buf_index] = ch;
4435 token_start = buf_index;
4440 HT2TB(html)->flush ();
bool_t a_Bw_expecting(BrowserWindow *bw)
void a_Bw_close_client(BrowserWindow *bw, int ClientKey)
Close a cache-client upon successful retrieval.
void a_Bw_add_url(BrowserWindow *bw, const DilloUrl *Url)
Add an URL to the browser window's list.
void a_Bw_add_client(BrowserWindow *bw, int Key, int Root)
Add a reference to a cache-client.
void a_Bw_remove_doc(BrowserWindow *bw, void *vdoc)
Remove a document from the bw's list.
void a_Bw_add_doc(BrowserWindow *bw, void *vdoc)
Add a document to the browser window's list.
void(* CA_Callback_t)(int Op, CacheClient_t *Client)
Callback type for cache clients.
int a_Capi_get_buf(const DilloUrl *Url, char **PBuf, int *BufSize)
Get the cache's buffer for the URL, and its size.
const char * a_Capi_set_content_type(const DilloUrl *url, const char *ctype, const char *from)
Set the Content-Type for the URL.
int a_Capi_dpi_verify_request(BrowserWindow *bw, DilloUrl *url)
Safety test: only allow GET|POST dpi-urls from dpi-generated pages.
void a_Capi_unref_buf(const DilloUrl *Url)
Unref the cache's buffer when no longer using it.
int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
Most used function for requesting a URL.
int a_Capi_get_flags_with_redirection(const DilloUrl *Url)
Same as a_Capi_get_flags() but following redirections.
A list of CssProperty objects.
bool enter(dw::core::Widget *widget, int link, int img, int x, int y)
Called, when a link is entered, left, or the position has changed.
bool press(dw::core::Widget *widget, int link, int img, int x, int y, dw::core::EventButton *event)
Handle the "press" signal.
bool click(dw::core::Widget *widget, int link, int img, int x, int y, dw::core::EventButton *event)
Handle the "click" signal.
bool ReqTagClose
Flag to close the stack's top tag.
void freeParseData()
Free parsing data.
int InFlags
tracks which elements we are in
DilloHtmlDocumentType DocType
int getCurrLineNumber()
Return the line number of the tag/word being processed by the parser.
void bugMessage(const char *format,...)
Collect HTML error strings.
lout::misc::SimpleVector< DilloHtmlState > * stack
void write(char *Buf, int BufSize, int Eof)
Process the newly arrived html and put it into the page structure.
dw::core::style::Style * backgroundStyle()
int formNew(DilloHtmlMethod method, const DilloUrl *action, DilloHtmlEnc enc, const char *charset)
Allocate and insert form information.
void finishParsing(int ClientKey)
Finish parsing a HTML page.
bool PreFirstChar
used to skip the first CR or CRLF in PRE tags
void startElement(int tag)
void addCssUrl(const DilloUrl *url)
Save URL in a vector (may be loaded later).
void initDw()
Miscellaneous initializations for Dw.
bool PrevWasCR
Flag to help parsing of "\r\n" in PRE tags.
bool TagSoup
Flag to enable the parser's cleanup functions.
int pre_column
current column, used in PRE tags with tabs
lout::misc::SimpleVector< DilloHtmlInput * > * inputs_outside_form
bool PrevWasHtmlClose
set when </html> is found
dw::core::style::Style * wordStyle()
int32_t non_css_visited_color
as provided by vlink attribute in BODY
bool loadCssFromStash
current stash content should be loaded as CSS
lout::misc::SimpleVector< DilloHtmlForm * > * forms
DilloHtml(BrowserWindow *bw, const DilloUrl *url, const char *content_type)
Create and initialize a new DilloHtml class.
~DilloHtml()
Free memory used by the DilloHtml class.
dw::core::style::Style * style()
uchar_t Num_HTML
element counters: used for validation purposes.
lout::misc::SimpleVector< DilloUrl * > * links
int32_t non_css_link_color
as provided by link attribute in BODY
Dstr * attr_data
Buffer for attribute value.
bool PrevWasBodyClose
set when </body> is found
lout::misc::SimpleVector< DilloUrl * > * cssUrls
int32_t visited_color
as computed according to CSS
bool InVisitedLink
used to 'contrast_visited_colors'
StyleEngine * styleEngine
lout::misc::SimpleVector< DilloHtmlImage * > * images
HtmlLinkReceiver linkReceiver
DilloHtmlForm * getCurrentForm()
Get the current form.
void loadImages(const DilloUrl *pattern)
Load images if they were disabled.
This class provides the glue between HTML parser and CSS subsystem.
void parse(DilloHtml *html, DilloUrl *url, const char *buf, int buflen, CssOrigin origin)
void setPseudoVisited()
set the CSS pseudo class :visited.
void setNonCssHint(CssPropertyName name, CssValueType type, CssPropertyValue value)
void setId(const char *id)
dw::core::style::Color * backgroundColor()
void endElement(int tag)
tell the styleEngine that a html element has ended.
void setPseudoLink()
set the CSS pseudo class :link.
void setStyle(const char *style)
void setClass(const char *klass)
void inheritBackgroundColor()
Use of the background color of the parent style as default.
dw::core::style::StyleImage * backgroundImage(dw::core::style::BackgroundRepeat *bgRepeat, dw::core::style::BackgroundAttachment *bgAttachment, dw::core::style::Length *bgPositionX, dw::core::style::Length *bgPositionY)
Displays different kind of bullets.
void addShapeToCurrentMap(core::Shape *shape, int link)
Add a shape to the current map-.
void startNewMap(lout::object::Object *key)
Start a new map and make it the current one.
void setCurrentMapDefaultLink(int link)
Set default link for current map-.
Displays an instance of dw::core::Imgbuf.
void setIsMap()
Sets image as server side image map.
void setUseMap(ImageMapsList *list, Object *key)
Sets image as client side image map.
void initWithText(const char *text, core::style::Style *style)
void initWithWidget(core::Widget *widget, core::style::Style *style)
Widget for drawing (horizontal) rules.
A Widget for rendering text blocks, i.e.
void addWidget(core::Widget *widget, core::style::Style *style)
Add a widget (word type) to the page.
void addSpace(core::style::Style *style)
?
void addText(const char *text, size_t len, core::style::Style *style)
Add a word to the page structure.
void addParbreak(int space, core::style::Style *style)
Cause a paragraph break.
dw::core::Shape implemtation for simple circles.
dw::core::Shape implemtation for polygons.
void addPoint(int x, int y)
dw::core::Shape implemtation for simple rectangles.
Abstract interface for different shapes.
ListStyleType listStyleType
static Style * create(StyleAttrs *attrs)
Simple (simpler than container::untyped::Vector and container::typed::Vector) template based vector.
void setSize(int newSize)
Set the size explicitly.
void increase()
Increase the vector size by one.
void set(int i, T t)
Store an object in the vector.
T get(int i) const
Return the one element, explicitly.
int size() const
Return the number of elements put into this vector.
T * getRef(int i) const
Return the reference of one element.
int32_t a_Color_parse(const char *str, int32_t default_color, int *err)
Parse a color string.
int32_t a_Color_vc(int32_t candidate, int32_t C_txt, int32_t C_lnk, int32_t C_bg)
Return a suitable "visited link" color.
@ CSS_PROPERTY_LIST_STYLE_TYPE
@ CSS_PROPERTY_MARGIN_BOTTOM
@ CSS_PROPERTY_BORDER_RIGHT_STYLE
@ CSS_PROPERTY_MARGIN_RIGHT
@ CSS_PROPERTY_BORDER_RIGHT_WIDTH
@ CSS_PROPERTY_BORDER_LEFT_WIDTH
@ CSS_PROPERTY_MARGIN_LEFT
@ CSS_PROPERTY_BORDER_TOP_WIDTH
@ CSS_PROPERTY_MARGIN_TOP
@ CSS_PROPERTY_VERTICAL_ALIGN
@ CSS_PROPERTY_BORDER_LEFT_STYLE
@ CSS_PROPERTY_TEXT_ALIGN
@ CSS_PROPERTY_BORDER_TOP_STYLE
@ CSS_PROPERTY_BACKGROUND_COLOR
@ CSS_PROPERTY_BORDER_BOTTOM_STYLE
@ CSS_PROPERTY_BORDER_BOTTOM_WIDTH
@ CSS_PROPERTY_FONT_FAMILY
@ CSS_TYPE_ENUM
Value is i, if represented by enum_symbols[i].
@ CSS_TYPE_INTEGER
This type is only used internally, for x-* properties.
@ CSS_TYPE_LENGTH_PERCENTAGE
<length> or <percentage>.
@ CSS_TYPE_STRING
<string>
@ CSS_TYPE_SYMBOL
Symbols, which are directly copied (as opposed to CSS_TYPE_ENUM and CSS_TYPE_MULTI_ENUM).
@ CSS_TYPE_COLOR
Represented as integer.
int CssLength
Lengths are represented as int in the following way:
CssLengthType CSS_LENGTH_TYPE(CssLength l)
CssLength CSS_CREATE_LENGTH(float v, CssLengthType t)
@ CSS_LENGTH_TYPE_RELATIVE
This does not exist in CSS but is used in HTML.
@ CSS_LENGTH_TYPE_PERCENTAGE
@ CSS_LENGTH_TYPE_AUTO
This can be used as a simple value.
float CSS_LENGTH_VALUE(CssLength l)
char * a_Url_decode_hex_str(const char *str, size_t *p_sz)
char * dStrconcat(const char *s1,...)
Concatenate a NULL-terminated list of strings.
int dStrAsciiCasecmp(const char *s1, const char *s2)
void dStr_sprintfa(Dstr *ds, const char *format,...)
Printf-like function that appends.
void dStr_append(Dstr *ds, const char *s)
Append a C string to a Dstr.
char * dStrdup(const char *s)
Dstr * dStr_sized_new(int sz)
Create a new string with a given size.
int dStrnAsciiCasecmp(const char *s1, const char *s2, size_t n)
void dStr_erase(Dstr *ds, int pos_0, int len)
Erase a substring.
void dStr_free(Dstr *ds, int all)
Free a dillo string.
char * dStriAsciiStr(const char *haystack, const char *needle)
Case insensitive strstr.
void dStr_append_l(Dstr *ds, const char *s, int l)
Append a C string to a Dstr (providing length).
void dStr_append_c(Dstr *ds, int c)
Append one character.
char * dStrndup(const char *s, size_t sz)
void dStr_sprintf(Dstr *ds, const char *format,...)
Printf-like function.
void dStr_vsprintfa(Dstr *ds, const char *format, va_list argp)
vsprintf-like function that appends.
Dstr * dStr_new(const char *s)
Create a new string.
void dStr_truncate(Dstr *ds, int len)
Truncate a Dstr to be 'len' bytes long.
char * dStrnfill(size_t len, char c)
Return a new string of length 'len' filled with 'c' characters.
#define dReturn_if_fail(expr)
#define dReturn_val_if_fail(expr, val)
#define dReturn_val_if(expr, val)
#define D_ASCII_TOLOWER(c)
#define dNew(type, count)
void a_History_set_title_by_url(const DilloUrl *url, const char *title)
Set the page-title for a given URL.
static void Html_tag_open_video(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_title(DilloHtml *html, const char *tag, int tagsize)
Handle open TITLE.
const char * a_Html_get_attr(DilloHtml *html, const char *tag, int tagsize, const char *attrname)
Call Html_get_attr2 telling it to parse entities and strip the result.
static misc::SimpleVector< int > * Html_read_coords(DilloHtml *html, const char *str)
Read coords in a string, returning a vector of ints.
static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize)
static void Html_css_load_callback(int Op, CacheClient_t *Client)
Called by the network engine when a stylesheet has new data.
static void Html_real_pop_tag(DilloHtml *html)
Pop the top tag in the stack.
static void Html_tag_open_blockquote(DilloHtml *html, const char *tag, int tagsize)
static void Html_push_tag(DilloHtml *html, int tag_idx)
Push the tag (copying attributes from the top of the stack)
static void Html_tag_open_dir(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_a(DilloHtml *html)
bool a_Html_tag_set_valign_attr(DilloHtml *html, const char *tag, int tagsize)
Evaluates the VALIGN attribute (top|bottom|middle|baseline) and sets the style in style_attrs.
static const TagInfo Tags[]
Function index for the open, content, and close functions for each tag.
static int Html_triggers_optional_close(int old_idx, int cur_idx)
For elements with optional close, check whether is time to close, by also following Firefox's de fact...
static void Html_tag_open_html(DilloHtml *html, const char *tag, int tagsize)
Handle open HTML element.
static bool Html_must_add_breaks(DilloHtml *html)
static void Html_tag_content_map(DilloHtml *html, const char *tag, int tagsize)
static void Html_add_anchor(DilloHtml *html, const char *name)
Register an anchor for this page.
static void Html_tag_open_span(DilloHtml *html, const char *tag, int tagsize)
static void Html_free(void *data)
static void Html_tag_open_pre(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize)
static void Html_test_section(DilloHtml *html, int new_idx, int IsCloseTag)
HTML, HEAD and BODY elements have optional open and close tags.
static int Html_set_new_link(DilloHtml *html, DilloUrl **url)
Create a new link, set it as the url's parent and return the index.
void a_Html_form_display_hiddens(void *v_html, void *v_form, bool_t display)
Used by the "Show/Hide hiddens" form menuitem.
static bool Html_contains_form(DilloHtml *html, void *v_form)
Search for form.
static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize)
Handle DOCTYPE declaration.
static void Html_tag_open_q(DilloHtml *html, const char *tag, int tagsize)
DilloUrl * a_Html_url_new(DilloHtml *html, const char *url_str, const char *base_url, int use_base_url)
Wrapper for a_Url_new that adds an error detection message.
static void Html_tag_content_frame(DilloHtml *html, const char *tag, int tagsize)
static void Html_display_listitem(DilloHtml *html)
static int Html_charref_comp(const void *a, const void *b)
Comparison function for binary search.
static void Html_tag_open_frame(DilloHtml *html, const char *tag, int tagsize)
static const char * Html_parse_entity(DilloHtml *html, const char *token, int toksize, int *entsize, bool_t is_attr)
Given an entity, return the corresponding string.
static void Html_tag_open_ul(DilloHtml *html, const char *tag, int tagsize)
static void Html_add_textblock(DilloHtml *html, bool addBreaks, int breakSpace, bool addBreakOpt)
Create and add a new Textblock to the current Textblock.
static void Html_tag_open_h(DilloHtml *html, const char *tag, int tagsize)
static void Html_process_word(DilloHtml *html, const char *word, int size)
Handles putting the word into its proper place.
static void Html_tag_open_object(DilloHtml *html, const char *tag, int tagsize)
void a_Html_tag_set_align_attr(DilloHtml *html, const char *tag, int tagsize)
Evaluates the ALIGN attribute (left|center|right|justify) and sets the style at the top of the stack.
static void Html_tag_open_menu(DilloHtml *html, const char *tag, int tagsize)
static void Html_display_block(DilloHtml *html)
static void Html_tag_close_li(DilloHtml *html)
static void Html_tag_close_pre(DilloHtml *html)
static void Html_tag_content_frameset(DilloHtml *html, const char *tag, int tagsize)
static Charref_t * Html_charref_search(char *key)
Binary search of 'key' in charref list.
static void Html_tag_open_link(DilloHtml *html, const char *tag, int tagsize)
Parse the LINK element (Only CSS stylesheets by now).
static void Html_tag_content_br(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_media(DilloHtml *html)
Media (AUDIO/VIDEO) close function.
static void Html_parse_common_attrs(DilloHtml *html, char *tag, int tagsize)
Parse attributes that can appear on any tag.
static const char * Html_parse_numeric_charref(DilloHtml *html, char *tok, bool_t is_attr, int *entsize)
Parse a numeric character reference (e.g., "/" or "/").
static void Html_tag_content_object(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_source(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_q(DilloHtml *html)
static void Html_tag_close_map(DilloHtml *html)
Handle close <MAP>.
static void Html_eventually_pop_dw(DilloHtml *html, bool hand_over_break)
This function is called after popping the stack, to handle nested Textblock widgets.
static void Html_tag_open_hr(DilloHtml *html, const char *tag, int tagsize)
static CssLength Html_parse_length_or_multi_length(const char *attr, char **endptr)
static void Html_process_space_pre_line(DilloHtml *html, const char *space, int spacesize)
For white-space: pre-line, we must break the line if encountering a newline.
static void Html_tag_cleanup_at_close(DilloHtml *html, int TagIdx)
Conditional cleanup of the stack, called before closing any tag.
static void Html_process_space(DilloHtml *html, const char *space, int spacesize)
Parse spaces.
void a_Html_form_submit(void *v_html, void *v_form)
Used by the "Submit form" form menuitem.
static void Html_tag_open_dd(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_content_hr(DilloHtml *html, const char *tag, int tagsize)
static const char * Html_get_attr2(DilloHtml *html, const char *tag, int tagsize, const char *attrname, int tag_parsing_flags)
Get attribute value for 'attrname' and return it.
static void Html_callback(int Op, CacheClient_t *Client)
Dispatch the apropriate function for 'Op'.
static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
Process a tag, given as 'tag' and 'tagsize'.
static void Html_tag_close_par(DilloHtml *html)
Default close for paragraph tags - pop the stack and break.
void(* TagCloseFunct)(DilloHtml *html)
static void Html_set_link_coordinates(DilloHtml *html, int link, int x, int y)
Set the URL data for image maps.
static void Html_tag_content_img(DilloHtml *html, const char *tag, int tagsize)
Create a new Image struct and request the image-url to the cache.
static void Html_update_content_type(DilloHtml *html, const char *content)
Update the document's content type information based on meta tag data.
void(* TagOpenFunct)(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_default(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_embed(DilloHtml *html, const char *tag, int tagsize)
static int Html_ms_stupid_quotes_2ucs(int codepoint)
This is M$ non-standard "smart quotes" (w1252).
static void Html_tag_open_img(DilloHtml *html, const char *tag, int tagsize)
void a_Html_load_images(void *v_html, DilloUrl *pattern)
Used by the "Load images" page menuitem.
static const char * Html_get_javascript_link(DilloHtml *html)
Test and extract the link from a javascript instruction.
static void Html_tag_content_source(DilloHtml *html, const char *tag, int tagsize)
static int Html_write_raw(DilloHtml *html, char *buf, int bufsize, int Eof)
Here's where we parse the html and put it into the Textblock structure.
static int Html_forbids_cross_nesting(const int InFlags, const int new_idx)
Check nesting and cross-nesting between BUTTON, SELECT, TEXTAREA and A.
static void Html_tag_close_html(DilloHtml *html)
Handle close HTML element.
static void Html_tag_close_title(DilloHtml *html)
Handle close TITLE.
static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize)
Handle META We do not support http-equiv=refresh with delay>0 because it's non standard,...
static void Html_tag_open_script(DilloHtml *html, const char *tag, int tagsize)
Handle open SCRIPT.
static void Html_tag_open_abbr(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_content_wbr(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_sectioning(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_dt(DilloHtml *html, const char *tag, int tagsize)
void * a_Html_text(const char *type, void *P, CA_Callback_t *Call, void **Data)
Set callback function and callback data for the "html/text" MIME type.
static bool Html_load_image(BrowserWindow *bw, DilloUrl *url, const DilloUrl *requester, DilloImage *image)
Tell cache to retrieve image.
static void Html_force_push_tag(DilloHtml *html, int tag_idx)
Push the tag (used to force en element with optional open into the stack).
static void Html_tag_open_style(DilloHtml *html, const char *tag, int tagsize)
Handle open STYLE.
static const char * Html_parse_named_charref(DilloHtml *html, char *tok, bool_t is_attr, int *entsize)
Parse a named character reference (e.g., "&" or "…").
static int Html_check_name_val(DilloHtml *html, const char *val, const char *attrname)
Check that 'val' is composed of characters inside [A-Za-z0-9:_.
int a_Html_tag_index(const char *tag)
Get 'tag' index.
static void Html_tag_open_base(DilloHtml *html, const char *tag, int tagsize)
Set the Document Base URI.
static void Html_tag_content_area(DilloHtml *html, const char *tag, int tagsize)
static bool Html_match_tag(const char *tagstr, char *tag, int tagsize)
Does the tag in tagstr (e.g.
static void Html_tag_close_body(DilloHtml *html)
static void Html_tag_open_audio(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_font(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_head(DilloHtml *html)
Handle close HEAD element.
static void Html_tag_cleanup_to_idx(DilloHtml *html, int s_idx, int new_idx, int fi, char op)
Cleanup the stack to a given index.
static void Html_tag_content_embed(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_script(DilloHtml *html)
Handle close SCRIPT.
static void Html_display_inline_block(DilloHtml *html)
static void Html_stack_cleanup_at_open(DilloHtml *html, int ni)
Conditional cleanup of the stack (at open time).
static int Html_tag_pre_excludes(DilloHtml *html, int tag_idx)
Check whether a tag is in the "excluding" element set for PRE.
static void Html_tag_open_head(DilloHtml *html, const char *tag, int tagsize)
Handle open HEAD element.
static void Html_tag_open_li(DilloHtml *html, const char *tag, int tagsize)
static int Html_tag_compare(const char *p1, const char *p2)
static void Html_check_html5_obsolete(DilloHtml *html, int ni)
Warn when encountering elements that are obsolete in HTML5.
static void Html_tag_open_p(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_style(DilloHtml *html)
Handle close STYLE.
static void Html_tag_open_ol(DilloHtml *html, const char *tag, int tagsize)
void a_Html_form_reset(void *v_html, void *v_form)
Used by the "Reset form" form menuitem.
static void Html_tag_open_dl(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_div(DilloHtml *html, const char *tag, int tagsize)
static const Charref_t Charrefs[NumRef]
const char * a_Html_get_attr(DilloHtml *html, const char *tag, int tagsize, const char *attrname)
Call Html_get_attr2 telling it to parse entities and strip the result.
void a_Html_stash_init(DilloHtml *html)
Initialize the stash buffer.
@ DILLO_HTML_TABLE_MODE_NONE
no table at all
DilloUrl * a_Html_url_new(DilloHtml *html, const char *url_str, const char *base_url, int use_base_url)
Wrapper for a_Url_new that adds an error detection message.
#define HT2TB(html)
"html struct" to Textblock
DilloImage * a_Html_image_new(DilloHtml *html, const char *tag, int tagsize)
int32_t a_Html_color_parse(DilloHtml *html, const char *str, int32_t default_color)
Parse a color attribute.
void a_Html_tag_set_align_attr(DilloHtml *html, const char *tag, int tagsize)
Evaluates the ALIGN attribute (left|center|right|justify) and sets the style at the top of the stack.
@ DILLO_HTML_PARSE_MODE_PRE
@ DILLO_HTML_PARSE_MODE_VERBATIM
@ DILLO_HTML_PARSE_MODE_BODY
@ DILLO_HTML_PARSE_MODE_INIT
@ DILLO_HTML_PARSE_MODE_STASH_AND_BODY
@ DILLO_HTML_PARSE_MODE_STASH
#define BUG_MSG(...)
Add a bug-meter message.
void a_Html_common_image_attrs(DilloHtml *html, const char *tag, int tagsize)
Read image-associated tag attributes and create new image.
#define S_TOP(html)
Top of the parsing stack.
dw::core::style::Length a_Html_parse_length(DilloHtml *html, const char *attr)
Returns a length or a percentage, or UNDEF_LENGTH in case of an error, or if attr is NULL.
#define HT2LT(html)
"html struct" to "Layout"
@ DILLO_HTML_TABLE_BORDER_SEPARATE
char * a_Html_get_attr_wdef(DilloHtml *html, const char *tag, int tagsize, const char *attrname, const char *def)
"a_Html_get_attr with default" Call a_Html_get_attr() and dStrdup() the returned string.
int a_Html_tag_index(const char *tag)
Get 'tag' index.
char * a_Html_parse_entities(DilloHtml *html, const char *token, int toksize)
Parse all the entities in a token.
void a_Html_load_stylesheet(DilloHtml *html, DilloUrl *url)
Tell cache to retrieve a stylesheet.
int a_Misc_content_type_cmp(const char *ct1, const char *ct2)
Compare two Content-Type strings.
void a_Misc_parse_content_type(const char *type, char **major, char **minor, char **charset)
Parse Content-Type string, e.g., "text/html; charset=utf-8".
Anything related to Dillo Widget styles is defined here.
@ LIST_STYLE_TYPE_UPPER_ALPHA
@ LIST_STYLE_TYPE_LOWER_ALPHA
@ LIST_STYLE_TYPE_UPPER_ROMAN
@ LIST_STYLE_TYPE_DECIMAL
@ LIST_STYLE_TYPE_LOWER_ROMAN
int Length
Type for representing all lengths within dw::core::style.
void numtostr(int num, char *buf, int buflen, ListStyleType listStyleType)
Convert a number into a string, in a given list style.
Anything related to embedded UI widgets is defined here.
The core of Dw is defined in this namespace.
Dw is in this namespace, or sub namespaces of this one.
DilloPrefs prefs
Global Data.
void a_Image_ref(DilloImage *Image)
Add a reference to an Image struct Do nothing if the argument is NULL.
void a_Image_unref(DilloImage *Image)
Unref and free if necessary Do nothing if the argument is NULL.
DilloImage * a_Image_new(void *layout, void *img_rndr, int32_t bg_color, int32_t fg_color)
Create and initialize a new image structure.
void Html_tag_open_td(DilloHtml *html, const char *tag, int tagsize)
void Html_tag_content_tbody(DilloHtml *html, const char *tag, int tagsize)
void Html_tag_open_tbody(DilloHtml *html, const char *tag, int tagsize)
void Html_tag_open_thead(DilloHtml *html, const char *tag, int tagsize)
void Html_tag_content_th(DilloHtml *html, const char *tag, int tagsize)
void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize)
void Html_tag_open_tfoot(DilloHtml *html, const char *tag, int tagsize)
void Html_tag_content_td(DilloHtml *html, const char *tag, int tagsize)
void Html_tag_content_tr(DilloHtml *html, const char *tag, int tagsize)
void Html_tag_open_th(DilloHtml *html, const char *tag, int tagsize)
void Html_tag_content_table(DilloHtml *html, const char *tag, int tagsize)
void Html_tag_open_tr(DilloHtml *html, const char *tag, int tagsize)
Contains the specific data for a single window.
int num_page_bugs
HTML-bugs detected at parse time.
int NumPendingStyleSheets
Number of not yet arrived style sheets.
Data structure for cache clients.
int Key
Primary Key for this client.
void * CbData
Client function data.
uint_t BufSize
Valid size of cache-data.
void * Buf
Pointer to cache-data.
void * Web
Pointer to the Web structure of our client.
DilloHtmlTableMode table_mode
bool hand_over_break
This is used for list items etc.
DilloHtmlTableBorderMode table_border_mode
dw::core::Widget * textblock
DilloHtmlListMode list_type
dw::core::Widget * ref_list_item
This is used to align list items (especially in enumerated lists)
DilloHtmlParseMode parse_mode
int tag_idx
TagInfo index for the tag that's being processed.
bool_t parse_embedded_css
bool_t show_extra_warnings
bool_t contrast_visited_color
bool_t middle_click_opens_new_tab
int flags
Additional info.
DilloUrl * url
Requested URL.
BrowserWindow * bw
The requesting browser window [reference].
DilloImage * Image
For image urls [reference].
void a_UIcmd_link_popup(void *vbw, const DilloUrl *url)
void a_UIcmd_set_bug_prog(BrowserWindow *bw, int n_bug)
void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, void *v_cssUrls)
void a_UIcmd_set_msg(BrowserWindow *bw, const char *format,...)
void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img, DilloUrl *page_url, DilloUrl *link_url)
void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label)
void a_UIcmd_open_url_nw(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd_repush(void *vbw)
void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd_redirection0(void *vbw, const DilloUrl *url)
void a_UIcmd_open_url_nt(void *vbw, const DilloUrl *url, int focus)
void a_Url_set_flags(DilloUrl *u, int flags)
Set DilloUrl flags.
int a_Url_cmp(const DilloUrl *A, const DilloUrl *B)
Compare two Url's to check if they're the same, or which one is bigger.
void a_Url_free(DilloUrl *url)
Free a DilloUrl.
void a_Url_set_ismap_coords(DilloUrl *u, char *coord_str)
Set DilloUrl ismap coordinates.
DilloUrl * a_Url_new(const char *url_str, const char *base_url)
Transform (and resolve) an URL string into the respective DilloURL.
char * a_Url_str(const DilloUrl *u)
Return the url as a string.
DilloUrl * a_Url_dup(const DilloUrl *ori)
Duplicate a Url structure.
#define URL_ILLEGAL_CHARS_SPC(u)
#define URL_ILLEGAL_CHARS(u)
bool_t a_Utf8_ideographic(const char *s, const char *end, int *len)
Does s point to a UTF-8-encoded ideographic character?.
int a_Utf8_encode(unsigned int ucs, char *buf)
Write UTF-8 encoding of ucs into buf and return number of bytes written.
static const char utf8_zero_width_space[]
Unicode zero width space U+200B.
DilloWeb * a_Web_new(BrowserWindow *bw, const DilloUrl *url, const DilloUrl *requester)
Allocate and set safe values for a DilloWeb structure.