mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Refactor computation of preferred aspect ratios (#34416)
* Refactor computation of preferred aspect ratios Computing min/max-content sizes required a ContainingBlock in order to resolve the padding and border when determining the preferred aspect ratio. However, all callers already knew the padding and border, so they can compute the ratio themselves, and pass it directly instead of the ContainingBlock. Signed-off-by: Oriol Brufau <obrufau@igalia.com> * Put preferred aspect ratio into ConstraintSpace Signed-off-by: Oriol Brufau <obrufau@igalia.com> --------- Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
16da1c2721
commit
19a7e95a6a
11 changed files with 133 additions and 113 deletions
|
@ -281,10 +281,6 @@ pub(crate) trait ComputedValuesExt {
|
|||
containing_block: &IndefiniteContainingBlock,
|
||||
) -> ContentBoxSizesAndPBM;
|
||||
fn padding_border_margin(&self, containing_block: &ContainingBlock) -> PaddingBorderMargin;
|
||||
fn padding_border_margin_for_intrinsic_size(
|
||||
&self,
|
||||
writing_mode: WritingMode,
|
||||
) -> PaddingBorderMargin;
|
||||
fn padding_border_margin_with_writing_mode_and_containing_block_inline_size(
|
||||
&self,
|
||||
writing_mode: WritingMode,
|
||||
|
@ -319,7 +315,7 @@ pub(crate) trait ComputedValuesExt {
|
|||
fn preferred_aspect_ratio(
|
||||
&self,
|
||||
natural_aspect_ratio: Option<CSSFloat>,
|
||||
containing_block: &IndefiniteContainingBlock,
|
||||
padding_border_sums: &LogicalVec2<Au>,
|
||||
) -> Option<AspectRatio>;
|
||||
fn background_is_transparent(&self) -> bool;
|
||||
fn get_webrender_primitive_flags(&self) -> wr::PrimitiveFlags;
|
||||
|
@ -579,16 +575,6 @@ impl ComputedValuesExt for ComputedValues {
|
|||
)
|
||||
}
|
||||
|
||||
fn padding_border_margin_for_intrinsic_size(
|
||||
&self,
|
||||
writing_mode: WritingMode,
|
||||
) -> PaddingBorderMargin {
|
||||
self.padding_border_margin_with_writing_mode_and_containing_block_inline_size(
|
||||
writing_mode,
|
||||
Au::zero(),
|
||||
)
|
||||
}
|
||||
|
||||
fn padding_border_margin_with_writing_mode_and_containing_block_inline_size(
|
||||
&self,
|
||||
writing_mode: WritingMode,
|
||||
|
@ -878,7 +864,7 @@ impl ComputedValuesExt for ComputedValues {
|
|||
fn preferred_aspect_ratio(
|
||||
&self,
|
||||
natural_aspect_ratio: Option<CSSFloat>,
|
||||
containing_block: &IndefiniteContainingBlock,
|
||||
padding_border_sums: &LogicalVec2<Au>,
|
||||
) -> Option<AspectRatio> {
|
||||
let GenericAspectRatio {
|
||||
auto,
|
||||
|
@ -921,15 +907,7 @@ impl ComputedValuesExt for ComputedValues {
|
|||
// border when calculating the aspect ratio.
|
||||
let box_sizing_adjustment = match self.clone_box_sizing() {
|
||||
BoxSizing::ContentBox => LogicalVec2::zero(),
|
||||
BoxSizing::BorderBox => containing_block.size.inline.non_auto().map_or_else(
|
||||
|| self.padding_border_margin_for_intrinsic_size(containing_block.writing_mode),
|
||||
|containing_block_inline_size| self
|
||||
.padding_border_margin_with_writing_mode_and_containing_block_inline_size(
|
||||
containing_block.writing_mode,
|
||||
containing_block_inline_size,
|
||||
)
|
||||
)
|
||||
.padding_border_sums,
|
||||
BoxSizing::BorderBox => *padding_border_sums,
|
||||
};
|
||||
Some(AspectRatio {
|
||||
i_over_b: (preferred_ratio.0).0 / (preferred_ratio.1).0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue