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) {
2167 if (
HT2TB(html)->getBgColor())
2170 if (
HT2TB(html)->getFgColor())
2213 return ClientKey != 0;
2219 const char *attrbuf;
2225 int space = strtol(attrbuf, NULL, 10);
2237 int space = strtol(attrbuf, NULL, 10);
2249 border = strtol(attrbuf, NULL, 10);
2283 const char *attrbuf;
2303 HT2TB(html)->addBreakOption (html->
style (),
false);
2308 _MSG(
" Html_tag_open_img: server-side map (ISMAP)\n");
2310 usemap_url == NULL) {
2328 const char *attrbuf;
2342 BUG_MSG(
"<map> requires name attribute.");
2357 for (
int i = 0; i < html->
images->
size(); i++) {
2379 const char *tail = str;
2380 char *newtail = NULL;
2384 coord = strtol(tail, &newtail, 10);
2385 if (coord == 0 && newtail == tail)
2388 coords->
set(coords->
size() - 1, coord);
2389 while (isspace(*newtail))
2393 if (*newtail !=
',') {
2394 BUG_MSG(
"<area> coords must be integers separated by commas.");
2408 enum types {UNKNOWN, RECTANGLE, CIRCLE, POLYGON, BACKGROUND};
2412 const char *attrbuf;
2414 Shape *shape = NULL;
2417 BUG_MSG(
"<area> not inside <map>.");
2433 BUG_MSG(
"<area> unknown shape: '%s'.", attrbuf);
2436 if (type == RECTANGLE || type == CIRCLE || type == POLYGON) {
2440 if (type == RECTANGLE) {
2441 if (coords->
size() != 4)
2442 BUG_MSG(
"<area> rectangle must have four coordinate values.");
2443 if (coords->
size() >= 4)
2446 coords->
get(2) - coords->
get(0),
2447 coords->
get(3) - coords->
get(1));
2448 }
else if (type == CIRCLE) {
2449 if (coords->
size() != 3)
2450 BUG_MSG(
"<area> circle must have three coordinate values.");
2451 if (coords->
size() >= 3)
2454 }
else if (type == POLYGON) {
2457 if (coords->
size() % 2)
2458 BUG_MSG(
"<area> polygon with odd number of coordinates.");
2460 for (i = 0; i < (coords->
size() / 2); i++)
2466 if (shape != NULL || type == BACKGROUND) {
2473 if (type == BACKGROUND)
2487 const char *attrbuf;
2524 const char *attrbuf;
2527 MSG(
"<video> not handled when already inside a media element.\n");
2557 const char *attrbuf;
2560 MSG(
"<audio> not handled when already inside a media element.\n");
2589 const char *attrbuf;
2597 BUG_MSG(
"<source> requires src attribute.");
2635 const char *attrbuf;
2669 i = strcspn(Buf->
str,
"'\"");
2671 if ((ch ==
'"' || ch ==
'\'') &&
2672 (p2 = strchr(Buf->
str + i + 1 , ch))) {
2674 BUG_MSG(
"Link depends on javascript().");
2687 _MSG(
"Registering ANCHOR: %s\n", name);
2688 if (!
HT2TB(html)->addAnchor (name, html->
style ()))
2689 BUG_MSG(
"Anchor names must be unique within the document (\"%s\").",
2707 const char *attrbuf;
2759 if (!
id || strcmp(nameVal,
id)) {
2761 BUG_MSG(
"In <a>, id ('%s') and name ('%s') attributes differ.",
2784 const char *tag,
int tagsize)
2798 const char *U201C =
"\xe2\x80\x9c";
2810 const char *U201D =
"\xe2\x80\x9d";
2820 const char *attrbuf;
2839 BUG_MSG(
"<ul> type attribute is obsolete.");
2843 S_TOP(html)->list_number = 0;
2844 S_TOP(html)->ref_list_item = NULL;
2857 S_TOP(html)->list_number = 0;
2858 S_TOP(html)->ref_list_item = NULL;
2861 BUG_MSG(
"Obsolete list type; use <ul> instead.");
2886 const char *attrbuf;
2892 if (*attrbuf ==
'1')
2894 else if (*attrbuf ==
'a')
2896 else if (*attrbuf ==
'A')
2898 else if (*attrbuf ==
'i')
2900 else if (*attrbuf ==
'I')
2910 (n = (
int) strtol(attrbuf, NULL, 10)) < 0) {
2911 BUG_MSG(
"Illegal '-' character in START attribute; Starting from 0.");
2914 S_TOP(html)->list_number = n;
2915 S_TOP(html)->ref_list_item = NULL;
2925 const char *attrbuf;
2932 BUG_MSG(
"<li> outside <ul> or <ol>.");
2943 (*list_number = strtol(attrbuf, NULL, 10)) < 0) {
2944 BUG_MSG(
"Illegal negative list value attribute; Starting from 0.");
2965 const char *attrbuf;
2971 BUG_MSG(
"<hr> width attribute is obsolete.");
2979 size = strtol(attrbuf, NULL, 10);
2981 BUG_MSG(
"<hr> size attribute is obsolete.");
2989 BUG_MSG(
"<hr> noshade attribute is obsolete.");
3025 hruler =
new Ruler();
3027 HT2TB(html)->addWidget (hruler, html->
style ());
3085 const char *es_set[] = {
"img",
"object",
"applet",
"big",
"small",
"sub",
3086 "sup",
"font",
"basefont", NULL};
3087 static int ei_set[10], i;
3091 for (i = 0; es_set[i]; ++i)
3094 for (i = 0; ei_set[i]; ++i)
3095 if (tag_idx == ei_set[i])
3132 const char meta_template[] =
3133"<table width='100%%'><tr><td bgcolor='#ee0000'>Warning:</td>\n"
3134" <td bgcolor='#8899aa' width='100%%'>\n"
3135" This page uses the NON-STANDARD meta refresh tag.<br> The HTML 4.01 SPEC\n"
3136" (sec 7.4.4) recommends explicitly to avoid it.</td></tr>\n"
3137" <tr><td bgcolor='#a0a0a0' colspan='2'>The author wanted you to go\n"
3138" <a href='%s'>here</a>%s</td></tr></table><br>\n";
3140 const char *p, *equiv, *
charset, *content;
3141 char delay_str[64], *mr_url;
3152 BUG_MSG(
"This <meta> element must be inside the HEAD section.");
3162 if ((delay = strtol(content, NULL, 0))) {
3163 snprintf(delay_str, 64,
" after %d second%s.",
3164 delay, (delay > 1) ?
"s" :
"");
3166 sprintf(delay_str,
".");
3171 content = p + strlen(
"url=");
3172 else if ((p = strstr(content,
";")))
3173 content = p + strlen(
";");
3179 if (*content ==
'"' || *content ==
'\'') {
3180 if ((p = strchr(content + 1, *content)))
3181 mr_url =
dStrndup(content + 1, p - content - 1);
3183 mr_url =
dStrdup(content + 1);
3195 BUG_MSG(
"<meta> refresh: %s.",
3196 *mr_url ?
"redirection loop" :
"no target URL");
3197 }
else if (delay == 0) {
3202 "WARNING: local URL with META refresh. Aborting.");
3213 int o_InFlags = html->
InFlags;
3214 int o_TagSoup = html->
TagSoup;
3228 _MSG(
"Html_tag_open_meta: content={%s}\n", content);
3245 _MSG(
"Html_css_load_callback: Op=%d\n", Op);
3264 _MSG(
"Html_load_stylesheet: ");
3268 if (strncmp(
"@charset \"", data, 10) == 0) {
3269 char *endq = strchr(data+10,
'"');
3271 if (endq && (endq - data <= 51)) {
3312 const char *attrbuf;
3328 BUG_MSG(
"This <link> element must be inside the HEAD section.");
3350 _MSG(
" Html_tag_open_link(): addCssUrl %s\n",
URL_STR(url));
3361 const char *attrbuf;
3379 BUG_MSG(
"<base> URI is relative (it MUST be absolute).");
3384 BUG_MSG(
"<base> not inside HEAD section.");
3398 const char *attrbuf;
3416 const char *attrbuf;
3592#define NTAGS (sizeof(Tags)/sizeof(Tags[0]))
3595#if __cpp_static_assert
3597 "Mismatch between number of tags in Tags and HTML_NTAGS");
3613 return !strchr(
" >/\n\r\t", *p1);
3622 int low, high, mid, cond;
3627 while (low <= high) {
3628 mid = (low + high) / 2;
3649 int Flags =
Tags[cur_idx].Flags;
3650 if (old_idx ==
i_P || old_idx ==
i_DT) {
3652 return (!(Flags & 1));
3653 }
else if (old_idx ==
i_LI) {
3656 return (cur_idx ==
i_LI);
3657 }
else if (old_idx ==
i_TD || old_idx ==
i_TH) {
3661 }
else if (old_idx ==
i_TR) {
3664 }
else if (old_idx ==
i_DD) {
3666 return (cur_idx ==
i_DD || cur_idx ==
i_DT);
3689 int f =
InFlags, ni = new_idx, oi = -1;
3706 int new_idx,
int fi,
char op)
3708 int s_top, ni = new_idx;
3709 while ((s_top = html->
stack->
size() - 1) >= s_idx) {
3710 int toptag_idx =
S_TOP(html)->tag_idx;
3711 TagInfo toptag =
Tags[toptag_idx];
3715 if (toptag_idx != fi)
3716 BUG_MSG(
" Nesting cleanup - forcing close of open tag: <%s>.",
3718 }
else if (s_top == s_idx && op ==
'c') {
3720 }
else if (toptag.EndTag ==
'O') {
3722 }
else if ((!(toptag.Flags & 4) &&
3723 (
Tags[ni].Flags & 4 || !(
Tags[ni].Flags & 1))) ||
3724 (
Tags[ni].Flags & 1 && !(toptag.Flags & 2))) {
3728 "Bad nesting: <%s> can't contain <%s>. -- closing <%s>." :
3729 "<%s> needs to be closed before </%s>. -- closing <%s>.",
3730 toptag.name,
Tags[ni].name, toptag.name);
3733 "<%s> should have been closed before </%s>. -- closing <%s>.",
3734 toptag.name,
Tags[ni].name, toptag.name);
3736 _MSG(
"op(%c): %s s_top=%d s_idx=%d\n", op, toptag.name, s_top, s_idx);
3737 if (toptag_idx ==
i_BODY &&
3762 int s_top = html->
stack->
size() - 1, s_idx;
3764 for (s_idx = s_top; s_idx > 0; --s_idx) {
3772 BUG_MSG(
"Forbidden nesting: <%s> can't contain <%s>. -- closing "
3778 }
else if (
Tags[ti].EndTag ==
'O') {
3781 }
else if (!(
Tags[ni].Flags & 1) && !(
Tags[ti].Flags & 4)) {
3809 int stack_idx, tag_idx, matched = 0, expected = 0;
3810 TagInfo new_tag =
Tags[new_idx];
3814 while (--stack_idx) {
3816 if (tag_idx == new_idx) {
3820 }
else if (
Tags[tag_idx].EndTag ==
'O') {
3829 }
else if (
Tags[new_idx].Flags & 4 &&
3830 Tags[stack_idx].Flags & 3) {
3842 }
else if (expected) {
3843 BUG_MSG(
"Unexpected closing tag: </%s> -- expected </%s>.",
3844 new_tag.name,
Tags[tag_idx].name);
3846 BUG_MSG(
"Unexpected closing tag: </%s>.", new_tag.name);
3860 BUG_MSG(
"The required DOCTYPE declaration is missing. "
3861 "Handling as HTML4.");
3866 if (tag_idx != new_idx || IsCloseTag) {
3870 Tags[tag_idx].open (html, tag, strlen(tag));
3874 if (
Tags[new_idx].Flags & 16) {
3879 if (tag_idx != new_idx || IsCloseTag) {
3883 Tags[tag_idx].open (html, tag, strlen(tag));
3887 }
else if (
Tags[new_idx].Flags & 8) {
3896 if (tag_idx != new_idx || IsCloseTag) {
3900 Tags[tag_idx].open (html, tag, strlen(tag));
3910 const char *attrbuf;
3941 memset(lang, 0,
sizeof(lang));
3942 if (tagsize >= 14) {
3946 strncpy(lang, attrbuf, 2);
3948 if (!lang[0] && tagsize >= 10) {
3952 strncpy(lang, attrbuf, 2);
3964 static int indexes[9] = {-1};
3966 if (indexes[0] == -1) {
3977 for (
int i = 0; i < 9; i++) {
3978 if (indexes[i] == ni) {
3979 BUG_MSG(
"<%s> is obsolete in HTML5.",
Tags[ni].name);
4014 *ref_list_item = list_item;
4015 S_TOP(html)->textblock = html->
dw = list_item;
4031 if (
S_TOP(html)->display_none)
4048 char *start = tag + 1;
4049 int IsCloseTag = (*start ==
'/');
4063 _MSG(
"Html_process_tag: %s%s\n", IsCloseTag ?
"/" :
"",
Tags[ni].name);
4069 if (i == 1 || (i == 2 && ni !=
i_HTML))
4070 BUG_MSG(
"Content after </%s> tag.", i == 1 ?
"html" :
"body");
4078 ti =
S_TOP(html)->tag_idx;
4079 switch (IsCloseTag) {
4090 BUG_MSG(
"<pre> is not allowed to contain <%s>.",
Tags[ni].name);
4102 _MSG(
"Html_process_tag Open : %s\n",
Tags[ni].name);
4103 Tags[ni].open (html, tag, tagsize);
4105 if (!
S_TOP(html)->display_none) {
4117 S_TOP(html)->display_none =
true;
4127 if (
Tags[ni].content && !
S_TOP(html)->display_none) {
4128 Tags[ni].content (html, tag, tagsize);
4151 if (
Tags[ni].EndTag ==
'F')
4161 if (*start ==
'/' ||
4163 (tag[tagsize-2] ==
'/' &&
4164 (strchr(
" \"'", tag[tagsize-3]) ||
4165 (
size_t)tagsize == strlen(
Tags[ni].name) + 3))) {
4167 _MSG(
"Html_process_tag Close: %s\n",
Tags[ni].name);
4188 const char *attrname,
4189 int tag_parsing_flags)
4191 int i, entsize, Found = 0, delimiter = 0, attr_pos = 0;
4199 for (i = 1; i < tagsize; ++i) {
4202 if (isspace(tag[i]))
4204 else if (tag[i] ==
'=')
4209 if (!attrname[attr_pos] &&
4210 (tag[i] ==
'=' || isspace(tag[i]) || tag[i] ==
'>')) {
4214 }
else if (!tag[i]) {
4224 if (tag[i] ==
'=') {
4226 }
else if (!isspace(tag[i])) {
4233 if (!isspace(tag[i])) {
4234 delimiter = (tag[i] ==
'"' || tag[i] ==
'\'') ? tag[i] :
' ';
4235 i -= (delimiter ==
' ');
4241 if ((delimiter ==
' ' && isspace(tag[i])) || tag[i] == delimiter)
4245 if ((delimiter ==
' ' && (isspace(tag[i]) || tag[i] ==
'>')) ||
4246 tag[i] == delimiter) {
4248 }
else if (tag[i] ==
'&' &&
4260 }
else if (tag[i] ==
'\r' || tag[i] ==
'\t') {
4262 }
else if (tag[i] ==
'\n') {
4276 while (isspace(Buf->
str[0]))
4279 while (Buf->
len && isspace(Buf->
str[Buf->
len - 1]))
4282 return (Found) ? Buf->
str : NULL;
4291 const char *attrname)
4305 const char *attrname,
4339 char ch = 0, *p, *text;
4340 int token_start, buf_index;
4345 token_start = buf_index;
4349 if (
S_TOP(html)->parse_mode ==
4353 const char *tag =
Tags[
S_TOP(html)->tag_idx].name;
4354 buf_index += strcspn(buf + buf_index,
"<");
4355 if (buf_index + (
int)strlen(tag) + 3 >
bufsize) {
4357 }
else if (strncmp(buf + buf_index,
"</", 2) == 0 &&
4360 text =
dStrndup(buf + token_start, buf_index - token_start);
4363 token_start = buf_index;
4367 }
while (buf_index <
bufsize);
4373 if (isspace(buf[buf_index])) {
4375 while (++buf_index <
bufsize && isspace(buf[buf_index])) ;
4377 token_start = buf_index;
4379 }
else if (buf[buf_index] ==
'<' && (ch = buf[buf_index + 1]) &&
4380 (isalpha(ch) || strchr(
"/!?", ch)) ) {
4382 if (buf_index + 3 <
bufsize && !strncmp(buf + buf_index,
"<!--", 4)) {
4385 while ( (p = (
char*) memchr(buf + buf_index,
'>',
4387 buf_index = p - buf + 1;
4388 if (p[-1] ==
'-' && p[-2] ==
'-')
break;
4392 token_start = buf_index;
4399 while ( buf_index <
bufsize ) {
4401 buf_index += strcspn(buf + buf_index,
">\"'<");
4402 if ((ch = buf[buf_index]) ==
'>') {
4404 }
else if (ch ==
'"' || ch ==
'\'') {
4407 buf_index += strcspn(buf + buf_index,
4408 (ch ==
'"') ?
"\">" :
"'>");
4409 if (buf[buf_index] ==
'>') {
4412 int offset = buf_index + 1;
4413 offset += strcspn(buf + offset,
4414 (ch ==
'"') ?
"\"<" :
"'<");
4415 if (buf[offset] == ch || !buf[offset]) {
4418 BUG_MSG(
"Attribute lacks closing quote.");
4422 }
else if (ch ==
'<') {
4425 strcspn(buf+token_start+1,
" <\n\r\t"));
4426 BUG_MSG(
"<%s> lacks its closing '>'.", p);
4435 buf_index - token_start);
4436 token_start = buf_index;
4443 while (++buf_index <
bufsize) {
4444 buf_index += strcspn(buf + buf_index,
" <\n\r\t\f\v");
4445 if (buf[buf_index] ==
'<' && (ch = buf[buf_index + 1]) &&
4446 !isalpha(ch) && !strchr(
"/!?", ch))
4450 if (buf_index <
bufsize || Eof) {
4452 ch = buf[buf_index];
4455 buf_index - token_start);
4456 buf[buf_index] = ch;
4457 token_start = buf_index;
4462 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 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.