mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue