mirror of
https://github.com/servo/servo.git
synced 2025-08-12 00:45:33 +01:00
Layout 2020: Move all Fragment code to the fragment_tree
directory
This is a simple code organization change with no behavior change with the idea of making Layout 2020 easier to understand by new folks to the project. The idea is that we will have a cleaner separation between the different parts of layout ie one directory for the fragment tree and one (currently multiple) directory for the box tree.
This commit is contained in:
parent
f26d17096d
commit
e563927718
20 changed files with 592 additions and 558 deletions
|
@ -7,7 +7,9 @@ use crate::context::LayoutContext;
|
|||
use crate::dom::NodeExt;
|
||||
use crate::dom_traversal::{Contents, NodeAndStyleInfo};
|
||||
use crate::formatting_contexts::IndependentFormattingContext;
|
||||
use crate::fragments::{BoxFragment, CollapsedBlockMargins, Fragment};
|
||||
use crate::fragment_tree::{
|
||||
AbsoluteBoxOffsets, BoxFragment, CollapsedBlockMargins, Fragment, HoistedSharedFragment,
|
||||
};
|
||||
use crate::geom::flow_relative::{Rect, Sides, Vec2};
|
||||
use crate::geom::{LengthOrAuto, LengthPercentageOrAuto};
|
||||
use crate::style_ext::{ComputedValuesExt, DisplayInside};
|
||||
|
@ -16,7 +18,7 @@ use rayon::iter::{IntoParallelRefMutIterator, ParallelExtend};
|
|||
use rayon_croissant::ParallelIteratorExt;
|
||||
use style::computed_values::position::T as Position;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{CSSPixelLength, Length, LengthPercentage};
|
||||
use style::values::computed::{CSSPixelLength, Length};
|
||||
use style::values::specified::text::TextDecorationLine;
|
||||
use style::Zero;
|
||||
|
||||
|
@ -48,67 +50,6 @@ pub(crate) struct HoistedAbsolutelyPositionedBox {
|
|||
pub fragment: ArcRefCell<HoistedSharedFragment>,
|
||||
}
|
||||
|
||||
/// A reference to a Fragment which is shared between `HoistedAbsolutelyPositionedBox`
|
||||
/// and its placeholder `AbsoluteOrFixedPositionedFragment` in the original tree position.
|
||||
/// This will be used later in order to paint this hoisted box in tree order.
|
||||
#[derive(Serialize)]
|
||||
pub(crate) struct HoistedSharedFragment {
|
||||
pub(crate) fragment: Option<ArcRefCell<Fragment>>,
|
||||
pub(crate) box_offsets: Vec2<AbsoluteBoxOffsets>,
|
||||
}
|
||||
|
||||
impl HoistedSharedFragment {
|
||||
pub(crate) fn new(box_offsets: Vec2<AbsoluteBoxOffsets>) -> Self {
|
||||
HoistedSharedFragment {
|
||||
fragment: None,
|
||||
box_offsets,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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>) {
|
||||
self.box_offsets.inline.adjust_offset(offsets.inline);
|
||||
self.box_offsets.block.adjust_offset(offsets.block);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub(crate) enum AbsoluteBoxOffsets {
|
||||
StaticStart {
|
||||
start: Length,
|
||||
},
|
||||
Start {
|
||||
start: LengthPercentage,
|
||||
},
|
||||
End {
|
||||
end: LengthPercentage,
|
||||
},
|
||||
Both {
|
||||
start: LengthPercentage,
|
||||
end: LengthPercentage,
|
||||
},
|
||||
}
|
||||
|
||||
impl AbsoluteBoxOffsets {
|
||||
fn both_specified(&self) -> bool {
|
||||
match self {
|
||||
AbsoluteBoxOffsets::Both { .. } => return true,
|
||||
_ => return false,
|
||||
}
|
||||
}
|
||||
|
||||
fn adjust_offset(&mut self, new_offset: Length) {
|
||||
match *self {
|
||||
AbsoluteBoxOffsets::StaticStart { ref mut start } => *start = new_offset,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AbsolutelyPositionedBox {
|
||||
pub fn construct<'dom>(
|
||||
context: &LayoutContext,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue