mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibWeb: Implement missing basic shapes
This commit is contained in:
parent
76e638b4ca
commit
a7e83c38ee
Notes:
github-actions[bot]
2024-10-31 10:49:39 +00:00
Author: https://github.com/Gingeh
Commit: a7e83c38ee
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1996
Reviewed-by: https://github.com/AtkinsSJ ✅
8 changed files with 620 additions and 28 deletions
|
@ -7,12 +7,71 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Variant.h>
|
||||
#include <LibGfx/DeprecatedPath.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/LengthBox.h>
|
||||
#include <LibWeb/CSS/PercentageOr.h>
|
||||
#include <LibWeb/CSS/StyleValues/PositionStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
struct Inset {
|
||||
Gfx::Path to_path(CSSPixelRect reference_box, Layout::Node const&) const;
|
||||
String to_string() const;
|
||||
|
||||
bool operator==(Inset const&) const = default;
|
||||
|
||||
LengthBox inset_box;
|
||||
};
|
||||
|
||||
struct Xywh {
|
||||
Gfx::Path to_path(CSSPixelRect reference_box, Layout::Node const&) const;
|
||||
String to_string() const;
|
||||
|
||||
bool operator==(Xywh const&) const = default;
|
||||
|
||||
LengthPercentage x;
|
||||
LengthPercentage y;
|
||||
LengthPercentage width;
|
||||
LengthPercentage height;
|
||||
};
|
||||
|
||||
struct Rect {
|
||||
Gfx::Path to_path(CSSPixelRect reference_box, Layout::Node const&) const;
|
||||
String to_string() const;
|
||||
|
||||
bool operator==(Rect const&) const = default;
|
||||
|
||||
LengthBox box;
|
||||
};
|
||||
|
||||
enum class FitSide {
|
||||
ClosestSide,
|
||||
FarthestSide,
|
||||
};
|
||||
|
||||
using ShapeRadius = Variant<LengthPercentage, FitSide>;
|
||||
|
||||
struct Circle {
|
||||
Gfx::Path to_path(CSSPixelRect reference_box, Layout::Node const&) const;
|
||||
String to_string() const;
|
||||
|
||||
bool operator==(Circle const&) const = default;
|
||||
|
||||
ShapeRadius radius;
|
||||
ValueComparingNonnullRefPtr<PositionStyleValue> position;
|
||||
};
|
||||
|
||||
struct Ellipse {
|
||||
Gfx::Path to_path(CSSPixelRect reference_box, Layout::Node const&) const;
|
||||
String to_string() const;
|
||||
|
||||
bool operator==(Ellipse const&) const = default;
|
||||
|
||||
ShapeRadius radius_x;
|
||||
ShapeRadius radius_y;
|
||||
ValueComparingNonnullRefPtr<PositionStyleValue> position;
|
||||
};
|
||||
|
||||
struct Polygon {
|
||||
struct Point {
|
||||
bool operator==(Point const&) const = default;
|
||||
|
@ -25,12 +84,13 @@ struct Polygon {
|
|||
|
||||
bool operator==(Polygon const&) const = default;
|
||||
|
||||
// FIXME: Actually use the fill rule
|
||||
FillRule fill_rule;
|
||||
Vector<Point> points;
|
||||
};
|
||||
|
||||
// FIXME: Implement other basic shapes. See: https://www.w3.org/TR/css-shapes-1/#basic-shape-functions
|
||||
using BasicShape = Variant<Polygon>;
|
||||
// FIXME: Implement path(). See: https://www.w3.org/TR/css-shapes-1/#basic-shape-functions
|
||||
using BasicShape = Variant<Inset, Xywh, Rect, Circle, Ellipse, Polygon>;
|
||||
|
||||
class BasicShapeStyleValue : public StyleValueWithDefaultOperators<BasicShapeStyleValue> {
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue