mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 18:00:31 +00:00
Instead of using a custom paintable to draw the controls for video and audio elements, we build them out of plain old HTML elements within a shadow root. This required a few hacks in the previous commits in order to allow a replaced element to host children within a shadow root, but it's fairly self-contained. A big benefit is that we can drive all the UI updates off of plain old DOM events (except the play button overlay on videos, which uses the video element representation), so we can test our media and input event handling more thoroughly. :^) The control bar visibility is now more similar to how other browsers handle it. It will show upon hovering over the element, but if the cursor is kept still for more than a second, it will hide again. While dragging, the controls remain visible, and will then hide after the mouse button is released. The icons have been redesigned from scratch, and the mute icon now visualizes the volume level along with indicating the mute state.
34 lines
968 B
C++
34 lines
968 B
C++
/*
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Forward.h>
|
|
#include <LibWeb/HTML/BrowsingContext.h>
|
|
#include <LibWeb/Layout/ReplacedBox.h>
|
|
|
|
namespace Web::Layout {
|
|
|
|
class AudioBox final : public ReplacedBox {
|
|
GC_CELL(AudioBox, ReplacedBox);
|
|
GC_DECLARE_ALLOCATOR(AudioBox);
|
|
|
|
public:
|
|
HTML::HTMLAudioElement& dom_node();
|
|
HTML::HTMLAudioElement const& dom_node() const;
|
|
|
|
virtual bool can_have_children() const override;
|
|
|
|
virtual GC::Ptr<Painting::Paintable> create_paintable() const override;
|
|
|
|
private:
|
|
// Treat the audio element as if it was not a replaced element, sizing based on its content.
|
|
// Thus, it can fit to the shadow DOM controls, instead of having a hardcoded height.
|
|
virtual bool has_auto_content_box_size() const override { return false; }
|
|
AudioBox(DOM::Document&, DOM::Element&, GC::Ref<CSS::ComputedProperties>);
|
|
};
|
|
|
|
}
|