mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 12:14:58 +00:00
LibWeb: Create an audio document for audio/
MIME types on navigation
This commit is contained in:
parent
d6db924d47
commit
7ec7015750
1 changed files with 22 additions and 0 deletions
|
@ -178,6 +178,26 @@ static bool build_video_document(DOM::Document& document)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool build_audio_document(DOM::Document& document)
|
||||||
|
{
|
||||||
|
auto html_element = DOM::create_element(document, HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||||
|
MUST(document.append_child(html_element));
|
||||||
|
|
||||||
|
auto head_element = DOM::create_element(document, HTML::TagNames::head, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||||
|
MUST(html_element->append_child(head_element));
|
||||||
|
|
||||||
|
auto body_element = DOM::create_element(document, HTML::TagNames::body, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||||
|
MUST(html_element->append_child(body_element));
|
||||||
|
|
||||||
|
auto video_element = DOM::create_element(document, HTML::TagNames::audio, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||||
|
MUST(video_element->set_attribute(HTML::AttributeNames::src, document.url().to_deprecated_string()));
|
||||||
|
MUST(video_element->set_attribute(HTML::AttributeNames::autoplay, DeprecatedString::empty()));
|
||||||
|
MUST(video_element->set_attribute(HTML::AttributeNames::controls, DeprecatedString::empty()));
|
||||||
|
MUST(body_element->append_child(video_element));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool parse_document(DOM::Document& document, ByteBuffer const& data)
|
bool parse_document(DOM::Document& document, ByteBuffer const& data)
|
||||||
{
|
{
|
||||||
auto& mime_type = document.content_type();
|
auto& mime_type = document.content_type();
|
||||||
|
@ -192,6 +212,8 @@ bool parse_document(DOM::Document& document, ByteBuffer const& data)
|
||||||
return build_image_document(document, data);
|
return build_image_document(document, data);
|
||||||
if (mime_type.starts_with("video/"sv))
|
if (mime_type.starts_with("video/"sv))
|
||||||
return build_video_document(document);
|
return build_video_document(document);
|
||||||
|
if (mime_type.starts_with("audio/"sv))
|
||||||
|
return build_audio_document(document);
|
||||||
if (mime_type == "text/plain" || mime_type == "application/json")
|
if (mime_type == "text/plain" || mime_type == "application/json")
|
||||||
return build_text_document(document, data);
|
return build_text_document(document, data);
|
||||||
if (mime_type == "text/markdown")
|
if (mime_type == "text/markdown")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue