layout: Use FastTransform for hit testing (#38554)

`FastTransform` provides faster matrix operations when the involved
transforms are just translations.

Testing: Not needed (no change in behavior)

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Oriol Brufau 2025-08-11 09:23:17 -07:00 committed by GitHub
parent 0d40547bec
commit 4ff1e8dbd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 58 additions and 71 deletions

View file

@ -16,4 +16,5 @@ app_units = { workspace = true }
euclid = { workspace = true }
malloc_size_of = { workspace = true }
malloc_size_of_derive = { workspace = true }
webrender = { workspace = true }
webrender_api = { workspace = true }

View file

@ -8,9 +8,10 @@ use app_units::{Au, MAX_AU, MIN_AU};
use euclid::default::{Point2D as UntypedPoint2D, Rect as UntypedRect, Size2D as UntypedSize2D};
use euclid::{Box2D, Length, Point2D, Scale, SideOffsets2D, Size2D, Vector2D};
use malloc_size_of_derive::MallocSizeOf;
use webrender::FastTransform;
use webrender_api::units::{
DeviceIntRect, DeviceIntSize, DevicePixel, FramebufferPixel, LayoutPoint, LayoutRect,
LayoutSize,
DeviceIntRect, DeviceIntSize, DevicePixel, FramebufferPixel, LayoutPixel, LayoutPoint,
LayoutRect, LayoutSize,
};
// Units for use with euclid::length and euclid::scale_factor.
@ -46,6 +47,8 @@ pub type DeviceIndependentPoint = Point2D<f32, DeviceIndependentPixel>;
pub type DeviceIndependentVector2D = Vector2D<f32, DeviceIndependentPixel>;
pub type DeviceIndependentSize = Size2D<f32, DeviceIndependentPixel>;
pub type FastLayoutTransform = FastTransform<LayoutPixel, LayoutPixel>;
// An Au is an "App Unit" and represents 1/60th of a CSS pixel. It was
// originally proposed in 2002 as a standard unit of measure in Gecko.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=177805 for more info.