aboutsummaryrefslogtreecommitdiff
path: root/src/html.cc
diff options
context:
space:
mode:
authorcorvid <corvid@dillo.org>2014-02-15 18:41:12 +0000
committercorvid <corvid@dillo.org>2014-02-15 18:41:12 +0000
commit8711f43231e783f0c71a0d3f903c747188bfa0ae (patch)
treebdaa9609226c950e7d4416496d1d84586c9b618f /src/html.cc
parent2908fe39a624bce28f25c0212a0b9eea08914119 (diff)
rudimentary support for html5 video,audio,source,embed
Diffstat (limited to 'src/html.cc')
-rw-r--r--src/html.cc136
1 files changed, 136 insertions, 0 deletions
diff --git a/src/html.cc b/src/html.cc
index 8774b93e..f759c56c 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -2515,6 +2515,138 @@ 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;
+ }
+
+ 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 +3411,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 +3438,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 +3497,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 +3522,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]))