Remove BoxFragment::overconstrained (#33907)

This was only used for serializing inset properties in getComputedStyle,
but it was unnecessary and the logic was wrong anyways: an `auto` size
doesn't imply that we won't be overconstrained, because it won't become
negative even if the insets are big enough.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2024-10-19 03:55:55 +02:00 committed by GitHub
parent 09fc988d3a
commit 73880ee1d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 287 deletions

View file

@ -10,13 +10,13 @@ use style::computed_values::overflow_x::T as ComputedOverflow;
use style::computed_values::position::T as ComputedPosition;
use style::logical_geometry::WritingMode;
use style::properties::ComputedValues;
use style::values::computed::{LengthPercentage, LengthPercentageOrAuto};
use style::values::computed::LengthPercentageOrAuto;
use style::Zero;
use super::{BaseFragment, BaseFragmentInfo, CollapsedBlockMargins, Fragment};
use crate::cell::ArcRefCell;
use crate::formatting_contexts::Baselines;
use crate::geom::{AuOrAuto, PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize, ToLogical};
use crate::geom::{AuOrAuto, PhysicalPoint, PhysicalRect, PhysicalSides, ToLogical};
use crate::style_ext::ComputedValuesExt;
/// Describes how a [`BoxFragment`] paints its background.
@ -71,9 +71,6 @@ pub(crate) struct BoxFragment {
/// The scrollable overflow of this box fragment.
pub scrollable_overflow_from_children: PhysicalRect<Au>,
/// Whether or not this box was overconstrained in the given dimension.
overconstrained: PhysicalSize<bool>,
/// The resolved box insets if this box is `position: sticky`. These are calculated
/// during stacking context tree construction because they rely on the size of the
/// scroll container.
@ -95,33 +92,6 @@ impl BoxFragment {
margin: PhysicalSides<Au>,
clearance: Option<Au>,
block_margins_collapsed_with_children: CollapsedBlockMargins,
) -> BoxFragment {
Self::new_with_overconstrained(
base_fragment_info,
style,
children,
content_rect,
padding,
border,
margin,
clearance,
block_margins_collapsed_with_children,
PhysicalSize::default(),
)
}
#[allow(clippy::too_many_arguments)]
pub fn new_with_overconstrained(
base_fragment_info: BaseFragmentInfo,
style: ServoArc<ComputedValues>,
children: Vec<Fragment>,
content_rect: PhysicalRect<Au>,
padding: PhysicalSides<Au>,
border: PhysicalSides<Au>,
margin: PhysicalSides<Au>,
clearance: Option<Au>,
block_margins_collapsed_with_children: CollapsedBlockMargins,
overconstrained: PhysicalSize<bool>,
) -> BoxFragment {
let scrollable_overflow_from_children =
children.iter().fold(PhysicalRect::zero(), |acc, child| {
@ -140,7 +110,6 @@ impl BoxFragment {
baselines: Baselines::default(),
block_margins_collapsed_with_children,
scrollable_overflow_from_children,
overconstrained,
resolved_sticky_insets: None,
background_mode: BackgroundMode::Normal,
}
@ -335,27 +304,22 @@ impl BoxFragment {
);
let margin_rect = self.margin_rect();
let resolve = |value: &LengthPercentageOrAuto, container_length: Au| -> Au {
value
.auto_is(LengthPercentage::zero)
.to_used_value(container_length)
};
let (top, bottom) = if self.overconstrained.height {
let (top, bottom) = match (&insets.top, &insets.bottom) {
(
resolve(&insets.top, cb_height),
resolve(&insets.bottom, cb_height),
)
} else {
(margin_rect.origin.y, cb_height - margin_rect.max_y())
LengthPercentageOrAuto::LengthPercentage(top),
LengthPercentageOrAuto::LengthPercentage(bottom),
) => (
top.to_used_value(cb_height),
bottom.to_used_value(cb_height),
),
_ => (margin_rect.origin.y, cb_height - margin_rect.max_y()),
};
let (left, right) = if self.overconstrained.width {
let (left, right) = match (&insets.left, &insets.right) {
(
resolve(&insets.left, cb_width),
resolve(&insets.right, cb_width),
)
} else {
(margin_rect.origin.x, cb_width - margin_rect.max_x())
LengthPercentageOrAuto::LengthPercentage(left),
LengthPercentageOrAuto::LengthPercentage(right),
) => (left.to_used_value(cb_width), right.to_used_value(cb_width)),
_ => (margin_rect.origin.x, cb_width - margin_rect.max_x()),
};
convert_to_au_or_auto(PhysicalSides::new(top, right, bottom, left))

View file

@ -533,10 +533,6 @@ impl HoistedAbsolutelyPositionedBox {
alignment: block_alignment,
flip_anchor: false,
};
let overconstrained = LogicalVec2 {
inline: inline_axis_solver.is_overconstrained_for_size(computed_size.inline),
block: block_axis_solver.is_overconstrained_for_size(computed_size.block),
};
let mut inline_axis = inline_axis_solver.solve_for_size(computed_size.inline);
let mut block_axis = block_axis_solver.solve_for_size(computed_size.block);
@ -739,10 +735,7 @@ impl HoistedAbsolutelyPositionedBox {
block_axis_solver.solve_alignment(margin_box_rect, &mut content_rect);
inline_axis_solver.solve_alignment(margin_box_rect, &mut content_rect);
let physical_overconstrained =
overconstrained.to_physical_size(containing_block.style.writing_mode);
BoxFragment::new_with_overconstrained(
BoxFragment::new(
absolutely_positioned_box.context.base_fragment_info(),
style,
fragments,
@ -754,7 +747,6 @@ impl HoistedAbsolutelyPositionedBox {
// We do not set the baseline offset, because absolutely positioned
// elements are not inflow.
CollapsedBlockMargins::zero(),
physical_overconstrained,
)
};
positioning_context.layout_collected_children(layout_context, &mut new_fragment);
@ -804,10 +796,6 @@ struct AbsoluteBoxOffsets<'a> {
}
impl AbsoluteBoxOffsets<'_> {
pub(crate) fn both_specified(&self) -> bool {
!self.start.is_auto() && !self.end.is_auto()
}
pub(crate) fn either_specified(&self) -> bool {
!self.start.is_auto() || !self.end.is_auto()
}
@ -931,13 +919,6 @@ impl<'a> AbsoluteAxisSolver<'a> {
}
}
fn is_overconstrained_for_size(&self, computed_size: AuOrAuto) -> bool {
!computed_size.is_auto() &&
self.box_offsets.both_specified() &&
!self.computed_margin_start.is_auto() &&
!self.computed_margin_end.is_auto()
}
fn origin_for_alignment_or_justification(&self, margin_box_axis: RectAxis) -> Option<Au> {
let alignment_container = match (
self.box_offsets.start.non_auto(),

View file

@ -2,48 +2,21 @@
[vertical-lr ltr inside vertical-lr ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb rtl inside vertical-rl rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside vertical-lr rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside vertical-lr rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr rtl inside vertical-rl ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside horizontal-tb rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside horizontal-tb rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl rtl inside vertical-lr ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr rtl inside horizontal-tb rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl rtl inside vertical-rl ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside horizontal-tb rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb rtl inside vertical-rl ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside vertical-lr rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside vertical-rl ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb rtl inside vertical-lr rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl ltr inside vertical-rl ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
@ -53,36 +26,18 @@
[vertical-rl ltr inside horizontal-tb rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr ltr inside horizontal-tb ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside vertical-lr ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr ltr inside vertical-lr rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside vertical-rl rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl ltr inside vertical-rl rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl ltr inside vertical-lr rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside horizontal-tb rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside horizontal-tb rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb ltr inside horizontal-tb ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl ltr inside vertical-lr ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl ltr inside vertical-lr rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
@ -92,57 +47,27 @@
[horizontal-tb rtl inside vertical-lr ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside vertical-lr ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl ltr inside vertical-rl rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl ltr inside horizontal-tb ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb rtl inside vertical-lr rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb rtl inside horizontal-tb ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl rtl inside vertical-rl rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside vertical-rl ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside vertical-rl rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr ltr inside vertical-rl rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside horizontal-tb ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl rtl inside horizontal-tb ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside horizontal-tb rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb rtl inside vertical-rl ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside vertical-rl ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside horizontal-tb ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside vertical-rl ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl ltr inside vertical-rl ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside horizontal-tb rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
@ -152,65 +77,32 @@
[vertical-lr rtl inside vertical-lr ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb ltr inside vertical-lr ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside horizontal-tb ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr ltr inside vertical-lr ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr rtl inside vertical-rl rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside vertical-rl ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl ltr inside horizontal-tb rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside vertical-lr rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb ltr inside vertical-lr ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside horizontal-tb ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl ltr inside vertical-lr ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside vertical-rl rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb rtl inside horizontal-tb rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside horizontal-tb ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside vertical-lr rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb rtl inside vertical-lr ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside vertical-lr rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl rtl inside vertical-rl rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb ltr inside vertical-rl rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb rtl inside horizontal-tb ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb rtl inside horizontal-tb rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb ltr inside vertical-rl ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL

View file

@ -2,48 +2,21 @@
[vertical-lr ltr inside vertical-lr ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb rtl inside vertical-rl rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside vertical-lr rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside vertical-lr rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr rtl inside vertical-rl ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside horizontal-tb rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside horizontal-tb rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl rtl inside vertical-lr ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr rtl inside horizontal-tb rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl rtl inside vertical-rl ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside horizontal-tb rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb rtl inside vertical-rl ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside vertical-lr rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside vertical-rl ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb rtl inside vertical-lr rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl ltr inside vertical-rl ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
@ -53,36 +26,18 @@
[vertical-rl ltr inside horizontal-tb rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr ltr inside horizontal-tb ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside vertical-lr ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr ltr inside vertical-lr rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside vertical-rl rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl ltr inside vertical-rl rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl ltr inside vertical-lr rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside horizontal-tb rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside horizontal-tb rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb ltr inside horizontal-tb ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl ltr inside vertical-lr ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl ltr inside vertical-lr rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
@ -92,57 +47,27 @@
[horizontal-tb rtl inside vertical-lr ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside vertical-lr ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl ltr inside vertical-rl rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl ltr inside horizontal-tb ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb rtl inside vertical-lr rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb rtl inside horizontal-tb ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl rtl inside vertical-rl rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside vertical-rl ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside vertical-rl rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr ltr inside vertical-rl rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside horizontal-tb ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl rtl inside horizontal-tb ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside horizontal-tb rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb rtl inside vertical-rl ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside vertical-rl ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside horizontal-tb ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside vertical-rl ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl ltr inside vertical-rl ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside horizontal-tb rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
@ -152,65 +77,32 @@
[vertical-lr rtl inside vertical-lr ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb ltr inside vertical-lr ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside horizontal-tb ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr ltr inside vertical-lr ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr rtl inside vertical-rl rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside vertical-rl ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl ltr inside horizontal-tb rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-lr ltr inside vertical-lr rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb ltr inside vertical-lr ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside horizontal-tb ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl ltr inside vertical-lr ltr - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-lr rtl inside vertical-rl rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb rtl inside horizontal-tb rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside horizontal-tb ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb ltr inside vertical-lr rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb rtl inside vertical-lr ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[vertical-rl rtl inside vertical-lr rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[vertical-rl rtl inside vertical-rl rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb ltr inside vertical-rl rtl - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb rtl inside horizontal-tb ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL
[horizontal-tb rtl inside horizontal-tb rtl - If opposite sides are 'auto', they resolve to used value]
expected: FAIL
[horizontal-tb ltr inside vertical-rl ltr - Percentages absolutize the computed value when overconstrained]
expected: FAIL