mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-27 20:58:16 +00:00
LibWeb: Implement CanvasDrawPath::isPointInPath()
This commit is contained in:
parent
18bc5972f4
commit
259e798a26
Notes:
github-actions[bot]
2024-09-18 20:22:53 +00:00
Author: https://github.com/mierenhoop
Commit: 259e798a26
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1423
Reviewed-by: https://github.com/AtkinsSJ
4 changed files with 25 additions and 2 deletions
|
@ -27,6 +27,9 @@ public:
|
||||||
virtual void clip(StringView fill_rule) = 0;
|
virtual void clip(StringView fill_rule) = 0;
|
||||||
virtual void clip(Path2D& path, StringView fill_rule) = 0;
|
virtual void clip(Path2D& path, StringView fill_rule) = 0;
|
||||||
|
|
||||||
|
virtual bool is_point_in_path(double x, double y, StringView fill_rule) = 0;
|
||||||
|
virtual bool is_point_in_path(Path2D const& path, double x, double y, StringView fill_rule) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CanvasDrawPath() = default;
|
CanvasDrawPath() = default;
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,8 +18,10 @@ interface mixin CanvasDrawPath {
|
||||||
// FIXME: `DOMString` should be `CanvasFillRule`
|
// FIXME: `DOMString` should be `CanvasFillRule`
|
||||||
undefined clip(Path2D path, optional DOMString fillRule = "nonzero");
|
undefined clip(Path2D path, optional DOMString fillRule = "nonzero");
|
||||||
|
|
||||||
[FIXME] boolean isPointInPath(unrestricted double x, unrestricted double y, optional CanvasFillRule fillRule = "nonzero");
|
// FIXME: `DOMString` should be `CanvasFillRule`
|
||||||
[FIXME] boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y, optional CanvasFillRule fillRule = "nonzero");
|
boolean isPointInPath(unrestricted double x, unrestricted double y, optional DOMString fillRule = "nonzero");
|
||||||
|
// FIXME: `DOMString` should be `CanvasFillRule`
|
||||||
|
boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y, optional DOMString fillRule = "nonzero");
|
||||||
[FIXME] boolean isPointInStroke(unrestricted double x, unrestricted double y);
|
[FIXME] boolean isPointInStroke(unrestricted double x, unrestricted double y);
|
||||||
[FIXME] boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y);
|
[FIXME] boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y);
|
||||||
};
|
};
|
||||||
|
|
|
@ -542,6 +542,21 @@ void CanvasRenderingContext2D::clip(Path2D& path, StringView fill_rule)
|
||||||
clip_internal(path.path(), parse_fill_rule(fill_rule));
|
clip_internal(path.path(), parse_fill_rule(fill_rule));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_point_in_path_internal(Gfx::Path path, double x, double y, StringView fill_rule)
|
||||||
|
{
|
||||||
|
return path.contains(Gfx::FloatPoint(x, y), parse_fill_rule(fill_rule));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CanvasRenderingContext2D::is_point_in_path(double x, double y, StringView fill_rule)
|
||||||
|
{
|
||||||
|
return is_point_in_path_internal(path(), x, y, fill_rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CanvasRenderingContext2D::is_point_in_path(Path2D const& path, double x, double y, StringView fill_rule)
|
||||||
|
{
|
||||||
|
return is_point_in_path_internal(path.path(), x, y, fill_rule);
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/canvas.html#check-the-usability-of-the-image-argument
|
// https://html.spec.whatwg.org/multipage/canvas.html#check-the-usability-of-the-image-argument
|
||||||
WebIDL::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasImageSource const& image)
|
WebIDL::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasImageSource const& image)
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,6 +87,9 @@ public:
|
||||||
virtual void clip(StringView fill_rule) override;
|
virtual void clip(StringView fill_rule) override;
|
||||||
virtual void clip(Path2D& path, StringView fill_rule) override;
|
virtual void clip(Path2D& path, StringView fill_rule) override;
|
||||||
|
|
||||||
|
virtual bool is_point_in_path(double x, double y, StringView fill_rule) override;
|
||||||
|
virtual bool is_point_in_path(Path2D const& path, double x, double y, StringView fill_rule) override;
|
||||||
|
|
||||||
virtual bool image_smoothing_enabled() const override;
|
virtual bool image_smoothing_enabled() const override;
|
||||||
virtual void set_image_smoothing_enabled(bool) override;
|
virtual void set_image_smoothing_enabled(bool) override;
|
||||||
virtual Bindings::ImageSmoothingQuality image_smoothing_quality() const override;
|
virtual Bindings::ImageSmoothingQuality image_smoothing_quality() const override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue