mirror of
https://github.com/servo/servo.git
synced 2025-07-23 23:33:43 +01:00
Containing blocks contains styles rather than just a writing mode
This commit is contained in:
parent
40ad9a722d
commit
fa1adf2ad3
6 changed files with 31 additions and 25 deletions
|
@ -69,7 +69,7 @@ struct PartialInlineBoxFragment<'box_tree> {
|
|||
|
||||
struct InlineFormattingContextState<'box_tree, 'a> {
|
||||
absolutely_positioned_fragments: &'a mut Vec<AbsolutelyPositionedFragment<'box_tree>>,
|
||||
containing_block: &'a ContainingBlock,
|
||||
containing_block: &'a ContainingBlock<'a>,
|
||||
line_boxes: LinesBoxes,
|
||||
inline_position: Length,
|
||||
partial_inline_boxes_stack: Vec<PartialInlineBoxFragment<'box_tree>>,
|
||||
|
@ -292,7 +292,7 @@ impl LinesBoxes {
|
|||
self.boxes.push(Fragment::Anonymous(AnonymousFragment {
|
||||
children: std::mem::take(&mut top_nesting_level.fragments_so_far),
|
||||
rect: Rect { start_corner, size },
|
||||
mode: containing_block.mode,
|
||||
mode: containing_block.style.writing_mode,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
@ -446,10 +446,11 @@ fn layout_atomic<'box_tree>(
|
|||
let containing_block_for_children = ContainingBlock {
|
||||
inline_size,
|
||||
block_size,
|
||||
mode: atomic.style.writing_mode,
|
||||
style: &atomic.style,
|
||||
};
|
||||
assert_eq!(
|
||||
ifc.containing_block.mode, containing_block_for_children.mode,
|
||||
ifc.containing_block.style.writing_mode,
|
||||
containing_block_for_children.style.writing_mode,
|
||||
"Mixed writing modes are not supported yet"
|
||||
);
|
||||
// FIXME is this correct?
|
||||
|
|
|
@ -324,11 +324,15 @@ impl BlockLevelBox {
|
|||
},
|
||||
BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(box_) => {
|
||||
absolutely_positioned_fragments.push(box_.layout(Vec2::zero(), tree_rank));
|
||||
Fragment::Anonymous(AnonymousFragment::no_op(containing_block.mode))
|
||||
Fragment::Anonymous(AnonymousFragment::no_op(
|
||||
containing_block.style.writing_mode,
|
||||
))
|
||||
},
|
||||
BlockLevelBox::OutOfFlowFloatBox(_box_) => {
|
||||
// TODO
|
||||
Fragment::Anonymous(AnonymousFragment::no_op(containing_block.mode))
|
||||
Fragment::Anonymous(AnonymousFragment::no_op(
|
||||
containing_block.style.writing_mode,
|
||||
))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -413,11 +417,11 @@ fn layout_in_flow_non_replaced_block_level<'a>(
|
|||
let containing_block_for_children = ContainingBlock {
|
||||
inline_size,
|
||||
block_size,
|
||||
mode: style.writing_mode,
|
||||
style,
|
||||
};
|
||||
// https://drafts.csswg.org/css-writing-modes/#orthogonal-flows
|
||||
assert_eq!(
|
||||
containing_block.mode, containing_block_for_children.mode,
|
||||
containing_block.style.writing_mode, containing_block_for_children.style.writing_mode,
|
||||
"Mixed writing modes are not supported yet"
|
||||
);
|
||||
|
||||
|
@ -494,7 +498,7 @@ fn layout_in_flow_non_replaced_block_level<'a>(
|
|||
&mut flow_layout.fragments,
|
||||
&content_rect.size,
|
||||
&padding,
|
||||
containing_block_for_children.mode,
|
||||
style,
|
||||
)
|
||||
}
|
||||
BoxFragment {
|
||||
|
|
|
@ -20,7 +20,7 @@ use crate::{ContainingBlock, DefiniteContainingBlock};
|
|||
use rayon::iter::{IntoParallelRefIterator, ParallelExtend, ParallelIterator};
|
||||
use script_layout_interface::wrapper_traits::LayoutNode;
|
||||
use servo_arc::Arc;
|
||||
use style::logical_geometry::WritingMode;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{Length, LengthOrAuto};
|
||||
use style::Zero;
|
||||
use style_traits::CSSPixel;
|
||||
|
@ -98,6 +98,7 @@ impl BoxTreeRoot {
|
|||
layout_context: &LayoutContext,
|
||||
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),
|
||||
|
@ -108,7 +109,7 @@ impl BoxTreeRoot {
|
|||
block_size: LengthOrAuto::LengthPercentage(initial_containing_block_size.block),
|
||||
// FIXME: use the document’s mode:
|
||||
// https://drafts.csswg.org/css-writing-modes/#principal-flow
|
||||
mode: WritingMode::empty(),
|
||||
style,
|
||||
};
|
||||
let dummy_tree_rank = 0;
|
||||
let mut absolutely_positioned_fragments = vec![];
|
||||
|
@ -121,7 +122,7 @@ impl BoxTreeRoot {
|
|||
|
||||
let initial_containing_block = DefiniteContainingBlock {
|
||||
size: initial_containing_block_size,
|
||||
mode: initial_containing_block.mode,
|
||||
style,
|
||||
};
|
||||
independent_layout.fragments.par_extend(
|
||||
absolutely_positioned_fragments
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
use std::fmt;
|
||||
use std::ops::{Add, AddAssign, Sub};
|
||||
use style::logical_geometry::{BlockFlowDirection, InlineBaseDirection, PhysicalCorner, WritingMode};
|
||||
use style::logical_geometry::{BlockFlowDirection, InlineBaseDirection};
|
||||
use style::logical_geometry::{PhysicalCorner, WritingMode};
|
||||
use style::values::computed::{Length, LengthOrAuto, LengthPercentage, LengthPercentageOrAuto};
|
||||
use style::Zero;
|
||||
use style_traits::CSSPixel;
|
||||
|
|
|
@ -29,20 +29,19 @@ pub use flow::{BoxTreeRoot, FragmentTreeRoot};
|
|||
use crate::geom::flow_relative::Vec2;
|
||||
use crate::style_ext::ComputedValuesExt;
|
||||
use style::computed_values::position::T as Position;
|
||||
use style::logical_geometry::WritingMode;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{Length, LengthOrAuto};
|
||||
use style::Zero;
|
||||
|
||||
struct ContainingBlock {
|
||||
struct ContainingBlock<'a> {
|
||||
inline_size: Length,
|
||||
block_size: LengthOrAuto,
|
||||
mode: WritingMode,
|
||||
style: &'a ComputedValues,
|
||||
}
|
||||
|
||||
struct DefiniteContainingBlock {
|
||||
struct DefiniteContainingBlock<'a> {
|
||||
size: Vec2<Length>,
|
||||
mode: WritingMode,
|
||||
style: &'a ComputedValues,
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css2/visuren.html#relative-positioning
|
||||
|
|
|
@ -12,7 +12,6 @@ use crate::style_ext::{ComputedValuesExt, DisplayInside};
|
|||
use crate::{ContainingBlock, DefiniteContainingBlock};
|
||||
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
||||
use servo_arc::Arc;
|
||||
use style::logical_geometry::WritingMode;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{Length, LengthOrAuto, LengthPercentage, LengthPercentageOrAuto};
|
||||
use style::Zero;
|
||||
|
@ -129,7 +128,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
|||
fragments: &mut Vec<Fragment>,
|
||||
content_rect_size: &Vec2<Length>,
|
||||
padding: &Sides<Length>,
|
||||
mode: WritingMode,
|
||||
style: &ComputedValues,
|
||||
) {
|
||||
if absolute.is_empty() {
|
||||
return;
|
||||
|
@ -142,7 +141,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
|||
.inflate(&padding);
|
||||
let containing_block = DefiniteContainingBlock {
|
||||
size: padding_rect.size.clone(),
|
||||
mode,
|
||||
style,
|
||||
};
|
||||
fragments.push(Fragment::Anonymous(AnonymousFragment {
|
||||
children: absolute
|
||||
|
@ -150,7 +149,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
|||
.map(|a| a.layout(layout_context, &containing_block))
|
||||
.collect(),
|
||||
rect: padding_rect,
|
||||
mode,
|
||||
mode: style.writing_mode,
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -325,11 +324,12 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
|||
let containing_block_for_children = ContainingBlock {
|
||||
inline_size,
|
||||
block_size,
|
||||
mode: style.writing_mode,
|
||||
style,
|
||||
};
|
||||
// https://drafts.csswg.org/css-writing-modes/#orthogonal-flows
|
||||
assert_eq!(
|
||||
containing_block.mode, containing_block_for_children.mode,
|
||||
containing_block.style.writing_mode,
|
||||
containing_block_for_children.style.writing_mode,
|
||||
"Mixed writing modes are not supported yet"
|
||||
);
|
||||
let dummy_tree_rank = 0;
|
||||
|
@ -370,7 +370,7 @@ impl<'a> AbsolutelyPositionedFragment<'a> {
|
|||
&mut independent_layout.fragments,
|
||||
&content_rect.size,
|
||||
&padding,
|
||||
style.writing_mode,
|
||||
style,
|
||||
);
|
||||
|
||||
Fragment::Box(BoxFragment {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue