use app unit in box_fragement (#32349)

This commit is contained in:
atbrakhi 2024-06-21 16:54:21 +02:00 committed by GitHub
parent 66edef8065
commit 26c585a0c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 273 additions and 289 deletions

View file

@ -216,6 +216,19 @@ impl fmt::Debug for LogicalRect<Length> {
}
}
impl fmt::Debug for LogicalRect<Au> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"Rect(i{}×b{} @ (i{},b{}))",
self.size.inline.to_px(),
self.size.block.to_px(),
self.start_corner.inline.to_px(),
self.start_corner.block.to_px(),
)
}
}
impl<T: Clone> LogicalVec2<T> {
pub fn to_physical(&self, mode: WritingMode) -> PhysicalSize<T> {
// https://drafts.csswg.org/css-writing-modes/#logical-to-physical
@ -525,17 +538,3 @@ impl From<LogicalRect<CSSPixelLength>> for LogicalRect<Au> {
}
}
}
/// Convert a `PhysicalRect<Length>` (one that uses CSSPixel as the unit) to an untyped `Rect<Au>`.
pub fn physical_rect_to_au_rect(rect: PhysicalRect<Length>) -> euclid::default::Rect<Au> {
euclid::default::Rect::new(
euclid::default::Point2D::new(
Au::from_f32_px(rect.origin.x.px()),
Au::from_f32_px(rect.origin.y.px()),
),
euclid::default::Size2D::new(
Au::from_f32_px(rect.size.width.px()),
Au::from_f32_px(rect.size.height.px()),
),
)
}