aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/flow/construct.rs
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2020-07-23 18:27:10 +0200
committerSimon Sapin <simon.sapin@exyr.org>2020-07-24 09:31:24 +0200
commitb91e2938194e49dc54cf44de3fa6df661fcb18fd (patch)
tree50d33a6d4933f8bc4264ce4ea39bd1b542c0bf2c /components/layout_2020/flow/construct.rs
parent4a4199c1d64705e8efbe092879ffd914cd8f33fc (diff)
downloadservo-b91e2938194e49dc54cf44de3fa6df661fcb18fd.tar.gz
servo-b91e2938194e49dc54cf44de3fa6df661fcb18fd.zip
Add layout support for list markers
Diffstat (limited to 'components/layout_2020/flow/construct.rs')
-rw-r--r--components/layout_2020/flow/construct.rs47
1 files changed, 45 insertions, 2 deletions
diff --git a/components/layout_2020/flow/construct.rs b/components/layout_2020/flow/construct.rs
index 908119e98d4..00bcfdd2586 100644
--- a/components/layout_2020/flow/construct.rs
+++ b/components/layout_2020/flow/construct.rs
@@ -20,6 +20,7 @@ use rayon_croissant::ParallelIteratorExt;
use servo_arc::Arc;
use std::borrow::Cow;
use std::convert::{TryFrom, TryInto};
+use style::properties::longhands::list_style_position::computed_value::T as ListStylePosition;
use style::properties::ComputedValues;
use style::selector_parser::PseudoElement;
use style::values::specified::text::TextDecorationLine;
@@ -192,7 +193,21 @@ impl BlockContainer {
};
if is_list_item {
- // FIXME: generate a box for the list marker
+ if let Some(marker_contents) = crate::lists::make_marker(context, info) {
+ let _position = info.style.clone_list_style_position();
+ // FIXME: implement support for `outside` and remove this:
+ let position = ListStylePosition::Inside;
+ match position {
+ ListStylePosition::Inside => {
+ builder.handle_list_item_marker_inside(info, marker_contents)
+ },
+ ListStylePosition::Outside => {
+ // FIXME: implement layout for this case
+ // https://github.com/servo/servo/issues/27383
+ // and enable `list-style-position` and the `list-style` shorthand in Stylo.
+ },
+ }
+ }
}
contents.traverse(context, info, &mut builder);
@@ -399,6 +414,29 @@ where
}
}
+ fn handle_list_item_marker_inside(
+ &mut self,
+ info: &NodeAndStyleInfo<Node>,
+ contents: Vec<crate::dom_traversal::PseudoElementContentItem>,
+ ) {
+ let marker_style = self
+ .context
+ .shared_context()
+ .stylist
+ .style_for_anonymous::<Node::ConcreteElement>(
+ &self.context.shared_context().guards,
+ &PseudoElement::ServoText, // FIMXE: use `PseudoElement::Marker` when we add it
+ &info.style,
+ );
+ self.handle_inline_level_element(
+ &info.new_replacing_style(marker_style),
+ DisplayInside::Flow {
+ is_list_item: false,
+ },
+ Contents::OfPseudoElement(contents),
+ );
+ }
+
fn handle_inline_level_element(
&mut self,
info: &NodeAndStyleInfo<Node>,
@@ -420,7 +458,12 @@ where
});
if is_list_item {
- // FIXME: generate a box for the list marker
+ if let Some(marker_contents) = crate::lists::make_marker(self.context, info) {
+ // Ignore `list-style-position` here:
+ // “If the list item is an inline box: this value is equivalent to `inside`.”
+ // https://drafts.csswg.org/css-lists/#list-style-position-outside
+ self.handle_list_item_marker_inside(info, marker_contents)
+ }
}
// `unwrap` doesn’t panic here because `is_replaced` returned `false`.