mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
style: Move the animation code of transform into a different file.
Basically, most of the animation code of transform don't need mako, so we could move them into values/animated/transform.rs. However, we still use mako to generate some code to make the methods of Matrix3D simpler, so I still leave them in animated_properties.mako.rs. Differential Revision: https://phabricator.services.mozilla.com/D11934
This commit is contained in:
parent
8e47e7f134
commit
e83f5629ff
4 changed files with 1619 additions and 1583 deletions
|
@ -13,9 +13,11 @@ use crate::gecko::values::GeckoStyleCoordConvertible;
|
|||
use crate::gecko_bindings::bindings;
|
||||
use crate::gecko_bindings::structs::{self, nsStyleCoord_CalcValue};
|
||||
use crate::gecko_bindings::structs::{nsStyleImage, nsresult, SheetType};
|
||||
use crate::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
|
||||
use crate::gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
|
||||
use crate::stylesheets::{Origin, RulesMutateError};
|
||||
use crate::values::computed::image::LineDirection;
|
||||
use crate::values::computed::transform::Matrix3D;
|
||||
use crate::values::computed::url::ComputedImageUrl;
|
||||
use crate::values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image};
|
||||
use crate::values::computed::{Integer, LengthOrPercentage};
|
||||
|
@ -1142,3 +1144,23 @@ pub unsafe fn string_from_chars_pointer(p: *const u16) -> String {
|
|||
let char_vec = slice::from_raw_parts(p, length as usize);
|
||||
String::from_utf16_lossy(char_vec)
|
||||
}
|
||||
|
||||
impl<'a> From< &'a RawGeckoGfxMatrix4x4> for Matrix3D {
|
||||
fn from(m: &'a RawGeckoGfxMatrix4x4) -> Matrix3D {
|
||||
Matrix3D {
|
||||
m11: m[0], m12: m[1], m13: m[2], m14: m[3],
|
||||
m21: m[4], m22: m[5], m23: m[6], m24: m[7],
|
||||
m31: m[8], m32: m[9], m33: m[10], m34: m[11],
|
||||
m41: m[12], m42: m[13], m43: m[14], m44: m[15],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Matrix3D> for RawGeckoGfxMatrix4x4 {
|
||||
fn from(matrix: Matrix3D) -> RawGeckoGfxMatrix4x4 {
|
||||
[ matrix.m11, matrix.m12, matrix.m13, matrix.m14,
|
||||
matrix.m21, matrix.m22, matrix.m23, matrix.m24,
|
||||
matrix.m31, matrix.m32, matrix.m33, matrix.m34,
|
||||
matrix.m41, matrix.m42, matrix.m43, matrix.m44 ]
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -14,12 +14,14 @@ use crate::values::computed::length::CalcLengthOrPercentage;
|
|||
use crate::values::computed::url::ComputedUrl;
|
||||
use crate::values::computed::Angle as ComputedAngle;
|
||||
use crate::values::computed::BorderCornerRadius as ComputedBorderCornerRadius;
|
||||
use crate::values::CSSFloat;
|
||||
use euclid::{Point2D, Size2D};
|
||||
use smallvec::SmallVec;
|
||||
use std::cmp;
|
||||
|
||||
pub mod color;
|
||||
pub mod effects;
|
||||
pub mod transform;
|
||||
mod font;
|
||||
mod length;
|
||||
mod svg;
|
||||
|
@ -86,6 +88,15 @@ pub fn compare_property_priority(a: &PropertyId, b: &PropertyId) -> cmp::Orderin
|
|||
.then_with(|| a.idl_name_sort_order().cmp(&b.idl_name_sort_order()))
|
||||
}
|
||||
|
||||
/// A helper function to animate two multiplicative factor.
|
||||
pub fn animate_multiplicative_factor(
|
||||
this: CSSFloat,
|
||||
other: CSSFloat,
|
||||
procedure: Procedure,
|
||||
) -> Result<CSSFloat, ()> {
|
||||
Ok((this - 1.).animate(&(other - 1.), procedure)? + 1.)
|
||||
}
|
||||
|
||||
/// Animate from one value to another.
|
||||
///
|
||||
/// This trait is derivable with `#[derive(Animate)]`. The derived
|
||||
|
|
1556
components/style/values/animated/transform.rs
Normal file
1556
components/style/values/animated/transform.rs
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue