pub struct WritingModeContext {
pub writing_mode: LayoutWritingMode,
pub direction: StyleDirection,
pub text_orientation: StyleTextOrientation,
}Expand description
Captures the resolved writing mode context for a node.
This struct bundles together all the CSS properties that affect how logical directions (inline/block) map to physical directions (x/y). Spec agents should use this struct to implement writing-mode-aware layout.
§CSS Writing Modes Level 4
writing-modedetermines the block flow direction and inline base directiondirectiondetermines the inline base direction (ltr or rtl)text-orientationdetermines glyph orientation in vertical writing modes
Fields§
§writing_mode: LayoutWritingMode§direction: StyleDirection§text_orientation: StyleTextOrientationImplementations§
Source§impl WritingModeContext
impl WritingModeContext
Sourcepub fn new(
writing_mode: LayoutWritingMode,
direction: StyleDirection,
text_orientation: StyleTextOrientation,
) -> Self
pub fn new( writing_mode: LayoutWritingMode, direction: StyleDirection, text_orientation: StyleTextOrientation, ) -> Self
Constructs a WritingModeContext, applying spec-mandated overrides.
Sourcepub fn used_direction(&self) -> StyleDirection
pub fn used_direction(&self) -> StyleDirection
Returns the used value of direction, accounting for text-orientation: upright
which forces direction to ltr in vertical writing modes per CSS Writing Modes 4 §5.1.
Sourcepub fn is_horizontal(&self) -> bool
pub fn is_horizontal(&self) -> bool
Returns true if the writing mode is horizontal (HorizontalTb).
When true, the inline axis is horizontal and the block axis is vertical.
Sourcepub fn inline_size_is_width(&self) -> bool
pub fn inline_size_is_width(&self) -> bool
Returns true if the inline size corresponds to the physical width.
In horizontal writing modes, inline size = width. In vertical writing modes, inline size = height.
Sourcepub fn block_size_is_height(&self) -> bool
pub fn block_size_is_height(&self) -> bool
Returns true if the block size corresponds to the physical height.
In horizontal writing modes, block size = height. In vertical writing modes, block size = width.
Sourcepub fn is_inline_reversed(&self) -> bool
pub fn is_inline_reversed(&self) -> bool
Returns true if the inline direction is reversed (RTL in horizontal, or bottom-to-top in certain vertical modes).
Trait Implementations§
Source§impl Clone for WritingModeContext
impl Clone for WritingModeContext
Source§fn clone(&self) -> WritingModeContext
fn clone(&self) -> WritingModeContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WritingModeContext
impl Debug for WritingModeContext
Source§impl Default for WritingModeContext
impl Default for WritingModeContext
Source§impl PartialEq for WritingModeContext
impl PartialEq for WritingModeContext
Source§fn eq(&self, other: &WritingModeContext) -> bool
fn eq(&self, other: &WritingModeContext) -> bool
self and other values to be equal, and is used by ==.impl Copy for WritingModeContext
impl Eq for WritingModeContext
impl StructuralPartialEq for WritingModeContext
Auto Trait Implementations§
impl Freeze for WritingModeContext
impl RefUnwindSafe for WritingModeContext
impl Send for WritingModeContext
impl Sync for WritingModeContext
impl Unpin for WritingModeContext
impl UnsafeUnpin for WritingModeContext
impl UnwindSafe for WritingModeContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more