mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00: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
|
@ -6,7 +6,7 @@
|
|||
|
||||
use style::properties::longhands::flex_direction::computed_value::T as FlexDirection;
|
||||
|
||||
use crate::geom::flow_relative::{Rect, Sides, Vec2};
|
||||
use crate::geom::{LogicalRect, LogicalSides, LogicalVec2};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub(super) struct FlexRelativeVec2<T> {
|
||||
|
@ -98,8 +98,8 @@ impl FlexAxis {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn vec2_to_flex_relative<T>(self, flow_relative: Vec2<T>) -> FlexRelativeVec2<T> {
|
||||
let Vec2 { inline, block } = flow_relative;
|
||||
pub fn vec2_to_flex_relative<T>(self, flow_relative: LogicalVec2<T>) -> FlexRelativeVec2<T> {
|
||||
let LogicalVec2 { inline, block } = flow_relative;
|
||||
match self {
|
||||
FlexAxis::Row => FlexRelativeVec2 {
|
||||
main: inline,
|
||||
|
@ -112,14 +112,14 @@ impl FlexAxis {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn vec2_to_flow_relative<T>(self, flex_relative: FlexRelativeVec2<T>) -> Vec2<T> {
|
||||
pub fn vec2_to_flow_relative<T>(self, flex_relative: FlexRelativeVec2<T>) -> LogicalVec2<T> {
|
||||
let FlexRelativeVec2 { main, cross } = flex_relative;
|
||||
match self {
|
||||
FlexAxis::Row => Vec2 {
|
||||
FlexAxis::Row => LogicalVec2 {
|
||||
inline: main,
|
||||
block: cross,
|
||||
},
|
||||
FlexAxis::Column => Vec2 {
|
||||
FlexAxis::Column => LogicalVec2 {
|
||||
block: main,
|
||||
inline: cross,
|
||||
},
|
||||
|
@ -135,7 +135,7 @@ macro_rules! sides_mapping_methods {
|
|||
},
|
||||
)+
|
||||
) => {
|
||||
pub fn sides_to_flex_relative<T>(self, flow_relative: Sides<T>) -> FlexRelativeSides<T> {
|
||||
pub fn sides_to_flex_relative<T>(self, flow_relative: LogicalSides<T>) -> FlexRelativeSides<T> {
|
||||
match self {
|
||||
$(
|
||||
$variant => FlexRelativeSides {
|
||||
|
@ -145,10 +145,10 @@ macro_rules! sides_mapping_methods {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn sides_to_flow_relative<T>(self, flex_relative: FlexRelativeSides<T>) -> Sides<T> {
|
||||
pub fn sides_to_flow_relative<T>(self, flex_relative: FlexRelativeSides<T>) -> LogicalSides<T> {
|
||||
match self {
|
||||
$(
|
||||
$variant => Sides {
|
||||
$variant => LogicalSides {
|
||||
$( $flow_relative_side: flex_relative.$flex_relative_side, )+
|
||||
},
|
||||
)+
|
||||
|
@ -235,7 +235,7 @@ pub(super) fn rect_to_flow_relative<T>(
|
|||
main_start_cross_start_sides_are: MainStartCrossStart,
|
||||
base_rect_size: FlexRelativeVec2<T>,
|
||||
rect: FlexRelativeRect<T>,
|
||||
) -> Rect<T>
|
||||
) -> LogicalRect<T>
|
||||
where
|
||||
T: Copy + std::ops::Add<Output = T> + std::ops::Sub<Output = T>,
|
||||
{
|
||||
|
@ -258,14 +258,14 @@ where
|
|||
let flow_relative_base_rect_size = flex_axis.vec2_to_flow_relative(base_rect_size);
|
||||
|
||||
// Finally, convert back to (start corner, size)
|
||||
let start_corner = Vec2 {
|
||||
let start_corner = LogicalVec2 {
|
||||
inline: flow_relative_offsets.inline_start,
|
||||
block: flow_relative_offsets.block_start,
|
||||
};
|
||||
let end_corner_position = Vec2 {
|
||||
let end_corner_position = LogicalVec2 {
|
||||
inline: flow_relative_base_rect_size.inline - flow_relative_offsets.inline_end,
|
||||
block: flow_relative_base_rect_size.block - flow_relative_offsets.block_end,
|
||||
};
|
||||
let size = &end_corner_position - &start_corner;
|
||||
Rect { start_corner, size }
|
||||
LogicalRect { start_corner, size }
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@ use super::{FlexContainer, FlexLevelBox};
|
|||
use crate::context::LayoutContext;
|
||||
use crate::formatting_contexts::{IndependentFormattingContext, IndependentLayout};
|
||||
use crate::fragment_tree::{BoxFragment, CollapsedBlockMargins, Fragment};
|
||||
use crate::geom::flow_relative::{Rect, Sides, Vec2};
|
||||
use crate::geom::LengthOrAuto;
|
||||
use crate::geom::{LengthOrAuto, LogicalRect, LogicalSides, LogicalVec2};
|
||||
use crate::positioned::{AbsolutelyPositionedBox, PositioningContext, PositioningContextLength};
|
||||
use crate::sizing::ContentSizes;
|
||||
use crate::style_ext::ComputedValuesExt;
|
||||
|
@ -97,16 +96,16 @@ struct FlexLineLayoutResult {
|
|||
}
|
||||
|
||||
impl FlexContext<'_> {
|
||||
fn vec2_to_flex_relative<T>(&self, x: Vec2<T>) -> FlexRelativeVec2<T> {
|
||||
fn vec2_to_flex_relative<T>(&self, x: LogicalVec2<T>) -> FlexRelativeVec2<T> {
|
||||
self.flex_axis.vec2_to_flex_relative(x)
|
||||
}
|
||||
|
||||
fn sides_to_flex_relative<T>(&self, x: Sides<T>) -> FlexRelativeSides<T> {
|
||||
fn sides_to_flex_relative<T>(&self, x: LogicalSides<T>) -> FlexRelativeSides<T> {
|
||||
self.main_start_cross_start_sides_are
|
||||
.sides_to_flex_relative(x)
|
||||
}
|
||||
|
||||
fn sides_to_flow_relative<T>(&self, x: FlexRelativeSides<T>) -> Sides<T> {
|
||||
fn sides_to_flow_relative<T>(&self, x: FlexRelativeSides<T>) -> LogicalSides<T> {
|
||||
self.main_start_cross_start_sides_are
|
||||
.sides_to_flow_relative(x)
|
||||
}
|
||||
|
@ -115,7 +114,7 @@ impl FlexContext<'_> {
|
|||
&self,
|
||||
base_rect_size: FlexRelativeVec2<Length>,
|
||||
rect: FlexRelativeRect<Length>,
|
||||
) -> Rect<Length> {
|
||||
) -> LogicalRect<Length> {
|
||||
super::geom::rect_to_flow_relative(
|
||||
self.flex_axis,
|
||||
self.main_start_cross_start_sides_are,
|
||||
|
@ -206,7 +205,7 @@ impl FlexContainer {
|
|||
Ok(absolutely_positioned) => {
|
||||
let hoisted_box = AbsolutelyPositionedBox::to_hoisted(
|
||||
absolutely_positioned,
|
||||
Vec2::zero(),
|
||||
LogicalVec2::zero(),
|
||||
containing_block,
|
||||
);
|
||||
let hoisted_fragment = hoisted_box.fragment.clone();
|
||||
|
@ -285,7 +284,7 @@ fn layout<'context, 'boxes>(
|
|||
flex_wrap_reverse,
|
||||
),
|
||||
// https://drafts.csswg.org/css-flexbox/#definite-sizes
|
||||
container_definite_inner_size: flex_axis.vec2_to_flex_relative(Vec2 {
|
||||
container_definite_inner_size: flex_axis.vec2_to_flex_relative(LogicalVec2 {
|
||||
inline: Some(containing_block.inline_size),
|
||||
block: containing_block.block_size.non_auto(),
|
||||
}),
|
||||
|
@ -394,19 +393,19 @@ fn layout<'context, 'boxes>(
|
|||
.zip(line_cross_start_positions)
|
||||
.flat_map(move |(mut line, line_cross_start_position)| {
|
||||
let flow_relative_line_position = match (flex_axis, flex_wrap_reverse) {
|
||||
(FlexAxis::Row, false) => Vec2 {
|
||||
(FlexAxis::Row, false) => LogicalVec2 {
|
||||
block: line_cross_start_position,
|
||||
inline: Length::zero(),
|
||||
},
|
||||
(FlexAxis::Row, true) => Vec2 {
|
||||
(FlexAxis::Row, true) => LogicalVec2 {
|
||||
block: container_cross_size - line_cross_start_position - line.cross_size,
|
||||
inline: Length::zero(),
|
||||
},
|
||||
(FlexAxis::Column, false) => Vec2 {
|
||||
(FlexAxis::Column, false) => LogicalVec2 {
|
||||
block: Length::zero(),
|
||||
inline: line_cross_start_position,
|
||||
},
|
||||
(FlexAxis::Column, true) => Vec2 {
|
||||
(FlexAxis::Column, true) => LogicalVec2 {
|
||||
block: Length::zero(),
|
||||
inline: container_cross_size - line_cross_start_position - line.cross_size,
|
||||
},
|
||||
|
@ -509,7 +508,7 @@ impl<'a> FlexItem<'a> {
|
|||
}
|
||||
};
|
||||
|
||||
let min_size = Vec2 {
|
||||
let min_size = LogicalVec2 {
|
||||
inline: min_size.inline.auto_is(automatic_min_size),
|
||||
block: min_size.block.auto_is(|| Length::zero()),
|
||||
};
|
||||
|
@ -1067,7 +1066,7 @@ impl<'a> FlexItem<'a> {
|
|||
let pbm = replaced
|
||||
.style
|
||||
.padding_border_margin(flex_context.containing_block);
|
||||
let box_size = used_cross_size_override.map(|size| Vec2 {
|
||||
let box_size = used_cross_size_override.map(|size| LogicalVec2 {
|
||||
inline: replaced
|
||||
.style
|
||||
.content_box_size(flex_context.containing_block, &pbm)
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -13,8 +13,9 @@ use style::Zero;
|
|||
|
||||
use super::{BaseFragment, BaseFragmentInfo, CollapsedBlockMargins, Fragment};
|
||||
use crate::cell::ArcRefCell;
|
||||
use crate::geom::flow_relative::{Rect, Sides};
|
||||
use crate::geom::{PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize};
|
||||
use crate::geom::{
|
||||
LogicalRect, LogicalSides, PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize,
|
||||
};
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub(crate) struct BoxFragment {
|
||||
|
@ -27,11 +28,11 @@ pub(crate) struct BoxFragment {
|
|||
/// From the containing block’s start corner…?
|
||||
/// This might be broken when the containing block is in a different writing mode:
|
||||
/// https://drafts.csswg.org/css-writing-modes/#orthogonal-flows
|
||||
pub content_rect: Rect<Length>,
|
||||
pub content_rect: LogicalRect<Length>,
|
||||
|
||||
pub padding: Sides<Length>,
|
||||
pub border: Sides<Length>,
|
||||
pub margin: Sides<Length>,
|
||||
pub padding: LogicalSides<Length>,
|
||||
pub border: LogicalSides<Length>,
|
||||
pub margin: LogicalSides<Length>,
|
||||
|
||||
/// When the `clear` property is not set to `none`, it may introduce clearance.
|
||||
/// Clearance is some extra spacing that is added above the top margin,
|
||||
|
@ -55,10 +56,10 @@ impl BoxFragment {
|
|||
base_fragment_info: BaseFragmentInfo,
|
||||
style: ServoArc<ComputedValues>,
|
||||
children: Vec<Fragment>,
|
||||
content_rect: Rect<Length>,
|
||||
padding: Sides<Length>,
|
||||
border: Sides<Length>,
|
||||
margin: Sides<Length>,
|
||||
content_rect: LogicalRect<Length>,
|
||||
padding: LogicalSides<Length>,
|
||||
border: LogicalSides<Length>,
|
||||
margin: LogicalSides<Length>,
|
||||
clearance: Option<Length>,
|
||||
block_margins_collapsed_with_children: CollapsedBlockMargins,
|
||||
) -> BoxFragment {
|
||||
|
@ -89,10 +90,10 @@ impl BoxFragment {
|
|||
base_fragment_info: BaseFragmentInfo,
|
||||
style: ServoArc<ComputedValues>,
|
||||
children: Vec<Fragment>,
|
||||
content_rect: Rect<Length>,
|
||||
padding: Sides<Length>,
|
||||
border: Sides<Length>,
|
||||
margin: Sides<Length>,
|
||||
content_rect: LogicalRect<Length>,
|
||||
padding: LogicalSides<Length>,
|
||||
border: LogicalSides<Length>,
|
||||
margin: LogicalSides<Length>,
|
||||
clearance: Option<Length>,
|
||||
block_margins_collapsed_with_children: CollapsedBlockMargins,
|
||||
overconstrained: PhysicalSize<bool>,
|
||||
|
@ -142,11 +143,11 @@ impl BoxFragment {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn padding_rect(&self) -> Rect<Length> {
|
||||
pub fn padding_rect(&self) -> LogicalRect<Length> {
|
||||
self.content_rect.inflate(&self.padding)
|
||||
}
|
||||
|
||||
pub fn border_rect(&self) -> Rect<Length> {
|
||||
pub fn border_rect(&self) -> LogicalRect<Length> {
|
||||
self.padding_rect().inflate(&self.border)
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@ use webrender_api::{FontInstanceKey, ImageKey};
|
|||
|
||||
use super::{BaseFragment, BoxFragment, ContainingBlockManager, HoistedSharedFragment, Tag};
|
||||
use crate::cell::ArcRefCell;
|
||||
use crate::geom::flow_relative::{Rect, Sides};
|
||||
use crate::geom::PhysicalRect;
|
||||
use crate::geom::{LogicalRect, LogicalSides, PhysicalRect};
|
||||
use crate::style_ext::ComputedValuesExt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -68,7 +67,7 @@ pub(crate) struct CollapsedMargin {
|
|||
#[derive(Serialize)]
|
||||
pub(crate) struct AnonymousFragment {
|
||||
pub base: BaseFragment,
|
||||
pub rect: Rect<Length>,
|
||||
pub rect: LogicalRect<Length>,
|
||||
pub children: Vec<ArcRefCell<Fragment>>,
|
||||
pub mode: WritingMode,
|
||||
|
||||
|
@ -104,7 +103,7 @@ pub(crate) struct TextFragment {
|
|||
pub base: BaseFragment,
|
||||
#[serde(skip_serializing)]
|
||||
pub parent_style: ServoArc<ComputedValues>,
|
||||
pub rect: Rect<Length>,
|
||||
pub rect: LogicalRect<Length>,
|
||||
pub font_metrics: FontMetrics,
|
||||
#[serde(skip_serializing)]
|
||||
pub font_key: FontInstanceKey,
|
||||
|
@ -118,7 +117,7 @@ pub(crate) struct ImageFragment {
|
|||
pub base: BaseFragment,
|
||||
#[serde(skip_serializing)]
|
||||
pub style: ServoArc<ComputedValues>,
|
||||
pub rect: Rect<Length>,
|
||||
pub rect: LogicalRect<Length>,
|
||||
#[serde(skip_serializing)]
|
||||
pub image_key: ImageKey,
|
||||
}
|
||||
|
@ -128,7 +127,7 @@ pub(crate) struct IFrameFragment {
|
|||
pub base: BaseFragment,
|
||||
pub pipeline_id: PipelineId,
|
||||
pub browsing_context_id: BrowsingContextId,
|
||||
pub rect: Rect<Length>,
|
||||
pub rect: LogicalRect<Length>,
|
||||
#[serde(skip_serializing)]
|
||||
pub style: ServoArc<ComputedValues>,
|
||||
}
|
||||
|
@ -247,7 +246,7 @@ impl Fragment {
|
|||
}
|
||||
|
||||
impl AnonymousFragment {
|
||||
pub fn new(rect: Rect<Length>, children: Vec<Fragment>, mode: WritingMode) -> Self {
|
||||
pub fn new(rect: LogicalRect<Length>, children: Vec<Fragment>, mode: WritingMode) -> Self {
|
||||
// FIXME(mrobinson, bug 25564): We should be using the containing block
|
||||
// here to properly convert scrollable overflow to physical geometry.
|
||||
let containing_block = PhysicalRect::zero();
|
||||
|
@ -320,7 +319,7 @@ impl IFrameFragment {
|
|||
}
|
||||
|
||||
impl CollapsedBlockMargins {
|
||||
pub fn from_margin(margin: &Sides<Length>) -> Self {
|
||||
pub fn from_margin(margin: &LogicalSides<Length>) -> Self {
|
||||
Self {
|
||||
collapsed_through: false,
|
||||
start: CollapsedMargin::new(margin.block_start),
|
||||
|
|
|
@ -7,7 +7,7 @@ use style::values::computed::{Length, LengthPercentage};
|
|||
|
||||
use super::Fragment;
|
||||
use crate::cell::ArcRefCell;
|
||||
use crate::geom::flow_relative::Vec2;
|
||||
use crate::geom::LogicalVec2;
|
||||
|
||||
/// A reference to a Fragment which is shared between `HoistedAbsolutelyPositionedBox`
|
||||
/// and its placeholder `AbsoluteOrFixedPositionedFragment` in the original tree position.
|
||||
|
@ -15,11 +15,11 @@ use crate::geom::flow_relative::Vec2;
|
|||
#[derive(Serialize)]
|
||||
pub(crate) struct HoistedSharedFragment {
|
||||
pub fragment: Option<ArcRefCell<Fragment>>,
|
||||
pub box_offsets: Vec2<AbsoluteBoxOffsets>,
|
||||
pub box_offsets: LogicalVec2<AbsoluteBoxOffsets>,
|
||||
}
|
||||
|
||||
impl HoistedSharedFragment {
|
||||
pub(crate) fn new(box_offsets: Vec2<AbsoluteBoxOffsets>) -> Self {
|
||||
pub(crate) fn new(box_offsets: LogicalVec2<AbsoluteBoxOffsets>) -> Self {
|
||||
HoistedSharedFragment {
|
||||
fragment: None,
|
||||
box_offsets,
|
||||
|
@ -31,7 +31,7 @@ impl HoistedSharedFragment {
|
|||
/// In some cases `inset: auto`-positioned elements do not know their precise
|
||||
/// position until after they're hoisted. This lets us adjust auto values
|
||||
/// after the fact.
|
||||
pub(crate) fn adjust_offsets(&mut self, offsets: Vec2<Length>) {
|
||||
pub(crate) fn adjust_offsets(&mut self, offsets: LogicalVec2<Length>) {
|
||||
self.box_offsets.inline.adjust_offset(offsets.inline);
|
||||
self.box_offsets.block.adjust_offset(offsets.block);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
use std::fmt;
|
||||
use std::ops::{Add, AddAssign, Sub};
|
||||
|
||||
use serde::Serialize;
|
||||
use style::logical_geometry::{
|
||||
BlockFlowDirection, InlineBaseDirection, PhysicalCorner, WritingMode,
|
||||
};
|
||||
|
@ -22,31 +23,27 @@ pub type PhysicalSides<U> = euclid::SideOffsets2D<U, CSSPixel>;
|
|||
pub type LengthOrAuto = AutoOr<Length>;
|
||||
pub type LengthPercentageOrAuto<'a> = AutoOr<&'a LengthPercentage>;
|
||||
|
||||
pub mod flow_relative {
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Clone, Serialize)]
|
||||
pub struct Vec2<T> {
|
||||
pub inline: T,
|
||||
pub block: T,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize)]
|
||||
pub struct Rect<T> {
|
||||
pub start_corner: Vec2<T>,
|
||||
pub size: Vec2<T>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct Sides<T> {
|
||||
pub inline_start: T,
|
||||
pub inline_end: T,
|
||||
pub block_start: T,
|
||||
pub block_end: T,
|
||||
}
|
||||
#[derive(Clone, Serialize)]
|
||||
pub struct LogicalVec2<T> {
|
||||
pub inline: T,
|
||||
pub block: T,
|
||||
}
|
||||
|
||||
impl<T: fmt::Debug> fmt::Debug for flow_relative::Vec2<T> {
|
||||
#[derive(Clone, Serialize)]
|
||||
pub struct LogicalRect<T> {
|
||||
pub start_corner: LogicalVec2<T>,
|
||||
pub size: LogicalVec2<T>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct LogicalSides<T> {
|
||||
pub inline_start: T,
|
||||
pub inline_end: T,
|
||||
pub block_start: T,
|
||||
pub block_end: T,
|
||||
}
|
||||
|
||||
impl<T: fmt::Debug> fmt::Debug for LogicalVec2<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
// Not using f.debug_struct on purpose here, to keep {:?} output somewhat compact
|
||||
f.write_str("Vec2 { i: ")?;
|
||||
|
@ -57,7 +54,7 @@ impl<T: fmt::Debug> fmt::Debug for flow_relative::Vec2<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Clone> flow_relative::Vec2<T> {
|
||||
impl<T: Clone> LogicalVec2<T> {
|
||||
pub fn from_physical_size(physical_size: &PhysicalSize<T>, mode: WritingMode) -> Self {
|
||||
// https://drafts.csswg.org/css-writing-modes/#logical-to-physical
|
||||
let (i, b) = if mode.is_horizontal() {
|
||||
|
@ -65,52 +62,52 @@ impl<T: Clone> flow_relative::Vec2<T> {
|
|||
} else {
|
||||
(&physical_size.height, &physical_size.width)
|
||||
};
|
||||
flow_relative::Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: i.clone(),
|
||||
block: b.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Add<&'_ flow_relative::Vec2<T>> for &'_ flow_relative::Vec2<T>
|
||||
impl<T> Add<&'_ LogicalVec2<T>> for &'_ LogicalVec2<T>
|
||||
where
|
||||
T: Add<Output = T> + Copy,
|
||||
{
|
||||
type Output = flow_relative::Vec2<T>;
|
||||
type Output = LogicalVec2<T>;
|
||||
|
||||
fn add(self, other: &'_ flow_relative::Vec2<T>) -> Self::Output {
|
||||
flow_relative::Vec2 {
|
||||
fn add(self, other: &'_ LogicalVec2<T>) -> Self::Output {
|
||||
LogicalVec2 {
|
||||
inline: self.inline + other.inline,
|
||||
block: self.block + other.block,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Sub<&'_ flow_relative::Vec2<T>> for &'_ flow_relative::Vec2<T>
|
||||
impl<T> Sub<&'_ LogicalVec2<T>> for &'_ LogicalVec2<T>
|
||||
where
|
||||
T: Sub<Output = T> + Copy,
|
||||
{
|
||||
type Output = flow_relative::Vec2<T>;
|
||||
type Output = LogicalVec2<T>;
|
||||
|
||||
fn sub(self, other: &'_ flow_relative::Vec2<T>) -> Self::Output {
|
||||
flow_relative::Vec2 {
|
||||
fn sub(self, other: &'_ LogicalVec2<T>) -> Self::Output {
|
||||
LogicalVec2 {
|
||||
inline: self.inline - other.inline,
|
||||
block: self.block - other.block,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> AddAssign<&'_ flow_relative::Vec2<T>> for flow_relative::Vec2<T>
|
||||
impl<T> AddAssign<&'_ LogicalVec2<T>> for LogicalVec2<T>
|
||||
where
|
||||
T: AddAssign<T> + Copy,
|
||||
{
|
||||
fn add_assign(&mut self, other: &'_ flow_relative::Vec2<T>) {
|
||||
fn add_assign(&mut self, other: &'_ LogicalVec2<T>) {
|
||||
self.inline += other.inline;
|
||||
self.block += other.block;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Zero> flow_relative::Vec2<T> {
|
||||
impl<T: Zero> LogicalVec2<T> {
|
||||
pub fn zero() -> Self {
|
||||
Self {
|
||||
inline: T::zero(),
|
||||
|
@ -119,21 +116,21 @@ impl<T: Zero> flow_relative::Vec2<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl flow_relative::Vec2<LengthOrAuto> {
|
||||
pub fn auto_is(&self, f: impl Fn() -> Length) -> flow_relative::Vec2<Length> {
|
||||
flow_relative::Vec2 {
|
||||
impl LogicalVec2<LengthOrAuto> {
|
||||
pub fn auto_is(&self, f: impl Fn() -> Length) -> LogicalVec2<Length> {
|
||||
LogicalVec2 {
|
||||
inline: self.inline.auto_is(&f),
|
||||
block: self.block.auto_is(&f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl flow_relative::Vec2<LengthPercentageOrAuto<'_>> {
|
||||
impl LogicalVec2<LengthPercentageOrAuto<'_>> {
|
||||
pub fn percentages_relative_to(
|
||||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
) -> flow_relative::Vec2<LengthOrAuto> {
|
||||
flow_relative::Vec2 {
|
||||
) -> LogicalVec2<LengthOrAuto> {
|
||||
LogicalVec2 {
|
||||
inline: self
|
||||
.inline
|
||||
.percentage_relative_to(containing_block.inline_size),
|
||||
|
@ -144,12 +141,12 @@ impl flow_relative::Vec2<LengthPercentageOrAuto<'_>> {
|
|||
}
|
||||
}
|
||||
|
||||
impl flow_relative::Vec2<Option<&'_ LengthPercentage>> {
|
||||
impl LogicalVec2<Option<&'_ LengthPercentage>> {
|
||||
pub fn percentages_relative_to(
|
||||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
) -> flow_relative::Vec2<Option<Length>> {
|
||||
flow_relative::Vec2 {
|
||||
) -> LogicalVec2<Option<Length>> {
|
||||
LogicalVec2 {
|
||||
inline: self
|
||||
.inline
|
||||
.map(|lp| lp.percentage_relative_to(containing_block.inline_size)),
|
||||
|
@ -160,16 +157,16 @@ impl flow_relative::Vec2<Option<&'_ LengthPercentage>> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Zero> flow_relative::Rect<T> {
|
||||
impl<T: Zero> LogicalRect<T> {
|
||||
pub fn zero() -> Self {
|
||||
Self {
|
||||
start_corner: flow_relative::Vec2::zero(),
|
||||
size: flow_relative::Vec2::zero(),
|
||||
start_corner: LogicalVec2::zero(),
|
||||
size: LogicalVec2::zero(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for flow_relative::Rect<Length> {
|
||||
impl fmt::Debug for LogicalRect<Length> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
|
@ -182,7 +179,7 @@ impl fmt::Debug for flow_relative::Rect<Length> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Clone> flow_relative::Vec2<T> {
|
||||
impl<T: Clone> LogicalVec2<T> {
|
||||
pub fn to_physical(&self, mode: WritingMode) -> PhysicalSize<T> {
|
||||
// https://drafts.csswg.org/css-writing-modes/#logical-to-physical
|
||||
let (x, y) = if mode.is_horizontal() {
|
||||
|
@ -194,7 +191,7 @@ impl<T: Clone> flow_relative::Vec2<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Clone> flow_relative::Sides<T> {
|
||||
impl<T: Clone> LogicalSides<T> {
|
||||
pub fn from_physical(sides: &PhysicalSides<T>, mode: WritingMode) -> Self {
|
||||
// https://drafts.csswg.org/css-writing-modes/#logical-to-physical
|
||||
let block_flow = mode.block_flow_direction();
|
||||
|
@ -210,7 +207,7 @@ impl<T: Clone> flow_relative::Sides<T> {
|
|||
(_, InlineBaseDirection::LeftToRight) => (&sides.top, &sides.bottom),
|
||||
(_, InlineBaseDirection::RightToLeft) => (&sides.bottom, &sides.top),
|
||||
};
|
||||
flow_relative::Sides {
|
||||
LogicalSides {
|
||||
inline_start: is.clone(),
|
||||
inline_end: ie.clone(),
|
||||
block_start: bs.clone(),
|
||||
|
@ -219,9 +216,9 @@ impl<T: Clone> flow_relative::Sides<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> flow_relative::Sides<T> {
|
||||
pub fn map<U>(&self, f: impl Fn(&T) -> U) -> flow_relative::Sides<U> {
|
||||
flow_relative::Sides {
|
||||
impl<T> LogicalSides<T> {
|
||||
pub fn map<U>(&self, f: impl Fn(&T) -> U) -> LogicalSides<U> {
|
||||
LogicalSides {
|
||||
inline_start: f(&self.inline_start),
|
||||
inline_end: f(&self.inline_end),
|
||||
block_start: f(&self.block_start),
|
||||
|
@ -233,8 +230,8 @@ impl<T> flow_relative::Sides<T> {
|
|||
&self,
|
||||
inline_f: impl Fn(&T) -> U,
|
||||
block_f: impl Fn(&T) -> U,
|
||||
) -> flow_relative::Sides<U> {
|
||||
flow_relative::Sides {
|
||||
) -> LogicalSides<U> {
|
||||
LogicalSides {
|
||||
inline_start: inline_f(&self.inline_start),
|
||||
inline_end: inline_f(&self.inline_end),
|
||||
block_start: block_f(&self.block_start),
|
||||
|
@ -256,11 +253,11 @@ impl<T> flow_relative::Sides<T> {
|
|||
self.block_start + self.block_end
|
||||
}
|
||||
|
||||
pub fn sum(&self) -> flow_relative::Vec2<T::Output>
|
||||
pub fn sum(&self) -> LogicalVec2<T::Output>
|
||||
where
|
||||
T: Add + Copy,
|
||||
{
|
||||
flow_relative::Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: self.inline_sum(),
|
||||
block: self.block_sum(),
|
||||
}
|
||||
|
@ -305,44 +302,44 @@ impl<T> flow_relative::Sides<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> flow_relative::Sides<T>
|
||||
impl<T> LogicalSides<T>
|
||||
where
|
||||
T: Copy,
|
||||
{
|
||||
pub fn start_offset(&self) -> flow_relative::Vec2<T> {
|
||||
flow_relative::Vec2 {
|
||||
pub fn start_offset(&self) -> LogicalVec2<T> {
|
||||
LogicalVec2 {
|
||||
inline: self.inline_start,
|
||||
block: self.block_start,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl flow_relative::Sides<&'_ LengthPercentage> {
|
||||
pub fn percentages_relative_to(&self, basis: Length) -> flow_relative::Sides<Length> {
|
||||
impl LogicalSides<&'_ LengthPercentage> {
|
||||
pub fn percentages_relative_to(&self, basis: Length) -> LogicalSides<Length> {
|
||||
self.map(|s| s.percentage_relative_to(basis))
|
||||
}
|
||||
}
|
||||
|
||||
impl flow_relative::Sides<LengthPercentageOrAuto<'_>> {
|
||||
pub fn percentages_relative_to(&self, basis: Length) -> flow_relative::Sides<LengthOrAuto> {
|
||||
impl LogicalSides<LengthPercentageOrAuto<'_>> {
|
||||
pub fn percentages_relative_to(&self, basis: Length) -> LogicalSides<LengthOrAuto> {
|
||||
self.map(|s| s.percentage_relative_to(basis))
|
||||
}
|
||||
}
|
||||
|
||||
impl flow_relative::Sides<LengthOrAuto> {
|
||||
pub fn auto_is(&self, f: impl Fn() -> Length) -> flow_relative::Sides<Length> {
|
||||
impl LogicalSides<LengthOrAuto> {
|
||||
pub fn auto_is(&self, f: impl Fn() -> Length) -> LogicalSides<Length> {
|
||||
self.map(|s| s.auto_is(&f))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Add<&'_ flow_relative::Sides<T>> for &'_ flow_relative::Sides<T>
|
||||
impl<T> Add<&'_ LogicalSides<T>> for &'_ LogicalSides<T>
|
||||
where
|
||||
T: Add<Output = T> + Copy,
|
||||
{
|
||||
type Output = flow_relative::Sides<T>;
|
||||
type Output = LogicalSides<T>;
|
||||
|
||||
fn add(self, other: &'_ flow_relative::Sides<T>) -> Self::Output {
|
||||
flow_relative::Sides {
|
||||
fn add(self, other: &'_ LogicalSides<T>) -> Self::Output {
|
||||
LogicalSides {
|
||||
inline_start: self.inline_start + other.inline_start,
|
||||
inline_end: self.inline_end + other.inline_end,
|
||||
block_start: self.block_start + other.block_start,
|
||||
|
@ -351,9 +348,9 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Zero> flow_relative::Sides<T> {
|
||||
pub(crate) fn zero() -> flow_relative::Sides<T> {
|
||||
flow_relative::Sides {
|
||||
impl<T: Zero> LogicalSides<T> {
|
||||
pub(crate) fn zero() -> LogicalSides<T> {
|
||||
LogicalSides {
|
||||
inline_start: T::zero(),
|
||||
inline_end: T::zero(),
|
||||
block_start: T::zero(),
|
||||
|
@ -362,7 +359,7 @@ impl<T: Zero> flow_relative::Sides<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> flow_relative::Rect<T> {
|
||||
impl<T> LogicalRect<T> {
|
||||
pub fn max_inline_position(&self) -> T
|
||||
where
|
||||
T: Add<Output = T> + Copy,
|
||||
|
@ -377,17 +374,17 @@ impl<T> flow_relative::Rect<T> {
|
|||
self.start_corner.block + self.size.block
|
||||
}
|
||||
|
||||
pub fn inflate(&self, sides: &flow_relative::Sides<T>) -> Self
|
||||
pub fn inflate(&self, sides: &LogicalSides<T>) -> Self
|
||||
where
|
||||
T: Add<Output = T> + Copy,
|
||||
T: Sub<Output = T> + Copy,
|
||||
{
|
||||
flow_relative::Rect {
|
||||
start_corner: flow_relative::Vec2 {
|
||||
LogicalRect {
|
||||
start_corner: LogicalVec2 {
|
||||
inline: self.start_corner.inline - sides.inline_start,
|
||||
block: self.start_corner.block - sides.block_start,
|
||||
},
|
||||
size: flow_relative::Vec2 {
|
||||
size: LogicalVec2 {
|
||||
inline: self.size.inline + sides.inline_sum(),
|
||||
block: self.size.block + sides.block_sum(),
|
||||
},
|
||||
|
|
|
@ -30,7 +30,7 @@ pub use fragment_tree::FragmentTree;
|
|||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{Length, LengthOrAuto};
|
||||
|
||||
use crate::geom::flow_relative::Vec2;
|
||||
use crate::geom::LogicalVec2;
|
||||
|
||||
pub struct ContainingBlock<'a> {
|
||||
inline_size: Length,
|
||||
|
@ -39,7 +39,7 @@ pub struct ContainingBlock<'a> {
|
|||
}
|
||||
|
||||
struct DefiniteContainingBlock<'a> {
|
||||
size: Vec2<Length>,
|
||||
size: LogicalVec2<Length>,
|
||||
style: &'a ComputedValues,
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@ use crate::formatting_contexts::IndependentFormattingContext;
|
|||
use crate::fragment_tree::{
|
||||
AbsoluteBoxOffsets, BoxFragment, CollapsedBlockMargins, Fragment, HoistedSharedFragment,
|
||||
};
|
||||
use crate::geom::flow_relative::{Rect, Sides, Vec2};
|
||||
use crate::geom::{LengthOrAuto, LengthPercentageOrAuto};
|
||||
use crate::geom::{LengthOrAuto, LengthPercentageOrAuto, LogicalRect, LogicalSides, LogicalVec2};
|
||||
use crate::style_ext::{ComputedValuesExt, DisplayInside};
|
||||
use crate::{ContainingBlock, DefiniteContainingBlock};
|
||||
|
||||
|
@ -68,7 +67,7 @@ impl AbsolutelyPositionedBox {
|
|||
|
||||
pub(crate) fn to_hoisted(
|
||||
self_: ArcRefCell<Self>,
|
||||
initial_start_corner: Vec2<Length>,
|
||||
initial_start_corner: LogicalVec2<Length>,
|
||||
containing_block: &ContainingBlock,
|
||||
) -> HoistedAbsolutelyPositionedBox {
|
||||
fn absolute_box_offsets(
|
||||
|
@ -94,7 +93,7 @@ impl AbsolutelyPositionedBox {
|
|||
let box_offsets = {
|
||||
let box_ = self_.borrow();
|
||||
let box_offsets = box_.context.style().box_offsets(containing_block);
|
||||
Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: absolute_box_offsets(
|
||||
initial_start_corner.inline,
|
||||
box_offsets.inline_start,
|
||||
|
@ -183,7 +182,7 @@ impl PositioningContext {
|
|||
/// See documentation for [adjust_static_position_of_hoisted_fragments].
|
||||
pub(crate) fn adjust_static_position_of_hoisted_fragments_with_offset(
|
||||
&mut self,
|
||||
start_offset: &Vec2<CSSPixelLength>,
|
||||
start_offset: &LogicalVec2<CSSPixelLength>,
|
||||
index: PositioningContextLength,
|
||||
) {
|
||||
let update_fragment_if_needed = |hoisted_fragment: &mut HoistedAbsolutelyPositionedBox| {
|
||||
|
@ -249,10 +248,10 @@ impl PositioningContext {
|
|||
layout_context: &LayoutContext,
|
||||
new_fragment: &mut BoxFragment,
|
||||
) {
|
||||
let padding_rect = Rect {
|
||||
let padding_rect = LogicalRect {
|
||||
size: new_fragment.content_rect.size.clone(),
|
||||
// Ignore the content rect’s position in its own containing block:
|
||||
start_corner: Vec2::zero(),
|
||||
start_corner: LogicalVec2::zero(),
|
||||
}
|
||||
.inflate(&new_fragment.padding);
|
||||
let containing_block = DefiniteContainingBlock {
|
||||
|
@ -490,7 +489,7 @@ impl HoistedAbsolutelyPositionedBox {
|
|||
None,
|
||||
&pbm,
|
||||
);
|
||||
Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: LengthOrAuto::LengthPercentage(used_size.inline),
|
||||
block: LengthOrAuto::LengthPercentage(used_size.block),
|
||||
}
|
||||
|
@ -518,7 +517,7 @@ impl HoistedAbsolutelyPositionedBox {
|
|||
avoid_negative_margin_start: false,
|
||||
box_offsets: &shared_fragment.box_offsets.block,
|
||||
};
|
||||
let overconstrained = Vec2 {
|
||||
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),
|
||||
};
|
||||
|
@ -592,7 +591,7 @@ impl HoistedAbsolutelyPositionedBox {
|
|||
}
|
||||
|
||||
struct Result {
|
||||
content_size: Vec2<CSSPixelLength>,
|
||||
content_size: LogicalVec2<CSSPixelLength>,
|
||||
fragments: Vec<Fragment>,
|
||||
}
|
||||
|
||||
|
@ -625,7 +624,7 @@ impl HoistedAbsolutelyPositionedBox {
|
|||
);
|
||||
let block_size = size.auto_is(|| independent_layout.content_block_size);
|
||||
Result {
|
||||
content_size: Vec2 {
|
||||
content_size: LogicalVec2 {
|
||||
inline: inline_size,
|
||||
block: block_size,
|
||||
},
|
||||
|
@ -664,7 +663,7 @@ impl HoistedAbsolutelyPositionedBox {
|
|||
},
|
||||
};
|
||||
|
||||
let margin = Sides {
|
||||
let margin = LogicalSides {
|
||||
inline_start: inline_axis.margin_start,
|
||||
inline_end: inline_axis.margin_end,
|
||||
block_start: block_axis.margin_start,
|
||||
|
@ -685,8 +684,8 @@ impl HoistedAbsolutelyPositionedBox {
|
|||
},
|
||||
};
|
||||
|
||||
let content_rect = Rect {
|
||||
start_corner: Vec2 {
|
||||
let content_rect = LogicalRect {
|
||||
start_corner: LogicalVec2 {
|
||||
inline: inline_start,
|
||||
block: block_start,
|
||||
},
|
||||
|
@ -860,7 +859,7 @@ fn vec_append_owned<T>(a: &mut Vec<T>, mut b: Vec<T>) {
|
|||
pub(crate) fn relative_adjustement(
|
||||
style: &ComputedValues,
|
||||
containing_block: &ContainingBlock,
|
||||
) -> Vec2<Length> {
|
||||
) -> LogicalVec2<Length> {
|
||||
// "If the height of the containing block is not specified explicitly (i.e.,
|
||||
// it depends on content height), and this element is not absolutely
|
||||
// positioned, the value computes to 'auto'.""
|
||||
|
@ -880,7 +879,7 @@ pub(crate) fn relative_adjustement(
|
|||
(LengthOrAuto::LengthPercentage(start), _) => start,
|
||||
}
|
||||
}
|
||||
Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: adjust(box_offsets.inline_start, box_offsets.inline_end),
|
||||
block: adjust(box_offsets.block_start, box_offsets.block_end),
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ use webrender_api::ImageKey;
|
|||
use crate::context::LayoutContext;
|
||||
use crate::dom::NodeExt;
|
||||
use crate::fragment_tree::{BaseFragmentInfo, Fragment, IFrameFragment, ImageFragment};
|
||||
use crate::geom::flow_relative::{Rect, Vec2};
|
||||
use crate::geom::PhysicalSize;
|
||||
use crate::geom::{LogicalRect, LogicalVec2, PhysicalSize};
|
||||
use crate::sizing::ContentSizes;
|
||||
use crate::style_ext::{ComputedValuesExt, PaddingBorderMargin};
|
||||
use crate::ContainingBlock;
|
||||
|
@ -211,9 +210,9 @@ impl ReplacedContent {
|
|||
}
|
||||
}
|
||||
|
||||
fn flow_relative_intrinsic_size(&self, style: &ComputedValues) -> Vec2<Option<Length>> {
|
||||
fn flow_relative_intrinsic_size(&self, style: &ComputedValues) -> LogicalVec2<Option<Length>> {
|
||||
let intrinsic_size = PhysicalSize::new(self.intrinsic.width, self.intrinsic.height);
|
||||
Vec2::from_physical_size(&intrinsic_size, style.writing_mode)
|
||||
LogicalVec2::from_physical_size(&intrinsic_size, style.writing_mode)
|
||||
}
|
||||
|
||||
pub fn inline_size_over_block_size_intrinsic_ratio(
|
||||
|
@ -246,7 +245,7 @@ impl ReplacedContent {
|
|||
pub fn make_fragments<'a>(
|
||||
&'a self,
|
||||
style: &ServoArc<ComputedValues>,
|
||||
size: Vec2<Length>,
|
||||
size: LogicalVec2<Length>,
|
||||
) -> Vec<Fragment> {
|
||||
match &self.kind {
|
||||
ReplacedContentKind::Image(image) => image
|
||||
|
@ -256,8 +255,8 @@ impl ReplacedContent {
|
|||
Fragment::Image(ImageFragment {
|
||||
base: self.base_fragment_info.into(),
|
||||
style: style.clone(),
|
||||
rect: Rect {
|
||||
start_corner: Vec2::zero(),
|
||||
rect: LogicalRect {
|
||||
start_corner: LogicalVec2::zero(),
|
||||
size,
|
||||
},
|
||||
image_key,
|
||||
|
@ -271,8 +270,8 @@ impl ReplacedContent {
|
|||
style: style.clone(),
|
||||
pipeline_id: iframe.pipeline_id,
|
||||
browsing_context_id: iframe.browsing_context_id,
|
||||
rect: Rect {
|
||||
start_corner: Vec2::zero(),
|
||||
rect: LogicalRect {
|
||||
start_corner: LogicalVec2::zero(),
|
||||
size,
|
||||
},
|
||||
})]
|
||||
|
@ -305,8 +304,8 @@ impl ReplacedContent {
|
|||
vec![Fragment::Image(ImageFragment {
|
||||
base: self.base_fragment_info.into(),
|
||||
style: style.clone(),
|
||||
rect: Rect {
|
||||
start_corner: Vec2::zero(),
|
||||
rect: LogicalRect {
|
||||
start_corner: LogicalVec2::zero(),
|
||||
size,
|
||||
},
|
||||
image_key,
|
||||
|
@ -324,9 +323,9 @@ impl ReplacedContent {
|
|||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
style: &ComputedValues,
|
||||
box_size: Option<Vec2<LengthOrAuto>>,
|
||||
box_size: Option<LogicalVec2<LengthOrAuto>>,
|
||||
pbm: &PaddingBorderMargin,
|
||||
) -> Vec2<Length> {
|
||||
) -> LogicalVec2<Length> {
|
||||
let mode = style.writing_mode;
|
||||
let intrinsic_size = self.flow_relative_intrinsic_size(style);
|
||||
let intrinsic_ratio = self.inline_size_over_block_size_intrinsic_ratio(style);
|
||||
|
@ -344,12 +343,12 @@ impl ReplacedContent {
|
|||
// the largest rectangle that has a 2:1 ratio and fits the device instead.”
|
||||
// “height of the largest rectangle that has a 2:1 ratio, has a height not greater
|
||||
// than 150px, and has a width not greater than the device width.”
|
||||
Vec2::from_physical_size(
|
||||
LogicalVec2::from_physical_size(
|
||||
&PhysicalSize::new(Length::new(300.), Length::new(150.)),
|
||||
mode,
|
||||
)
|
||||
};
|
||||
let clamp = |inline_size: Length, block_size: Length| Vec2 {
|
||||
let clamp = |inline_size: Length, block_size: Length| LogicalVec2 {
|
||||
inline: inline_size.clamp_between_extremums(min_box_size.inline, max_box_size.inline),
|
||||
block: block_size.clamp_between_extremums(min_box_size.block, max_box_size.block),
|
||||
};
|
||||
|
@ -447,27 +446,27 @@ impl ReplacedContent {
|
|||
violation(block_size, min_box_size.block, max_box_size.block),
|
||||
) {
|
||||
// Row 1.
|
||||
(Violation::None, Violation::None) => Vec2 {
|
||||
(Violation::None, Violation::None) => LogicalVec2 {
|
||||
inline: inline_size,
|
||||
block: block_size,
|
||||
},
|
||||
// Row 2.
|
||||
(Violation::Above(max_inline_size), Violation::None) => Vec2 {
|
||||
(Violation::Above(max_inline_size), Violation::None) => LogicalVec2 {
|
||||
inline: max_inline_size,
|
||||
block: (max_inline_size / i_over_b).max(min_box_size.block),
|
||||
},
|
||||
// Row 3.
|
||||
(Violation::Below(min_inline_size), Violation::None) => Vec2 {
|
||||
(Violation::Below(min_inline_size), Violation::None) => LogicalVec2 {
|
||||
inline: min_inline_size,
|
||||
block: (min_inline_size / i_over_b).clamp_below_max(max_box_size.block),
|
||||
},
|
||||
// Row 4.
|
||||
(Violation::None, Violation::Above(max_block_size)) => Vec2 {
|
||||
(Violation::None, Violation::Above(max_block_size)) => LogicalVec2 {
|
||||
inline: (max_block_size * i_over_b).max(min_box_size.inline),
|
||||
block: max_block_size,
|
||||
},
|
||||
// Row 5.
|
||||
(Violation::None, Violation::Below(min_block_size)) => Vec2 {
|
||||
(Violation::None, Violation::Below(min_block_size)) => LogicalVec2 {
|
||||
inline: (min_block_size * i_over_b).clamp_below_max(max_box_size.inline),
|
||||
block: min_block_size,
|
||||
},
|
||||
|
@ -477,13 +476,13 @@ impl ReplacedContent {
|
|||
max_block_size.px() / block_size.px()
|
||||
{
|
||||
// Row 6.
|
||||
Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: max_inline_size,
|
||||
block: (max_inline_size / i_over_b).max(min_box_size.block),
|
||||
}
|
||||
} else {
|
||||
// Row 7.
|
||||
Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: (max_block_size * i_over_b).max(min_box_size.inline),
|
||||
block: max_block_size,
|
||||
}
|
||||
|
@ -495,14 +494,14 @@ impl ReplacedContent {
|
|||
min_block_size.px() / block_size.px()
|
||||
{
|
||||
// Row 8.
|
||||
Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: (min_block_size * i_over_b)
|
||||
.clamp_below_max(max_box_size.inline),
|
||||
block: min_block_size,
|
||||
}
|
||||
} else {
|
||||
// Row 9.
|
||||
Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: min_inline_size,
|
||||
block: (min_inline_size / i_over_b)
|
||||
.clamp_below_max(max_box_size.block),
|
||||
|
@ -510,14 +509,18 @@ impl ReplacedContent {
|
|||
}
|
||||
},
|
||||
// Row 10.
|
||||
(Violation::Below(min_inline_size), Violation::Above(max_block_size)) => Vec2 {
|
||||
inline: min_inline_size,
|
||||
block: max_block_size,
|
||||
(Violation::Below(min_inline_size), Violation::Above(max_block_size)) => {
|
||||
LogicalVec2 {
|
||||
inline: min_inline_size,
|
||||
block: max_block_size,
|
||||
}
|
||||
},
|
||||
// Row 11.
|
||||
(Violation::Above(max_inline_size), Violation::Below(min_block_size)) => Vec2 {
|
||||
inline: max_inline_size,
|
||||
block: min_block_size,
|
||||
(Violation::Above(max_inline_size), Violation::Below(min_block_size)) => {
|
||||
LogicalVec2 {
|
||||
inline: max_inline_size,
|
||||
block: min_block_size,
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
|
|
|
@ -19,7 +19,7 @@ use style::Zero;
|
|||
use webrender_api as wr;
|
||||
|
||||
use crate::geom::{
|
||||
flow_relative, LengthOrAuto, LengthPercentageOrAuto, PhysicalSides, PhysicalSize,
|
||||
LengthOrAuto, LengthPercentageOrAuto, LogicalSides, LogicalVec2, PhysicalSides, PhysicalSize,
|
||||
};
|
||||
use crate::ContainingBlock;
|
||||
|
||||
|
@ -58,21 +58,21 @@ pub(crate) enum DisplayInside {
|
|||
/// Percentages resolved but not `auto` margins
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct PaddingBorderMargin {
|
||||
pub padding: flow_relative::Sides<Length>,
|
||||
pub border: flow_relative::Sides<Length>,
|
||||
pub margin: flow_relative::Sides<LengthOrAuto>,
|
||||
pub padding: LogicalSides<Length>,
|
||||
pub border: LogicalSides<Length>,
|
||||
pub margin: LogicalSides<LengthOrAuto>,
|
||||
|
||||
/// Pre-computed sums in each axis
|
||||
pub padding_border_sums: flow_relative::Vec2<Length>,
|
||||
pub padding_border_sums: LogicalVec2<Length>,
|
||||
}
|
||||
|
||||
impl PaddingBorderMargin {
|
||||
pub(crate) fn zero() -> Self {
|
||||
Self {
|
||||
padding: flow_relative::Sides::zero(),
|
||||
border: flow_relative::Sides::zero(),
|
||||
margin: flow_relative::Sides::zero(),
|
||||
padding_border_sums: flow_relative::Vec2::zero(),
|
||||
padding: LogicalSides::zero(),
|
||||
border: LogicalSides::zero(),
|
||||
margin: LogicalSides::zero(),
|
||||
padding_border_sums: LogicalVec2::zero(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,47 +83,44 @@ pub(crate) trait ComputedValuesExt {
|
|||
fn box_offsets(
|
||||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
) -> flow_relative::Sides<LengthPercentageOrAuto<'_>>;
|
||||
) -> LogicalSides<LengthPercentageOrAuto<'_>>;
|
||||
fn box_size(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> flow_relative::Vec2<LengthPercentageOrAuto<'_>>;
|
||||
) -> LogicalVec2<LengthPercentageOrAuto<'_>>;
|
||||
fn min_box_size(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> flow_relative::Vec2<LengthPercentageOrAuto<'_>>;
|
||||
) -> LogicalVec2<LengthPercentageOrAuto<'_>>;
|
||||
fn max_box_size(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> flow_relative::Vec2<Option<&LengthPercentage>>;
|
||||
) -> LogicalVec2<Option<&LengthPercentage>>;
|
||||
fn content_box_size(
|
||||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
pbm: &PaddingBorderMargin,
|
||||
) -> flow_relative::Vec2<LengthOrAuto>;
|
||||
) -> LogicalVec2<LengthOrAuto>;
|
||||
fn content_min_box_size(
|
||||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
pbm: &PaddingBorderMargin,
|
||||
) -> flow_relative::Vec2<LengthOrAuto>;
|
||||
) -> LogicalVec2<LengthOrAuto>;
|
||||
fn content_max_box_size(
|
||||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
pbm: &PaddingBorderMargin,
|
||||
) -> flow_relative::Vec2<Option<Length>>;
|
||||
) -> LogicalVec2<Option<Length>>;
|
||||
fn padding_border_margin(&self, containing_block: &ContainingBlock) -> PaddingBorderMargin;
|
||||
fn padding(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> flow_relative::Sides<&LengthPercentage>;
|
||||
fn border_width(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> flow_relative::Sides<Length>;
|
||||
) -> LogicalSides<&LengthPercentage>;
|
||||
fn border_width(&self, containing_block_writing_mode: WritingMode) -> LogicalSides<Length>;
|
||||
fn margin(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> flow_relative::Sides<LengthPercentageOrAuto<'_>>;
|
||||
) -> LogicalSides<LengthPercentageOrAuto<'_>>;
|
||||
fn has_transform_or_perspective(&self) -> bool;
|
||||
fn effective_z_index(&self) -> i32;
|
||||
fn establishes_block_formatting_context(&self) -> bool;
|
||||
|
@ -160,9 +157,9 @@ impl ComputedValuesExt for ComputedValues {
|
|||
fn box_offsets(
|
||||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
) -> flow_relative::Sides<LengthPercentageOrAuto<'_>> {
|
||||
) -> LogicalSides<LengthPercentageOrAuto<'_>> {
|
||||
let position = self.get_position();
|
||||
flow_relative::Sides::from_physical(
|
||||
LogicalSides::from_physical(
|
||||
&PhysicalSides::new(
|
||||
position.top.as_ref(),
|
||||
position.right.as_ref(),
|
||||
|
@ -176,9 +173,9 @@ impl ComputedValuesExt for ComputedValues {
|
|||
fn box_size(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> flow_relative::Vec2<LengthPercentageOrAuto<'_>> {
|
||||
) -> LogicalVec2<LengthPercentageOrAuto<'_>> {
|
||||
let position = self.get_position();
|
||||
flow_relative::Vec2::from_physical_size(
|
||||
LogicalVec2::from_physical_size(
|
||||
&PhysicalSize::new(
|
||||
size_to_length(&position.width),
|
||||
size_to_length(&position.height),
|
||||
|
@ -190,9 +187,9 @@ impl ComputedValuesExt for ComputedValues {
|
|||
fn min_box_size(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> flow_relative::Vec2<LengthPercentageOrAuto<'_>> {
|
||||
) -> LogicalVec2<LengthPercentageOrAuto<'_>> {
|
||||
let position = self.get_position();
|
||||
flow_relative::Vec2::from_physical_size(
|
||||
LogicalVec2::from_physical_size(
|
||||
&PhysicalSize::new(
|
||||
size_to_length(&position.min_width),
|
||||
size_to_length(&position.min_height),
|
||||
|
@ -204,7 +201,7 @@ impl ComputedValuesExt for ComputedValues {
|
|||
fn max_box_size(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> flow_relative::Vec2<Option<&LengthPercentage>> {
|
||||
) -> LogicalVec2<Option<&LengthPercentage>> {
|
||||
fn unwrap(max_size: &MaxSize<NonNegativeLengthPercentage>) -> Option<&LengthPercentage> {
|
||||
match max_size {
|
||||
MaxSize::LengthPercentage(length) => Some(&length.0),
|
||||
|
@ -212,7 +209,7 @@ impl ComputedValuesExt for ComputedValues {
|
|||
}
|
||||
}
|
||||
let position = self.get_position();
|
||||
flow_relative::Vec2::from_physical_size(
|
||||
LogicalVec2::from_physical_size(
|
||||
&PhysicalSize::new(unwrap(&position.max_width), unwrap(&position.max_height)),
|
||||
containing_block_writing_mode,
|
||||
)
|
||||
|
@ -222,13 +219,13 @@ impl ComputedValuesExt for ComputedValues {
|
|||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
pbm: &PaddingBorderMargin,
|
||||
) -> flow_relative::Vec2<LengthOrAuto> {
|
||||
) -> LogicalVec2<LengthOrAuto> {
|
||||
let box_size = self
|
||||
.box_size(containing_block.style.writing_mode)
|
||||
.percentages_relative_to(containing_block);
|
||||
match self.get_position().box_sizing {
|
||||
BoxSizing::ContentBox => box_size,
|
||||
BoxSizing::BorderBox => flow_relative::Vec2 {
|
||||
BoxSizing::BorderBox => LogicalVec2 {
|
||||
// These may be negative, but will later be clamped by `min-width`/`min-height`
|
||||
// which is clamped to zero.
|
||||
inline: box_size.inline.map(|i| i - pbm.padding_border_sums.inline),
|
||||
|
@ -241,13 +238,13 @@ impl ComputedValuesExt for ComputedValues {
|
|||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
pbm: &PaddingBorderMargin,
|
||||
) -> flow_relative::Vec2<LengthOrAuto> {
|
||||
) -> LogicalVec2<LengthOrAuto> {
|
||||
let min_box_size = self
|
||||
.min_box_size(containing_block.style.writing_mode)
|
||||
.percentages_relative_to(containing_block);
|
||||
match self.get_position().box_sizing {
|
||||
BoxSizing::ContentBox => min_box_size,
|
||||
BoxSizing::BorderBox => flow_relative::Vec2 {
|
||||
BoxSizing::BorderBox => LogicalVec2 {
|
||||
// Clamp to zero to make sure the used size components are non-negative
|
||||
inline: min_box_size
|
||||
.inline
|
||||
|
@ -263,7 +260,7 @@ impl ComputedValuesExt for ComputedValues {
|
|||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
pbm: &PaddingBorderMargin,
|
||||
) -> flow_relative::Vec2<Option<Length>> {
|
||||
) -> LogicalVec2<Option<Length>> {
|
||||
let max_box_size = self
|
||||
.max_box_size(containing_block.style.writing_mode)
|
||||
.percentages_relative_to(containing_block);
|
||||
|
@ -272,7 +269,7 @@ impl ComputedValuesExt for ComputedValues {
|
|||
BoxSizing::BorderBox => {
|
||||
// This may be negative, but will later be clamped by `min-width`
|
||||
// which itself is clamped to zero.
|
||||
flow_relative::Vec2 {
|
||||
LogicalVec2 {
|
||||
inline: max_box_size
|
||||
.inline
|
||||
.map(|i| i - pbm.padding_border_sums.inline),
|
||||
|
@ -291,7 +288,7 @@ impl ComputedValuesExt for ComputedValues {
|
|||
.percentages_relative_to(cbis);
|
||||
let border = self.border_width(containing_block.style.writing_mode);
|
||||
PaddingBorderMargin {
|
||||
padding_border_sums: flow_relative::Vec2 {
|
||||
padding_border_sums: LogicalVec2 {
|
||||
inline: padding.inline_sum() + border.inline_sum(),
|
||||
block: padding.block_sum() + border.block_sum(),
|
||||
},
|
||||
|
@ -306,9 +303,9 @@ impl ComputedValuesExt for ComputedValues {
|
|||
fn padding(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> flow_relative::Sides<&LengthPercentage> {
|
||||
) -> LogicalSides<&LengthPercentage> {
|
||||
let padding = self.get_padding();
|
||||
flow_relative::Sides::from_physical(
|
||||
LogicalSides::from_physical(
|
||||
&PhysicalSides::new(
|
||||
&padding.padding_top.0,
|
||||
&padding.padding_right.0,
|
||||
|
@ -319,12 +316,9 @@ impl ComputedValuesExt for ComputedValues {
|
|||
)
|
||||
}
|
||||
|
||||
fn border_width(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> flow_relative::Sides<Length> {
|
||||
fn border_width(&self, containing_block_writing_mode: WritingMode) -> LogicalSides<Length> {
|
||||
let border = self.get_border();
|
||||
flow_relative::Sides::from_physical(
|
||||
LogicalSides::from_physical(
|
||||
&PhysicalSides::new(
|
||||
border.border_top_width.0,
|
||||
border.border_right_width.0,
|
||||
|
@ -338,9 +332,9 @@ impl ComputedValuesExt for ComputedValues {
|
|||
fn margin(
|
||||
&self,
|
||||
containing_block_writing_mode: WritingMode,
|
||||
) -> flow_relative::Sides<LengthPercentageOrAuto<'_>> {
|
||||
) -> LogicalSides<LengthPercentageOrAuto<'_>> {
|
||||
let margin = self.get_margin();
|
||||
flow_relative::Sides::from_physical(
|
||||
LogicalSides::from_physical(
|
||||
&PhysicalSides::new(
|
||||
margin.margin_top.as_ref(),
|
||||
margin.margin_right.as_ref(),
|
||||
|
|
|
@ -14,7 +14,7 @@ use layout_2020::flow::float::{
|
|||
ContainingBlockPositionInfo, FloatBand, FloatBandNode, FloatBandTree, FloatContext, FloatSide,
|
||||
PlacementInfo,
|
||||
};
|
||||
use layout_2020::geom::flow_relative::{Rect, Vec2};
|
||||
use layout_2020::geom::{LogicalRect, LogicalVec2};
|
||||
use lazy_static::lazy_static;
|
||||
use quickcheck::{Arbitrary, Gen};
|
||||
use style::values::computed::{Clear, Length};
|
||||
|
@ -352,7 +352,7 @@ impl Arbitrary for FloatInput {
|
|||
let clear = u8::arbitrary(generator);
|
||||
FloatInput {
|
||||
info: PlacementInfo {
|
||||
size: Vec2 {
|
||||
size: LogicalVec2 {
|
||||
inline: Length::new(width as f32),
|
||||
block: Length::new(height as f32),
|
||||
},
|
||||
|
@ -424,7 +424,7 @@ struct FloatPlacement {
|
|||
// Information about the placement of a float.
|
||||
#[derive(Clone)]
|
||||
struct PlacedFloat {
|
||||
origin: Vec2<Length>,
|
||||
origin: LogicalVec2<Length>,
|
||||
info: PlacementInfo,
|
||||
ceiling: Length,
|
||||
containing_block_info: ContainingBlockPositionInfo,
|
||||
|
@ -453,8 +453,8 @@ impl Drop for FloatPlacement {
|
|||
}
|
||||
|
||||
impl PlacedFloat {
|
||||
fn rect(&self) -> Rect<Length> {
|
||||
Rect {
|
||||
fn rect(&self) -> LogicalRect<Length> {
|
||||
LogicalRect {
|
||||
start_corner: self.origin.clone(),
|
||||
size: self.info.size.clone(),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue