Implement text-align (except justify)

This commit is contained in:
Simon Sapin 2019-12-07 14:08:11 +01:00
parent 6d91d77fba
commit 9f4b1a0f14
5 changed files with 84 additions and 13 deletions

View file

@ -206,6 +206,20 @@ impl WritingMode {
self.intersects(WritingMode::UPRIGHT)
}
/// https://drafts.csswg.org/css-writing-modes/#logical-to-physical
///
/// | Return | line-left is… | line-right is… |
/// |---------|---------------|----------------|
/// | `true` | inline-start | inline-end |
/// | `false` | inline-end | inline-start |
#[inline]
pub fn line_left_is_inline_start(&self) -> bool {
// https://drafts.csswg.org/css-writing-modes/#inline-start
// “For boxes with a used direction value of ltr, this means the line-left side.
// For boxes with a used direction value of rtl, this means the line-right side.”
self.is_bidi_ltr()
}
#[inline]
pub fn inline_start_physical_side(&self) -> PhysicalSide {
match (self.is_vertical(), self.is_inline_tb(), self.is_bidi_ltr()) {

View file

@ -156,7 +156,6 @@ ${helpers.predefined_type(
"TextAlign",
"computed::TextAlign::Start",
engines="gecko servo-2013 servo-2020",
servo_2020_pref="layout.2020.unimplemented",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text/#propdef-text-align",
servo_restyle_damage = "reflow",

View file

@ -544,6 +544,7 @@ pub enum TextAlignKeyword {
Left,
Right,
Center,
#[cfg(any(feature = "gecko", feature = "servo-layout-2013"))]
Justify,
#[cfg(feature = "gecko")]
MozCenter,
@ -551,11 +552,11 @@ pub enum TextAlignKeyword {
MozLeft,
#[cfg(feature = "gecko")]
MozRight,
#[cfg(feature = "servo")]
#[cfg(feature = "servo-layout-2013")]
ServoCenter,
#[cfg(feature = "servo")]
#[cfg(feature = "servo-layout-2013")]
ServoLeft,
#[cfg(feature = "servo")]
#[cfg(feature = "servo-layout-2013")]
ServoRight,
#[css(skip)]
#[cfg(feature = "gecko")]