2023-04-04 18:32:09 -04:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibWeb/HTML/HTMLVideoElement.h>
|
|
|
|
|
#include <LibWeb/Layout/VideoBox.h>
|
|
|
|
|
#include <LibWeb/Painting/VideoPaintable.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::Layout {
|
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DEFINE_ALLOCATOR(VideoBox);
|
2024-04-06 10:16:04 -07:00
|
|
|
|
2024-12-20 16:35:12 +01:00
|
|
|
VideoBox::VideoBox(DOM::Document& document, DOM::Element& element, GC::Ref<CSS::ComputedProperties> style)
|
2026-02-20 19:54:03 -06:00
|
|
|
: ReplacedBox(document, element, style)
|
2023-04-04 18:32:09 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HTML::HTMLVideoElement& VideoBox::dom_node()
|
|
|
|
|
{
|
2025-07-26 14:22:50 +02:00
|
|
|
return static_cast<HTML::HTMLVideoElement&>(*ReplacedBox::dom_node());
|
2023-04-04 18:32:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HTML::HTMLVideoElement const& VideoBox::dom_node() const
|
|
|
|
|
{
|
2025-07-26 14:22:50 +02:00
|
|
|
return static_cast<HTML::HTMLVideoElement const&>(*ReplacedBox::dom_node());
|
2023-04-04 18:32:09 -04:00
|
|
|
}
|
|
|
|
|
|
2026-02-21 00:14:45 -06:00
|
|
|
bool VideoBox::can_have_children() const
|
|
|
|
|
{
|
|
|
|
|
// If we allow children when controls are disabled, innerText may be non-empty.
|
|
|
|
|
return dom_node().shadow_root() != nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-11 00:31:07 -06:00
|
|
|
CSS::SizeWithAspectRatio VideoBox::natural_size() const
|
2023-04-04 18:32:09 -04:00
|
|
|
{
|
2023-09-03 17:33:58 -05:00
|
|
|
CSSPixels width = dom_node().video_width();
|
|
|
|
|
CSSPixels height = dom_node().video_height();
|
2026-01-11 00:31:07 -06:00
|
|
|
if (width > 0 && height > 0)
|
|
|
|
|
return { width, height, CSSPixelFraction(width, height) };
|
|
|
|
|
return { width, height, {} };
|
2023-04-04 18:32:09 -04:00
|
|
|
}
|
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<Painting::Paintable> VideoBox::create_paintable() const
|
2023-04-04 18:32:09 -04:00
|
|
|
{
|
|
|
|
|
return Painting::VideoPaintable::create(*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|