mirror of
https://github.com/servo/servo.git
synced 2025-08-16 02:45:36 +01:00
Implement Servo_ParseTransformIntoMatrix.
DOMMatrix needs to convert a specified transform list into a matrix, so we could rewrite to_transform_3d_matrix by generics for both specified and computed transform lists. Besides, we have to update the test case because we use Transform3D<f64> to compute the matrix, instead of Transform3D<f32>, so the result will be the same as that in Gecko. Using 0.3 may cause floating point issue because (0.3f32 as f64) is not equal to 0.3 (i.e. floating point precision issue), so using 0.25 instead.
This commit is contained in:
parent
ac6e04ebfb
commit
3a38e815ec
16 changed files with 450 additions and 238 deletions
|
@ -4638,6 +4638,42 @@ pub extern "C" fn Servo_ParseIntersectionObserverRootMargin(
|
|||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ParseTransformIntoMatrix(
|
||||
value: *const nsAString,
|
||||
contain_3d: *mut bool,
|
||||
result: *mut RawGeckoGfxMatrix4x4
|
||||
) -> bool {
|
||||
use style::properties::longhands::transform;
|
||||
|
||||
let string = unsafe { (*value).to_string() };
|
||||
let mut input = ParserInput::new(&string);
|
||||
let mut parser = Parser::new(&mut input);
|
||||
let context = ParserContext::new(
|
||||
Origin::Author,
|
||||
unsafe { dummy_url_data() },
|
||||
Some(CssRuleType::Style),
|
||||
ParsingMode::DEFAULT,
|
||||
QuirksMode::NoQuirks
|
||||
);
|
||||
|
||||
let transform = match parser.parse_entirely(|t| transform::parse(&context, t)) {
|
||||
Ok(t) => t,
|
||||
Err(..) => return false,
|
||||
};
|
||||
|
||||
let (m, is_3d) = match transform.to_transform_3d_matrix(None) {
|
||||
Ok(result) => result,
|
||||
Err(..) => return false,
|
||||
};
|
||||
|
||||
let result = unsafe { result.as_mut() }.expect("not a valid matrix");
|
||||
let contain_3d = unsafe { contain_3d.as_mut() }.expect("not a valid bool");
|
||||
*result = m.to_row_major_array();
|
||||
*contain_3d = is_3d;
|
||||
true
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_SourceSizeList_Parse(
|
||||
value: *const nsACString,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue