mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
impl From<&'_ DefiniteContainingBlock> for ContainingBlock
This commit is contained in:
parent
14ddf39215
commit
f09c14aa6b
2 changed files with 19 additions and 15 deletions
|
@ -16,12 +16,12 @@ use crate::positioned::AbsolutelyPositionedBox;
|
|||
use crate::replaced::ReplacedContent;
|
||||
use crate::sizing::ContentSizesRequest;
|
||||
use crate::style_ext::{Display, DisplayGeneratingBox, DisplayInside};
|
||||
use crate::{ContainingBlock, DefiniteContainingBlock};
|
||||
use crate::DefiniteContainingBlock;
|
||||
use rayon::iter::{IntoParallelRefIterator, ParallelExtend, ParallelIterator};
|
||||
use script_layout_interface::wrapper_traits::LayoutNode;
|
||||
use servo_arc::Arc;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{Length, LengthOrAuto};
|
||||
use style::values::computed::Length;
|
||||
use style::Zero;
|
||||
use style_traits::CSSPixel;
|
||||
|
||||
|
@ -99,31 +99,25 @@ impl BoxTreeRoot {
|
|||
viewport: geom::Size<CSSPixel>,
|
||||
) -> FragmentTreeRoot {
|
||||
let style = ComputedValues::initial_values();
|
||||
let initial_containing_block_size = Vec2 {
|
||||
inline: Length::new(viewport.width),
|
||||
block: Length::new(viewport.height),
|
||||
};
|
||||
|
||||
let initial_containing_block = ContainingBlock {
|
||||
inline_size: initial_containing_block_size.inline,
|
||||
block_size: LengthOrAuto::LengthPercentage(initial_containing_block_size.block),
|
||||
let initial_containing_block = DefiniteContainingBlock {
|
||||
size: Vec2 {
|
||||
inline: Length::new(viewport.width),
|
||||
block: Length::new(viewport.height),
|
||||
},
|
||||
// FIXME: use the document’s mode:
|
||||
// https://drafts.csswg.org/css-writing-modes/#principal-flow
|
||||
style,
|
||||
};
|
||||
|
||||
let dummy_tree_rank = 0;
|
||||
let mut absolutely_positioned_fragments = vec![];
|
||||
let mut independent_layout = self.0.layout(
|
||||
layout_context,
|
||||
&initial_containing_block,
|
||||
&(&initial_containing_block).into(),
|
||||
dummy_tree_rank,
|
||||
&mut absolutely_positioned_fragments,
|
||||
);
|
||||
|
||||
let initial_containing_block = DefiniteContainingBlock {
|
||||
size: initial_containing_block_size,
|
||||
style,
|
||||
};
|
||||
independent_layout.fragments.par_extend(
|
||||
absolutely_positioned_fragments
|
||||
.par_iter()
|
||||
|
|
|
@ -44,6 +44,16 @@ struct DefiniteContainingBlock<'a> {
|
|||
style: &'a ComputedValues,
|
||||
}
|
||||
|
||||
impl<'a> From<&'_ DefiniteContainingBlock<'a>> for ContainingBlock<'a> {
|
||||
fn from(definite: &DefiniteContainingBlock<'a>) -> Self {
|
||||
ContainingBlock {
|
||||
inline_size: definite.size.inline,
|
||||
block_size: LengthOrAuto::LengthPercentage(definite.size.block),
|
||||
style: definite.style,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css2/visuren.html#relative-positioning
|
||||
fn relative_adjustement(
|
||||
style: &ComputedValues,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue