mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +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
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue