lewp_css/domain/expressions/
expression.rs

1// This file is part of css. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/css/master/COPYRIGHT. No part of predicator, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
2// Copyright © 2017 The developers of css. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/css/master/COPYRIGHT.
3
4use crate::domain::units::{conversions::*, Unit};
5
6pub trait Expression<U: Unit> {
7    /// Evaluate the Expression by returning the numeric value of the canonical dimension
8    /// Division by zero is handled by returning the maximum possible f32 value
9    /// Subtractions for UnsignedCssNumber that are negative are handled by returning 0.0
10    fn evaluate<
11        Conversion: FontRelativeLengthConversion<U::Number>
12            + ViewportPercentageLengthConversion<U::Number>
13            + PercentageConversion<U::Number>
14            + AttributeConversion<U>
15            + CssVariableConversion,
16    >(
17        &self,
18        conversion: &Conversion,
19    ) -> Option<U::Number>;
20}