tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 238Markdown 7TOML 31453 Definiciones

⎇ 7e8d5b1d733ed84c0db8e8d359f84df371bdaadc src/style/block.rs Rust · 49 líneas · 1.5 KB Historia Quién tocó qué crudo

Implement Floats (#866) 25759dad4 · 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::CustomIdent>::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}