2023-06-12 13:55:43 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <AK/Array.h>
|
|
|
|
#include <AK/NumberFormat.h>
|
|
|
|
#include <LibWeb/DOM/Document.h>
|
|
|
|
#include <LibWeb/HTML/AudioTrackList.h>
|
|
|
|
#include <LibWeb/HTML/HTMLAudioElement.h>
|
|
|
|
#include <LibWeb/HTML/HTMLMediaElement.h>
|
|
|
|
#include <LibWeb/Layout/AudioBox.h>
|
|
|
|
#include <LibWeb/Painting/AudioPaintable.h>
|
|
|
|
#include <LibWeb/Painting/BorderRadiusCornerClipper.h>
|
2025-02-02 15:55:26 +01:00
|
|
|
#include <LibWeb/Painting/DisplayListRecorder.h>
|
2023-06-12 13:55:43 -04:00
|
|
|
|
|
|
|
namespace Web::Painting {
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DEFINE_ALLOCATOR(AudioPaintable);
|
2024-04-06 10:16:04 -07:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<AudioPaintable> AudioPaintable::create(Layout::AudioBox const& layout_box)
|
2023-06-12 13:55:43 -04:00
|
|
|
{
|
2024-11-14 06:13:46 +13:00
|
|
|
return layout_box.heap().allocate<AudioPaintable>(layout_box);
|
2023-06-12 13:55:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
AudioPaintable::AudioPaintable(Layout::AudioBox const& layout_box)
|
|
|
|
: MediaPaintable(layout_box)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Layout::AudioBox& AudioPaintable::layout_box()
|
|
|
|
{
|
|
|
|
return static_cast<Layout::AudioBox&>(layout_node());
|
|
|
|
}
|
|
|
|
|
|
|
|
Layout::AudioBox const& AudioPaintable::layout_box() const
|
|
|
|
{
|
|
|
|
return static_cast<Layout::AudioBox const&>(layout_node());
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioPaintable::paint(PaintContext& context, PaintPhase phase) const
|
|
|
|
{
|
|
|
|
if (!is_visible())
|
|
|
|
return;
|
|
|
|
|
2025-01-04 12:13:40 +01:00
|
|
|
if (!layout_box().should_paint())
|
|
|
|
return;
|
|
|
|
|
2023-06-12 13:55:43 -04:00
|
|
|
Base::paint(context, phase);
|
|
|
|
|
|
|
|
if (phase != PaintPhase::Foreground)
|
|
|
|
return;
|
|
|
|
|
2024-06-23 18:40:10 +02:00
|
|
|
DisplayListRecorderStateSaver saver { context.display_list_recorder() };
|
2023-08-01 10:25:26 -04:00
|
|
|
|
2023-06-12 13:55:43 -04:00
|
|
|
auto audio_rect = context.rounded_device_rect(absolute_rect());
|
2024-06-23 18:40:10 +02:00
|
|
|
context.display_list_recorder().add_clip_rect(audio_rect.to_type<int>());
|
2023-08-01 10:25:26 -04:00
|
|
|
|
2023-10-15 04:27:48 +02:00
|
|
|
ScopedCornerRadiusClip corner_clip { context, audio_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) };
|
2023-06-12 13:55:43 -04:00
|
|
|
|
|
|
|
auto const& audio_element = layout_box().dom_node();
|
|
|
|
auto mouse_position = MediaPaintable::mouse_position(context, audio_element);
|
2025-01-04 12:13:40 +01:00
|
|
|
paint_media_controls(context, audio_element, audio_rect, mouse_position);
|
2023-06-12 13:55:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|