style: Add Gecko-only support for writing-mode:sideways-{lr,rl}.
draft
style: Add Gecko-only support for writing-mode:sideways-{lr,rl}.
Fixes #15213.
MozReview-Commit-ID: 9KLM3BqbMIo
--- a/servo/components/style/logical_geometry.rs
+++ b/servo/components/style/logical_geometry.rs
@@ -24,18 +24,19 @@ pub enum InlineBaseDirection {
// TODO: improve the readability of the WritingMode serialization, refer to the Debug:fmt()
bitflags!(
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Serialize))]
pub flags WritingMode: u8 {
const FLAG_RTL = 1 << 0,
const FLAG_VERTICAL = 1 << 1,
const FLAG_VERTICAL_LR = 1 << 2,
- const FLAG_SIDEWAYS = 1 << 3,
- const FLAG_UPRIGHT = 1 << 4,
+ const FLAG_LINE_INVERTED = 1 << 3,
+ const FLAG_SIDEWAYS = 1 << 4,
+ const FLAG_UPRIGHT = 1 << 5,
}
);
impl WritingMode {
#[inline]
pub fn is_vertical(&self) -> bool {
self.intersects(FLAG_VERTICAL)
}
@@ -45,17 +46,17 @@ impl WritingMode {
pub fn is_vertical_lr(&self) -> bool {
self.intersects(FLAG_VERTICAL_LR)
}
/// Assuming .is_vertical(), does the inline direction go top to bottom?
#[inline]
pub fn is_inline_tb(&self) -> bool {
// https://drafts.csswg.org/css-writing-modes-3/#logical-to-physical
- !self.intersects(FLAG_RTL)
+ self.intersects(FLAG_RTL) == self.intersects(FLAG_LINE_INVERTED)
}
#[inline]
pub fn is_bidi_ltr(&self) -> bool {
!self.intersects(FLAG_RTL)
}
#[inline]
@@ -140,16 +141,19 @@ impl fmt::Display for WritingMode {
if self.is_vertical_lr() {
try!(write!(formatter, " LR"));
} else {
try!(write!(formatter, " RL"));
}
if self.intersects(FLAG_SIDEWAYS) {
try!(write!(formatter, " Sideways"));
}
+ if self.intersects(FLAG_LINE_INVERTED) {
+ try!(write!(formatter, " Inverted"));
+ }
} else {
try!(write!(formatter, "H"));
}
if self.is_bidi_ltr() {
write!(formatter, " LTR")
} else {
write!(formatter, " RTL")
}
--- a/servo/components/style/properties/longhand/inherited_box.mako.rs
+++ b/servo/components/style/properties/longhand/inherited_box.mako.rs
@@ -13,16 +13,17 @@
gecko_ffi_name="mVisible",
animation_type="normal",
spec="https://drafts.csswg.org/css-box/#propdef-visibility")}
// CSS Writing Modes Level 3
// https://drafts.csswg.org/css-writing-modes-3
${helpers.single_keyword("writing-mode",
"horizontal-tb vertical-rl vertical-lr",
+ extra_gecko_values="sideways-rl sideways-lr",
experimental=True,
need_clone=True,
animation_type="none",
spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode")}
${helpers.single_keyword("direction", "ltr rtl", need_clone=True, animation_type="none",
spec="https://drafts.csswg.org/css-writing-modes/#propdef-direction",
needs_conversion=True)}
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -1931,26 +1931,43 @@ pub fn get_writing_mode(inheritedbox_sty
computed_values::writing_mode::T::horizontal_tb => {},
computed_values::writing_mode::T::vertical_rl => {
flags.insert(logical_geometry::FLAG_VERTICAL);
},
computed_values::writing_mode::T::vertical_lr => {
flags.insert(logical_geometry::FLAG_VERTICAL);
flags.insert(logical_geometry::FLAG_VERTICAL_LR);
},
+ % if product == "gecko":
+ computed_values::writing_mode::T::sideways_rl => {
+ flags.insert(logical_geometry::FLAG_VERTICAL);
+ flags.insert(logical_geometry::FLAG_SIDEWAYS);
+ },
+ computed_values::writing_mode::T::sideways_lr => {
+ flags.insert(logical_geometry::FLAG_VERTICAL);
+ flags.insert(logical_geometry::FLAG_VERTICAL_LR);
+ flags.insert(logical_geometry::FLAG_LINE_INVERTED);
+ flags.insert(logical_geometry::FLAG_SIDEWAYS);
+ },
+ % endif
}
% if product == "gecko":
- match inheritedbox_style.clone_text_orientation() {
- computed_values::text_orientation::T::mixed => {},
- computed_values::text_orientation::T::upright => {
- flags.insert(logical_geometry::FLAG_UPRIGHT);
- },
- computed_values::text_orientation::T::sideways => {
- flags.insert(logical_geometry::FLAG_SIDEWAYS);
- },
+ // If FLAG_SIDEWAYS is already set, this means writing-mode is either
+ // sideways-rl or sideways-lr, and for both of these values,
+ // text-orientation has no effect.
+ if !flags.intersects(logical_geometry::FLAG_SIDEWAYS) {
+ match inheritedbox_style.clone_text_orientation() {
+ computed_values::text_orientation::T::mixed => {},
+ computed_values::text_orientation::T::upright => {
+ flags.insert(logical_geometry::FLAG_UPRIGHT);
+ },
+ computed_values::text_orientation::T::sideways => {
+ flags.insert(logical_geometry::FLAG_SIDEWAYS);
+ },
+ }
}
% endif
flags
}
#[cfg(feature = "servo")]
pub use self::lazy_static_module::INITIAL_SERVO_VALUES;