mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Make a bool for display: list-item
available to flow box construction
This commit is contained in:
parent
9261cf6ead
commit
82e274aec9
5 changed files with 63 additions and 25 deletions
|
@ -219,7 +219,9 @@ fn traverse_pseudo_element_contents<'dom, Node>(
|
|||
});
|
||||
let display_inline = DisplayGeneratingBox::OutsideInside {
|
||||
outside: DisplayOutside::Inline,
|
||||
inside: DisplayInside::Flow,
|
||||
inside: DisplayInside::Flow {
|
||||
is_list_item: false,
|
||||
},
|
||||
};
|
||||
// `display` is not inherited, so we get the initial value
|
||||
debug_assert!(
|
||||
|
|
|
@ -30,12 +30,18 @@ impl BlockFormattingContext {
|
|||
info: &NodeAndStyleInfo<Node>,
|
||||
contents: NonReplacedContents,
|
||||
propagated_text_decoration_line: TextDecorationLine,
|
||||
is_list_item: bool,
|
||||
) -> Self
|
||||
where
|
||||
Node: NodeExt<'dom>,
|
||||
{
|
||||
let (contents, contains_floats) =
|
||||
BlockContainer::construct(context, info, contents, propagated_text_decoration_line);
|
||||
let (contents, contains_floats) = BlockContainer::construct(
|
||||
context,
|
||||
info,
|
||||
contents,
|
||||
propagated_text_decoration_line,
|
||||
is_list_item,
|
||||
);
|
||||
let bfc = Self {
|
||||
contents,
|
||||
contains_floats: contains_floats == ContainsFloats::Yes,
|
||||
|
@ -97,7 +103,11 @@ enum BlockLevelCreator {
|
|||
/// Deferring allows using rayon’s `into_par_iter`.
|
||||
enum IntermediateBlockContainer {
|
||||
InlineFormattingContext(InlineFormattingContext),
|
||||
Deferred(NonReplacedContents, TextDecorationLine),
|
||||
Deferred {
|
||||
contents: NonReplacedContents,
|
||||
propagated_text_decoration_line: TextDecorationLine,
|
||||
is_list_item: bool,
|
||||
},
|
||||
}
|
||||
|
||||
/// A builder for a block container.
|
||||
|
@ -164,6 +174,7 @@ impl BlockContainer {
|
|||
info: &NodeAndStyleInfo<Node>,
|
||||
contents: NonReplacedContents,
|
||||
propagated_text_decoration_line: TextDecorationLine,
|
||||
is_list_item: bool,
|
||||
) -> (BlockContainer, ContainsFloats)
|
||||
where
|
||||
Node: NodeExt<'dom>,
|
||||
|
@ -180,6 +191,10 @@ impl BlockContainer {
|
|||
contains_floats: ContainsFloats::No,
|
||||
};
|
||||
|
||||
if is_list_item {
|
||||
// FIXME: generate a box for the list marker
|
||||
}
|
||||
|
||||
contents.traverse(context, info, &mut builder);
|
||||
|
||||
debug_assert!(builder.ongoing_inline_boxes_stack.is_empty());
|
||||
|
@ -390,7 +405,9 @@ where
|
|||
display_inside: DisplayInside,
|
||||
contents: Contents,
|
||||
) -> ArcRefCell<InlineLevelBox> {
|
||||
let box_ = if display_inside == DisplayInside::Flow && !contents.is_replaced() {
|
||||
let box_ = if let (DisplayInside::Flow { is_list_item }, false) =
|
||||
(display_inside, contents.is_replaced())
|
||||
{
|
||||
// We found un inline box.
|
||||
// Whatever happened before, all we need to do before recurring
|
||||
// is to remember this ongoing inline level box.
|
||||
|
@ -402,6 +419,10 @@ where
|
|||
children: vec![],
|
||||
});
|
||||
|
||||
if is_list_item {
|
||||
// FIXME: generate a box for the list marker
|
||||
}
|
||||
|
||||
// `unwrap` doesn’t panic here because `is_replaced` returned `false`.
|
||||
NonReplacedContents::try_from(contents)
|
||||
.unwrap()
|
||||
|
@ -485,9 +506,15 @@ where
|
|||
|
||||
let kind = match contents.try_into() {
|
||||
Ok(contents) => match display_inside {
|
||||
DisplayInside::Flow => BlockLevelCreator::SameFormattingContextBlock(
|
||||
IntermediateBlockContainer::Deferred(contents, propagated_text_decoration_line),
|
||||
),
|
||||
DisplayInside::Flow { is_list_item } => {
|
||||
BlockLevelCreator::SameFormattingContextBlock(
|
||||
IntermediateBlockContainer::Deferred {
|
||||
contents,
|
||||
propagated_text_decoration_line,
|
||||
is_list_item,
|
||||
},
|
||||
)
|
||||
},
|
||||
_ => BlockLevelCreator::Independent {
|
||||
display_inside,
|
||||
contents: contents.into(),
|
||||
|
@ -695,9 +722,17 @@ impl IntermediateBlockContainer {
|
|||
Node: NodeExt<'dom>,
|
||||
{
|
||||
match self {
|
||||
IntermediateBlockContainer::Deferred(contents, propagated_text_decoration_line) => {
|
||||
BlockContainer::construct(context, info, contents, propagated_text_decoration_line)
|
||||
},
|
||||
IntermediateBlockContainer::Deferred {
|
||||
contents,
|
||||
propagated_text_decoration_line,
|
||||
is_list_item,
|
||||
} => BlockContainer::construct(
|
||||
context,
|
||||
info,
|
||||
contents,
|
||||
propagated_text_decoration_line,
|
||||
is_list_item,
|
||||
),
|
||||
IntermediateBlockContainer::InlineFormattingContext(ifc) => {
|
||||
// If that inline formatting context contained any float, those
|
||||
// were already taken into account during the first phase of
|
||||
|
|
|
@ -71,13 +71,15 @@ impl IndependentFormattingContext {
|
|||
match contents.try_into() {
|
||||
Ok(non_replaced) => {
|
||||
let contents = match display_inside {
|
||||
DisplayInside::Flow | DisplayInside::FlowRoot => {
|
||||
DisplayInside::Flow { is_list_item } |
|
||||
DisplayInside::FlowRoot { is_list_item } => {
|
||||
NonReplacedFormattingContextContents::Flow(
|
||||
BlockFormattingContext::construct(
|
||||
context,
|
||||
info,
|
||||
non_replaced,
|
||||
propagated_text_decoration_line,
|
||||
is_list_item,
|
||||
),
|
||||
)
|
||||
},
|
||||
|
|
|
@ -33,7 +33,6 @@ pub(crate) enum DisplayGeneratingBox {
|
|||
OutsideInside {
|
||||
outside: DisplayOutside,
|
||||
inside: DisplayInside,
|
||||
// list_item: bool,
|
||||
},
|
||||
// Layout-internal display types go here:
|
||||
// https://drafts.csswg.org/css-display-3/#layout-specific-display
|
||||
|
@ -47,8 +46,10 @@ pub(crate) enum DisplayOutside {
|
|||
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
pub(crate) enum DisplayInside {
|
||||
Flow,
|
||||
FlowRoot,
|
||||
// “list-items are limited to the Flow Layout display types”
|
||||
// https://drafts.csswg.org/css-display/#list-items
|
||||
Flow { is_list_item: bool },
|
||||
FlowRoot { is_list_item: bool },
|
||||
Flex,
|
||||
}
|
||||
|
||||
|
@ -444,8 +445,12 @@ impl ComputedValuesExt for ComputedValues {
|
|||
impl From<stylo::Display> for Display {
|
||||
fn from(packed: stylo::Display) -> Self {
|
||||
let inside = match packed.inside() {
|
||||
stylo::DisplayInside::Flow => DisplayInside::Flow,
|
||||
stylo::DisplayInside::FlowRoot => DisplayInside::FlowRoot,
|
||||
stylo::DisplayInside::Flow => DisplayInside::Flow {
|
||||
is_list_item: packed.is_list_item(),
|
||||
},
|
||||
stylo::DisplayInside::FlowRoot => DisplayInside::FlowRoot {
|
||||
is_list_item: packed.is_list_item(),
|
||||
},
|
||||
stylo::DisplayInside::Flex => DisplayInside::Flex,
|
||||
|
||||
// These should not be values of DisplayInside, but oh well
|
||||
|
@ -459,11 +464,7 @@ impl From<stylo::Display> for Display {
|
|||
// This should not be a value of DisplayInside, but oh well
|
||||
stylo::DisplayOutside::None => return Display::None,
|
||||
};
|
||||
Display::GeneratingBox(DisplayGeneratingBox::OutsideInside {
|
||||
outside,
|
||||
inside,
|
||||
// list_item: packed.is_list_item(),
|
||||
})
|
||||
Display::GeneratingBox(DisplayGeneratingBox::OutsideInside { outside, inside })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -520,9 +520,7 @@ fn is_valid_inside_for_list_item<'i>(inside: &Result<DisplayInside, ParseError<'
|
|||
|
||||
/// Parse `list-item`.
|
||||
fn parse_list_item<'i, 't>(input: &mut Parser<'i, 't>) -> Result<(), ParseError<'i>> {
|
||||
Ok(try_match_ident_ignore_ascii_case! { input,
|
||||
"list-item" => (),
|
||||
})
|
||||
Ok(input.expect_ident_matching("list-item")?)
|
||||
}
|
||||
|
||||
impl Parse for Display {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue