Bug 1758127 - Don't use tight bounding rect if glyph transform fails. r=jnicol

Differential Revision: https://phabricator.services.mozilla.com/D140746
This commit is contained in:
Lee Salzman 2022-03-11 08:06:39 +00:00
parent 9fbf6f9b14
commit eb9953e3f6
3 changed files with 36 additions and 11 deletions

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<style>
* {
display: table-footer-group;
transform: rotateY(18.03772675170004deg);
perspective: 116in;
letter-spacing: -80ex;
}
</style>
</head>
</html>

View File

@ -210,4 +210,4 @@ load 1702638.html
load 1730695.html
load 1745775.html
load 1757002.html
load 1758127-1.html

View File

@ -1356,10 +1356,18 @@ impl BatchBuilder {
let glyph_translation = DeviceVector2D::new(glyph_transform.m41, glyph_transform.m42);
let mut use_tight_bounding_rect = true;
for glyph in glyphs {
let glyph_offset = prim_data.glyphs[glyph.index_in_text_run as usize].point + prim_header.local_rect.min.to_vector();
let raster_glyph_offset = (glyph_transform.transform_point2d(glyph_offset).unwrap() + snap_bias).floor();
let transformed_offset = match glyph_transform.transform_point2d(glyph_offset) {
Some(transformed_offset) => transformed_offset,
None => {
use_tight_bounding_rect = false;
break;
}
};
let raster_glyph_offset = (transformed_offset + snap_bias).floor();
let raster_text_offset = (
glyph_transform.transform_vector2d(text_offset) +
glyph_translation +
@ -1374,16 +1382,20 @@ impl BatchBuilder {
device_bounding_rect = device_bounding_rect.union(&device_glyph_rect);
}
let map_device_to_surface: SpaceMapper<PicturePixel, DevicePixel> = SpaceMapper::new_with_target(
root_spatial_node_index,
surface_spatial_node_index,
device_bounding_rect,
ctx.spatial_tree,
);
if use_tight_bounding_rect {
let map_device_to_surface: SpaceMapper<PicturePixel, DevicePixel> = SpaceMapper::new_with_target(
root_spatial_node_index,
surface_spatial_node_index,
device_bounding_rect,
ctx.spatial_tree,
);
match map_device_to_surface.unmap(&device_bounding_rect) {
Some(r) => r.intersection(bounding_rect),
None => Some(*bounding_rect),
match map_device_to_surface.unmap(&device_bounding_rect) {
Some(r) => r.intersection(bounding_rect),
None => Some(*bounding_rect),
}
} else {
Some(*bounding_rect)
}
} else {
let mut local_bounding_rect = LayoutRect::default();