mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +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 }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue