mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:27:46 +00:00
LibWeb: Implement CSS round()
This commit is contained in:
parent
ec0054da06
commit
b2230c826b
4 changed files with 210 additions and 0 deletions
|
@ -125,6 +125,14 @@ public:
|
|||
MinusInfinity,
|
||||
};
|
||||
|
||||
// https://drafts.csswg.org/css-values-4/#round-func
|
||||
enum class RoundingMode {
|
||||
Nearest,
|
||||
Up,
|
||||
Down,
|
||||
TowardZero
|
||||
};
|
||||
|
||||
enum class Type {
|
||||
Numeric,
|
||||
// NOTE: Currently, any value with a `var()` or `attr()` function in it is always an
|
||||
|
@ -170,6 +178,12 @@ public:
|
|||
Log,
|
||||
Exp,
|
||||
|
||||
// Stepped value functions, a sub-type of operator node
|
||||
// https://drafts.csswg.org/css-values-4/#round-func
|
||||
Round,
|
||||
Mod,
|
||||
Rem,
|
||||
|
||||
// This only exists during parsing.
|
||||
Unparsed,
|
||||
};
|
||||
|
@ -623,4 +637,24 @@ private:
|
|||
NonnullOwnPtr<CalculationNode> m_value;
|
||||
};
|
||||
|
||||
class RoundCalculationNode final : public CalculationNode {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<RoundCalculationNode>> create(CalculationNode::RoundingMode, NonnullOwnPtr<CalculationNode>, NonnullOwnPtr<CalculationNode>);
|
||||
~RoundCalculationNode();
|
||||
|
||||
virtual ErrorOr<String> to_string() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
virtual ErrorOr<void> for_each_child_node(Function<ErrorOr<void>(NonnullOwnPtr<CalculationNode>&)> const&) override;
|
||||
|
||||
virtual ErrorOr<void> dump(StringBuilder&, int indent) const override;
|
||||
|
||||
private:
|
||||
RoundCalculationNode(RoundingMode, NonnullOwnPtr<CalculationNode>, NonnullOwnPtr<CalculationNode>);
|
||||
CalculationNode::RoundingMode m_mode;
|
||||
NonnullOwnPtr<CalculationNode> m_x;
|
||||
NonnullOwnPtr<CalculationNode> m_y;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue