1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 10:47:35 +00:00

LibWeb: Fix typo and use auto where possible

This commit is contained in:
MacDue 2023-02-02 20:41:03 +00:00 committed by Andreas Kling
parent e96df1599c
commit b106fd640b
3 changed files with 29 additions and 18 deletions

View file

@ -22,37 +22,37 @@ public:
~CanvasFillStrokeStyles() = default;
using FillOrStrokeStyleVariant = Variant<DeprecatedString, JS::Handle<CanvasGradient>>;
static CanvasState::FillOrStrokeStyle to_canvas_state_fill_or_stoke_style(auto const& style)
static CanvasState::FillOrStrokeStyle to_canvas_state_fill_or_stroke_style(auto const& style)
{
return style.visit(
[&](DeprecatedString const& string) -> CanvasState::FillOrStrokeStyle {
return Gfx::Color::from_string(string).value_or(Color::Black);
},
[&](JS::Handle<CanvasGradient> gradient) -> CanvasState::FillOrStrokeStyle {
return gradient;
[&](auto fill_or_stroke_style) -> CanvasState::FillOrStrokeStyle {
return fill_or_stroke_style;
});
}
void set_fill_style(FillOrStrokeStyleVariant style)
{
// FIXME: 2. If the given value is a CanvasPattern object that is marked as not origin-clean, then set this's origin-clean flag to false.
my_drawing_state().fill_style = to_canvas_state_fill_or_stoke_style(style);
my_drawing_state().fill_style = to_canvas_state_fill_or_stroke_style(style);
}
FillOrStrokeStyleVariant fill_style() const
{
return my_drawing_state().fill_style.to_js_fill_or_stoke_style();
return my_drawing_state().fill_style.to_js_fill_or_stroke_style();
}
void set_stroke_style(FillOrStrokeStyleVariant style)
{
// FIXME: 2. If the given value is a CanvasPattern object that is marked as not origin-clean, then set this's origin-clean flag to false.
my_drawing_state().stroke_style = to_canvas_state_fill_or_stoke_style(style);
my_drawing_state().stroke_style = to_canvas_state_fill_or_stroke_style(style);
}
FillOrStrokeStyleVariant stroke_style() const
{
return my_drawing_state().stroke_style.to_js_fill_or_stoke_style();
return my_drawing_state().stroke_style.to_js_fill_or_stroke_style();
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<CanvasGradient>> create_radial_gradient(double x0, double y0, double r0, double x1, double y1, double r1)