diff options
-rw-r--r-- | src/css.hh | 7 | ||||
-rw-r--r-- | src/html.cc | 136 | ||||
-rw-r--r-- | src/html_common.hh | 5 |
3 files changed, 143 insertions, 5 deletions
@@ -464,10 +464,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/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])) diff --git a/src/html_common.hh b/src/html_common.hh index b70c8f80..bb1508b5 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; /* |