mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Clamp perspective() values to a minimum of 1px
Differential Revision: https://phabricator.services.mozilla.com/D118250
This commit is contained in:
parent
2c5aa34bb0
commit
f81ffda69d
2 changed files with 4 additions and 11 deletions
|
@ -1204,8 +1204,8 @@ impl ComputeSquaredDistance for ComputedTransformOperation {
|
||||||
// FIXME(emilio): Is this right? Why interpolating this with
|
// FIXME(emilio): Is this right? Why interpolating this with
|
||||||
// Perspective but not with anything else?
|
// Perspective but not with anything else?
|
||||||
let mut p_matrix = Matrix3D::identity();
|
let mut p_matrix = Matrix3D::identity();
|
||||||
if p.px() > 0. {
|
if p.px() >= 0. {
|
||||||
p_matrix.m34 = -1. / p.px();
|
p_matrix.m34 = -1. / p.px().max(1.);
|
||||||
}
|
}
|
||||||
p_matrix.compute_squared_distance(&m)
|
p_matrix.compute_squared_distance(&m)
|
||||||
},
|
},
|
||||||
|
|
|
@ -583,17 +583,10 @@ impl<T: ToMatrix> Transform<T> {
|
||||||
/// Return the transform matrix from a perspective length.
|
/// Return the transform matrix from a perspective length.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn create_perspective_matrix(d: CSSFloat) -> Transform3D<CSSFloat> {
|
pub fn create_perspective_matrix(d: CSSFloat) -> Transform3D<CSSFloat> {
|
||||||
// TODO(gw): The transforms spec says that perspective length must
|
if d < 0.0 {
|
||||||
// be positive. However, there is some confusion between the spec
|
|
||||||
// and browser implementations as to handling the case of 0 for the
|
|
||||||
// perspective value. Until the spec bug is resolved, at least ensure
|
|
||||||
// that a provided perspective value of <= 0.0 doesn't cause panics
|
|
||||||
// and behaves as it does in other browsers.
|
|
||||||
// See https://lists.w3.org/Archives/Public/www-style/2016Jan/0020.html for more details.
|
|
||||||
if d <= 0.0 {
|
|
||||||
Transform3D::identity()
|
Transform3D::identity()
|
||||||
} else {
|
} else {
|
||||||
Transform3D::perspective(d)
|
Transform3D::perspective(d.max(1.))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue