aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2013-09-06 12:19:55 +0200
committerSebastian Geerken <devnull@localhost>2013-09-06 12:19:55 +0200
commit8949f7c58340b0c468fde3ea4bc1b23352f55b88 (patch)
tree0124c2d94106cbb3c0fb44f9a42e221575d955fd /src
parenta8d6e82558673ee440dcdeb82a72166732f12af1 (diff)
parent5768a90c1502da9324fe35246bf1ed743a17c68d (diff)
Merge with main repo.
Diffstat (limited to 'src')
-rw-r--r--src/IO/dpi.c10
-rw-r--r--src/css.hh6
-rw-r--r--src/dillo.cc62
-rw-r--r--src/form.cc10
-rw-r--r--src/html.cc53
-rw-r--r--src/html_common.hh1
-rw-r--r--src/styleengine.cc11
7 files changed, 125 insertions, 28 deletions
diff --git a/src/IO/dpi.c b/src/IO/dpi.c
index 8e71f8ca..c99bb3f0 100644
--- a/src/IO/dpi.c
+++ b/src/IO/dpi.c
@@ -492,7 +492,7 @@ static int Dpi_check_dpid(int num_tries)
}
}
- _MSG("Dpi_check_dpid:: %s\n",
+ _MSG("Dpi_check_dpid: %s\n",
(ret == 0) ? "OK" : (ret == 1 ? "EAGAIN" : "ERROR"));
return ret;
}
@@ -531,7 +531,7 @@ static int Dpi_get_server_port(const char *server_name)
socklen_t sin_sz;
dReturn_val_if_fail (server_name != NULL, dpi_port);
- _MSG("Dpi_get_server_port:: server_name = [%s]\n", server_name);
+ _MSG("Dpi_get_server_port: server_name = [%s]\n", server_name);
/* Read dpid's port from saved file */
if (Dpi_read_comm_keys(&dpid_port) != -1) {
@@ -608,7 +608,7 @@ static int Dpi_connect_socket(const char *server_name)
/* Query dpid for the port number for this server */
if ((dpi_port = Dpi_get_server_port(server_name)) == -1) {
- _MSG("Dpi_connect_socket:: can't get port number for %s\n", server_name);
+ _MSG("Dpi_connect_socket: can't get port number for %s\n", server_name);
return -1;
}
_MSG("Dpi_connect_socket: server=%s port=%d\n", server_name, dpi_port);
@@ -620,9 +620,9 @@ static int Dpi_connect_socket(const char *server_name)
sin.sin_port = htons(dpi_port);
if ((sock_fd = Dpi_make_socket_fd()) == -1) {
- perror("[dpi::socket]");
+ MSG_ERR("[Dpi_connect_socket] %s\n", dStrerror(errno));
} else if (connect(sock_fd, (void*)&sin, sizeof(sin)) == -1) {
- MSG("[dpi::connect] errno:%d %s\n", errno, dStrerror(errno));
+ MSG_ERR("[Dpi_connect_socket] errno:%d %s\n", errno, dStrerror(errno));
/* send authentication Key (the server closes sock_fd on auth error) */
} else if (!(cmd = a_Dpip_build_cmd("cmd=%s msg=%s", "auth", SharedKey))) {
diff --git a/src/css.hh b/src/css.hh
index e81fde62..4ad75f73 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -451,7 +451,11 @@ class CssStyleSheet {
<lout::object::ConstString, RuleList > (true, true, 256) {};
};
- static const int ntags = 90; // \todo replace 90
+ static const int ntags = 90 + 9; // \todo don't hardcode
+ /* 90 is the full number of html4 elements, including those which we have
+ * implemented. From html 5, let's add: article, header, footer, mark,
+ * nav, section, aside, figure, figcaption.
+ */
RuleList elementTable[ntags], anyTable;
RuleMap idTable, classTable;
diff --git a/src/dillo.cc b/src/dillo.cc
index 5c1e7364..567d897f 100644
--- a/src/dillo.cc
+++ b/src/dillo.cc
@@ -21,8 +21,11 @@
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include <signal.h>
#include <locale.h>
+#include <errno.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
@@ -95,6 +98,63 @@ static const CLI_options Options[] = {
{NULL, NULL, 0, DILLO_CLI_NONE, NULL}
};
+
+/*
+ * SIGCHLD handling ----------------------------------------------------------
+ */
+
+/*
+ * Avoid our children (Dpid) to become zombies. :-)
+ * Notes:
+ * . We let sigaction block SIGCHLD while in the handler.
+ * . Portability is not simple. e.g.
+ * http://www.faqs.org/faqs/unix-faq/faq/part3/section-13.html
+ * man sigaction, waitpid
+ */
+static void raw_sigchld2(int signum)
+{
+ pid_t pid;
+ int status;
+
+ while (1) {
+ pid = waitpid(-1, &status, WNOHANG);
+ if (pid > 0) {
+ if (WIFEXITED(status)) /* normal exit */
+ printf("[dpid]: terminated normally (%d)\n", WEXITSTATUS(status));
+ else if (WIFSIGNALED(status)) /* terminated by signal */
+ printf("[dpid]: terminated by signal %d\n", WTERMSIG(status));
+ } else if (pid == 0 || errno == ECHILD) {
+ break;
+ } else {
+ if (errno == EINTR)
+ continue;
+ perror("waitpid");
+ break;
+ }
+ }
+ ++signum; /* compiler happiness */
+}
+
+/*
+ * Establish SIGCHLD handler
+ */
+static void est_sigchld(void)
+{
+ struct sigaction sigact;
+ sigset_t set;
+
+ (void) sigemptyset(&set);
+ sigact.sa_handler = raw_sigchld2; /* our custom handler */
+ sigact.sa_mask = set; /* no aditional signal blocks */
+ sigact.sa_flags = SA_NOCLDSTOP; /* ignore stop/resume states */
+ if (sigaction(SIGCHLD, &sigact, NULL) == -1) {
+ perror("sigaction");
+ exit(1);
+ }
+}
+
+//----------------------------------------------------------------------------
+
/*
* Print help text generated from the options structure
*/
@@ -329,6 +389,8 @@ int main(int argc, char **argv)
// Some OSes exit dillo without this (not GNU/Linux).
signal(SIGPIPE, SIG_IGN);
+ // Establish our custom SIGCHLD handler
+ est_sigchld();
/* Handle command line options */
opt_argv = dNew0(char*, numOptions(Options) + 1);
diff --git a/src/form.cc b/src/form.cc
index 6da5567b..f756a1c9 100644
--- a/src/form.cc
+++ b/src/form.cc
@@ -530,8 +530,6 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize)
} else {
/* Text input, which also is the default */
inp_type = DILLO_HTML_INPUT_TEXT;
- if (*type && dStrAsciiCasecmp(type, "text"))
- BUG_MSG("Unknown input type: \"%s\"\n", type);
attrbuf = a_Html_get_attr(html, tag, tagsize, "size");
int size = Html_input_get_size(html, attrbuf);
resource = factory->createEntryResource(size, false, NULL);
@@ -641,7 +639,8 @@ void Html_tag_content_textarea(DilloHtml *html, const char *tag, int tagsize)
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "cols"))) {
cols = strtol(attrbuf, NULL, 10);
} else {
- BUG_MSG("cols attribute is required for <textarea>\n");
+ if (html->DocType != DT_HTML || html->DocTypeVersion <= 4.01f)
+ BUG_MSG("cols attribute is required for <textarea>\n");
cols = 20;
}
if (cols < 1 || cols > MAX_COLS) {
@@ -652,7 +651,8 @@ void Html_tag_content_textarea(DilloHtml *html, const char *tag, int tagsize)
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "rows"))) {
rows = strtol(attrbuf, NULL, 10);
} else {
- BUG_MSG("rows attribute is required for <textarea>\n");
+ if (html->DocType != DT_HTML || html->DocTypeVersion <= 4.01f)
+ BUG_MSG("rows attribute is required for <textarea>\n");
rows = 10;
}
if (rows < 1 || rows > MAX_ROWS) {
@@ -797,8 +797,6 @@ void Html_tag_close_select(DilloHtml *html)
void Html_tag_open_optgroup(DilloHtml *html, const char *tag, int tagsize)
{
- MSG("OPEN OPTGROUP\n");
-
if (!(html->InFlags & IN_SELECT)) {
BUG_MSG("<optgroup> element outside <select>\n");
return;
diff --git a/src/html.cc b/src/html.cc
index 65371ff5..4732548a 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -1513,17 +1513,27 @@ int32_t a_Html_color_parse(DilloHtml *html, const char *str,
static int
Html_check_name_val(DilloHtml *html, const char *val, const char *attrname)
{
- int i;
+ if (html->DocType == DT_HTML && html->DocTypeVersion >= 5.0f) {
+ bool valid = *val && !strchr(val, ' ');
- for (i = 0; val[i]; ++i)
- if (!isascii(val[i]) || !(isalnum(val[i]) || strchr(":_.-", val[i])))
- break;
+ if (!valid) {
+ BUG_MSG("'%s' value must not be empty and must not contain spaces.\n",
+ attrname);
+ }
+ return valid ? 1 : 0;
+ } else {
+ int i;
+
+ for (i = 0; val[i]; ++i)
+ if (!isascii(val[i]) || !(isalnum(val[i]) || strchr(":_.-", val[i])))
+ break;
- if (val[i] || !(isascii(val[0]) && isalpha(val[0])))
- BUG_MSG("'%s' value \"%s\" is not of the form "
- "[A-Za-z][A-Za-z0-9:_.-]*\n", attrname, val);
+ if (val[i] || !(isascii(val[0]) && isalpha(val[0])))
+ BUG_MSG("'%s' value \"%s\" is not of the form "
+ "[A-Za-z][A-Za-z0-9:_.-]*\n", attrname, val);
- return !(val[i]);
+ return !(val[i]);
+ }
}
/*
@@ -1584,6 +1594,9 @@ static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize)
_MSG("New: {%s}\n", ntag);
+ if (html->DocType != DT_NONE)
+ BUG_MSG("Multiple DOCTYPE declarations.\n");
+
/* The default DT_NONE type is TagSoup */
if (i > strlen(HTML_SGML_sig) && // avoid out of bounds reads!
!dStrnAsciiCasecmp(ntag, HTML_SGML_sig, strlen(HTML_SGML_sig))) {
@@ -1611,11 +1624,13 @@ static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize)
html->DocTypeVersion = 2.0f;
}
} else if (!dStrAsciiCasecmp(ntag, HTML5_sig)) {
- BUG_MSG("Document follows HTML5 working draft; treating as HTML4.\n");
html->DocType = DT_HTML;
html->DocTypeVersion = 5.0f;
}
-
+ if (html->DocType == DT_NONE) {
+ html->DocType = DT_UNRECOGNIZED;
+ BUG_MSG("DOCTYPE not recognized:\n%s.\n", ntag);
+ }
dFree(ntag);
}
@@ -1759,7 +1774,8 @@ static void Html_tag_open_style(DilloHtml *html, const char *tag, int tagsize)
html->loadCssFromStash = true;
if (!(attrbuf = a_Html_get_attr(html, tag, tagsize, "type"))) {
- BUG_MSG("type attribute is required for <style>\n");
+ if (html->DocType != DT_HTML || html->DocTypeVersion <= 4.01f)
+ BUG_MSG("type attribute is required for <style>\n");
} else if (dStrAsciiCasecmp(attrbuf, "text/css")) {
html->loadCssFromStash = false;
}
@@ -3205,12 +3221,14 @@ static void Html_tag_close_par(DilloHtml *html)
*/
const TagInfo Tags[] = {
- {"a", B8(010101),'R',2, Html_tag_open_a, NULL, Html_tag_close_a},
+ {"a", B8(011101),'R',2, Html_tag_open_a, NULL, Html_tag_close_a},
{"abbr", B8(010101),'R',2, Html_tag_open_abbr, NULL, NULL},
/* acronym 010101 */
{"address", B8(010110),'R',2,Html_tag_open_default, NULL, Html_tag_close_par},
{"area", B8(010001),'F',0, Html_tag_open_default, Html_tag_content_area,
NULL},
+ {"article", B8(011110),'R',2, Html_tag_open_default, NULL, NULL},
+ {"aside", B8(011110),'R',2, Html_tag_open_default, NULL, NULL},
{"b", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
{"base", B8(100001),'F',0, Html_tag_open_base, NULL, NULL},
/* basefont 010001 */
@@ -3238,7 +3256,10 @@ const TagInfo Tags[] = {
{"dt", B8(010110),'O',1, Html_tag_open_dt, NULL, Html_tag_close_par},
{"em", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
/* fieldset */
+ {"figcaption", B8(011110),'R',2, Html_tag_open_default, NULL, NULL},
+ {"figure", B8(011110),'R',2, Html_tag_open_default, NULL, NULL},
{"font", B8(010101),'R',2, Html_tag_open_font, NULL, NULL},
+ {"footer", B8(011110),'R',2, Html_tag_open_default, NULL, NULL},
{"form", B8(011110),'R',2, Html_tag_open_form, NULL, Html_tag_close_form},
{"frame", B8(010010),'F',0, Html_tag_open_frame, Html_tag_content_frame,
NULL},
@@ -3251,6 +3272,7 @@ const TagInfo Tags[] = {
{"h5", B8(010110),'R',2, Html_tag_open_h, NULL, NULL},
{"h6", B8(010110),'R',2, Html_tag_open_h, NULL, NULL},
{"head", B8(101101),'O',1, Html_tag_open_head, NULL, Html_tag_close_head},
+ {"header", B8(011110),'R',2, Html_tag_open_default, NULL, NULL},
{"hr", B8(010010),'F',0, Html_tag_open_hr, Html_tag_content_hr,
NULL},
{"html", B8(001110),'O',1, Html_tag_open_html, NULL, Html_tag_close_html},
@@ -3260,7 +3282,7 @@ const TagInfo Tags[] = {
{"img", B8(010001),'F',0, Html_tag_open_img, Html_tag_content_img,
NULL},
{"input", B8(010001),'F',0, Html_tag_open_input, NULL, NULL},
- /* ins */
+ {"ins", B8(011101),'R',2, Html_tag_open_default, NULL, NULL},
{"isindex", B8(110001),'F',0, Html_tag_open_isindex, NULL, NULL},
{"kbd", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
/* label 010101 */
@@ -3269,9 +3291,11 @@ const TagInfo Tags[] = {
{"link", B8(100001),'F',0, Html_tag_open_link, NULL, NULL},
{"map", B8(011001),'R',2, Html_tag_open_default, Html_tag_content_map,
Html_tag_close_map},
+ {"mark", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
/* menu 1010 -- TODO: not exactly 1010, it can contain LI and inline */
{"menu", B8(011010),'R',2, Html_tag_open_menu, NULL, Html_tag_close_par},
{"meta", B8(100001),'F',0, Html_tag_open_meta, NULL, NULL},
+ {"nav", B8(011110),'R',2, Html_tag_open_default, NULL, NULL},
/* noframes 1011 */
/* noscript 1011 */
{"object", B8(111101),'R',2, Html_tag_open_object, NULL, NULL},
@@ -3286,6 +3310,7 @@ const TagInfo Tags[] = {
{"s", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
{"samp", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
{"script", B8(111001),'R',2, Html_tag_open_script,NULL,Html_tag_close_script},
+ {"section", B8(011110),'R',2, Html_tag_open_default, NULL, NULL},
{"select", B8(010101),'R',2, Html_tag_open_select,NULL,Html_tag_close_select},
{"small", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
{"span", B8(010101),'R',2, Html_tag_open_span, NULL, NULL},
@@ -3471,7 +3496,7 @@ static void Html_test_section(DilloHtml *html, int new_idx, int IsCloseTag)
int tag_idx;
if (!(html->InFlags & IN_HTML) && html->DocType == DT_NONE)
- BUG_MSG("the required DOCTYPE declaration is missing (or invalid)\n");
+ BUG_MSG("the required DOCTYPE declaration is missing.\n");
if (!(html->InFlags & IN_HTML)) {
tag = "<html>";
diff --git a/src/html_common.hh b/src/html_common.hh
index d0eff7eb..6c5d4807 100644
--- a/src/html_common.hh
+++ b/src/html_common.hh
@@ -41,6 +41,7 @@
typedef enum {
DT_NONE,
+ DT_UNRECOGNIZED,
DT_HTML,
DT_XHTML
} DilloHtmlDocumentType;
diff --git a/src/styleengine.cc b/src/styleengine.cc
index 22dbbf7e..8817479f 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -851,7 +851,9 @@ void StyleEngine::buildUserAgentStyle () {
":link {color: blue; text-decoration: underline; cursor: pointer}"
":visited {color: #800080; text-decoration: underline; cursor: pointer}"
"h1, h2, h3, h4, h5, h6, b, strong {font-weight: bolder}"
- "address, center, div, h1, h2, h3, h4, h5, h6, ol, p, ul, pre {display: block}"
+ "address, article, aside, center, div, figure, figcaption, footer,"
+ " h1, h2, h3, h4, h5, h6, header, nav, ol, p, pre, section, ul"
+ " {display: block}"
"i, em, cite, address, var {font-style: italic}"
":link img, :visited img {border: 1px solid}"
"frameset, ul, ol, dir {margin-left: 40px}"
@@ -860,6 +862,7 @@ void StyleEngine::buildUserAgentStyle () {
* look better like this.
*/
"p {margin: 0.5em 0}"
+ "figure {margin: 1em 40px}"
"h1 {font-size: 2em; margin-top: .67em; margin-bottom: 0}"
"h2 {font-size: 1.5em; margin-top: .75em; margin-bottom: 0}"
"h3 {font-size: 1.17em; margin-top: .83em; margin-bottom: 0}"
@@ -874,11 +877,15 @@ void StyleEngine::buildUserAgentStyle () {
"ul ul {list-style-type: circle}"
"ul ul ul {list-style-type: square}"
"ul ul ul ul {list-style-type: disc}"
- "u {text-decoration: underline}"
+ "ins, u {text-decoration: underline}"
"small, sub, sup {font-size: 0.83em}"
"sub {vertical-align: sub}"
"sup {vertical-align: super}"
"s, strike, del {text-decoration: line-through}"
+ /* HTML5 spec notes that mark styling "is just a suggestion and can be
+ * changed based on implementation feedback"
+ */
+ "mark {background: yellow; color: black;}"
"table {border-spacing: 2px}"
"td, th {padding: 2px}"
"thead, tbody, tfoot {vertical-align: middle}"