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