mirror of
https://github.com/servo/servo.git
synced 2025-10-15 16:00:28 +01:00
style: Add experimental support for "e", "pi", and various trigonometric functions in calc()
I'll add some tests before enabling. Also, WebKit folks (who have implemented cos() / tan() / sin()) said they will upstream their tests to WPT, so I'll extend those with the inverse functions before landing as well. Differential Revision: https://phabricator.services.mozilla.com/D124990
This commit is contained in:
parent
4f193fbf49
commit
4522e7f94a
2 changed files with 93 additions and 8 deletions
|
@ -130,6 +130,15 @@ impl Angle {
|
|||
}
|
||||
}
|
||||
|
||||
/// Creates an angle with the given value in radians.
|
||||
#[inline]
|
||||
pub fn from_radians(value: CSSFloat) -> Self {
|
||||
Angle {
|
||||
value: AngleDimension::Rad(value),
|
||||
was_calc: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Return `0deg`.
|
||||
pub fn zero() -> Self {
|
||||
Self::from_degrees(0.0, false)
|
||||
|
@ -141,6 +150,13 @@ impl Angle {
|
|||
self.value.degrees()
|
||||
}
|
||||
|
||||
/// Returns the value of the angle in radians.
|
||||
#[inline]
|
||||
pub fn radians(&self) -> CSSFloat {
|
||||
const RAD_PER_DEG: f32 = PI / 180.0;
|
||||
self.value.degrees() * RAD_PER_DEG
|
||||
}
|
||||
|
||||
/// Whether this specified angle came from a `calc()` expression.
|
||||
#[inline]
|
||||
pub fn was_calc(&self) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue