Convert text-orientation to a Gecko-only property

Remove incomplete and buggy support for text-orientation in Servo.
Make the property values align with Gecko and the latest draft of CSS
Writing Modes Level 3.
This commit is contained in:
Matt Brubeck 2017-01-27 17:22:15 -08:00
parent bd72da5f02
commit b3820c1296
9 changed files with 78 additions and 63 deletions

View file

@ -29,7 +29,8 @@ bitflags!(
const FLAG_RTL = 1 << 0,
const FLAG_VERTICAL = 1 << 1,
const FLAG_VERTICAL_LR = 1 << 2,
const FLAG_SIDEWAYS_LEFT = 1 << 3
const FLAG_SIDEWAYS = 1 << 3,
const FLAG_UPRIGHT = 1 << 4,
}
);
@ -48,7 +49,8 @@ impl WritingMode {
/// Assuming .is_vertical(), does the inline direction go top to bottom?
#[inline]
pub fn is_inline_tb(&self) -> bool {
!(self.intersects(FLAG_SIDEWAYS_LEFT) ^ self.intersects(FLAG_RTL))
// https://drafts.csswg.org/css-writing-modes-3/#logical-to-physical
!self.intersects(FLAG_RTL)
}
#[inline]
@ -57,8 +59,13 @@ impl WritingMode {
}
#[inline]
pub fn is_sideways_left(&self) -> bool {
self.intersects(FLAG_SIDEWAYS_LEFT)
pub fn is_sideways(&self) -> bool {
self.intersects(FLAG_SIDEWAYS)
}
#[inline]
pub fn is_upright(&self) -> bool {
self.intersects(FLAG_UPRIGHT)
}
#[inline]
@ -135,8 +142,8 @@ impl fmt::Display for WritingMode {
} else {
try!(write!(formatter, " RL"));
}
if self.intersects(FLAG_SIDEWAYS_LEFT) {
try!(write!(formatter, " SidewaysL"));
if self.intersects(FLAG_SIDEWAYS) {
try!(write!(formatter, " Sideways"));
}
} else {
try!(write!(formatter, "H"));

View file

@ -26,17 +26,42 @@ ${helpers.single_keyword("writing-mode",
${helpers.single_keyword("direction", "ltr rtl", need_clone=True, animatable=False,
spec="https://drafts.csswg.org/css-writing-modes/#propdef-direction")}
// FIXME(SimonSapin): Add 'mixed' and 'upright' (needs vertical text support)
// FIXME(SimonSapin): initial (first) value should be 'mixed', when that's implemented
// FIXME(bholley): sideways-right is needed as an alias to sideways in gecko.
${helpers.single_keyword("text-orientation",
"sideways",
experimental=True,
need_clone=True,
extra_gecko_values="mixed upright",
extra_servo_values="sideways-right sideways-left",
animatable=False,
spec="https://drafts.csswg.org/css-writing-modes/#propdef-text-orientation")}
<%helpers:single_keyword_computed
name="text-orientation"
values="mixed upright sideways"
extra_specified="sideways-right"
products="gecko"
need_clone="True"
animatable="False"
spec="https://drafts.csswg.org/css-writing-modes/#propdef-text-orientation"
>
use values::NoViewportPercentage;
impl NoViewportPercentage for SpecifiedValue {}
impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T;
#[inline]
fn to_computed_value(&self, _: &Context) -> computed_value::T {
match *self {
% for value in "mixed upright sideways".split():
SpecifiedValue::${value} => computed_value::T::${value},
% endfor
// https://drafts.csswg.org/css-writing-modes-3/#valdef-text-orientation-sideways-right
SpecifiedValue::sideways_right => computed_value::T::sideways,
}
}
#[inline]
fn from_computed_value(computed: &computed_value::T) -> SpecifiedValue {
match *computed {
% for value in "mixed upright sideways".split():
computed_value::T::${value} => SpecifiedValue::${value},
% endfor
}
}
}
</%helpers:single_keyword_computed>
// CSS Color Module Level 4
// https://drafts.csswg.org/css-color/

View file

@ -1664,24 +1664,17 @@ pub fn get_writing_mode(inheritedbox_style: &style_structs::InheritedBox) -> Wri
flags.insert(logical_geometry::FLAG_VERTICAL_LR);
},
}
% if product == "gecko":
match inheritedbox_style.clone_text_orientation() {
% if product == "servo":
computed_values::text_orientation::T::sideways_right => {},
computed_values::text_orientation::T::sideways_left => {
flags.insert(logical_geometry::FLAG_VERTICAL_LR);
},
% elif product == "gecko":
// FIXME(bholley): Need to make sure these are correct when we add
// full writing-mode support.
computed_values::text_orientation::T::mixed => {},
computed_values::text_orientation::T::upright => {},
% endif
computed_values::text_orientation::T::upright => {
flags.insert(logical_geometry::FLAG_UPRIGHT);
},
computed_values::text_orientation::T::sideways => {
if flags.intersects(logical_geometry::FLAG_VERTICAL_LR) {
flags.insert(logical_geometry::FLAG_SIDEWAYS_LEFT);
}
flags.insert(logical_geometry::FLAG_SIDEWAYS);
},
}
% endif
flags
}
@ -1915,8 +1908,10 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
PropertyDeclaration::Float(_) |
PropertyDeclaration::TextDecoration${'' if product == 'servo' else 'Line'}(_) |
PropertyDeclaration::WritingMode(_) |
PropertyDeclaration::Direction(_) |
PropertyDeclaration::TextOrientation(_)
PropertyDeclaration::Direction(_)
% if product == 'gecko':
| PropertyDeclaration::TextOrientation(_)
% endif
);
if
% if category_to_cascade_now == "early":

View file

@ -185,7 +185,6 @@ fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> Servo
get_font.font_family, get_font.font_style, get_font.font_variant, get_font.font_weight,
get_font.font_size, get_font.font_stretch,
get_inheritedbox.direction, get_inheritedbox.writing_mode,
get_inheritedbox.text_orientation,
get_text.text_decoration, get_text.unicode_bidi,
get_inheritedtable.empty_cells, get_inheritedtable.caption_side,
get_column.column_width, get_column.column_count