mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 09:27:35 +00:00
LibWeb: Create a video document for video/
MIME types on navigation
This commit is contained in:
parent
819b6332d1
commit
8fa9ca8b7f
1 changed files with 22 additions and 0 deletions
|
@ -184,6 +184,26 @@ static bool build_xml_document(DOM::Document& document, ByteBuffer const& data)
|
||||||
return !result.is_error() && !builder.has_error();
|
return !result.is_error() && !builder.has_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool build_video_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::video, 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 FrameLoader::parse_document(DOM::Document& document, ByteBuffer const& data)
|
bool FrameLoader::parse_document(DOM::Document& document, ByteBuffer const& data)
|
||||||
{
|
{
|
||||||
auto& mime_type = document.content_type();
|
auto& mime_type = document.content_type();
|
||||||
|
@ -196,6 +216,8 @@ bool FrameLoader::parse_document(DOM::Document& document, ByteBuffer const& data
|
||||||
return build_xml_document(document, data);
|
return build_xml_document(document, data);
|
||||||
if (mime_type.starts_with("image/"sv))
|
if (mime_type.starts_with("image/"sv))
|
||||||
return build_image_document(document, data);
|
return build_image_document(document, data);
|
||||||
|
if (mime_type.starts_with("video/"sv))
|
||||||
|
return build_video_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