Bug 1458927: Fix perspective squared distance computation. r=hiro

MozReview-Commit-ID: YwjTheRonB

--HG--
extra : rebase_source : d3734aad5d37dda1ccaf24f1f84e2f0972e45f5d
This commit is contained in:
Emilio Cobos Álvarez 2018-05-03 17:43:30 +02:00
Родитель 18ca834662
Коммит da45aa5fed
2 изменённых файлов: 4 добавлений и 13 удалений

Просмотреть файл

@ -192,7 +192,7 @@ test(function(t) {
var dist = getDistance(target, 'transform',
'perspective(128px)',
'none');
assert_equals(dist, 1/128, 'distance of perspective');
assert_equals(dist, 128, 'distance of perspective');
}, 'Test distance of perspective function and none');
test(function(t) {
@ -202,7 +202,7 @@ test(function(t) {
var dist = getDistance(target, 'transform',
'perspective(128px)',
'perspective(0)');
assert_equals(dist, 1/128, 'distance of perspective');
assert_equals(dist, 128, 'distance of perspective');
}, 'Test distance of perspective function and an invalid perspective');
test(function(t) {
@ -210,7 +210,7 @@ test(function(t) {
var dist = getDistance(target, 'transform',
'perspective(128px)',
'perspective(1024px)');
assert_equals(dist, 1/128 - 1/1024, 'distance of perspective');
assert_equals(dist, 1024 - 128, 'distance of perspective');
}, 'Test distance of perspective functions');
test(function(t) {

Просмотреть файл

@ -2632,16 +2632,7 @@ impl ComputeSquaredDistance for ComputedTransformOperation {
&TransformOperation::Perspective(ref fd),
&TransformOperation::Perspective(ref td),
) => {
let mut fd_matrix = Matrix3D::identity();
let mut td_matrix = Matrix3D::identity();
if fd.px() > 0. {
fd_matrix.m34 = -1. / fd.px();
}
if td.px() > 0. {
td_matrix.m34 = -1. / td.px();
}
fd_matrix.compute_squared_distance(&td_matrix)
fd.compute_squared_distance(td)
}
(
&TransformOperation::Perspective(ref p),