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