160 "HTML warning: line %d, ",
162 va_start(argp, format);
173 const char *url_str,
const char *base_url,
177 MSG(
"a_Html_url_new: URL is NULL\n");
185 BUG_MSG(
"URL is not valid '%s'.", url_str);
191 const char *suffix = (n_ic) > 1 ?
"s" :
"";
193 if (n_ic == n_ic_spc) {
194 BUG_MSG(
"URL has %d illegal space%s ('%s').", n_ic, suffix, url_str);
195 }
else if (n_ic_spc == 0) {
196 BUG_MSG(
"URL has %d illegal byte%s in {00-1F, 7F-FF} range ('%s').",
197 n_ic, suffix, url_str);
199 BUG_MSG(
"URL has %d illegal byte%s: "
200 "%d space%s and %d in {00-1F, 7F-FF} range ('%s').",
202 n_ic_spc, n_ic_spc > 1 ?
"s" :
"", n_ic-n_ic_spc, url_str);
219 return (
void*)html->
dw;
242 for (
int i = 0; i < html->
forms->
size(); i++) {
243 if (html->
forms->
get(i) == v_form) {
297 snprintf(data, 64,
"?%d,%d", x, y);
310 html->
links->
set(nl, (*url) ? *url : NULL);
326 BUG_MSG(
"The align attribute is obsolete in HTML5.");
341 if (charattr[0] == 0)
346 style_attrs.textAlignChar =
' ';
348 style_attrs.textAlignChar = charattr[0];
351 style_attrs.textAlignChar =
'.';
370 BUG_MSG(
"The valign attribute is obsolete in HTML5.");
404 style = html->
style ();
411 HT2TB(html)->addWidget (textblock, style);
413 HT2TB(html)->addBreakOption (html->
style (),
false);
417 S_TOP(html)->textblock = html->
dw = textblock;
419 S_TOP(html)->hand_over_break =
true;
426 return HT2TB(html)->mustAddBreaks (html->
style ());
433 const char *content_type)
467 cssUrls =
new misc::SimpleVector <DilloUrl*> (1);
469 stack =
new misc::SimpleVector <DilloHtmlState> (16);
508 forms =
new misc::SimpleVector <DilloHtmlForm*> (1);
510 links =
new misc::SimpleVector <DilloUrl*> (64);
511 images =
new misc::SimpleVector <DilloHtmlImage*> (16);
538 _MSG(
"::~DilloHtml(this=%p)\n",
this);
584 _MSG(
"DilloHtml::write BufSize=%d Start_Ofs=%d\n", BufSize,
Start_Ofs);
616 for (i =
OldOfs; i < ofs; ++i)
617 if (p[i] ==
'\n' || (p[i] ==
'\r' && p[i+1] !=
'\n'))
677 _MSG(
"Html formNew: action=%s nform=%d\n", action, nf);
747 _MSG(
" Link LEAVE notify...\n");
750 _MSG(
" Link ENTER notify...\n");
773 linkurl = html->links->get(link);
774 const bool_t loaded_img = (html->images->get(img)->image == NULL);
776 html->page_url, linkurl);
799 if ((img != -1) && (html->images->get(img)->image)) {
803 DilloUrl *pattern = html->images->get(img)->url;
804 html->loadImages(pattern);
810 DilloUrl *url = html->links->get(link);
827 }
else if (event->
button == 2) {
840 _MSG(
" ->%s\n", w->getClassName());
842 ((
Textblock*)w)->changeLinkColor (link, html->visited_color);
871 case 146: ret =
'\'';
break;
873 case 148: ret =
'"';
break;
874 case 149: ret = 176;
break;
876 case 151: ret =
'-';
break;
877 default: ret = codepoint;
break;
887 bool_t is_attr,
int *entsize)
891 int n, codepoint = -1;
895 if (*s ==
'x' || *s ==
'X') {
896 if (isxdigit(*++s)) {
898 if (*s ==
'0' && s[1] ==
'x') {
902 codepoint = strtol(s, &s, 16);
905 }
else if (isdigit(*s)) {
906 codepoint = strtol(s, &s, 10);
918 BUG_MSG(
"Character reference '&#%s' lacks ';'.", tok);
931 if ((codepoint < 0x20 && codepoint !=
'\t' && codepoint !=
'\n' &&
932 codepoint !=
'\f') ||
933 (codepoint >= 0x7f && codepoint <= 0x9f) ||
934 (codepoint >= 0xd800 && codepoint <= 0xdfff) || codepoint > 0x10ffff ||
935 ((codepoint & 0xfffe) == 0xfffe) ||
937 codepoint > 0xffff)) {
943 BUG_MSG(
"Numeric character reference '&#%s' is not valid.", tok);
946 codepoint = (codepoint >= 145 && codepoint <= 151) ?
949 if (codepoint != -1) {
950 if (codepoint >= 128) {
954 buf[0] = (char) codepoint;
990 bool_t is_attr,
int *entsize)
995 const char *ret = NULL;
997 while (*++s && (isalnum(*s) || strchr(
":_.-", *s))) ;
1003 BUG_MSG(
"Character reference '&%s' lacks ';'.", tok);
1030 BUG_MSG(
"Undefined character reference '&%s'.", tok);
1046 int toksize,
int *entsize,
bool_t is_attr)
1048 const char *ret = NULL;
1064 }
else if (isalpha(*tok)) {
1082 const char *esc_set =
"&";
1086 s = strcspn(token, esc_set);
1095 for (i = s; i < toksize; i++) {
1099 if (token[i] ==
'&' &&
1121 int i, breakCnt = 0;
1123 for (i = 0; i < spacesize; i++) {
1125 if (space[i] ==
'\r' || (space[i] ==
'\n' && !html->
PrevWasCR)) {
1132 if (breakCnt == 0) {
1147 if (
S_TOP(html)->display_none) {
1159 for (i = 0; i < spacesize; i++) {
1162 (space[i] ==
'\r' || (space[i] ==
'\n' && !html->
PrevWasCR))) {
1182 BUG_MSG(
"TAB character inside <pre>.");
1232 if (
S_TOP(html)->display_none)
1235 BUG_MSG(
"Content after </%s> tag.", i == 1 ?
"html" :
"body");
1261 for (start = i = 0; Pword[i]; start = i)
1262 if (isspace(Pword[i])) {
1263 while (Pword[++i] && isspace(Pword[i])) ;
1266 while (Pword[++i] && !isspace(Pword[i])) ;
1267 HT2TB(html)->addText(Pword + start, i - start, html->
wordStyle ());
1274 const char *word2, *beyond_word2;
1277 if (!memchr(word,
'&', size)) {
1280 beyond_word2 = word + size;
1285 for (i = j = 0; (Pword[i] = Pword[j]); ++i, ++j) {
1286 if (strchr(
" \t\f\n\r", Pword[i])) {
1287 if (i == 0 || (i > 0 && Pword[i-1] !=
' '))
1290 for (--i; Pword[j+1] && strchr(
" \t\f\n\r", Pword[j+1]); ++j)
1295 beyond_word2 = word2 + strlen(word2);
1297 for (start = i = 0; word2[i]; start = i) {
1300 if (isspace(word2[i])) {
1301 while (word2[++i] && isspace(word2[i])) ;
1308 HT2TB(html)->addText(word2 + start, i - start, html->
wordStyle ());
1313 }
while (word2[i] && !isspace(word2[i]) &&
1316 HT2TB(html)->addText(word2 + start, i - start, html->
wordStyle ());
1332 for (i = 0; i < tagsize && tagstr[i] !=
'\0'; i++) {
1337 if (i < tagsize && (isspace(tag[i]) || tag[i] ==
'>' || tag[i] ==
'/'))
1348 if (html->
dw !=
S_TOP(html)->textblock) {
1349 if (hand_over_break)
1351 HT2TB(html)->flush ();
1352 html->
dw =
S_TOP(html)->textblock;
1369 html->
dw =
S_TOP(html)->textblock;
1387 bool hand_over_break;
1390 hand_over_break =
S_TOP(html)->hand_over_break;
1411 v = strtod (attr, &end);
1454 if (*end && !isspace (*end)) {
1455 BUG_MSG(
"Garbage after length: '%s'.", attr);
1469 int32_t default_color)
1475 BUG_MSG(
"Color \"%s\" is not in \"#RRGGBB\" format.", str);
1489 bool valid = *val && !strchr(val,
' ');
1492 BUG_MSG(
"'%s' value \"%s\" must not be empty and must not contain "
1493 "spaces.", attrname, val);
1495 return valid ? 1 : 0;
1499 for (i = 0; val[i]; ++i)
1500 if (!
d_isascii(val[i]) || !(isalnum(val[i]) || strchr(
":_.-", val[i])))
1503 if (val[i] || !(
d_isascii(val[0]) && isalpha(val[0])))
1504 BUG_MSG(
"%s attribute value \"%s\" is not of the form "
1505 "'[A-Za-z][A-Za-z0-9:_.-]*'.", attrname, val);
1532 static const char HTML_SGML_sig [] =
"<!DOCTYPE HTML PUBLIC ";
1533 static const char HTML20 [] =
"-//IETF//DTD HTML";
1534 static const char HTML32 [] =
"-//W3C//DTD HTML 3.2";
1535 static const char HTML40 [] =
"-//W3C//DTD HTML 4.0";
1536 static const char HTML401 [] =
"-//W3C//DTD HTML 4.01";
1537 static const char HTML401_url[] =
"http://www.w3.org/TR/html4/";
1538 static const char XHTML1 [] =
"-//W3C//DTD XHTML 1.0";
1539 static const char XHTML1_url [] =
"http://www.w3.org/TR/xhtml1/DTD/";
1540 static const char XHTML11 [] =
"-//W3C//DTD XHTML 1.1";
1541 static const char XHTML11_url[] =
"http://www.w3.org/TR/xhtml11/DTD/";
1545 char *p, *ntag =
dStrndup(tag, tagsize);
1549 for (i = 0, p = ntag; *p; ++p) {
1551 for (ntag[i++] =
' '; isspace(p[1]); ++p) ;
1552 }
else if ((quote = *p) ==
'"' || *p ==
'\'') {
1553 for (ntag[i++] = *p++; (ntag[i] = *p) && ntag[i++] != quote; ++p) {
1554 if (*p ==
'\n' || *p ==
'\r')
1556 p += (p[0] ==
'\r' && p[1] ==
'\n') ? 1 : 0;
1566 _MSG(
"New: {%s}\n", ntag);
1569 BUG_MSG(
"Multiple DOCTYPE declarations.");
1572 if (i > strlen(HTML_SGML_sig) &&
1574 p = ntag + strlen(HTML_SGML_sig) + 1;
1575 if (!strncmp(p, HTML401, strlen(HTML401)) &&
1579 }
else if (!strncmp(p, XHTML1, strlen(XHTML1)) &&
1583 }
else if (!strncmp(p, XHTML11, strlen(XHTML11)) &&
1587 }
else if (!strncmp(p, HTML40, strlen(HTML40))) {
1590 }
else if (!strncmp(p, HTML32, strlen(HTML32))) {
1593 }
else if (!strncmp(p, HTML20, strlen(HTML20))) {
1600 "<!DOCTYPE html SYSTEM \"about:legacy-compat\">") ||
1602 "<!DOCTYPE html SYSTEM 'about:legacy-compat'>")) {
1608 BUG_MSG(
"DOCTYPE not recognized: ('%s').", ntag);
1627 BUG_MSG(
"<html> was already open.");
1637 _MSG(
"Html_tag_close_html: Num_HTML=%d\n", html->
Num_HTML);
1650 BUG_MSG(
"<head> must go before the BODY section.");
1658 BUG_MSG(
"<head> was already open.");
1661 BUG_MSG(
"<head> already finished -- ignoring.");
1678 BUG_MSG(
"<head> lacks <title>.");
1708 BUG_MSG(
"Redundant <title>.");
1710 BUG_MSG(
"<title> must be inside <head> -- ignoring.");
1724 if (!title || title[0] ==
'\0')
1756 const char *attrbuf;
1762 BUG_MSG(
"<style> requires type attribute.");
1795 const char *attrbuf;
1803 _MSG(
"Html_tag_open_body Num_BODY=%d\n", html->
Num_BODY);
1810 BUG_MSG(
"<body> was already open.");
1824 BUG_MSG(
"<body> bgcolor attribute is obsolete.");
1835 BUG_MSG(
"<body> text attribute is obsolete.");
1847 BUG_MSG(
"<body> link attribute is obsolete.");
1853 BUG_MSG(
"<body> vlink attribute is obsolete.");
1860 HT2LT(html)->setBgColor(bgColor);
1863 &bgPositionX, &bgPositionY);
1865 HT2LT(html)->setBgImage(bgImage, bgRepeat, bgAttachment, bgPositionX,
1901 _MSG(
"Html_tag_close_body: Num_BODY=%d\n", html->
Num_BODY);
1927 const char *attrbuf;
1952 const char *attrbuf;
1957 textblock =
HT2TB(html);
1996 const char *tag,
int tagsize)
2011 S_TOP(html)->parse_mode =
2028 const char *attrbuf;
2029 char *fontFamily = NULL;
2045 fontFamily =
dStrdup(attrbuf);
2058 const char *attrbuf;
2075 char *width_ptr, *height_ptr;
2076 const char *attrbuf;
2109 if (w < 0 || h < 0 ||
2114 width_ptr = height_ptr = NULL;
2115 MSG(
"a_Html_common_image_attrs: suspicious image size request %d x %d\n",
2147 const char *attrbuf;
2156 if (!alt_ptr || !*alt_ptr) {
2159 }
else if (alt_ptr) {
2160 char *new_alt =
dStrconcat(
"[IMG] ", alt_ptr, NULL);
2171 if (
HT2TB(html)->getBgColor())
2174 if (
HT2TB(html)->getFgColor())
2217 return ClientKey != 0;
2223 const char *attrbuf;
2229 int space = strtol(attrbuf, NULL, 10);
2241 int space = strtol(attrbuf, NULL, 10);
2253 border = strtol(attrbuf, NULL, 10);
2287 const char *attrbuf;
2307 HT2TB(html)->addBreakOption (html->
style (),
false);
2312 _MSG(
" Html_tag_open_img: server-side map (ISMAP)\n");
2314 usemap_url == NULL) {
2332 const char *attrbuf;
2346 BUG_MSG(
"<map> requires name attribute.");
2361 for (
int i = 0; i < html->
images->
size(); i++) {
2383 const char *tail = str;
2384 char *newtail = NULL;
2388 coord = strtol(tail, &newtail, 10);
2389 if (coord == 0 && newtail == tail)
2392 coords->
set(coords->
size() - 1, coord);
2393 while (isspace(*newtail))
2397 if (*newtail !=
',') {
2398 BUG_MSG(
"<area> coords must be integers separated by commas.");
2412 enum types {UNKNOWN, RECTANGLE, CIRCLE, POLYGON, BACKGROUND};
2416 const char *attrbuf;
2418 Shape *shape = NULL;
2421 BUG_MSG(
"<area> not inside <map>.");
2437 BUG_MSG(
"<area> unknown shape: '%s'.", attrbuf);
2440 if (type == RECTANGLE || type == CIRCLE || type == POLYGON) {
2444 if (type == RECTANGLE) {
2445 if (coords->
size() != 4)
2446 BUG_MSG(
"<area> rectangle must have four coordinate values.");
2447 if (coords->
size() >= 4)
2450 coords->
get(2) - coords->
get(0),
2451 coords->
get(3) - coords->
get(1));
2452 }
else if (type == CIRCLE) {
2453 if (coords->
size() != 3)
2454 BUG_MSG(
"<area> circle must have three coordinate values.");
2455 if (coords->
size() >= 3)
2458 }
else if (type == POLYGON) {
2461 if (coords->
size() % 2)
2462 BUG_MSG(
"<area> polygon with odd number of coordinates.");
2464 for (i = 0; i < (coords->
size() / 2); i++)
2470 if (shape != NULL || type == BACKGROUND) {
2477 if (type == BACKGROUND)
2491 const char *attrbuf;
2528 const char *attrbuf;
2531 MSG(
"<video> not handled when already inside a media element.\n");
2561 const char *attrbuf;
2564 MSG(
"<audio> not handled when already inside a media element.\n");
2593 const char *attrbuf;
2601 BUG_MSG(
"<source> requires src attribute.");
2639 const char *attrbuf;
2673 i = strcspn(Buf->
str,
"'\"");
2675 if ((ch ==
'"' || ch ==
'\'') &&
2676 (p2 = strchr(Buf->
str + i + 1 , ch))) {
2678 BUG_MSG(
"Link depends on javascript().");
2691 _MSG(
"Registering ANCHOR: %s\n", name);
2692 if (!
HT2TB(html)->addAnchor (name, html->
style ()))
2693 BUG_MSG(
"Anchor names must be unique within the document (\"%s\").",
2711 const char *attrbuf;
2763 if (!
id || strcmp(nameVal,
id)) {
2765 BUG_MSG(
"In <a>, id ('%s') and name ('%s') attributes differ.",
2788 const char *tag,
int tagsize)
2802 const char *U201C =
"\xe2\x80\x9c";
2814 const char *U201D =
"\xe2\x80\x9d";
2824 const char *attrbuf;
2843 BUG_MSG(
"<ul> type attribute is obsolete.");
2847 S_TOP(html)->list_number = 0;
2848 S_TOP(html)->ref_list_item = NULL;
2861 S_TOP(html)->list_number = 0;
2862 S_TOP(html)->ref_list_item = NULL;
2865 BUG_MSG(
"Obsolete list type; use <ul> instead.");
2890 const char *attrbuf;
2896 if (*attrbuf ==
'1')
2898 else if (*attrbuf ==
'a')
2900 else if (*attrbuf ==
'A')
2902 else if (*attrbuf ==
'i')
2904 else if (*attrbuf ==
'I')
2914 (n = (
int) strtol(attrbuf, NULL, 10)) < 0) {
2915 BUG_MSG(
"Illegal '-' character in START attribute; Starting from 0.");
2918 S_TOP(html)->list_number = n;
2919 S_TOP(html)->ref_list_item = NULL;
2929 const char *attrbuf;
2936 BUG_MSG(
"<li> outside <ul> or <ol>.");
2947 (*list_number = strtol(attrbuf, NULL, 10)) < 0) {
2948 BUG_MSG(
"Illegal negative list value attribute; Starting from 0.");
2969 const char *attrbuf;
2975 BUG_MSG(
"<hr> width attribute is obsolete.");
2983 size = strtol(attrbuf, NULL, 10);
2985 BUG_MSG(
"<hr> size attribute is obsolete.");
2993 BUG_MSG(
"<hr> noshade attribute is obsolete.");
3029 hruler =
new Ruler();
3031 HT2TB(html)->addWidget (hruler, html->
style ());
3089 const char *es_set[] = {
"img",
"object",
"applet",
"big",
"small",
"sub",
3090 "sup",
"font",
"basefont", NULL};
3091 static int ei_set[10], i;
3095 for (i = 0; es_set[i]; ++i)
3098 for (i = 0; ei_set[i]; ++i)
3099 if (tag_idx == ei_set[i])
3136 const char meta_template[] =
3137"<table width='100%%'><tr><td bgcolor='#ee0000'>Warning:</td>\n"
3138" <td bgcolor='#8899aa' width='100%%'>\n"
3139" This page uses the NON-STANDARD meta refresh tag.<br> The HTML 4.01 SPEC\n"
3140" (sec 7.4.4) recommends explicitly to avoid it.</td></tr>\n"
3141" <tr><td bgcolor='#a0a0a0' colspan='2'>The author wanted you to go\n"
3142" <a href='%s'>here</a>%s</td></tr></table><br>\n";
3144 const char *p, *equiv, *
charset, *content;
3145 char delay_str[64], *mr_url;
3156 BUG_MSG(
"This <meta> element must be inside the HEAD section.");
3166 if ((delay = strtol(content, NULL, 0))) {
3167 snprintf(delay_str, 64,
" after %d second%s.",
3168 delay, (delay > 1) ?
"s" :
"");
3170 sprintf(delay_str,
".");
3175 content = p + strlen(
"url=");
3176 else if ((p = strstr(content,
";")))
3177 content = p + strlen(
";");
3183 if (*content ==
'"' || *content ==
'\'') {
3184 if ((p = strchr(content + 1, *content)))
3185 mr_url =
dStrndup(content + 1, p - content - 1);
3187 mr_url =
dStrdup(content + 1);
3199 BUG_MSG(
"<meta> refresh: %s.",
3200 *mr_url ?
"redirection loop" :
"no target URL");
3201 }
else if (delay == 0) {
3206 "WARNING: local URL with META refresh. Aborting.");
3217 int o_InFlags = html->
InFlags;
3218 int o_TagSoup = html->
TagSoup;
3232 _MSG(
"Html_tag_open_meta: content={%s}\n", content);
3249 _MSG(
"Html_css_load_callback: Op=%d\n", Op);
3268 _MSG(
"Html_load_stylesheet: ");
3272 if (strncmp(
"@charset \"", data, 10) == 0) {
3273 char *endq = strchr(data+10,
'"');
3275 if (endq && (endq - data <= 51)) {
3316 const char *attrbuf;
3332 BUG_MSG(
"This <link> element must be inside the HEAD section.");
3354 _MSG(
" Html_tag_open_link(): addCssUrl %s\n",
URL_STR(url));
3365 const char *attrbuf;
3383 BUG_MSG(
"<base> URI is relative (it MUST be absolute).");
3388 BUG_MSG(
"<base> not inside HEAD section.");
3402 const char *attrbuf;
3420 const char *attrbuf;
3596#define NTAGS (sizeof(Tags)/sizeof(Tags[0]))
3599#if __cpp_static_assert
3601 "Mismatch between number of tags in Tags and HTML_NTAGS");
3617 return !strchr(
" >/\n\r\t", *p1);
3626 int low, high, mid, cond;
3631 while (low <= high) {
3632 mid = (low + high) / 2;
3653 int Flags =
Tags[cur_idx].Flags;
3654 if (old_idx ==
i_P || old_idx ==
i_DT) {
3656 return (!(Flags & 1));
3657 }
else if (old_idx ==
i_LI) {
3660 return (cur_idx ==
i_LI);
3661 }
else if (old_idx ==
i_TD || old_idx ==
i_TH) {
3665 }
else if (old_idx ==
i_TR) {
3668 }
else if (old_idx ==
i_DD) {
3670 return (cur_idx ==
i_DD || cur_idx ==
i_DT);
3693 int f =
InFlags, ni = new_idx, oi = -1;
3710 int new_idx,
int fi,
char op)
3712 int s_top, ni = new_idx;
3713 while ((s_top = html->
stack->
size() - 1) >= s_idx) {
3714 int toptag_idx =
S_TOP(html)->tag_idx;
3715 TagInfo toptag =
Tags[toptag_idx];
3719 if (toptag_idx != fi)
3720 BUG_MSG(
" Nesting cleanup - forcing close of open tag: <%s>.",
3722 }
else if (s_top == s_idx && op ==
'c') {
3724 }
else if (toptag.EndTag ==
'O') {
3726 }
else if ((!(toptag.Flags & 4) &&
3727 (
Tags[ni].Flags & 4 || !(
Tags[ni].Flags & 1))) ||
3728 (
Tags[ni].Flags & 1 && !(toptag.Flags & 2))) {
3732 "Bad nesting: <%s> can't contain <%s>. -- closing <%s>." :
3733 "<%s> needs to be closed before </%s>. -- closing <%s>.",
3734 toptag.name,
Tags[ni].name, toptag.name);
3737 "<%s> should have been closed before </%s>. -- closing <%s>.",
3738 toptag.name,
Tags[ni].name, toptag.name);
3740 _MSG(
"op(%c): %s s_top=%d s_idx=%d\n", op, toptag.name, s_top, s_idx);
3741 if (toptag_idx ==
i_BODY &&
3766 int s_top = html->
stack->
size() - 1, s_idx;
3768 for (s_idx = s_top; s_idx > 0; --s_idx) {
3776 BUG_MSG(
"Forbidden nesting: <%s> can't contain <%s>. -- closing "
3782 }
else if (
Tags[ti].EndTag ==
'O') {
3785 }
else if (!(
Tags[ni].Flags & 1) && !(
Tags[ti].Flags & 4)) {
3813 int stack_idx, tag_idx, matched = 0, expected = 0;
3814 TagInfo new_tag =
Tags[new_idx];
3818 while (--stack_idx) {
3820 if (tag_idx == new_idx) {
3824 }
else if (
Tags[tag_idx].EndTag ==
'O') {
3833 }
else if (
Tags[new_idx].Flags & 4 &&
3834 Tags[stack_idx].Flags & 3) {
3846 }
else if (expected) {
3847 BUG_MSG(
"Unexpected closing tag: </%s> -- expected </%s>.",
3848 new_tag.name,
Tags[tag_idx].name);
3850 BUG_MSG(
"Unexpected closing tag: </%s>.", new_tag.name);
3864 BUG_MSG(
"The required DOCTYPE declaration is missing. "
3865 "Handling as HTML4.");
3870 if (tag_idx != new_idx || IsCloseTag) {
3874 Tags[tag_idx].open (html, tag, strlen(tag));
3878 if (
Tags[new_idx].Flags & 16) {
3883 if (tag_idx != new_idx || IsCloseTag) {
3887 Tags[tag_idx].open (html, tag, strlen(tag));
3891 }
else if (
Tags[new_idx].Flags & 8) {
3900 if (tag_idx != new_idx || IsCloseTag) {
3904 Tags[tag_idx].open (html, tag, strlen(tag));
3914 const char *attrbuf;
3945 memset(lang, 0,
sizeof(lang));
3946 if (tagsize >= 14) {
3950 strncpy(lang, attrbuf, 2);
3952 if (!lang[0] && tagsize >= 10) {
3956 strncpy(lang, attrbuf, 2);
3968 static int indexes[9] = {-1};
3970 if (indexes[0] == -1) {
3981 for (
int i = 0; i < 9; i++) {
3982 if (indexes[i] == ni) {
3983 BUG_MSG(
"<%s> is obsolete in HTML5.",
Tags[ni].name);
4018 *ref_list_item = list_item;
4019 S_TOP(html)->textblock = html->
dw = list_item;
4035 if (
S_TOP(html)->display_none)
4052 char *start = tag + 1;
4053 int IsCloseTag = (*start ==
'/');
4067 _MSG(
"Html_process_tag: %s%s\n", IsCloseTag ?
"/" :
"",
Tags[ni].name);
4073 if (i == 1 || (i == 2 && ni !=
i_HTML))
4074 BUG_MSG(
"Content after </%s> tag.", i == 1 ?
"html" :
"body");
4082 ti =
S_TOP(html)->tag_idx;
4083 switch (IsCloseTag) {
4094 BUG_MSG(
"<pre> is not allowed to contain <%s>.",
Tags[ni].name);
4106 _MSG(
"Html_process_tag Open : %s\n",
Tags[ni].name);
4107 Tags[ni].open (html, tag, tagsize);
4109 if (!
S_TOP(html)->display_none) {
4121 S_TOP(html)->display_none =
true;
4131 if (
Tags[ni].content && !
S_TOP(html)->display_none) {
4132 Tags[ni].content (html, tag, tagsize);
4155 if (
Tags[ni].EndTag ==
'F')
4165 if (*start ==
'/' ||
4167 (tag[tagsize-2] ==
'/' &&
4168 (strchr(
" \"'", tag[tagsize-3]) ||
4169 (
size_t)tagsize == strlen(
Tags[ni].name) + 3))) {
4171 _MSG(
"Html_process_tag Close: %s\n",
Tags[ni].name);
4192 const char *attrname,
4193 int tag_parsing_flags)
4195 int i, entsize, Found = 0, delimiter = 0, attr_pos = 0;
4203 for (i = 1; i < tagsize; ++i) {
4206 if (isspace(tag[i]))
4208 else if (tag[i] ==
'=')
4213 if (!attrname[attr_pos] &&
4214 (tag[i] ==
'=' || isspace(tag[i]) || tag[i] ==
'>')) {
4218 }
else if (!tag[i]) {
4228 if (tag[i] ==
'=') {
4230 }
else if (!isspace(tag[i])) {
4237 if (!isspace(tag[i])) {
4238 delimiter = (tag[i] ==
'"' || tag[i] ==
'\'') ? tag[i] :
' ';
4239 i -= (delimiter ==
' ');
4245 if ((delimiter ==
' ' && isspace(tag[i])) || tag[i] == delimiter)
4249 if ((delimiter ==
' ' && (isspace(tag[i]) || tag[i] ==
'>')) ||
4250 tag[i] == delimiter) {
4252 }
else if (tag[i] ==
'&' &&
4264 }
else if (tag[i] ==
'\r' || tag[i] ==
'\t') {
4266 }
else if (tag[i] ==
'\n') {
4280 while (isspace(Buf->
str[0]))
4283 while (Buf->
len && isspace(Buf->
str[Buf->
len - 1]))
4286 return (Found) ? Buf->
str : NULL;
4295 const char *attrname)
4309 const char *attrname,
4343 char ch = 0, *p, *text;
4344 int token_start, buf_index;
4349 token_start = buf_index;
4353 if (
S_TOP(html)->parse_mode ==
4357 const char *tag =
Tags[
S_TOP(html)->tag_idx].name;
4358 buf_index += strcspn(buf + buf_index,
"<");
4359 if (buf_index + (
int)strlen(tag) + 3 >
bufsize) {
4361 }
else if (strncmp(buf + buf_index,
"</", 2) == 0 &&
4364 text =
dStrndup(buf + token_start, buf_index - token_start);
4367 token_start = buf_index;
4371 }
while (buf_index <
bufsize);
4377 if (isspace(buf[buf_index])) {
4379 while (++buf_index <
bufsize && isspace(buf[buf_index])) ;
4381 token_start = buf_index;
4383 }
else if (buf[buf_index] ==
'<' && (ch = buf[buf_index + 1]) &&
4384 (isalpha(ch) || strchr(
"/!?", ch)) ) {
4386 if (buf_index + 3 <
bufsize && !strncmp(buf + buf_index,
"<!--", 4)) {
4389 while ( (p = (
char*) memchr(buf + buf_index,
'>',
4391 buf_index = p - buf + 1;
4392 if (p[-1] ==
'-' && p[-2] ==
'-')
break;
4396 token_start = buf_index;
4403 while ( buf_index <
bufsize ) {
4405 buf_index += strcspn(buf + buf_index,
">\"'<");
4406 if ((ch = buf[buf_index]) ==
'>') {
4408 }
else if (ch ==
'"' || ch ==
'\'') {
4411 buf_index += strcspn(buf + buf_index,
4412 (ch ==
'"') ?
"\">" :
"'>");
4413 if (buf[buf_index] ==
'>') {
4416 int offset = buf_index + 1;
4417 offset += strcspn(buf + offset,
4418 (ch ==
'"') ?
"\"<" :
"'<");
4419 if (buf[offset] == ch || !buf[offset]) {
4422 BUG_MSG(
"Attribute lacks closing quote.");
4426 }
else if (ch ==
'<') {
4429 strcspn(buf+token_start+1,
" <\n\r\t"));
4430 BUG_MSG(
"<%s> lacks its closing '>'.", p);
4439 buf_index - token_start);
4440 token_start = buf_index;
4447 while (++buf_index <
bufsize) {
4448 buf_index += strcspn(buf + buf_index,
" <\n\r\t\f\v");
4449 if (buf[buf_index] ==
'<' && (ch = buf[buf_index + 1]) &&
4450 !isalpha(ch) && !strchr(
"/!?", ch))
4454 if (buf_index <
bufsize || Eof) {
4456 ch = buf[buf_index];
4459 buf_index - token_start);
4460 buf[buf_index] = ch;
4461 token_start = buf_index;
4466 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 implementation for simple circles.
dw::core::Shape implementation for polygons.
void addPoint(int x, int y)
dw::core::Shape implementation 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.
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 appropriate 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
bool a_Html_should_display(DilloHtml *html)
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)
CssLength 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.
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.
#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 mark_unloaded_images
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, const DilloUrl *page_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.