mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 16:16:43 +00:00
LibWeb: Implemented shadows support for CanvasRenderingContext2D
This commit is contained in:
parent
6d68d6ddb2
commit
34f7bf979d
Notes:
github-actions[bot]
2024-10-23 18:44:55 +00:00
Author: https://github.com/uysalibov 🔰
Commit: 34f7bf979d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1848
Reviewed-by: https://github.com/kalenikaliaksandr ✅
5 changed files with 152 additions and 3 deletions
40
Userland/Libraries/LibWeb/HTML/Canvas/CanvasShadowStyles.h
Normal file
40
Userland/Libraries/LibWeb/HTML/Canvas/CanvasShadowStyles.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2024, İbrahim UYSAL <uysalibov@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/HTML/Canvas/CanvasState.h>
|
||||
#include <LibWeb/HTML/CanvasGradient.h>
|
||||
#include <LibWeb/HTML/CanvasPattern.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/canvas.html#canvasshadowstyles
|
||||
template<typename IncludingClass>
|
||||
class CanvasShadowStyles {
|
||||
public:
|
||||
~CanvasShadowStyles() = default;
|
||||
|
||||
virtual float shadow_offset_x() const = 0;
|
||||
virtual void set_shadow_offset_x(float offsetX) = 0;
|
||||
|
||||
virtual float shadow_offset_y() const = 0;
|
||||
virtual void set_shadow_offset_y(float offsetY) = 0;
|
||||
|
||||
virtual String shadow_color() const = 0;
|
||||
virtual void set_shadow_color(String color) = 0;
|
||||
|
||||
protected:
|
||||
CanvasShadowStyles() = default;
|
||||
|
||||
private:
|
||||
CanvasState::DrawingState& my_drawing_state() { return reinterpret_cast<IncludingClass&>(*this).drawing_state(); }
|
||||
CanvasState::DrawingState const& my_drawing_state() const { return reinterpret_cast<IncludingClass const&>(*this).drawing_state(); }
|
||||
};
|
||||
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
// https://html.spec.whatwg.org/multipage/canvas.html#canvasshadowstyles
|
||||
interface mixin CanvasShadowStyles {
|
||||
// shadows
|
||||
[FIXME] attribute unrestricted double shadowOffsetX; // (default 0)
|
||||
[FIXME] attribute unrestricted double shadowOffsetY; // (default 0)
|
||||
attribute unrestricted double shadowOffsetX; // (default 0)
|
||||
attribute unrestricted double shadowOffsetY; // (default 0)
|
||||
[FIXME] attribute unrestricted double shadowBlur; // (default 0)
|
||||
[FIXME] attribute DOMString shadowColor; // (default transparent black)
|
||||
attribute DOMString shadowColor; // (default transparent black)
|
||||
};
|
||||
|
|
|
@ -80,6 +80,9 @@ public:
|
|||
Gfx::AffineTransform transform;
|
||||
FillOrStrokeStyle fill_style { Gfx::Color::Black };
|
||||
FillOrStrokeStyle stroke_style { Gfx::Color::Black };
|
||||
float shadow_offset_x { 0.0f };
|
||||
float shadow_offset_y { 0.0f };
|
||||
Gfx::Color shadow_color { Gfx::Color::Transparent };
|
||||
float line_width { 1 };
|
||||
Vector<double> dash_list;
|
||||
bool image_smoothing_enabled { true };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue