aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/css.hh7
-rw-r--r--src/cssparser.cc2
-rw-r--r--src/form.cc2
-rw-r--r--src/html.cc254
-rw-r--r--src/html_common.hh9
-rw-r--r--src/styleengine.cc2
-rw-r--r--src/url.c10
7 files changed, 215 insertions, 71 deletions
diff --git a/src/css.hh b/src/css.hh
index 938bc020..239bffaf 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -474,10 +474,11 @@ class CssStyleSheet {
<lout::object::ConstString, RuleList > (true, true, 256) {};
};
- static const int ntags = 90 + 10; // \todo don't hardcode
+ static const int ntags = 90 + 14; // \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, wbr.
+ * implemented. From html5, let's add: article, header, footer, mark,
+ * nav, section, aside, figure, figcaption, wbr, audio, video, source,
+ * embed.
*/
RuleList elementTable[ntags], anyTable;
diff --git a/src/cssparser.cc b/src/cssparser.cc
index be5032d6..fcff7688 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -716,7 +716,7 @@ bool CssParser::tokenMatchesProperty(CssPropertyName prop, CssValueType *type)
dStrAsciiCasecmp(tval, "right") == 0 ||
dStrAsciiCasecmp(tval, "top") == 0 ||
dStrAsciiCasecmp(tval, "bottom") == 0))
- return true;
+ return true;
// Fall Through (lenght and percentage)
case CSS_TYPE_LENGTH_PERCENTAGE:
case CSS_TYPE_LENGTH_PERCENTAGE_NUMBER:
diff --git a/src/form.cc b/src/form.cc
index c5bb10af..07c12815 100644
--- a/src/form.cc
+++ b/src/form.cc
@@ -2003,7 +2003,7 @@ static Embed *Html_input_image(DilloHtml *html, const char *tag, int tagsize)
html->styleEngine->setPseudoLink ();
/* create new image and add it to the button */
- a_Html_image_attrs(html, tag, tagsize);
+ a_Html_common_image_attrs(html, tag, tagsize);
if ((Image = a_Html_image_new(html, tag, tagsize))) {
// At this point, we know that Image->ir represents an image
// widget. Notice that the order of the casts matters, because
diff --git a/src/html.cc b/src/html.cc
index 1257c102..4f5d51b5 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -1382,7 +1382,7 @@ static void Html_tag_cleanup_at_close(DilloHtml *html, int new_idx)
* by closing them before opening another.
* This is not an HTML SPEC restriction , but it avoids lots of trouble
* inside dillo (concurrent inputs), and makes almost no sense to have.
- */
+ */
static void Html_tag_cleanup_nested_inputs(DilloHtml *html, int new_idx)
{
static int i_BUTTON = a_Html_tag_index("button"),
@@ -1695,9 +1695,9 @@ static void Html_tag_close_head(DilloHtml *html)
/* match for the well formed start of HEAD section */
if (html->Num_TITLE == 0)
BUG_MSG("HEAD section lacks the TITLE element\n");
-
+
html->InFlags &= ~IN_HEAD;
-
+
/* charset is already set, load remote stylesheets now */
for (int i = 0; i < html->cssUrls->size(); i++) {
a_Html_load_stylesheet(html, html->cssUrls->get(i));
@@ -2083,13 +2083,13 @@ static void Html_tag_open_abbr(DilloHtml *html, const char *tag, int tagsize)
/*
* Read image-associated tag attributes and create new image.
*/
-void a_Html_image_attrs(DilloHtml *html, const char *tag, int tagsize)
+void a_Html_common_image_attrs(DilloHtml *html, const char *tag, int tagsize)
{
char *width_ptr, *height_ptr;
const char *attrbuf;
CssLength l_w = CSS_CREATE_LENGTH(0.0, CSS_LENGTH_TYPE_AUTO);
CssLength l_h = CSS_CREATE_LENGTH(0.0, CSS_LENGTH_TYPE_AUTO);
- int space, border, w = 0, h = 0;
+ int w = 0, h = 0;
if (prefs.show_tooltip &&
(attrbuf = a_Html_get_attr(html, tag, tagsize, "title"))) {
@@ -2125,7 +2125,8 @@ void a_Html_image_attrs(DilloHtml *html, const char *tag, int tagsize)
dFree(width_ptr);
dFree(height_ptr);
width_ptr = height_ptr = NULL;
- MSG("a_Html_image_attrs: suspicious image size request %d x %d\n", w, h);
+ MSG("a_Html_common_image_attrs: suspicious image size request %d x %d\n",
+ w, h);
} else {
if (CSS_LENGTH_TYPE(l_w) != CSS_LENGTH_TYPE_AUTO)
html->styleEngine->setNonCssHint (CSS_PROPERTY_WIDTH,
@@ -2142,55 +2143,6 @@ void a_Html_image_attrs(DilloHtml *html, const char *tag, int tagsize)
[...]
*/
- /* Spacing to the left and right */
- if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "hspace"))) {
- space = strtol(attrbuf, NULL, 10);
- if (space > 0) {
- space = CSS_CREATE_LENGTH(space, CSS_LENGTH_TYPE_PX);
- html->styleEngine->setNonCssHint (CSS_PROPERTY_MARGIN_LEFT,
- CSS_TYPE_LENGTH_PERCENTAGE, space);
- html->styleEngine->setNonCssHint (CSS_PROPERTY_MARGIN_RIGHT,
- CSS_TYPE_LENGTH_PERCENTAGE, space);
- }
- }
-
- /* Spacing at the top and bottom */
- if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "vspace"))) {
- space = strtol(attrbuf, NULL, 10);
- if (space > 0) {
- space = CSS_CREATE_LENGTH(space, CSS_LENGTH_TYPE_PX);
- html->styleEngine->setNonCssHint (CSS_PROPERTY_MARGIN_TOP,
- CSS_TYPE_LENGTH_PERCENTAGE, space);
- html->styleEngine->setNonCssHint (CSS_PROPERTY_MARGIN_BOTTOM,
- CSS_TYPE_LENGTH_PERCENTAGE, space);
- }
- }
-
- /* Border */
- if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "border"))) {
- border = strtol(attrbuf, NULL, 10);
- if (border >= 0) {
- border = CSS_CREATE_LENGTH(border, CSS_LENGTH_TYPE_PX);
- html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_TOP_WIDTH,
- CSS_TYPE_LENGTH_PERCENTAGE, border);
- html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_BOTTOM_WIDTH,
- CSS_TYPE_LENGTH_PERCENTAGE, border);
- html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_LEFT_WIDTH,
- CSS_TYPE_LENGTH_PERCENTAGE, border);
- html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_RIGHT_WIDTH,
- CSS_TYPE_LENGTH_PERCENTAGE, border);
-
- html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_TOP_STYLE,
- CSS_TYPE_ENUM, BORDER_SOLID);
- html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_BOTTOM_STYLE,
- CSS_TYPE_ENUM, BORDER_SOLID);
- html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_LEFT_STYLE,
- CSS_TYPE_ENUM, BORDER_SOLID);
- html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_RIGHT_STYLE,
- CSS_TYPE_ENUM, BORDER_SOLID);
- }
- }
-
/* x_img is an index to a list of {url,image} pairs.
* We know a_Html_image_new() will use size() as its next index */
html->styleEngine->setNonCssHint (PROPERTY_X_IMG, CSS_TYPE_INTEGER,
@@ -2271,7 +2223,60 @@ static bool Html_load_image(BrowserWindow *bw, DilloUrl *url,
static void Html_tag_open_img(DilloHtml *html, const char *tag, int tagsize)
{
- a_Html_image_attrs(html, tag, tagsize);
+ int space, border;
+ const char *attrbuf;
+
+ a_Html_common_image_attrs(html, tag, tagsize);
+
+ /* Spacing to the left and right */
+ if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "hspace"))) {
+ space = strtol(attrbuf, NULL, 10);
+ if (space > 0) {
+ space = CSS_CREATE_LENGTH(space, CSS_LENGTH_TYPE_PX);
+ html->styleEngine->setNonCssHint (CSS_PROPERTY_MARGIN_LEFT,
+ CSS_TYPE_LENGTH_PERCENTAGE, space);
+ html->styleEngine->setNonCssHint (CSS_PROPERTY_MARGIN_RIGHT,
+ CSS_TYPE_LENGTH_PERCENTAGE, space);
+ }
+ }
+
+ /* Spacing at the top and bottom */
+ if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "vspace"))) {
+ space = strtol(attrbuf, NULL, 10);
+ if (space > 0) {
+ space = CSS_CREATE_LENGTH(space, CSS_LENGTH_TYPE_PX);
+ html->styleEngine->setNonCssHint (CSS_PROPERTY_MARGIN_TOP,
+ CSS_TYPE_LENGTH_PERCENTAGE, space);
+ html->styleEngine->setNonCssHint (CSS_PROPERTY_MARGIN_BOTTOM,
+ CSS_TYPE_LENGTH_PERCENTAGE, space);
+ }
+ }
+
+ /* Border */
+ if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "border"))) {
+ border = strtol(attrbuf, NULL, 10);
+ if (border >= 0) {
+ border = CSS_CREATE_LENGTH(border, CSS_LENGTH_TYPE_PX);
+ html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_TOP_WIDTH,
+ CSS_TYPE_LENGTH_PERCENTAGE, border);
+ html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_BOTTOM_WIDTH,
+ CSS_TYPE_LENGTH_PERCENTAGE, border);
+ html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_LEFT_WIDTH,
+ CSS_TYPE_LENGTH_PERCENTAGE, border);
+ html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_RIGHT_WIDTH,
+ CSS_TYPE_LENGTH_PERCENTAGE, border);
+
+ html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_TOP_STYLE,
+ CSS_TYPE_ENUM, BORDER_SOLID);
+ html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_BOTTOM_STYLE,
+ CSS_TYPE_ENUM, BORDER_SOLID);
+ html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_LEFT_STYLE,
+ CSS_TYPE_ENUM, BORDER_SOLID);
+ html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_RIGHT_STYLE,
+ CSS_TYPE_ENUM, BORDER_SOLID);
+ }
+ }
+
}
/*
@@ -2515,6 +2520,139 @@ static void Html_tag_open_object(DilloHtml *html, const char *tag, int tagsize)
}
/*
+ * <VIDEO>
+ * Provide a link to the video.
+ */
+static void Html_tag_open_video(DilloHtml *html, const char *tag, int tagsize)
+{
+ DilloUrl *url;
+ const char *attrbuf;
+
+ if (html->InFlags & IN_MEDIA) {
+ MSG("<video> not handled when already inside a media element.\n");
+ return;
+ }
+ /* TODO: poster attr */
+
+ if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "src"))) {
+ url = a_Html_url_new(html, attrbuf, NULL, 0);
+ dReturn_if_fail ( url != NULL );
+
+ if (a_Capi_get_flags_with_redirection(url) & CAPI_IsCached) {
+ html->styleEngine->setPseudoVisited ();
+ } else {
+ html->styleEngine->setPseudoLink ();
+ }
+
+ html->styleEngine->setNonCssHint(PROPERTY_X_LINK, CSS_TYPE_INTEGER,
+ Html_set_new_link(html, &url));
+
+ HT2TB(html)->addText("[VIDEO]", html->wordStyle ());
+ }
+ html->InFlags |= IN_MEDIA;
+}
+
+/*
+ * <AUDIO>
+ * Provide a link to the audio.
+ */
+static void Html_tag_open_audio(DilloHtml *html, const char *tag, int tagsize)
+{
+ DilloUrl *url;
+ const char *attrbuf;
+
+ if (html->InFlags & IN_MEDIA) {
+ MSG("<audio> not handled when already inside a media element.\n");
+ return;
+ }
+
+ if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "src"))) {
+ url = a_Html_url_new(html, attrbuf, NULL, 0);
+ dReturn_if_fail ( url != NULL );
+
+ if (a_Capi_get_flags_with_redirection(url) & CAPI_IsCached) {
+ html->styleEngine->setPseudoVisited ();
+ } else {
+ html->styleEngine->setPseudoLink ();
+ }
+
+ html->styleEngine->setNonCssHint(PROPERTY_X_LINK, CSS_TYPE_INTEGER,
+ Html_set_new_link(html, &url));
+
+ HT2TB(html)->addText("[AUDIO]", html->wordStyle ());
+ }
+ html->InFlags |= IN_MEDIA;
+}
+
+/*
+ * <SOURCE>
+ * Media resource; provide a link to its address.
+ */
+static void Html_tag_open_source(DilloHtml *html, const char *tag,
+ int tagsize)
+{
+ const char *attrbuf;
+
+ if (!(html->InFlags & IN_MEDIA)) {
+ BUG_MSG("<source> element not inside a media element.\n");
+ return;
+ }
+ if (!(attrbuf = a_Html_get_attr(html, tag, tagsize, "src"))) {
+ BUG_MSG("src attribute is required in <source> element.\n");
+ return;
+ } else {
+ DilloUrl *url = a_Html_url_new(html, attrbuf, NULL, 0);
+
+ dReturn_if_fail ( url != NULL );
+
+ if (a_Capi_get_flags_with_redirection(url) & CAPI_IsCached) {
+ html->styleEngine->setPseudoVisited ();
+ } else {
+ html->styleEngine->setPseudoLink ();
+ }
+
+ html->styleEngine->setNonCssHint(PROPERTY_X_LINK, CSS_TYPE_INTEGER,
+ Html_set_new_link(html, &url));
+
+ HT2TB(html)->addText("[MEDIA SOURCE]", html->wordStyle ());
+ }
+}
+
+/*
+ * Media (AUDIO/VIDEO) close function
+ */
+static void Html_tag_close_media(DilloHtml *html)
+{
+ html->InFlags &= ~IN_MEDIA;
+}
+
+/*
+ * <EMBED>
+ * Provide a link to embedded content.
+ */
+static void Html_tag_open_embed(DilloHtml *html, const char *tag, int tagsize)
+{
+ const char *attrbuf;
+
+ if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "src"))) {
+ DilloUrl *url = a_Html_url_new(html, attrbuf, NULL, 0);
+
+ dReturn_if_fail ( url != NULL );
+
+ if (a_Capi_get_flags_with_redirection(url) & CAPI_IsCached) {
+ html->styleEngine->setPseudoVisited ();
+ } else {
+ html->styleEngine->setPseudoLink ();
+ }
+
+ html->styleEngine->setNonCssHint(PROPERTY_X_LINK, CSS_TYPE_INTEGER,
+ Html_set_new_link(html, &url));
+
+ HT2TB(html)->addText("[EMBED]", html->wordStyle ());
+ }
+}
+
+/*
* Test and extract the link from a javascript instruction.
*/
static const char* Html_get_javascript_link(DilloHtml *html)
@@ -3279,6 +3417,7 @@ const TagInfo Tags[] = {
NULL},
{"article", B8(011110),'R',2, Html_tag_open_default, NULL, NULL},
{"aside", B8(011110),'R',2, Html_tag_open_default, NULL, NULL},
+ {"audio", B8(011101),'R',2, Html_tag_open_audio, NULL, Html_tag_close_media},
{"b", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
{"base", B8(100001),'F',0, Html_tag_open_base, NULL, NULL},
/* basefont 010001 -- obsolete in HTML5 */
@@ -3305,6 +3444,7 @@ const TagInfo Tags[] = {
{"dl", B8(011010),'R',2, Html_tag_open_dl, NULL, Html_tag_close_par},
{"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},
+ {"embed", B8(010001),'F',0, Html_tag_open_embed, 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},
@@ -3363,6 +3503,7 @@ const TagInfo Tags[] = {
{"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},
+ {"source", B8(010001),'F',0, Html_tag_open_source, NULL, NULL},
{"span", B8(010101),'R',2, Html_tag_open_span, NULL, NULL},
{"strike", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
{"strong", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
@@ -3387,6 +3528,7 @@ const TagInfo Tags[] = {
{"u", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
{"ul", B8(011010),'R',2, Html_tag_open_ul, NULL, NULL},
{"var", B8(010101),'R',2, Html_tag_open_default, NULL, NULL},
+ {"video", B8(011101),'R',2, Html_tag_open_video, NULL, Html_tag_close_media},
{"wbr", B8(010101),'F',0, Html_tag_open_default, Html_tag_content_wbr, NULL}
};
#define NTAGS (sizeof(Tags)/sizeof(Tags[0]))
diff --git a/src/html_common.hh b/src/html_common.hh
index a43d91b7..de3069cb 100644
--- a/src/html_common.hh
+++ b/src/html_common.hh
@@ -87,8 +87,9 @@ typedef enum {
IN_MAP = 1 << 9,
IN_PRE = 1 << 10,
IN_LI = 1 << 11,
- IN_META_HACK = 1 << 12,
- IN_EOF = 1 << 13,
+ IN_MEDIA = 1 << 12,
+ IN_META_HACK = 1 << 13,
+ IN_EOF = 1 << 14,
} DilloHtmlProcessingState;
/*
@@ -233,7 +234,7 @@ public:
{ return styleEngine->wordStyle (bw, base_url); }
inline void restyle () { styleEngine->restyle (bw, base_url); }
-
+
};
/*
@@ -257,7 +258,7 @@ DilloUrl *a_Html_url_new(DilloHtml *html,
const char *url_str, const char *base_url,
int use_base_url);
-void a_Html_image_attrs(DilloHtml *html, const char *tag, int tagsize);
+void a_Html_common_image_attrs(DilloHtml *html, const char *tag, int tagsize);
DilloImage *a_Html_image_new(DilloHtml *html, const char *tag, int tagsize);
char *a_Html_parse_entities(DilloHtml *html, const char *token, int toksize);
diff --git a/src/styleengine.cc b/src/styleengine.cc
index 3f621cee..64861973 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -551,7 +551,7 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props,
a_Url_free (imgUrl);
}
- break;
+ break;
case CSS_PROPERTY_BACKGROUND_POSITION:
computeLength (&attrs->backgroundPositionX, p->value.posVal->posX,
attrs->font);
diff --git a/src/url.c b/src/url.c
index 6780ca8e..9d3e14b2 100644
--- a/src/url.c
+++ b/src/url.c
@@ -688,14 +688,14 @@ static uint_t Url_host_public_internal_dots(const char *host)
if (tld_len > 0) {
/* These TLDs were chosen by examining the current publicsuffix list
- * in September 2013 and picking out those where it was simplest for
+ * in February 2014 and picking out those where it was simplest for
* them to describe the situation by beginning with a "*.[tld]" rule
* or every rule was "[something].[tld]".
*/
- const char *const tlds[] = {"au","bd","bn","ck","cy","er","et","fj",
- "fk","gn","gu","il","jm","ke","kh","kp",
- "kw","lb","lr","mm","mt","mz","ni","np",
- "nz","pg","tr","uk","ye","za","zm","zw"};
+ const char *const tlds[] = {"bd","bn","ck","cy","er","et","fj","fk",
+ "gu","il","jm","ke","kh","kw","mm","mz",
+ "ni","np","nz","pg","tr","uk","ye","za",
+ "zm","zw"};
uint_t i, tld_num = sizeof(tlds) / sizeof(tlds[0]);
for (i = 0; i < tld_num; i++) {