mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 02:10:26 +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.
42 lines
1,017 B
C++
42 lines
1,017 B
C++
/*
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/DOM/ViewportClient.h>
|
|
#include <LibWeb/Forward.h>
|
|
#include <LibWeb/Layout/ReplacedBox.h>
|
|
|
|
namespace Web::Layout {
|
|
|
|
class VideoBox final
|
|
: public ReplacedBox
|
|
, public DOM::ViewportClient {
|
|
GC_CELL(VideoBox, ReplacedBox);
|
|
GC_DECLARE_ALLOCATOR(VideoBox);
|
|
|
|
public:
|
|
static constexpr bool OVERRIDES_FINALIZE = true;
|
|
|
|
HTML::HTMLVideoElement& dom_node();
|
|
HTML::HTMLVideoElement const& dom_node() const;
|
|
|
|
virtual bool can_have_children() const override;
|
|
|
|
virtual GC::Ptr<Painting::Paintable> create_paintable() const override;
|
|
|
|
private:
|
|
VideoBox(DOM::Document&, DOM::Element&, GC::Ref<CSS::ComputedProperties>);
|
|
virtual CSS::SizeWithAspectRatio natural_size() const override;
|
|
|
|
// ^Document::ViewportClient
|
|
virtual void did_set_viewport_rect(CSSPixelRect const&) final;
|
|
|
|
// ^JS::Cell
|
|
virtual void finalize() override;
|
|
};
|
|
|
|
}
|