Temporarily convert more cfg(debug_assertions) crashes to warnings (#30590)

This commit is contained in:
Delan Azabani 2023-10-20 18:19:41 +08:00 committed by GitHub
parent aabae55407
commit e95de5d858
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 1 deletions

View file

@ -1760,7 +1760,10 @@ impl Flow for InlineFlow {
first_fragment.style.logical_border_width())
.start;
containing_block_positions.push(
padding_box_origin.to_physical(self.base.writing_mode, container_size),
// TODO(servo#30577) revert once underlying bug is fixed
// padding_box_origin.to_physical(self.base.writing_mode, container_size),
padding_box_origin
.to_physical_or_warn(self.base.writing_mode, container_size),
);
},
SpecificFragmentInfo::InlineBlock(_) if fragment.is_positioned() => {

View file

@ -771,6 +771,38 @@ impl<T: Copy + Sub<T, Output = T>> LogicalPoint<T> {
}
}
// TODO(servo#30577) remove this once underlying bugs are fixed
#[inline]
pub fn to_physical_or_warn(&self, mode: WritingMode, container_size: Size2D<T>) -> Point2D<T> {
#[cfg(debug_assertions)]
if !(self.debug_writing_mode.mode == mode) {
log::warn!("debug assertion failed! self.debug_writing_mode.mode == mode");
}
if mode.is_vertical() {
Point2D::new(
if mode.is_vertical_lr() {
self.b
} else {
container_size.width - self.b
},
if mode.is_inline_tb() {
self.i
} else {
container_size.height - self.i
},
)
} else {
Point2D::new(
if mode.is_bidi_ltr() {
self.i
} else {
container_size.width - self.i
},
self.b,
)
}
}
#[inline]
pub fn convert(
&self,