2023-04-04 19:32:09 -03: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-14 12:01:23 -03:00
|
|
|
GC_DEFINE_ALLOCATOR(VideoBox);
|
2024-04-06 14:16:04 -03:00
|
|
|
|
2024-12-20 12:35:12 -03:00
|
|
|
VideoBox::VideoBox(DOM::Document& document, DOM::Element& element, GC::Ref<CSS::ComputedProperties> style)
|
2026-02-20 22:54:03 -03:00
|
|
|
: ReplacedBox(document, element, style)
|
2023-04-04 19:32:09 -03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HTML::HTMLVideoElement& VideoBox::dom_node()
|
|
|
|
|
{
|
2025-07-26 09:22:50 -03:00
|
|
|
return static_cast<HTML::HTMLVideoElement&>(*ReplacedBox::dom_node());
|
2023-04-04 19:32:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HTML::HTMLVideoElement const& VideoBox::dom_node() const
|
|
|
|
|
{
|
2025-07-26 09:22:50 -03:00
|
|
|
return static_cast<HTML::HTMLVideoElement const&>(*ReplacedBox::dom_node());
|
2023-04-04 19:32:09 -03:00
|
|
|
}
|
|
|
|
|
|
2026-02-21 03:14:45 -03: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 03:31:07 -03:00
|
|
|
CSS::SizeWithAspectRatio VideoBox::natural_size() const
|
2023-04-04 19:32:09 -03:00
|
|
|
{
|
2023-09-03 19:33:58 -03:00
|
|
|
CSSPixels width = dom_node().video_width();
|
|
|
|
|
CSSPixels height = dom_node().video_height();
|
2026-01-11 03:31:07 -03:00
|
|
|
if (width > 0 && height > 0)
|
|
|
|
|
return { width, height, CSSPixelFraction(width, height) };
|
|
|
|
|
return { width, height, {} };
|
2023-04-04 19:32:09 -03:00
|
|
|
}
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ptr<Painting::Paintable> VideoBox::create_paintable() const
|
2023-04-04 19:32:09 -03:00
|
|
|
{
|
|
|
|
|
return Painting::VideoPaintable::create(*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|