mirror of
https://github.com/servo/servo.git
synced 2025-08-10 07:55:33 +01:00
Layout 2020: Rename flow_relative
types to Logical...
(#30324)
This makes the names of flow relative geometry consistent with what is used in the style crate and removes them from a module. With this change it's more obvious what makes these types different from the ones in `euclid`.
This commit is contained in:
parent
90ad5920e2
commit
8299868bd5
15 changed files with 314 additions and 317 deletions
|
@ -24,7 +24,7 @@ use crate::dom::NodeExt;
|
|||
use crate::dom_traversal::{Contents, NodeAndStyleInfo};
|
||||
use crate::formatting_contexts::IndependentFormattingContext;
|
||||
use crate::fragment_tree::{BoxFragment, CollapsedBlockMargins, CollapsedMargin, FloatFragment};
|
||||
use crate::geom::flow_relative::{Rect, Vec2};
|
||||
use crate::geom::{LogicalRect, LogicalVec2};
|
||||
use crate::positioned::PositioningContext;
|
||||
use crate::style_ext::{ComputedValuesExt, DisplayInside, PaddingBorderMargin};
|
||||
use crate::ContainingBlock;
|
||||
|
@ -84,7 +84,7 @@ pub(crate) struct PlacementAmongFloats<'a> {
|
|||
/// The next band, needed to know the height of the last band in current_bands.
|
||||
next_band: FloatBand,
|
||||
/// The size of the object to place.
|
||||
object_size: Vec2<Length>,
|
||||
object_size: LogicalVec2<Length>,
|
||||
/// The minimum position in the block direction for the placement. Objects should not
|
||||
/// be placed before this point.
|
||||
ceiling: Length,
|
||||
|
@ -99,7 +99,7 @@ impl<'a> PlacementAmongFloats<'a> {
|
|||
pub(crate) fn new(
|
||||
float_context: &'a FloatContext,
|
||||
ceiling: Length,
|
||||
object_size: Vec2<Length>,
|
||||
object_size: LogicalVec2<Length>,
|
||||
pbm: &PaddingBorderMargin,
|
||||
) -> Self {
|
||||
assert!(!ceiling.px().is_infinite());
|
||||
|
@ -182,7 +182,7 @@ impl<'a> PlacementAmongFloats<'a> {
|
|||
inline_end - inline_start
|
||||
}
|
||||
|
||||
fn try_place_once(&mut self) -> Option<Rect<Length>> {
|
||||
fn try_place_once(&mut self) -> Option<LogicalRect<Length>> {
|
||||
assert!(!self.current_bands.is_empty());
|
||||
self.accumulate_enough_bands_for_block_size();
|
||||
let (inline_start, inline_end) = self.calculate_inline_start_and_end();
|
||||
|
@ -191,12 +191,12 @@ impl<'a> PlacementAmongFloats<'a> {
|
|||
return None;
|
||||
}
|
||||
let top = self.top_of_bands().unwrap();
|
||||
Some(Rect {
|
||||
start_corner: Vec2 {
|
||||
Some(LogicalRect {
|
||||
start_corner: LogicalVec2 {
|
||||
inline: inline_start,
|
||||
block: top,
|
||||
},
|
||||
size: Vec2 {
|
||||
size: LogicalVec2 {
|
||||
inline: available_inline_size,
|
||||
block: self.next_band.top - top,
|
||||
},
|
||||
|
@ -217,7 +217,7 @@ impl<'a> PlacementAmongFloats<'a> {
|
|||
}
|
||||
|
||||
/// Run the placement algorithm for this [PlacementAmongFloats].
|
||||
pub(crate) fn place(&mut self) -> Rect<Length> {
|
||||
pub(crate) fn place(&mut self) -> LogicalRect<Length> {
|
||||
debug_assert!(self.has_bands_or_at_end());
|
||||
while !self.current_bands.is_empty() {
|
||||
if let Some(result) = self.try_place_once() {
|
||||
|
@ -229,15 +229,15 @@ impl<'a> PlacementAmongFloats<'a> {
|
|||
|
||||
// We could not fit the object in among the floats, so we place it as if it
|
||||
// cleared all floats.
|
||||
Rect {
|
||||
start_corner: Vec2 {
|
||||
LogicalRect {
|
||||
start_corner: LogicalVec2 {
|
||||
inline: self.min_inline_start,
|
||||
block: self
|
||||
.ceiling
|
||||
.max(self.float_context.clear_left_position)
|
||||
.max(self.float_context.clear_right_position),
|
||||
},
|
||||
size: Vec2 {
|
||||
size: LogicalVec2 {
|
||||
inline: self.max_inline_end - self.min_inline_start,
|
||||
block: Length::new(f32::INFINITY),
|
||||
},
|
||||
|
@ -253,7 +253,7 @@ impl<'a> PlacementAmongFloats<'a> {
|
|||
pub(crate) fn try_to_expand_for_auto_block_size(
|
||||
&mut self,
|
||||
block_size_after_layout: Length,
|
||||
size_from_placement: &Vec2<Length>,
|
||||
size_from_placement: &LogicalVec2<Length>,
|
||||
) -> bool {
|
||||
debug_assert!(self.has_bands_or_at_end());
|
||||
debug_assert_eq!(size_from_placement.block, self.current_bands_height());
|
||||
|
@ -359,7 +359,11 @@ impl FloatContext {
|
|||
///
|
||||
/// This should be used for placing inline elements and block formatting contexts so that they
|
||||
/// don't collide with floats.
|
||||
pub(crate) fn place_object(&self, object: &PlacementInfo, ceiling: Length) -> Vec2<Length> {
|
||||
pub(crate) fn place_object(
|
||||
&self,
|
||||
object: &PlacementInfo,
|
||||
ceiling: Length,
|
||||
) -> LogicalVec2<Length> {
|
||||
let ceiling = match object.clear {
|
||||
Clear::None => ceiling,
|
||||
Clear::Left => ceiling.max(self.clear_left_position),
|
||||
|
@ -386,7 +390,7 @@ impl FloatContext {
|
|||
Some(band_left) => band_left.max(self.containing_block_info.inline_start),
|
||||
None => self.containing_block_info.inline_start,
|
||||
};
|
||||
Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: left_object_edge,
|
||||
block: first_band.top.max(ceiling),
|
||||
}
|
||||
|
@ -396,7 +400,7 @@ impl FloatContext {
|
|||
Some(band_right) => band_right.min(self.containing_block_info.inline_end),
|
||||
None => self.containing_block_info.inline_end,
|
||||
};
|
||||
Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: right_object_edge - object.size.inline,
|
||||
block: first_band.top.max(ceiling),
|
||||
}
|
||||
|
@ -405,7 +409,7 @@ impl FloatContext {
|
|||
}
|
||||
|
||||
/// Places a new float and adds it to the list. Returns the start corner of its margin box.
|
||||
pub fn add_float(&mut self, new_float: &PlacementInfo) -> Vec2<Length> {
|
||||
pub fn add_float(&mut self, new_float: &PlacementInfo) -> LogicalVec2<Length> {
|
||||
// Place the float.
|
||||
let new_float_origin = self.place_object(&new_float, self.ceiling);
|
||||
let new_float_extent = match new_float.side {
|
||||
|
@ -413,13 +417,13 @@ impl FloatContext {
|
|||
FloatSide::Right => new_float_origin.inline,
|
||||
};
|
||||
|
||||
let new_float_rect = Rect {
|
||||
let new_float_rect = LogicalRect {
|
||||
start_corner: new_float_origin,
|
||||
// If this float has a negative margin, we should only consider its non-negative
|
||||
// block size contribution when determing where to place it. When the margin is
|
||||
// so negative that it's placed completely above the current float ceiling, then
|
||||
// we should position it as if it had zero block size.
|
||||
size: Vec2 {
|
||||
size: LogicalVec2 {
|
||||
inline: new_float.size.inline.max(CSSPixelLength::zero()),
|
||||
block: new_float.size.block.max(CSSPixelLength::zero()),
|
||||
},
|
||||
|
@ -469,7 +473,7 @@ impl FloatContext {
|
|||
#[derive(Clone, Debug)]
|
||||
pub struct PlacementInfo {
|
||||
/// The *margin* box size of the object.
|
||||
pub size: Vec2<Length>,
|
||||
pub size: LogicalVec2<Length>,
|
||||
/// Whether the object is (logically) aligned to the left or right.
|
||||
pub side: FloatSide,
|
||||
/// Which side or sides to clear floats on.
|
||||
|
@ -909,7 +913,7 @@ impl FloatBox {
|
|||
&mut positioning_context,
|
||||
&containing_block_for_children,
|
||||
);
|
||||
content_size = Vec2 {
|
||||
content_size = LogicalVec2 {
|
||||
inline: inline_size,
|
||||
block: box_size
|
||||
.block
|
||||
|
@ -932,8 +936,8 @@ impl FloatBox {
|
|||
},
|
||||
};
|
||||
|
||||
let content_rect = Rect {
|
||||
start_corner: Vec2::zero(),
|
||||
let content_rect = LogicalRect {
|
||||
start_corner: LogicalVec2::zero(),
|
||||
size: content_size,
|
||||
};
|
||||
|
||||
|
@ -1103,14 +1107,14 @@ impl SequentialLayoutState {
|
|||
/// It returns a tuple with:
|
||||
/// - The clearance amount (if any), which includes both the effect of 'clear'
|
||||
/// and the extra space to avoid floats.
|
||||
/// - The Rect in which the block can be placed without overlapping floats.
|
||||
/// - The LogicalRect in which the block can be placed without overlapping floats.
|
||||
pub(crate) fn calculate_clearance_and_inline_adjustment(
|
||||
&self,
|
||||
clear: Clear,
|
||||
block_start_margin: &CollapsedMargin,
|
||||
pbm: &PaddingBorderMargin,
|
||||
object_size: Vec2<Length>,
|
||||
) -> (Option<Length>, Rect<Length>) {
|
||||
object_size: LogicalVec2<Length>,
|
||||
) -> (Option<Length>, LogicalRect<Length>) {
|
||||
// First compute the clear position required by the 'clear' property.
|
||||
// The code below may then add extra clearance when the element can't fit
|
||||
// next to floats not covered by 'clear'.
|
||||
|
@ -1174,7 +1178,7 @@ impl SequentialLayoutState {
|
|||
&box_fragment.content_rect.start_corner;
|
||||
|
||||
// This is the position of the float relative to the containing block start.
|
||||
let new_position_in_containing_block = Vec2 {
|
||||
let new_position_in_containing_block = LogicalVec2 {
|
||||
inline: new_position_in_bfc.inline - self.floats.containing_block_info.inline_start,
|
||||
block: new_position_in_bfc.block - block_start_of_containing_block_in_bfc,
|
||||
};
|
||||
|
|
|
@ -31,8 +31,7 @@ use crate::fragment_tree::{
|
|||
AnonymousFragment, BaseFragmentInfo, BoxFragment, CollapsedBlockMargins, CollapsedMargin,
|
||||
FontMetrics, Fragment, HoistedSharedFragment, TextFragment,
|
||||
};
|
||||
use crate::geom::flow_relative::{Rect, Vec2};
|
||||
use crate::geom::LengthOrAuto;
|
||||
use crate::geom::{LengthOrAuto, LogicalRect, LogicalVec2};
|
||||
use crate::positioned::{
|
||||
relative_adjustement, AbsolutelyPositionedBox, PositioningContext, PositioningContextLength,
|
||||
};
|
||||
|
@ -98,7 +97,7 @@ pub(crate) struct TextRun {
|
|||
struct LineUnderConstruction {
|
||||
/// The position where this line will start once it is laid out. This includes any
|
||||
/// offset from `text-indent`.
|
||||
start_position: Vec2<Length>,
|
||||
start_position: LogicalVec2<Length>,
|
||||
|
||||
/// The current inline position in the line being laid out into [`LineItems`] in this
|
||||
/// [`InlineFormattingContext`] independent of the depth in the nesting level.
|
||||
|
@ -128,11 +127,11 @@ struct LineUnderConstruction {
|
|||
/// context boundaries) where we can fit the line box without overlapping floats.
|
||||
/// Note that when this is not empty, its start corner takes precedence over
|
||||
/// [`LineUnderConstruction::start_position`].
|
||||
placement_among_floats: OnceCell<Rect<Length>>,
|
||||
placement_among_floats: OnceCell<LogicalRect<Length>>,
|
||||
}
|
||||
|
||||
impl LineUnderConstruction {
|
||||
fn new(start_position: Vec2<Length>) -> Self {
|
||||
fn new(start_position: LogicalVec2<Length>) -> Self {
|
||||
Self {
|
||||
inline_position: start_position.inline.clone(),
|
||||
trailing_whitespace_advance: Length::zero(),
|
||||
|
@ -151,7 +150,7 @@ impl LineUnderConstruction {
|
|||
}
|
||||
}
|
||||
|
||||
fn replace_placement_among_floats(&mut self, new_placement: Rect<Length>) {
|
||||
fn replace_placement_among_floats(&mut self, new_placement: LogicalRect<Length>) {
|
||||
self.placement_among_floats.take();
|
||||
let _ = self.placement_among_floats.set(new_placement);
|
||||
}
|
||||
|
@ -380,7 +379,7 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
|||
let positioning_context_length = state.positioning_context.len();
|
||||
let fragments = layout_line_items(line_items, layout_context, &mut state);
|
||||
|
||||
let size = Vec2 {
|
||||
let size = LogicalVec2 {
|
||||
inline: self.containing_block.inline_size,
|
||||
block: state.max_block_size,
|
||||
};
|
||||
|
@ -388,7 +387,7 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
|||
// The inline part of this start offset was taken into account when determining
|
||||
// the inline start of the line in `calculate_inline_start_for_current_line` so
|
||||
// we do not need to include it in the `start_corner` of the line's main Fragment.
|
||||
let start_corner = Vec2 {
|
||||
let start_corner = LogicalVec2 {
|
||||
inline: Length::zero(),
|
||||
block: block_start_position,
|
||||
};
|
||||
|
@ -405,13 +404,13 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
|||
|
||||
self.fragments
|
||||
.push(Fragment::Anonymous(AnonymousFragment::new(
|
||||
Rect { start_corner, size },
|
||||
LogicalRect { start_corner, size },
|
||||
fragments,
|
||||
self.containing_block.style.writing_mode,
|
||||
)));
|
||||
}
|
||||
|
||||
self.current_line = LineUnderConstruction::new(Vec2 {
|
||||
self.current_line = LineUnderConstruction::new(LogicalVec2 {
|
||||
inline: Length::zero(),
|
||||
block: block_end_position,
|
||||
});
|
||||
|
@ -508,13 +507,16 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
|||
/// This tells us whether or not the new potential line will fit in the current block position
|
||||
/// or need to be moved. In addition, the placement rect determines the inline start and end
|
||||
/// of the line if it's used as the final placement among floats.
|
||||
fn place_line_among_floats(&self, potential_line_size: &Vec2<Length>) -> Rect<Length> {
|
||||
fn place_line_among_floats(
|
||||
&self,
|
||||
potential_line_size: &LogicalVec2<Length>,
|
||||
) -> LogicalRect<Length> {
|
||||
let sequential_layout_state = self
|
||||
.sequential_layout_state
|
||||
.as_ref()
|
||||
.expect("Should not have called this function without having floats.");
|
||||
|
||||
let ifc_offset_in_float_container = Vec2 {
|
||||
let ifc_offset_in_float_container = LogicalVec2 {
|
||||
inline: sequential_layout_state
|
||||
.floats
|
||||
.containing_block_info
|
||||
|
@ -545,7 +547,7 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
|||
/// line or the next.
|
||||
fn new_potential_line_size_causes_line_break(
|
||||
&mut self,
|
||||
potential_line_size: &Vec2<Length>,
|
||||
potential_line_size: &LogicalVec2<Length>,
|
||||
) -> bool {
|
||||
let available_line_space = if self.sequential_layout_state.is_some() {
|
||||
self.current_line
|
||||
|
@ -554,7 +556,7 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
|||
.size
|
||||
.clone()
|
||||
} else {
|
||||
Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: self.containing_block.inline_size,
|
||||
block: Length::new(f32::INFINITY),
|
||||
}
|
||||
|
@ -794,7 +796,7 @@ impl InlineFormattingContext {
|
|||
containing_block,
|
||||
sequential_layout_state,
|
||||
fragments: Vec::new(),
|
||||
current_line: LineUnderConstruction::new(Vec2 {
|
||||
current_line: LineUnderConstruction::new(LogicalVec2 {
|
||||
inline: first_line_inline_start,
|
||||
block: Length::zero(),
|
||||
}),
|
||||
|
@ -998,7 +1000,7 @@ impl IndependentFormattingContext {
|
|||
let fragments = replaced
|
||||
.contents
|
||||
.make_fragments(&replaced.style, size.clone());
|
||||
let content_rect = Rect {
|
||||
let content_rect = LogicalRect {
|
||||
start_corner: pbm_sums.start_offset(),
|
||||
size,
|
||||
};
|
||||
|
@ -1074,9 +1076,9 @@ impl IndependentFormattingContext {
|
|||
let block_size = tentative_block_size
|
||||
.clamp_between_extremums(min_box_size.block, max_box_size.block);
|
||||
|
||||
let content_rect = Rect {
|
||||
let content_rect = LogicalRect {
|
||||
start_corner: pbm_sums.start_offset(),
|
||||
size: Vec2 {
|
||||
size: LogicalVec2 {
|
||||
block: block_size,
|
||||
inline: inline_size,
|
||||
},
|
||||
|
@ -1097,7 +1099,7 @@ impl IndependentFormattingContext {
|
|||
};
|
||||
|
||||
let size = &pbm_sums.sum() + &fragment.content_rect.size;
|
||||
let new_potential_line_size = Vec2 {
|
||||
let new_potential_line_size = LogicalVec2 {
|
||||
inline: ifc.current_line.inline_position + size.inline,
|
||||
block: ifc.current_line.block_size.max(size.block),
|
||||
};
|
||||
|
@ -1279,7 +1281,7 @@ impl TextRun {
|
|||
advance_from_text_run +
|
||||
ifc.current_line.inline_position;
|
||||
|
||||
let new_potential_line_size = Vec2 {
|
||||
let new_potential_line_size = LogicalVec2 {
|
||||
inline: new_total_advance,
|
||||
block: new_max_height_of_line,
|
||||
};
|
||||
|
@ -1373,7 +1375,7 @@ impl FloatBox {
|
|||
// position of the current line. In order to determine that we regenerate the
|
||||
// placement among floats for the current line, which may adjust its inline
|
||||
// start position.
|
||||
let new_placement = ifc.place_line_among_floats(&Vec2 {
|
||||
let new_placement = ifc.place_line_among_floats(&LogicalVec2 {
|
||||
inline: ifc.current_line.inline_position,
|
||||
block: ifc.current_line.block_size,
|
||||
});
|
||||
|
@ -1611,12 +1613,12 @@ impl TextRunLineItem {
|
|||
.iter()
|
||||
.map(|glyph_store| Length::from(glyph_store.total_advance()))
|
||||
.sum();
|
||||
let rect = Rect {
|
||||
start_corner: Vec2 {
|
||||
let rect = LogicalRect {
|
||||
start_corner: LogicalVec2 {
|
||||
block: Length::zero(),
|
||||
inline: state.inline_position - state.inline_start_of_parent,
|
||||
},
|
||||
size: Vec2 {
|
||||
size: LogicalVec2 {
|
||||
block: self.line_height(),
|
||||
inline: inline_advance,
|
||||
},
|
||||
|
@ -1688,12 +1690,12 @@ impl InlineBoxLineItem {
|
|||
return None;
|
||||
}
|
||||
|
||||
let mut content_rect = Rect {
|
||||
start_corner: Vec2 {
|
||||
let mut content_rect = LogicalRect {
|
||||
start_corner: LogicalVec2 {
|
||||
inline: state.inline_position - state.inline_start_of_parent,
|
||||
block: Length::zero(),
|
||||
},
|
||||
size: Vec2 {
|
||||
size: LogicalVec2 {
|
||||
inline: nested_state.inline_position - state.inline_position,
|
||||
block: nested_state.max_block_size,
|
||||
},
|
||||
|
@ -1743,7 +1745,7 @@ impl InlineBoxLineItem {
|
|||
|
||||
struct AtomicLineItem {
|
||||
fragment: BoxFragment,
|
||||
size: Vec2<Length>,
|
||||
size: LogicalVec2<Length>,
|
||||
positioning_context: Option<PositioningContext>,
|
||||
}
|
||||
|
||||
|
@ -1786,7 +1788,7 @@ impl AbsolutelyPositionedLineItem {
|
|||
let style = AtomicRef::map(box_.borrow(), |box_| box_.context.style());
|
||||
let initial_start_corner = match Display::from(style.get_box().original_display) {
|
||||
Display::GeneratingBox(DisplayGeneratingBox::OutsideInside { outside, inside: _ }) => {
|
||||
Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: match outside {
|
||||
DisplayOutside::Inline => {
|
||||
state.inline_position - state.inline_start_of_parent
|
||||
|
@ -1829,7 +1831,7 @@ impl FloatLineItem {
|
|||
// fragments are children of these InlineBoxes and not children of the inline
|
||||
// formatting context, so that they are parented properly for StackingContext
|
||||
// properties such as opacity & filters.
|
||||
let distance_from_parent_to_ifc = Vec2 {
|
||||
let distance_from_parent_to_ifc = LogicalVec2 {
|
||||
inline: state.inline_start_of_parent,
|
||||
block: state.line_block_start,
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@ use crate::formatting_contexts::{
|
|||
use crate::fragment_tree::{
|
||||
BaseFragmentInfo, BoxFragment, CollapsedBlockMargins, CollapsedMargin, Fragment,
|
||||
};
|
||||
use crate::geom::flow_relative::{Rect, Sides, Vec2};
|
||||
use crate::geom::{LogicalRect, LogicalSides, LogicalVec2};
|
||||
use crate::positioned::{AbsolutelyPositionedBox, PositioningContext, PositioningContextLength};
|
||||
use crate::replaced::ReplacedContent;
|
||||
use crate::sizing::{self, ContentSizes};
|
||||
|
@ -587,7 +587,7 @@ impl BlockLevelBox {
|
|||
// This is incorrect, however we do not know the
|
||||
// correct positioning until later, in place_block_level_fragment,
|
||||
// and this value will be adjusted there
|
||||
Vec2::zero(),
|
||||
LogicalVec2::zero(),
|
||||
containing_block,
|
||||
);
|
||||
let hoisted_fragment = hoisted_box.fragment.clone();
|
||||
|
@ -771,14 +771,14 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
|||
sequential_layout_state.adjoin_assign(&CollapsedMargin::new(margin.block_end));
|
||||
}
|
||||
|
||||
let content_rect = Rect {
|
||||
start_corner: Vec2 {
|
||||
let content_rect = LogicalRect {
|
||||
start_corner: LogicalVec2 {
|
||||
block: pbm.padding.block_start +
|
||||
pbm.border.block_start +
|
||||
clearance.unwrap_or_else(Length::zero),
|
||||
inline: pbm.padding.inline_start + pbm.border.inline_start + margin.inline_start,
|
||||
},
|
||||
size: Vec2 {
|
||||
size: LogicalVec2 {
|
||||
block: block_size,
|
||||
inline: containing_block_for_children.inline_size,
|
||||
},
|
||||
|
@ -842,12 +842,12 @@ impl NonReplacedFormattingContext {
|
|||
.clamp_between_extremums(min_box_size.block, max_box_size.block)
|
||||
});
|
||||
|
||||
let content_rect = Rect {
|
||||
start_corner: Vec2 {
|
||||
let content_rect = LogicalRect {
|
||||
start_corner: LogicalVec2 {
|
||||
block: pbm.padding.block_start + pbm.border.block_start,
|
||||
inline: pbm.padding.inline_start + pbm.border.inline_start + margin.inline_start,
|
||||
},
|
||||
size: Vec2 {
|
||||
size: LogicalVec2 {
|
||||
block: block_size,
|
||||
inline: containing_block_for_children.inline_size,
|
||||
},
|
||||
|
@ -919,7 +919,7 @@ impl NonReplacedFormattingContext {
|
|||
style: &self.style,
|
||||
},
|
||||
);
|
||||
content_size = Vec2 {
|
||||
content_size = LogicalVec2 {
|
||||
inline: inline_size,
|
||||
block: block_size.auto_is(|| {
|
||||
layout
|
||||
|
@ -950,7 +950,7 @@ impl NonReplacedFormattingContext {
|
|||
});
|
||||
|
||||
// Create a PlacementAmongFloats using the minimum size in all dimensions as the object size.
|
||||
let minimum_size_of_block = &Vec2 {
|
||||
let minimum_size_of_block = &LogicalVec2 {
|
||||
inline: min_box_size.inline,
|
||||
block: block_size.auto_is(|| min_box_size.block),
|
||||
} + &pbm.padding_border_sums;
|
||||
|
@ -983,7 +983,7 @@ impl NonReplacedFormattingContext {
|
|||
},
|
||||
);
|
||||
|
||||
content_size = Vec2 {
|
||||
content_size = LogicalVec2 {
|
||||
inline: proposed_inline_size,
|
||||
block: block_size.auto_is(|| {
|
||||
layout
|
||||
|
@ -1030,7 +1030,7 @@ impl NonReplacedFormattingContext {
|
|||
);
|
||||
}
|
||||
|
||||
let margin = Sides {
|
||||
let margin = LogicalSides {
|
||||
inline_start: margin_inline_start,
|
||||
inline_end: margin_inline_end,
|
||||
block_start: margin_block_start,
|
||||
|
@ -1053,8 +1053,8 @@ impl NonReplacedFormattingContext {
|
|||
);
|
||||
sequential_layout_state.adjoin_assign(&CollapsedMargin::new(margin.block_end));
|
||||
|
||||
let content_rect = Rect {
|
||||
start_corner: Vec2 {
|
||||
let content_rect = LogicalRect {
|
||||
start_corner: LogicalVec2 {
|
||||
block: pbm.padding.block_start +
|
||||
pbm.border.block_start +
|
||||
clearance.unwrap_or_else(Length::zero),
|
||||
|
@ -1140,21 +1140,21 @@ fn layout_in_flow_replaced_block_level<'a>(
|
|||
);
|
||||
};
|
||||
|
||||
let margin = Sides {
|
||||
let margin = LogicalSides {
|
||||
inline_start: margin_inline_start,
|
||||
inline_end: margin_inline_end,
|
||||
block_start: margin_block_start,
|
||||
block_end: margin_block_end,
|
||||
};
|
||||
|
||||
let start_corner = Vec2 {
|
||||
let start_corner = LogicalVec2 {
|
||||
block: pbm.padding.block_start +
|
||||
pbm.border.block_start +
|
||||
clearance.unwrap_or_else(Length::zero),
|
||||
inline: pbm.padding.inline_start + pbm.border.inline_start + margin.inline_start,
|
||||
};
|
||||
|
||||
let content_rect = Rect {
|
||||
let content_rect = LogicalRect {
|
||||
start_corner,
|
||||
size: content_size,
|
||||
};
|
||||
|
@ -1175,9 +1175,9 @@ fn layout_in_flow_replaced_block_level<'a>(
|
|||
struct ContainingBlockPaddingBorderAndMargin<'a> {
|
||||
containing_block: ContainingBlock<'a>,
|
||||
pbm: PaddingBorderMargin,
|
||||
min_box_size: Vec2<Length>,
|
||||
max_box_size: Vec2<Option<Length>>,
|
||||
margin: Sides<Length>,
|
||||
min_box_size: LogicalVec2<Length>,
|
||||
max_box_size: LogicalVec2<Option<Length>>,
|
||||
margin: LogicalSides<Length>,
|
||||
}
|
||||
|
||||
/// Given the style for in in flow box and its containing block, determine the containing
|
||||
|
@ -1213,7 +1213,7 @@ fn solve_containing_block_padding_border_and_margin_for_in_flow_box<'a>(
|
|||
let inline_margins =
|
||||
solve_inline_margins_for_in_flow_block_level(containing_block, &pbm, inline_size);
|
||||
let block_margins = solve_block_margins_for_in_flow_block_level(&pbm);
|
||||
let margin = Sides {
|
||||
let margin = LogicalSides {
|
||||
inline_start: inline_margins.0,
|
||||
inline_end: inline_margins.1,
|
||||
block_start: block_margins.0,
|
||||
|
@ -1256,7 +1256,7 @@ fn solve_clearance_and_inline_margins_avoiding_floats(
|
|||
containing_block: &ContainingBlock,
|
||||
block_start_margin: &CollapsedMargin,
|
||||
pbm: &PaddingBorderMargin,
|
||||
size: Vec2<Length>,
|
||||
size: LogicalVec2<Length>,
|
||||
style: &Arc<ComputedValues>,
|
||||
) -> (Option<Length>, (Length, Length)) {
|
||||
let (clearance, placement_rect) = sequential_layout_state
|
||||
|
@ -1284,7 +1284,7 @@ fn solve_inline_margins_avoiding_floats(
|
|||
containing_block: &ContainingBlock,
|
||||
pbm: &PaddingBorderMargin,
|
||||
inline_size: Length,
|
||||
placement_rect: Rect<Length>,
|
||||
placement_rect: LogicalRect<Length>,
|
||||
) -> (Length, Length) {
|
||||
let inline_adjustment = placement_rect.start_corner.inline -
|
||||
sequential_layout_state
|
||||
|
@ -1424,7 +1424,7 @@ impl PlacementState {
|
|||
}
|
||||
},
|
||||
Fragment::AbsoluteOrFixedPositioned(fragment) => {
|
||||
let offset = Vec2 {
|
||||
let offset = LogicalVec2 {
|
||||
block: self.current_margin.solve() + self.current_block_direction_position,
|
||||
inline: Length::new(0.),
|
||||
};
|
||||
|
|
|
@ -22,8 +22,7 @@ use crate::flow::inline::InlineLevelBox;
|
|||
use crate::flow::{BlockContainer, BlockFormattingContext, BlockLevelBox};
|
||||
use crate::formatting_contexts::IndependentFormattingContext;
|
||||
use crate::fragment_tree::FragmentTree;
|
||||
use crate::geom::flow_relative::Vec2;
|
||||
use crate::geom::{PhysicalPoint, PhysicalRect, PhysicalSize};
|
||||
use crate::geom::{LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSize};
|
||||
use crate::positioned::{AbsolutelyPositionedBox, PositioningContext};
|
||||
use crate::replaced::ReplacedContent;
|
||||
use crate::style_ext::{ComputedValuesExt, Display, DisplayGeneratingBox, DisplayInside};
|
||||
|
@ -274,7 +273,7 @@ impl BoxTree {
|
|||
PhysicalSize::new(Length::new(viewport.width), Length::new(viewport.height)),
|
||||
);
|
||||
let initial_containing_block = DefiniteContainingBlock {
|
||||
size: Vec2 {
|
||||
size: LogicalVec2 {
|
||||
inline: physical_containing_block.size.width,
|
||||
block: physical_containing_block.size.height,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue