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);
817 }
else if (event->
button == 2) {
830 _MSG(
" ->%s\n", w->getClassName());
832 ((
Textblock*)w)->changeLinkColor (link, html->visited_color);
861 case 146: ret =
'\'';
break;
863 case 148: ret =
'"';
break;
864 case 149: ret = 176;
break;
866 case 151: ret =
'-';
break;
867 default: ret = codepoint;
break;
877 bool_t is_attr,
int *entsize)
881 int n, codepoint = -1;
885 if (*s ==
'x' || *s ==
'X') {
886 if (isxdigit(*++s)) {
888 if (*s ==
'0' && s[1] ==
'x') {
892 codepoint = strtol(s, &s, 16);
895 }
else if (isdigit(*s)) {
896 codepoint = strtol(s, &s, 10);
908 BUG_MSG(
"Character reference '&#%s' lacks ';'.", tok);
921 if ((codepoint < 0x20 && codepoint !=
'\t' && codepoint !=
'\n' &&
922 codepoint !=
'\f') ||
923 (codepoint >= 0x7f && codepoint <= 0x9f) ||
924 (codepoint >= 0xd800 && codepoint <= 0xdfff) || codepoint > 0x10ffff ||
925 ((codepoint & 0xfffe) == 0xfffe) ||
927 codepoint > 0xffff)) {
933 BUG_MSG(
"Numeric character reference '&#%s' is not valid.", tok);
936 codepoint = (codepoint >= 145 && codepoint <= 151) ?
939 if (codepoint != -1) {
940 if (codepoint >= 128) {
944 buf[0] = (char) codepoint;
980 bool_t is_attr,
int *entsize)
985 const char *ret = NULL;
987 while (*++s && (isalnum(*s) || strchr(
":_.-", *s))) ;
993 BUG_MSG(
"Character reference '&%s' lacks ';'.", tok);
1020 BUG_MSG(
"Undefined character reference '&%s'.", tok);
1036 int toksize,
int *entsize,
bool_t is_attr)
1038 const char *ret = NULL;
1054 }
else if (isalpha(*tok)) {
1072 const char *esc_set =
"&";
1076 s = strcspn(token, esc_set);
1085 for (i = s; i < toksize; i++) {
1089 if (token[i] ==
'&' &&
1111 int i, breakCnt = 0;
1113 for (i = 0; i < spacesize; i++) {
1115 if (space[i] ==
'\r' || (space[i] ==
'\n' && !html->
PrevWasCR)) {
1122 if (breakCnt == 0) {
1137 if (
S_TOP(html)->display_none) {
1149 for (i = 0; i < spacesize; i++) {
1152 (space[i] ==
'\r' || (space[i] ==
'\n' && !html->
PrevWasCR))) {
1172 BUG_MSG(
"TAB character inside <pre>.");
1222 if (
S_TOP(html)->display_none)
1225 BUG_MSG(
"Content after </%s> tag.", i == 1 ?
"html" :
"body");
1251 for (start = i = 0; Pword[i]; start = i)
1252 if (isspace(Pword[i])) {
1253 while (Pword[++i] && isspace(Pword[i])) ;
1256 while (Pword[++i] && !isspace(Pword[i])) ;
1257 HT2TB(html)->addText(Pword + start, i - start, html->
wordStyle ());
1264 const char *word2, *beyond_word2;
1267 if (!memchr(word,
'&', size)) {
1270 beyond_word2 = word + size;
1275 for (i = j = 0; (Pword[i] = Pword[j]); ++i, ++j) {
1276 if (strchr(
" \t\f\n\r", Pword[i])) {
1277 if (i == 0 || (i > 0 && Pword[i-1] !=
' '))
1280 for (--i; Pword[j+1] && strchr(
" \t\f\n\r", Pword[j+1]); ++j)
1285 beyond_word2 = word2 + strlen(word2);
1287 for (start = i = 0; word2[i]; start = i) {
1290 if (isspace(word2[i])) {
1291 while (word2[++i] && isspace(word2[i])) ;
1298 HT2TB(html)->addText(word2 + start, i - start, html->
wordStyle ());
1303 }
while (word2[i] && !isspace(word2[i]) &&
1306 HT2TB(html)->addText(word2 + start, i - start, html->
wordStyle ());
1322 for (i = 0; i < tagsize && tagstr[i] !=
'\0'; i++) {
1327 if (i < tagsize && (isspace(tag[i]) || tag[i] ==
'>' || tag[i] ==
'/'))
1338 if (html->
dw !=
S_TOP(html)->textblock) {
1339 if (hand_over_break)
1341 HT2TB(html)->flush ();
1342 html->
dw =
S_TOP(html)->textblock;
1359 html->
dw =
S_TOP(html)->textblock;
1377 bool hand_over_break;
1380 hand_over_break =
S_TOP(html)->hand_over_break;
1401 v = strtod (attr, &end);
1444 if (*end && !isspace (*end)) {
1445 BUG_MSG(
"Garbage after length: '%s'.", attr);
1459 int32_t default_color)
1465 BUG_MSG(
"Color \"%s\" is not in \"#RRGGBB\" format.", str);
1479 bool valid = *val && !strchr(val,
' ');
1482 BUG_MSG(
"'%s' value \"%s\" must not be empty and must not contain "
1483 "spaces.", attrname, val);
1485 return valid ? 1 : 0;
1489 for (i = 0; val[i]; ++i)
1490 if (!
d_isascii(val[i]) || !(isalnum(val[i]) || strchr(
":_.-", val[i])))
1493 if (val[i] || !(
d_isascii(val[0]) && isalpha(val[0])))
1494 BUG_MSG(
"%s attribute value \"%s\" is not of the form "
1495 "'[A-Za-z][A-Za-z0-9:_.-]*'.", attrname, val);
1522 static const char HTML_SGML_sig [] =
"<!DOCTYPE HTML PUBLIC ";
1523 static const char HTML20 [] =
"-//IETF//DTD HTML";
1524 static const char HTML32 [] =
"-//W3C//DTD HTML 3.2";
1525 static const char HTML40 [] =
"-//W3C//DTD HTML 4.0";
1526 static const char HTML401 [] =
"-//W3C//DTD HTML 4.01";
1527 static const char HTML401_url[] =
"http://www.w3.org/TR/html4/";
1528 static const char XHTML1 [] =
"-//W3C//DTD XHTML 1.0";
1529 static const char XHTML1_url [] =
"http://www.w3.org/TR/xhtml1/DTD/";
1530 static const char XHTML11 [] =
"-//W3C//DTD XHTML 1.1";
1531 static const char XHTML11_url[] =
"http://www.w3.org/TR/xhtml11/DTD/";
1535 char *p, *ntag =
dStrndup(tag, tagsize);
1539 for (i = 0, p = ntag; *p; ++p) {
1541 for (ntag[i++] =
' '; isspace(p[1]); ++p) ;
1542 }
else if ((quote = *p) ==
'"' || *p ==
'\'') {
1543 for (ntag[i++] = *p++; (ntag[i] = *p) && ntag[i++] != quote; ++p) {
1544 if (*p ==
'\n' || *p ==
'\r')
1546 p += (p[0] ==
'\r' && p[1] ==
'\n') ? 1 : 0;
1556 _MSG(
"New: {%s}\n", ntag);
1559 BUG_MSG(
"Multiple DOCTYPE declarations.");
1562 if (i > strlen(HTML_SGML_sig) &&
1564 p = ntag + strlen(HTML_SGML_sig) + 1;
1565 if (!strncmp(p, HTML401, strlen(HTML401)) &&
1569 }
else if (!strncmp(p, XHTML1, strlen(XHTML1)) &&
1573 }
else if (!strncmp(p, XHTML11, strlen(XHTML11)) &&
1577 }
else if (!strncmp(p, HTML40, strlen(HTML40))) {
1580 }
else if (!strncmp(p, HTML32, strlen(HTML32))) {
1583 }
else if (!strncmp(p, HTML20, strlen(HTML20))) {
1590 "<!DOCTYPE html SYSTEM \"about:legacy-compat\">") ||
1592 "<!DOCTYPE html SYSTEM 'about:legacy-compat'>")) {
1598 BUG_MSG(
"DOCTYPE not recognized: ('%s').", ntag);
1617 BUG_MSG(
"<html> was already open.");
1627 _MSG(
"Html_tag_close_html: Num_HTML=%d\n", html->
Num_HTML);
1640 BUG_MSG(
"<head> must go before the BODY section.");
1648 BUG_MSG(
"<head> was already open.");
1651 BUG_MSG(
"<head> already finished -- ignoring.");
1668 BUG_MSG(
"<head> lacks <title>.");
1698 BUG_MSG(
"Redundant <title>.");
1700 BUG_MSG(
"<title> must be inside <head> -- ignoring.");
1714 if (!title || title[0] ==
'\0')
1746 const char *attrbuf;
1752 BUG_MSG(
"<style> requires type attribute.");
1785 const char *attrbuf;
1793 _MSG(
"Html_tag_open_body Num_BODY=%d\n", html->
Num_BODY);
1800 BUG_MSG(
"<body> was already open.");
1814 BUG_MSG(
"<body> bgcolor attribute is obsolete.");
1825 BUG_MSG(
"<body> text attribute is obsolete.");
1837 BUG_MSG(
"<body> link attribute is obsolete.");
1843 BUG_MSG(
"<body> vlink attribute is obsolete.");
1850 HT2LT(html)->setBgColor(bgColor);
1853 &bgPositionX, &bgPositionY);
1855 HT2LT(html)->setBgImage(bgImage, bgRepeat, bgAttachment, bgPositionX,
1891 _MSG(
"Html_tag_close_body: Num_BODY=%d\n", html->
Num_BODY);
1917 const char *attrbuf;
1942 const char *attrbuf;
1947 textblock =
HT2TB(html);
1986 const char *tag,
int tagsize)
2001 S_TOP(html)->parse_mode =
2018 const char *attrbuf;
2019 char *fontFamily = NULL;
2035 fontFamily =
dStrdup(attrbuf);
2048 const char *attrbuf;
2065 char *width_ptr, *height_ptr;
2066 const char *attrbuf;
2099 if (w < 0 || h < 0 ||
2104 width_ptr = height_ptr = NULL;
2105 MSG(
"a_Html_common_image_attrs: suspicious image size request %d x %d\n",
2137 const char *attrbuf;
2146 if (!alt_ptr || !*alt_ptr) {
2157 if (
HT2TB(html)->getBgColor())
2160 if (
HT2TB(html)->getFgColor())
2203 return ClientKey != 0;
2209 const char *attrbuf;
2215 int space = strtol(attrbuf, NULL, 10);
2227 int space = strtol(attrbuf, NULL, 10);
2239 border = strtol(attrbuf, NULL, 10);
2273 const char *attrbuf;
2293 HT2TB(html)->addBreakOption (html->
style (),
false);
2298 _MSG(
" Html_tag_open_img: server-side map (ISMAP)\n");
2300 usemap_url == NULL) {
2318 const char *attrbuf;
2332 BUG_MSG(
"<map> requires name attribute.");
2347 for (
int i = 0; i < html->
images->
size(); i++) {
2369 const char *tail = str;
2370 char *newtail = NULL;
2374 coord = strtol(tail, &newtail, 10);
2375 if (coord == 0 && newtail == tail)
2378 coords->
set(coords->
size() - 1, coord);
2379 while (isspace(*newtail))
2383 if (*newtail !=
',') {
2384 BUG_MSG(
"<area> coords must be integers separated by commas.");
2398 enum types {UNKNOWN, RECTANGLE, CIRCLE, POLYGON, BACKGROUND};
2402 const char *attrbuf;
2404 Shape *shape = NULL;
2407 BUG_MSG(
"<area> not inside <map>.");
2423 BUG_MSG(
"<area> unknown shape: '%s'.", attrbuf);
2426 if (type == RECTANGLE || type == CIRCLE || type == POLYGON) {
2430 if (type == RECTANGLE) {
2431 if (coords->
size() != 4)
2432 BUG_MSG(
"<area> rectangle must have four coordinate values.");
2433 if (coords->
size() >= 4)
2436 coords->
get(2) - coords->
get(0),
2437 coords->
get(3) - coords->
get(1));
2438 }
else if (type == CIRCLE) {
2439 if (coords->
size() != 3)
2440 BUG_MSG(
"<area> circle must have three coordinate values.");
2441 if (coords->
size() >= 3)
2444 }
else if (type == POLYGON) {
2447 if (coords->
size() % 2)
2448 BUG_MSG(
"<area> polygon with odd number of coordinates.");
2450 for (i = 0; i < (coords->
size() / 2); i++)
2456 if (shape != NULL || type == BACKGROUND) {
2463 if (type == BACKGROUND)
2477 const char *attrbuf;
2514 const char *attrbuf;
2517 MSG(
"<video> not handled when already inside a media element.\n");
2547 const char *attrbuf;
2550 MSG(
"<audio> not handled when already inside a media element.\n");
2579 const char *attrbuf;
2587 BUG_MSG(
"<source> requires src attribute.");
2625 const char *attrbuf;
2659 i = strcspn(Buf->
str,
"'\"");
2661 if ((ch ==
'"' || ch ==
'\'') &&
2662 (p2 = strchr(Buf->
str + i + 1 , ch))) {
2664 BUG_MSG(
"Link depends on javascript().");
2677 _MSG(
"Registering ANCHOR: %s\n", name);
2678 if (!
HT2TB(html)->addAnchor (name, html->
style ()))
2679 BUG_MSG(
"Anchor names must be unique within the document (\"%s\").",
2697 const char *attrbuf;
2749 if (!
id || strcmp(nameVal,
id)) {
2751 BUG_MSG(
"In <a>, id ('%s') and name ('%s') attributes differ.",
2774 const char *tag,
int tagsize)
2788 const char *U201C =
"\xe2\x80\x9c";
2800 const char *U201D =
"\xe2\x80\x9d";
2810 const char *attrbuf;
2829 BUG_MSG(
"<ul> type attribute is obsolete.");
2833 S_TOP(html)->list_number = 0;
2834 S_TOP(html)->ref_list_item = NULL;
2847 S_TOP(html)->list_number = 0;
2848 S_TOP(html)->ref_list_item = NULL;
2851 BUG_MSG(
"Obsolete list type; use <ul> instead.");
2876 const char *attrbuf;
2882 if (*attrbuf ==
'1')
2884 else if (*attrbuf ==
'a')
2886 else if (*attrbuf ==
'A')
2888 else if (*attrbuf ==
'i')
2890 else if (*attrbuf ==
'I')
2900 (n = (
int) strtol(attrbuf, NULL, 10)) < 0) {
2901 BUG_MSG(
"Illegal '-' character in START attribute; Starting from 0.");
2904 S_TOP(html)->list_number = n;
2905 S_TOP(html)->ref_list_item = NULL;
2915 const char *attrbuf;
2922 BUG_MSG(
"<li> outside <ul> or <ol>.");
2933 (*list_number = strtol(attrbuf, NULL, 10)) < 0) {
2934 BUG_MSG(
"Illegal negative list value attribute; Starting from 0.");
2955 const char *attrbuf;
2961 BUG_MSG(
"<hr> width attribute is obsolete.");
2969 size = strtol(attrbuf, NULL, 10);
2971 BUG_MSG(
"<hr> size attribute is obsolete.");
2979 BUG_MSG(
"<hr> noshade attribute is obsolete.");
3015 hruler =
new Ruler();
3017 HT2TB(html)->addWidget (hruler, html->
style ());
3075 const char *es_set[] = {
"img",
"object",
"applet",
"big",
"small",
"sub",
3076 "sup",
"font",
"basefont", NULL};
3077 static int ei_set[10], i;
3081 for (i = 0; es_set[i]; ++i)
3084 for (i = 0; ei_set[i]; ++i)
3085 if (tag_idx == ei_set[i])
3122 const char meta_template[] =
3123"<table width='100%%'><tr><td bgcolor='#ee0000'>Warning:</td>\n"
3124" <td bgcolor='#8899aa' width='100%%'>\n"
3125" This page uses the NON-STANDARD meta refresh tag.<br> The HTML 4.01 SPEC\n"
3126" (sec 7.4.4) recommends explicitly to avoid it.</td></tr>\n"
3127" <tr><td bgcolor='#a0a0a0' colspan='2'>The author wanted you to go\n"
3128" <a href='%s'>here</a>%s</td></tr></table><br>\n";
3130 const char *p, *equiv, *
charset, *content;
3131 char delay_str[64], *mr_url;
3142 BUG_MSG(
"This <meta> element must be inside the HEAD section.");
3152 if ((delay = strtol(content, NULL, 0))) {
3153 snprintf(delay_str, 64,
" after %d second%s.",
3154 delay, (delay > 1) ?
"s" :
"");
3156 sprintf(delay_str,
".");
3161 content = p + strlen(
"url=");
3162 else if ((p = strstr(content,
";")))
3163 content = p + strlen(
";");
3169 if (*content ==
'"' || *content ==
'\'') {
3170 if ((p = strchr(content + 1, *content)))
3171 mr_url =
dStrndup(content + 1, p - content - 1);
3173 mr_url =
dStrdup(content + 1);
3185 BUG_MSG(
"<meta> refresh: %s.",
3186 *mr_url ?
"redirection loop" :
"no target URL");
3187 }
else if (delay == 0) {
3192 "WARNING: local URL with META refresh. Aborting.");
3203 int o_InFlags = html->
InFlags;
3204 int o_TagSoup = html->
TagSoup;
3218 _MSG(
"Html_tag_open_meta: content={%s}\n", content);
3235 _MSG(
"Html_css_load_callback: Op=%d\n", Op);
3254 _MSG(
"Html_load_stylesheet: ");
3258 if (strncmp(
"@charset \"", data, 10) == 0) {
3259 char *endq = strchr(data+10,
'"');
3261 if (endq && (endq - data <= 51)) {
3302 const char *attrbuf;
3318 BUG_MSG(
"This <link> element must be inside the HEAD section.");
3340 _MSG(
" Html_tag_open_link(): addCssUrl %s\n",
URL_STR(url));
3351 const char *attrbuf;
3369 BUG_MSG(
"<base> URI is relative (it MUST be absolute).");
3374 BUG_MSG(
"<base> not inside HEAD section.");
3388 const char *attrbuf;
3406 const char *attrbuf;
3582#define NTAGS (sizeof(Tags)/sizeof(Tags[0]))
3585#if __cpp_static_assert
3587 "Mismatch between number of tags in Tags and HTML_NTAGS");
3603 return !strchr(
" >/\n\r\t", *p1);
3612 int low, high, mid, cond;
3617 while (low <= high) {
3618 mid = (low + high) / 2;
3639 int Flags =
Tags[cur_idx].Flags;
3640 if (old_idx ==
i_P || old_idx ==
i_DT) {
3642 return (!(Flags & 1));
3643 }
else if (old_idx ==
i_LI) {
3646 return (cur_idx ==
i_LI);
3647 }
else if (old_idx ==
i_TD || old_idx ==
i_TH) {
3651 }
else if (old_idx ==
i_TR) {
3654 }
else if (old_idx ==
i_DD) {
3656 return (cur_idx ==
i_DD || cur_idx ==
i_DT);
3679 int f =
InFlags, ni = new_idx, oi = -1;
3696 int new_idx,
int fi,
char op)
3698 int s_top, ni = new_idx;
3699 while ((s_top = html->
stack->
size() - 1) >= s_idx) {
3700 int toptag_idx =
S_TOP(html)->tag_idx;
3701 TagInfo toptag =
Tags[toptag_idx];
3705 if (toptag_idx != fi)
3706 BUG_MSG(
" Nesting cleanup - forcing close of open tag: <%s>.",
3708 }
else if (s_top == s_idx && op ==
'c') {
3710 }
else if (toptag.EndTag ==
'O') {
3712 }
else if ((!(toptag.Flags & 4) &&
3713 (
Tags[ni].Flags & 4 || !(
Tags[ni].Flags & 1))) ||
3714 (
Tags[ni].Flags & 1 && !(toptag.Flags & 2))) {
3718 "Bad nesting: <%s> can't contain <%s>. -- closing <%s>." :
3719 "<%s> needs to be closed before </%s>. -- closing <%s>.",
3720 toptag.name,
Tags[ni].name, toptag.name);
3723 "<%s> should have been closed before </%s>. -- closing <%s>.",
3724 toptag.name,
Tags[ni].name, toptag.name);
3726 _MSG(
"op(%c): %s s_top=%d s_idx=%d\n", op, toptag.name, s_top, s_idx);
3727 if (toptag_idx ==
i_BODY &&
3752 int s_top = html->
stack->
size() - 1, s_idx;
3754 for (s_idx = s_top; s_idx > 0; --s_idx) {
3762 BUG_MSG(
"Forbidden nesting: <%s> can't contain <%s>. -- closing "
3768 }
else if (
Tags[ti].EndTag ==
'O') {
3771 }
else if (!(
Tags[ni].Flags & 1) && !(
Tags[ti].Flags & 4)) {
3799 int stack_idx, tag_idx, matched = 0, expected = 0;
3800 TagInfo new_tag =
Tags[new_idx];
3804 while (--stack_idx) {
3806 if (tag_idx == new_idx) {
3810 }
else if (
Tags[tag_idx].EndTag ==
'O') {
3819 }
else if (
Tags[new_idx].Flags & 4 &&
3820 Tags[stack_idx].Flags & 3) {
3832 }
else if (expected) {
3833 BUG_MSG(
"Unexpected closing tag: </%s> -- expected </%s>.",
3834 new_tag.name,
Tags[tag_idx].name);
3836 BUG_MSG(
"Unexpected closing tag: </%s>.", new_tag.name);
3850 BUG_MSG(
"The required DOCTYPE declaration is missing. "
3851 "Handling as HTML4.");
3856 if (tag_idx != new_idx || IsCloseTag) {
3860 Tags[tag_idx].open (html, tag, strlen(tag));
3864 if (
Tags[new_idx].Flags & 16) {
3869 if (tag_idx != new_idx || IsCloseTag) {
3873 Tags[tag_idx].open (html, tag, strlen(tag));
3877 }
else if (
Tags[new_idx].Flags & 8) {
3886 if (tag_idx != new_idx || IsCloseTag) {
3890 Tags[tag_idx].open (html, tag, strlen(tag));
3900 const char *attrbuf;
3931 memset(lang, 0,
sizeof(lang));
3932 if (tagsize >= 14) {
3936 strncpy(lang, attrbuf, 2);
3938 if (!lang[0] && tagsize >= 10) {
3942 strncpy(lang, attrbuf, 2);
3954 static int indexes[9] = {-1};
3956 if (indexes[0] == -1) {
3967 for (
int i = 0; i < 9; i++) {
3968 if (indexes[i] == ni) {
3969 BUG_MSG(
"<%s> is obsolete in HTML5.",
Tags[ni].name);
4004 *ref_list_item = list_item;
4005 S_TOP(html)->textblock = html->
dw = list_item;
4027 char *start = tag + 1;
4028 int IsCloseTag = (*start ==
'/');
4042 _MSG(
"Html_process_tag: %s%s\n", IsCloseTag ?
"/" :
"",
Tags[ni].name);
4048 if (i == 1 || (i == 2 && ni !=
i_HTML))
4049 BUG_MSG(
"Content after </%s> tag.", i == 1 ?
"html" :
"body");
4057 ti =
S_TOP(html)->tag_idx;
4058 switch (IsCloseTag) {
4069 BUG_MSG(
"<pre> is not allowed to contain <%s>.",
Tags[ni].name);
4081 _MSG(
"Html_process_tag Open : %s\n",
Tags[ni].name);
4082 Tags[ni].open (html, tag, tagsize);
4084 if (!
S_TOP(html)->display_none) {
4096 S_TOP(html)->display_none =
true;
4106 if (
Tags[ni].content && !
S_TOP(html)->display_none) {
4107 Tags[ni].content (html, tag, tagsize);
4130 if (
Tags[ni].EndTag ==
'F')
4140 if (*start ==
'/' ||
4142 (tag[tagsize-2] ==
'/' &&
4143 (strchr(
" \"'", tag[tagsize-3]) ||
4144 (
size_t)tagsize == strlen(
Tags[ni].name) + 3))) {
4146 _MSG(
"Html_process_tag Close: %s\n",
Tags[ni].name);
4167 const char *attrname,
4168 int tag_parsing_flags)
4170 int i, entsize, Found = 0, delimiter = 0, attr_pos = 0;
4178 for (i = 1; i < tagsize; ++i) {
4181 if (isspace(tag[i]))
4183 else if (tag[i] ==
'=')
4188 if (!attrname[attr_pos] &&
4189 (tag[i] ==
'=' || isspace(tag[i]) || tag[i] ==
'>')) {
4193 }
else if (!tag[i]) {
4203 if (tag[i] ==
'=') {
4205 }
else if (!isspace(tag[i])) {
4212 if (!isspace(tag[i])) {
4213 delimiter = (tag[i] ==
'"' || tag[i] ==
'\'') ? tag[i] :
' ';
4214 i -= (delimiter ==
' ');
4220 if ((delimiter ==
' ' && isspace(tag[i])) || tag[i] == delimiter)
4224 if ((delimiter ==
' ' && (isspace(tag[i]) || tag[i] ==
'>')) ||
4225 tag[i] == delimiter) {
4227 }
else if (tag[i] ==
'&' &&
4239 }
else if (tag[i] ==
'\r' || tag[i] ==
'\t') {
4241 }
else if (tag[i] ==
'\n') {
4255 while (isspace(Buf->
str[0]))
4258 while (Buf->
len && isspace(Buf->
str[Buf->
len - 1]))
4261 return (Found) ? Buf->
str : NULL;
4270 const char *attrname)
4284 const char *attrname,
4318 char ch = 0, *p, *text;
4319 int token_start, buf_index;
4324 token_start = buf_index;
4328 if (
S_TOP(html)->parse_mode ==
4332 const char *tag =
Tags[
S_TOP(html)->tag_idx].name;
4333 buf_index += strcspn(buf + buf_index,
"<");
4334 if (buf_index + (
int)strlen(tag) + 3 >
bufsize) {
4336 }
else if (strncmp(buf + buf_index,
"</", 2) == 0 &&
4339 text =
dStrndup(buf + token_start, buf_index - token_start);
4342 token_start = buf_index;
4346 }
while (buf_index <
bufsize);
4352 if (isspace(buf[buf_index])) {
4354 while (++buf_index <
bufsize && isspace(buf[buf_index])) ;
4356 token_start = buf_index;
4358 }
else if (buf[buf_index] ==
'<' && (ch = buf[buf_index + 1]) &&
4359 (isalpha(ch) || strchr(
"/!?", ch)) ) {
4361 if (buf_index + 3 <
bufsize && !strncmp(buf + buf_index,
"<!--", 4)) {
4364 while ( (p = (
char*) memchr(buf + buf_index,
'>',
4366 buf_index = p - buf + 1;
4367 if (p[-1] ==
'-' && p[-2] ==
'-')
break;
4371 token_start = buf_index;
4378 while ( buf_index <
bufsize ) {
4380 buf_index += strcspn(buf + buf_index,
">\"'<");
4381 if ((ch = buf[buf_index]) ==
'>') {
4383 }
else if (ch ==
'"' || ch ==
'\'') {
4386 buf_index += strcspn(buf + buf_index,
4387 (ch ==
'"') ?
"\">" :
"'>");
4388 if (buf[buf_index] ==
'>') {
4391 int offset = buf_index + 1;
4392 offset += strcspn(buf + offset,
4393 (ch ==
'"') ?
"\"<" :
"'<");
4394 if (buf[offset] == ch || !buf[offset]) {
4397 BUG_MSG(
"Attribute lacks closing quote.");
4401 }
else if (ch ==
'<') {
4404 strcspn(buf+token_start+1,
" <\n\r\t"));
4405 BUG_MSG(
"<%s> lacks its closing '>'.", p);
4414 buf_index - token_start);
4415 token_start = buf_index;
4422 while (++buf_index <
bufsize) {
4423 buf_index += strcspn(buf + buf_index,
" <\n\r\t\f\v");
4424 if (buf[buf_index] ==
'<' && (ch = buf[buf_index + 1]) &&
4425 !isalpha(ch) && !strchr(
"/!?", ch))
4429 if (buf_index <
bufsize || Eof) {
4431 ch = buf[buf_index];
4434 buf_index - token_start);
4435 buf[buf_index] = ch;
4436 token_start = buf_index;
4441 HT2TB(html)->flush ();
bool_t a_Bw_expecting(BrowserWindow *bw)
void a_Bw_close_client(BrowserWindow *bw, int ClientKey)
Close a cache-client upon successful retrieval.
void a_Bw_add_url(BrowserWindow *bw, const DilloUrl *Url)
Add an URL to the browser window's list.
void a_Bw_add_client(BrowserWindow *bw, int Key, int Root)
Add a reference to a cache-client.
void a_Bw_remove_doc(BrowserWindow *bw, void *vdoc)
Remove a document from the bw's list.
void a_Bw_add_doc(BrowserWindow *bw, void *vdoc)
Add a document to the browser window's list.
void(* CA_Callback_t)(int Op, CacheClient_t *Client)
Callback type for cache clients.
int a_Capi_get_buf(const DilloUrl *Url, char **PBuf, int *BufSize)
Get the cache's buffer for the URL, and its size.
const char * a_Capi_set_content_type(const DilloUrl *url, const char *ctype, const char *from)
Set the Content-Type for the URL.
int a_Capi_dpi_verify_request(BrowserWindow *bw, DilloUrl *url)
Safety test: only allow GET|POST dpi-urls from dpi-generated pages.
void a_Capi_unref_buf(const DilloUrl *Url)
Unref the cache's buffer when no longer using it.
int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
Most used function for requesting a URL.
int a_Capi_get_flags_with_redirection(const DilloUrl *Url)
Same as a_Capi_get_flags() but following redirections.
A list of CssProperty objects.
bool enter(dw::core::Widget *widget, int link, int img, int x, int y)
Called, when a link is entered, left, or the position has changed.
bool press(dw::core::Widget *widget, int link, int img, int x, int y, dw::core::EventButton *event)
Handle the "press" signal.
bool click(dw::core::Widget *widget, int link, int img, int x, int y, dw::core::EventButton *event)
Handle the "click" signal.
bool ReqTagClose
Flag to close the stack's top tag.
void freeParseData()
Free parsing data.
int InFlags
tracks which elements we are in
DilloHtmlDocumentType DocType
int getCurrLineNumber()
Return the line number of the tag/word being processed by the parser.
void bugMessage(const char *format,...)
Collect HTML error strings.
lout::misc::SimpleVector< DilloHtmlState > * stack
void write(char *Buf, int BufSize, int Eof)
Process the newly arrived html and put it into the page structure.
dw::core::style::Style * backgroundStyle()
int formNew(DilloHtmlMethod method, const DilloUrl *action, DilloHtmlEnc enc, const char *charset)
Allocate and insert form information.
void finishParsing(int ClientKey)
Finish parsing a HTML page.
bool PreFirstChar
used to skip the first CR or CRLF in PRE tags
void startElement(int tag)
void addCssUrl(const DilloUrl *url)
Save URL in a vector (may be loaded later).
void initDw()
Miscellaneous initializations for Dw.
bool PrevWasCR
Flag to help parsing of "\r\n" in PRE tags.
bool TagSoup
Flag to enable the parser's cleanup functions.
int pre_column
current column, used in PRE tags with tabs
lout::misc::SimpleVector< DilloHtmlInput * > * inputs_outside_form
bool PrevWasHtmlClose
set when </html> is found
dw::core::style::Style * wordStyle()
int32_t non_css_visited_color
as provided by vlink attribute in BODY
bool loadCssFromStash
current stash content should be loaded as CSS
lout::misc::SimpleVector< DilloHtmlForm * > * forms
DilloHtml(BrowserWindow *bw, const DilloUrl *url, const char *content_type)
Create and initialize a new DilloHtml class.
~DilloHtml()
Free memory used by the DilloHtml class.
dw::core::style::Style * style()
uchar_t Num_HTML
element counters: used for validation purposes.
lout::misc::SimpleVector< DilloUrl * > * links
int32_t non_css_link_color
as provided by link attribute in BODY
Dstr * attr_data
Buffer for attribute value.
bool PrevWasBodyClose
set when </body> is found
lout::misc::SimpleVector< DilloUrl * > * cssUrls
int32_t visited_color
as computed according to CSS
bool InVisitedLink
used to 'contrast_visited_colors'
StyleEngine * styleEngine
lout::misc::SimpleVector< DilloHtmlImage * > * images
HtmlLinkReceiver linkReceiver
DilloHtmlForm * getCurrentForm()
Get the current form.
void loadImages(const DilloUrl *pattern)
Load images if they were disabled.
This class provides the glue between HTML parser and CSS subsystem.
void parse(DilloHtml *html, DilloUrl *url, const char *buf, int buflen, CssOrigin origin)
void setPseudoVisited()
set the CSS pseudo class :visited.
void setNonCssHint(CssPropertyName name, CssValueType type, CssPropertyValue value)
void setId(const char *id)
dw::core::style::Color * backgroundColor()
void endElement(int tag)
tell the styleEngine that a html element has ended.
void setPseudoLink()
set the CSS pseudo class :link.
void setStyle(const char *style)
void setClass(const char *klass)
void inheritBackgroundColor()
Use of the background color of the parent style as default.
dw::core::style::StyleImage * backgroundImage(dw::core::style::BackgroundRepeat *bgRepeat, dw::core::style::BackgroundAttachment *bgAttachment, dw::core::style::Length *bgPositionX, dw::core::style::Length *bgPositionY)
Displays different kind of bullets.
void addShapeToCurrentMap(core::Shape *shape, int link)
Add a shape to the current map-.
void startNewMap(lout::object::Object *key)
Start a new map and make it the current one.
void setCurrentMapDefaultLink(int link)
Set default link for current map-.
Displays an instance of dw::core::Imgbuf.
void setIsMap()
Sets image as server side image map.
void setUseMap(ImageMapsList *list, Object *key)
Sets image as client side image map.
void initWithText(const char *text, core::style::Style *style)
void initWithWidget(core::Widget *widget, core::style::Style *style)
Widget for drawing (horizontal) rules.
A Widget for rendering text blocks, i.e.
void addWidget(core::Widget *widget, core::style::Style *style)
Add a widget (word type) to the page.
void addSpace(core::style::Style *style)
?
void addText(const char *text, size_t len, core::style::Style *style)
Add a word to the page structure.
void addParbreak(int space, core::style::Style *style)
Cause a paragraph break.
dw::core::Shape implemtation for simple circles.
dw::core::Shape implemtation for polygons.
void addPoint(int x, int y)
dw::core::Shape implemtation for simple rectangles.
Abstract interface for different shapes.
ListStyleType listStyleType
static Style * create(StyleAttrs *attrs)
Simple (simpler than container::untyped::Vector and container::typed::Vector) template based vector.
void setSize(int newSize)
Set the size explicitly.
void increase()
Increase the vector size by one.
void set(int i, T t)
Store an object in the vector.
T get(int i) const
Return the one element, explicitly.
int size() const
Return the number of elements put into this vector.
T * getRef(int i) const
Return the reference of one element.
int32_t a_Color_parse(const char *str, int32_t default_color, int *err)
Parse a color string.
int32_t a_Color_vc(int32_t candidate, int32_t C_txt, int32_t C_lnk, int32_t C_bg)
Return a suitable "visited link" color.
@ CSS_PROPERTY_LIST_STYLE_TYPE
@ CSS_PROPERTY_MARGIN_BOTTOM
@ CSS_PROPERTY_BORDER_RIGHT_STYLE
@ CSS_PROPERTY_MARGIN_RIGHT
@ CSS_PROPERTY_BORDER_RIGHT_WIDTH
@ CSS_PROPERTY_BORDER_LEFT_WIDTH
@ CSS_PROPERTY_MARGIN_LEFT
@ CSS_PROPERTY_BORDER_TOP_WIDTH
@ CSS_PROPERTY_MARGIN_TOP
@ CSS_PROPERTY_VERTICAL_ALIGN
@ CSS_PROPERTY_BORDER_LEFT_STYLE
@ CSS_PROPERTY_TEXT_ALIGN
@ CSS_PROPERTY_BORDER_TOP_STYLE
@ CSS_PROPERTY_BACKGROUND_COLOR
@ CSS_PROPERTY_BORDER_BOTTOM_STYLE
@ CSS_PROPERTY_BORDER_BOTTOM_WIDTH
@ CSS_PROPERTY_FONT_FAMILY
@ CSS_TYPE_ENUM
Value is i, if represented by enum_symbols[i].
@ CSS_TYPE_INTEGER
This type is only used internally, for x-* properties.
@ CSS_TYPE_LENGTH_PERCENTAGE
<length> or <percentage>.
@ CSS_TYPE_STRING
<string>
@ CSS_TYPE_SYMBOL
Symbols, which are directly copied (as opposed to CSS_TYPE_ENUM and CSS_TYPE_MULTI_ENUM).
@ CSS_TYPE_COLOR
Represented as integer.
CssLengthType CSS_LENGTH_TYPE(CssLength l)
CssLength CSS_CREATE_LENGTH(float v, CssLengthType t)
@ CSS_LENGTH_TYPE_RELATIVE
This does not exist in CSS but is used in HTML.
@ CSS_LENGTH_TYPE_PERCENTAGE
@ CSS_LENGTH_TYPE_AUTO
This can be used as a simple value.
float CSS_LENGTH_VALUE(CssLength l)
char * a_Url_decode_hex_str(const char *str, size_t *p_sz)
char * dStrconcat(const char *s1,...)
Concatenate a NULL-terminated list of strings.
int dStrAsciiCasecmp(const char *s1, const char *s2)
void dStr_sprintfa(Dstr *ds, const char *format,...)
Printf-like function that appends.
void dStr_append(Dstr *ds, const char *s)
Append a C string to a Dstr.
char * dStrdup(const char *s)
Dstr * dStr_sized_new(int sz)
Create a new string with a given size.
int dStrnAsciiCasecmp(const char *s1, const char *s2, size_t n)
void dStr_erase(Dstr *ds, int pos_0, int len)
Erase a substring.
void dStr_free(Dstr *ds, int all)
Free a dillo string.
char * dStriAsciiStr(const char *haystack, const char *needle)
Case insensitive strstr.
void dStr_append_l(Dstr *ds, const char *s, int l)
Append a C string to a Dstr (providing length).
void dStr_append_c(Dstr *ds, int c)
Append one character.
char * dStrndup(const char *s, size_t sz)
void dStr_sprintf(Dstr *ds, const char *format,...)
Printf-like function.
void dStr_vsprintfa(Dstr *ds, const char *format, va_list argp)
vsprintf-like function that appends.
Dstr * dStr_new(const char *s)
Create a new string.
void dStr_truncate(Dstr *ds, int len)
Truncate a Dstr to be 'len' bytes long.
char * dStrnfill(size_t len, char c)
Return a new string of length 'len' filled with 'c' characters.
#define dReturn_if_fail(expr)
#define dReturn_val_if_fail(expr, val)
#define dReturn_val_if(expr, val)
#define D_ASCII_TOLOWER(c)
#define dNew(type, count)
void a_History_set_title_by_url(const DilloUrl *url, const char *title)
Set the page-title for a given URL.
static void Html_tag_open_video(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_title(DilloHtml *html, const char *tag, int tagsize)
Handle open TITLE.
const char * a_Html_get_attr(DilloHtml *html, const char *tag, int tagsize, const char *attrname)
Call Html_get_attr2 telling it to parse entities and strip the result.
static misc::SimpleVector< int > * Html_read_coords(DilloHtml *html, const char *str)
Read coords in a string, returning a vector of ints.
static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize)
static void Html_css_load_callback(int Op, CacheClient_t *Client)
Called by the network engine when a stylesheet has new data.
static void Html_real_pop_tag(DilloHtml *html)
Pop the top tag in the stack.
static void Html_tag_open_blockquote(DilloHtml *html, const char *tag, int tagsize)
static void Html_push_tag(DilloHtml *html, int tag_idx)
Push the tag (copying attributes from the top of the stack)
static void Html_tag_open_dir(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_a(DilloHtml *html)
bool a_Html_tag_set_valign_attr(DilloHtml *html, const char *tag, int tagsize)
Evaluates the VALIGN attribute (top|bottom|middle|baseline) and sets the style in style_attrs.
static const TagInfo Tags[]
Function index for the open, content, and close functions for each tag.
static int Html_triggers_optional_close(int old_idx, int cur_idx)
For elements with optional close, check whether is time to close, by also following Firefox's de fact...
static void Html_tag_open_html(DilloHtml *html, const char *tag, int tagsize)
Handle open HTML element.
static bool Html_must_add_breaks(DilloHtml *html)
static void Html_tag_content_map(DilloHtml *html, const char *tag, int tagsize)
static void Html_add_anchor(DilloHtml *html, const char *name)
Register an anchor for this page.
static void Html_tag_open_span(DilloHtml *html, const char *tag, int tagsize)
static void Html_free(void *data)
static void Html_tag_open_pre(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize)
static void Html_test_section(DilloHtml *html, int new_idx, int IsCloseTag)
HTML, HEAD and BODY elements have optional open and close tags.
static int Html_set_new_link(DilloHtml *html, DilloUrl **url)
Create a new link, set it as the url's parent and return the index.
void a_Html_form_display_hiddens(void *v_html, void *v_form, bool_t display)
Used by the "Show/Hide hiddens" form menuitem.
static bool Html_contains_form(DilloHtml *html, void *v_form)
Search for form.
static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize)
Handle DOCTYPE declaration.
static void Html_tag_open_q(DilloHtml *html, const char *tag, int tagsize)
DilloUrl * a_Html_url_new(DilloHtml *html, const char *url_str, const char *base_url, int use_base_url)
Wrapper for a_Url_new that adds an error detection message.
static void Html_tag_content_frame(DilloHtml *html, const char *tag, int tagsize)
static void Html_display_listitem(DilloHtml *html)
static int Html_charref_comp(const void *a, const void *b)
Comparison function for binary search.
static void Html_tag_open_frame(DilloHtml *html, const char *tag, int tagsize)
static const char * Html_parse_entity(DilloHtml *html, const char *token, int toksize, int *entsize, bool_t is_attr)
Given an entity, return the corresponding string.
static void Html_tag_open_ul(DilloHtml *html, const char *tag, int tagsize)
static void Html_add_textblock(DilloHtml *html, bool addBreaks, int breakSpace, bool addBreakOpt)
Create and add a new Textblock to the current Textblock.
static void Html_tag_open_h(DilloHtml *html, const char *tag, int tagsize)
static void Html_process_word(DilloHtml *html, const char *word, int size)
Handles putting the word into its proper place.
static void Html_tag_open_object(DilloHtml *html, const char *tag, int tagsize)
void a_Html_tag_set_align_attr(DilloHtml *html, const char *tag, int tagsize)
Evaluates the ALIGN attribute (left|center|right|justify) and sets the style at the top of the stack.
static void Html_tag_open_menu(DilloHtml *html, const char *tag, int tagsize)
static void Html_display_block(DilloHtml *html)
static void Html_tag_close_li(DilloHtml *html)
static void Html_tag_close_pre(DilloHtml *html)
static void Html_tag_content_frameset(DilloHtml *html, const char *tag, int tagsize)
static Charref_t * Html_charref_search(char *key)
Binary search of 'key' in charref list.
static void Html_tag_open_link(DilloHtml *html, const char *tag, int tagsize)
Parse the LINK element (Only CSS stylesheets by now).
static void Html_tag_content_br(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_media(DilloHtml *html)
Media (AUDIO/VIDEO) close function.
static void Html_parse_common_attrs(DilloHtml *html, char *tag, int tagsize)
Parse attributes that can appear on any tag.
static const char * Html_parse_numeric_charref(DilloHtml *html, char *tok, bool_t is_attr, int *entsize)
Parse a numeric character reference (e.g., "/" or "/").
static void Html_tag_content_object(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_source(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_q(DilloHtml *html)
static void Html_tag_close_map(DilloHtml *html)
Handle close <MAP>.
static void Html_eventually_pop_dw(DilloHtml *html, bool hand_over_break)
This function is called after popping the stack, to handle nested Textblock widgets.
static void Html_tag_open_hr(DilloHtml *html, const char *tag, int tagsize)
static CssLength Html_parse_length_or_multi_length(const char *attr, char **endptr)
static void Html_process_space_pre_line(DilloHtml *html, const char *space, int spacesize)
For white-space: pre-line, we must break the line if encountering a newline.
static void Html_tag_cleanup_at_close(DilloHtml *html, int TagIdx)
Conditional cleanup of the stack, called before closing any tag.
static void Html_process_space(DilloHtml *html, const char *space, int spacesize)
Parse spaces.
void a_Html_form_submit(void *v_html, void *v_form)
Used by the "Submit form" form menuitem.
static void Html_tag_open_dd(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_content_hr(DilloHtml *html, const char *tag, int tagsize)
static const char * Html_get_attr2(DilloHtml *html, const char *tag, int tagsize, const char *attrname, int tag_parsing_flags)
Get attribute value for 'attrname' and return it.
static void Html_callback(int Op, CacheClient_t *Client)
Dispatch the apropriate function for 'Op'.
static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
Process a tag, given as 'tag' and 'tagsize'.
static void Html_tag_close_par(DilloHtml *html)
Default close for paragraph tags - pop the stack and break.
void(* TagCloseFunct)(DilloHtml *html)
static void Html_set_link_coordinates(DilloHtml *html, int link, int x, int y)
Set the URL data for image maps.
static void Html_tag_content_img(DilloHtml *html, const char *tag, int tagsize)
Create a new Image struct and request the image-url to the cache.
static void Html_update_content_type(DilloHtml *html, const char *content)
Update the document's content type information based on meta tag data.
void(* TagOpenFunct)(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_default(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_embed(DilloHtml *html, const char *tag, int tagsize)
static int Html_ms_stupid_quotes_2ucs(int codepoint)
This is M$ non-standard "smart quotes" (w1252).
static void Html_tag_open_img(DilloHtml *html, const char *tag, int tagsize)
void a_Html_load_images(void *v_html, DilloUrl *pattern)
Used by the "Load images" page menuitem.
static const char * Html_get_javascript_link(DilloHtml *html)
Test and extract the link from a javascript instruction.
static void Html_tag_content_source(DilloHtml *html, const char *tag, int tagsize)
static int Html_write_raw(DilloHtml *html, char *buf, int bufsize, int Eof)
Here's where we parse the html and put it into the Textblock structure.
static int Html_forbids_cross_nesting(const int InFlags, const int new_idx)
Check nesting and cross-nesting between BUTTON, SELECT, TEXTAREA and A.
static void Html_tag_close_html(DilloHtml *html)
Handle close HTML element.
static void Html_tag_close_title(DilloHtml *html)
Handle close TITLE.
static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize)
Handle META We do not support http-equiv=refresh with delay>0 because it's non standard,...
static void Html_tag_open_script(DilloHtml *html, const char *tag, int tagsize)
Handle open SCRIPT.
static void Html_tag_open_abbr(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_content_wbr(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_sectioning(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_dt(DilloHtml *html, const char *tag, int tagsize)
void * a_Html_text(const char *type, void *P, CA_Callback_t *Call, void **Data)
Set callback function and callback data for the "html/text" MIME type.
static bool Html_load_image(BrowserWindow *bw, DilloUrl *url, const DilloUrl *requester, DilloImage *image)
Tell cache to retrieve image.
static void Html_force_push_tag(DilloHtml *html, int tag_idx)
Push the tag (used to force en element with optional open into the stack).
static void Html_tag_open_style(DilloHtml *html, const char *tag, int tagsize)
Handle open STYLE.
static const char * Html_parse_named_charref(DilloHtml *html, char *tok, bool_t is_attr, int *entsize)
Parse a named character reference (e.g., "&" or "…").
static int Html_check_name_val(DilloHtml *html, const char *val, const char *attrname)
Check that 'val' is composed of characters inside [A-Za-z0-9:_.
int a_Html_tag_index(const char *tag)
Get 'tag' index.
static void Html_tag_open_base(DilloHtml *html, const char *tag, int tagsize)
Set the Document Base URI.
static void Html_tag_content_area(DilloHtml *html, const char *tag, int tagsize)
static bool Html_match_tag(const char *tagstr, char *tag, int tagsize)
Does the tag in tagstr (e.g.
static void Html_tag_close_body(DilloHtml *html)
static void Html_tag_open_audio(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_font(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_head(DilloHtml *html)
Handle close HEAD element.
static void Html_tag_cleanup_to_idx(DilloHtml *html, int s_idx, int new_idx, int fi, char op)
Cleanup the stack to a given index.
static void Html_tag_content_embed(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_script(DilloHtml *html)
Handle close SCRIPT.
static void Html_display_inline_block(DilloHtml *html)
static void Html_stack_cleanup_at_open(DilloHtml *html, int ni)
Conditional cleanup of the stack (at open time).
static int Html_tag_pre_excludes(DilloHtml *html, int tag_idx)
Check whether a tag is in the "excluding" element set for PRE.
static void Html_tag_open_head(DilloHtml *html, const char *tag, int tagsize)
Handle open HEAD element.
static void Html_tag_open_li(DilloHtml *html, const char *tag, int tagsize)
static int Html_tag_compare(const char *p1, const char *p2)
static void Html_check_html5_obsolete(DilloHtml *html, int ni)
Warn when encountering elements that are obsolete in HTML5.
static void Html_tag_open_p(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_style(DilloHtml *html)
Handle close STYLE.
static void Html_tag_open_ol(DilloHtml *html, const char *tag, int tagsize)
void a_Html_form_reset(void *v_html, void *v_form)
Used by the "Reset form" form menuitem.
static void Html_tag_open_dl(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_open_div(DilloHtml *html, const char *tag, int tagsize)
static const Charref_t Charrefs[NumRef]
const char * a_Html_get_attr(DilloHtml *html, const char *tag, int tagsize, const char *attrname)
Call Html_get_attr2 telling it to parse entities and strip the result.
void a_Html_stash_init(DilloHtml *html)
Initialize the stash buffer.
@ DILLO_HTML_TABLE_MODE_NONE
no table at all
DilloUrl * a_Html_url_new(DilloHtml *html, const char *url_str, const char *base_url, int use_base_url)
Wrapper for a_Url_new that adds an error detection message.
#define HT2TB(html)
"html struct" to Textblock
DilloImage * a_Html_image_new(DilloHtml *html, const char *tag, int tagsize)
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)
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.