mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Split SIDEWAYS bit in WritingMode.
Currently, there's no way to tell whether the SIDEWAYS bit is set from `writing-mode:sideways-*` or `writing-mode:vertical-*; text-orientation:sideways;`. To be able to tell them apart, split SIDEWAYS bits into VERTICAL_SIDEWAYS and TEXT_SIDEWAYS. This is needed by my proposed solution in bug 1102175. Also, provide convenience methods related to sideways writing-mode, and replace obscure checks in the codebase. Note that we don't have the use cases to distinguish vertical-rl from sideways-rl in layout, but for the completeness, IsSidewaysLR() is still defined. Differential Revision: https://phabricator.services.mozilla.com/D46321
This commit is contained in:
parent
c92d1f6b9c
commit
0138fc3707
1 changed files with 16 additions and 10 deletions
|
@ -50,16 +50,22 @@ bitflags!(
|
|||
const LINE_INVERTED = 1 << 3;
|
||||
/// direction is rtl.
|
||||
const RTL = 1 << 4;
|
||||
/// Horizontal text within a vertical writing mode is displayed sideways
|
||||
/// All text within a vertical writing mode is displayed sideways
|
||||
/// and runs top-to-bottom or bottom-to-top; set in these cases:
|
||||
///
|
||||
/// * writing-mode: vertical-rl; text-orientation: sideways;
|
||||
/// * writing-mode: vertical-lr; text-orientation: sideways;
|
||||
/// * writing-mode: sideways-rl;
|
||||
/// * writing-mode: sideways-lr;
|
||||
///
|
||||
/// Never set without VERTICAL.
|
||||
const SIDEWAYS = 1 << 5;
|
||||
const VERTICAL_SIDEWAYS = 1 << 5;
|
||||
/// Similar to VERTICAL_SIDEWAYS, but is set via text-orientation;
|
||||
/// set in these cases:
|
||||
///
|
||||
/// * writing-mode: vertical-rl; text-orientation: sideways;
|
||||
/// * writing-mode: vertical-lr; text-orientation: sideways;
|
||||
///
|
||||
/// Never set without VERTICAL.
|
||||
const TEXT_SIDEWAYS = 1 << 6;
|
||||
/// Horizontal text within a vertical writing mode is displayed with each
|
||||
/// glyph upright; set in these cases:
|
||||
///
|
||||
|
@ -67,7 +73,7 @@ bitflags!(
|
|||
/// * writing-mode: vertical-lr: text-orientation: upright;
|
||||
///
|
||||
/// Never set without VERTICAL.
|
||||
const UPRIGHT = 1 << 6;
|
||||
const UPRIGHT = 1 << 7;
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -112,7 +118,7 @@ impl WritingMode {
|
|||
#[cfg(feature = "gecko")]
|
||||
SpecifiedWritingMode::SidewaysRl => {
|
||||
flags.insert(WritingMode::VERTICAL);
|
||||
flags.insert(WritingMode::SIDEWAYS);
|
||||
flags.insert(WritingMode::VERTICAL_SIDEWAYS);
|
||||
if direction == Direction::Rtl {
|
||||
flags.insert(WritingMode::INLINE_REVERSED);
|
||||
}
|
||||
|
@ -121,7 +127,7 @@ impl WritingMode {
|
|||
SpecifiedWritingMode::SidewaysLr => {
|
||||
flags.insert(WritingMode::VERTICAL);
|
||||
flags.insert(WritingMode::VERTICAL_LR);
|
||||
flags.insert(WritingMode::SIDEWAYS);
|
||||
flags.insert(WritingMode::VERTICAL_SIDEWAYS);
|
||||
if direction == Direction::Ltr {
|
||||
flags.insert(WritingMode::INLINE_REVERSED);
|
||||
}
|
||||
|
@ -151,7 +157,7 @@ impl WritingMode {
|
|||
flags.remove(WritingMode::INLINE_REVERSED);
|
||||
},
|
||||
TextOrientation::Sideways => {
|
||||
flags.insert(WritingMode::SIDEWAYS);
|
||||
flags.insert(WritingMode::TEXT_SIDEWAYS);
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -187,7 +193,7 @@ impl WritingMode {
|
|||
|
||||
#[inline]
|
||||
pub fn is_sideways(&self) -> bool {
|
||||
self.intersects(WritingMode::SIDEWAYS)
|
||||
self.intersects(WritingMode::VERTICAL_SIDEWAYS | WritingMode::TEXT_SIDEWAYS)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -325,7 +331,7 @@ impl fmt::Display for WritingMode {
|
|||
} else {
|
||||
write!(formatter, " RL")?;
|
||||
}
|
||||
if self.intersects(WritingMode::SIDEWAYS) {
|
||||
if self.is_sideways() {
|
||||
write!(formatter, " Sideways")?;
|
||||
}
|
||||
if self.intersects(WritingMode::LINE_INVERTED) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue