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:
Martin Robinson 2023-09-12 09:31:30 +02:00 committed by GitHub
parent 90ad5920e2
commit 8299868bd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 314 additions and 317 deletions

View file

@ -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 blocks 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)
}

View file

@ -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),

View file

@ -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);
}