Auto merge of #19388 - BorisChiou:stylo/dommatrix/parser, r=emilio,heycam

stylo: Implement Servo_ParseTransformIntoMatrix

This is an inter-dependent patch of Bug 1408310.

DOMMatrix needs to convert a specified transform list into a matrix, so we rewrite
to_transform_3d_matrix by generics for both specified and computed transform lists.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [Bug 1408310](https://bugzilla.mozilla.org/show_bug.cgi?id=1408310).
- [X] These changes do not require tests because we can count on the wpt tests for DOMMatrix on Gecko side.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19388)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-11-27 20:13:34 -06:00 committed by GitHub
commit 823da9e34a
16 changed files with 450 additions and 238 deletions

View file

@ -4650,6 +4650,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,