mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:27:43 +00:00
LibWeb: Remove progress element custom paintable use shadow dom instead
This commit is contained in:
parent
ca94df3c88
commit
4966c083df
11 changed files with 93 additions and 212 deletions
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGfx/StylePainter.h>
|
||||
#include <LibWeb/Painting/ProgressPaintable.h>
|
||||
|
||||
namespace Web::Painting {
|
||||
|
||||
JS::NonnullGCPtr<ProgressPaintable> ProgressPaintable::create(Layout::Progress const& layout_box)
|
||||
{
|
||||
return layout_box.heap().allocate_without_realm<ProgressPaintable>(layout_box);
|
||||
}
|
||||
|
||||
ProgressPaintable::ProgressPaintable(Layout::Progress const& layout_box)
|
||||
: PaintableBox(layout_box)
|
||||
{
|
||||
}
|
||||
|
||||
Layout::Progress const& ProgressPaintable::layout_box() const
|
||||
{
|
||||
return static_cast<Layout::Progress const&>(layout_node());
|
||||
}
|
||||
|
||||
void ProgressPaintable::paint(PaintContext& context, PaintPhase phase) const
|
||||
{
|
||||
if (!is_visible())
|
||||
return;
|
||||
|
||||
if (phase == PaintPhase::Foreground) {
|
||||
auto progress_rect = context.rounded_device_rect(absolute_rect());
|
||||
auto min_frame_thickness = context.rounded_device_pixels(3);
|
||||
auto frame_thickness = min(min(progress_rect.width(), progress_rect.height()) / 6, min_frame_thickness);
|
||||
|
||||
context.recording_painter().paint_progressbar(
|
||||
progress_rect.to_type<int>(),
|
||||
progress_rect.shrunken(frame_thickness, frame_thickness).to_type<int>(),
|
||||
context.palette(),
|
||||
0,
|
||||
round_to<int>(layout_box().dom_node().max()),
|
||||
round_to<int>(layout_box().dom_node().value()),
|
||||
""sv);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Layout/Progress.h>
|
||||
#include <LibWeb/Painting/PaintableBox.h>
|
||||
|
||||
namespace Web::Painting {
|
||||
|
||||
// FIXME: ProgressPaintable should inherit from LabelablePaintable, as it is a LabelableNode.
|
||||
// LabelablePaintable should be split into FormAssociatedLabelablePaintable once this
|
||||
// happens.
|
||||
class ProgressPaintable final : public PaintableBox {
|
||||
JS_CELL(ProgressPaintable, PaintableBox);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<ProgressPaintable> create(Layout::Progress const&);
|
||||
|
||||
virtual void paint(PaintContext&, PaintPhase) const override;
|
||||
|
||||
Layout::Progress const& layout_box() const;
|
||||
|
||||
private:
|
||||
ProgressPaintable(Layout::Progress const&);
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue