mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
layout: Refine the check for dependending on available space (#34907)
When laying out a block-level box that avoids floats, if we know that its size doesn't depend on the available space, we can take a fast path and only lay it out once. If its size depends on the available space, we may have to lay it out multiple times, which can be slower. This patch improves the check for this dependency on the available space. For example, `min-width: 200px; width: 100px; max-width: stretch` was previously considered to depend on the available space because of `max-width`. However, `max-width` is irrelevant when the min size is greater than the preferred size. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
51a1aeb535
commit
02c10fc502
2 changed files with 11 additions and 16 deletions
|
@ -899,18 +899,6 @@ impl Sizes {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn depends_on_available_space(&self) -> bool {
|
||||
// TODO: this logic could be refined further, since even if some of the 3 sizes
|
||||
// depends on the available space, the resulting size might not. For example,
|
||||
// `min-width: 200px; width: 100px; max-width: stretch`.
|
||||
matches!(
|
||||
self.preferred,
|
||||
Size::Initial | Size::Stretch | Size::FitContent
|
||||
) || matches!(self.min, Size::Stretch | Size::FitContent) ||
|
||||
matches!(self.max, Size::Stretch | Size::FitContent)
|
||||
}
|
||||
|
||||
/// Resolves the three sizes into a single numerical value.
|
||||
#[inline]
|
||||
pub(crate) fn resolve(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue