gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5364Rust 86Markdown 12TOML 91841 Sutichaykuna

⎇ 7c123d3d5dffec52b7d432cbfdfd2b1ba6354040 src/style/block.rs Rust · 57 siq'ikuna · 1.7 KB Ñawpa willay Pi imata llamkarqan ch'uya

Units trait WIP 7c123d3d5 · Nico Burns ·

1//! Style types for Block layout
2use crate::{CoreStyle, Style};
3
4/// The set of styles required for a Block layout container
5pub trait BlockContainerStyle: CoreStyle {
6    /// Defines which row in the grid the item should start and end at
7    #[inline(always)]
8    fn text_align(&self) -> TextAlign {
9        Style::<Self::Units>::DEFAULT.text_align
10    }
11}
12
13/// The set of styles required for a Block layout item (child of a Block container)
14pub trait BlockItemStyle: CoreStyle {
15    /// Whether the item is a table. Table children are handled specially in block layout.
16    #[inline(always)]
17    fn is_table(&self) -> bool {
18        false
19    }
20
21    /// Whether the item is a floated
22    #[cfg(feature = "float_layout")]
23    #[inline(always)]
24    fn float(&self) -> super::Float {
25        super::Float::None
26    }
27
28    /// Whether the item is a floated
29    #[cfg(feature = "float_layout")]
30    #[inline(always)]
31    fn clear(&self) -> super::Clear {
32        super::Clear::None
33    }
34}
35
36/// Used by block layout to implement the legacy behaviour of `<center>` and `<div align="left | right | center">`
37#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
38#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
39pub enum TextAlign {
40    /// No special legacy text align behaviour.
41    #[default]
42    Auto,
43    /// Corresponds to `-webkit-left` or `-moz-left` in browsers
44    LegacyLeft,
45    /// Corresponds to `-webkit-right` or `-moz-right` in browsers
46    LegacyRight,
47    /// Corresponds to `-webkit-center` or `-moz-center` in browsers
48    LegacyCenter,
49}
50
51#[cfg(feature = "parse")]
52crate::util::parse::impl_parse_for_keyword_enum!(TextAlign,
53    "auto" => Auto,
54    "-webkit-left" => LegacyLeft,
55    "-webkit-right" => LegacyRight,
56    "-webkit-center" => LegacyCenter,
57);