2023-06-12 13:55:43 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibWeb/HTML/HTMLAudioElement.h>
|
|
|
|
#include <LibWeb/Layout/AudioBox.h>
|
|
|
|
#include <LibWeb/Painting/AudioPaintable.h>
|
|
|
|
|
|
|
|
namespace Web::Layout {
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DEFINE_ALLOCATOR(AudioBox);
|
2024-04-06 10:16:04 -07:00
|
|
|
|
2024-12-20 16:35:12 +01:00
|
|
|
AudioBox::AudioBox(DOM::Document& document, DOM::Element& element, GC::Ref<CSS::ComputedProperties> style)
|
2023-06-12 13:55:43 -04:00
|
|
|
: ReplacedBox(document, element, move(style))
|
|
|
|
{
|
|
|
|
set_natural_width(300);
|
|
|
|
set_natural_height(40);
|
|
|
|
}
|
|
|
|
|
|
|
|
HTML::HTMLAudioElement& AudioBox::dom_node()
|
|
|
|
{
|
2025-07-26 14:22:50 +02:00
|
|
|
return static_cast<HTML::HTMLAudioElement&>(*ReplacedBox::dom_node());
|
2023-06-12 13:55:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HTML::HTMLAudioElement const& AudioBox::dom_node() const
|
|
|
|
{
|
2025-07-26 14:22:50 +02:00
|
|
|
return static_cast<HTML::HTMLAudioElement const&>(*ReplacedBox::dom_node());
|
2023-06-12 13:55:43 -04:00
|
|
|
}
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<Painting::Paintable> AudioBox::create_paintable() const
|
2023-06-12 13:55:43 -04:00
|
|
|
{
|
|
|
|
return Painting::AudioPaintable::create(*this);
|
|
|
|
}
|
|
|
|
|
2025-01-04 12:13:40 +01:00
|
|
|
void AudioBox::prepare_for_replaced_layout()
|
|
|
|
{
|
2025-10-10 03:46:19 +02:00
|
|
|
if (dom_node().should_paint()) {
|
2025-01-04 12:13:40 +01:00
|
|
|
set_natural_width(300);
|
|
|
|
set_natural_height(40);
|
|
|
|
} else {
|
|
|
|
set_natural_width(0);
|
|
|
|
set_natural_height(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-12 13:55:43 -04:00
|
|
|
}
|