Skip to main content

CSSOMManager

Struct CSSOMManager 

Source
pub struct CSSOMManager { /* private fields */ }
Expand description

CSSOM 管理器

管理多个样式表,并提供与 iris-layout 的集成接口。

§示例

use iris_cssom::bridge::CSSOMManager;

let mut manager = CSSOMManager::new();
manager.add_stylesheet("sheet1");
manager.insert_rule_to_sheet("sheet1", ".class { color: red; }", 0).unwrap();

let stylesheet = manager.get_stylesheet_for_layout("sheet1");
assert!(stylesheet.is_some());

Implementations§

Source§

impl CSSOMManager

Source

pub fn new() -> Self

创建新的 CSSOM 管理器

Source

pub fn add_stylesheet(&mut self, name: &str)

添加样式表

§参数
  • name - 样式表名称(唯一标识)
Source

pub fn add_stylesheet_from_css(&mut self, name: &str, css_text: &str)

从 CSS 文本添加样式表

§参数
  • name - 样式表名称
  • css_text - CSS 文本内容
Source

pub fn get_stylesheet(&self, name: &str) -> Option<Arc<Mutex<CSSStyleSheet>>>

获取样式表

Source

pub fn remove_stylesheet(&mut self, name: &str)

移除样式表

Source

pub fn insert_rule_to_sheet( &mut self, sheet_name: &str, rule: &str, index: usize, ) -> Result<u32, String>

向指定样式表插入规则

§参数
  • sheet_name - 样式表名称
  • rule - CSS 规则文本
  • index - 插入位置
Source

pub fn delete_rule_from_sheet( &mut self, sheet_name: &str, index: usize, ) -> Result<(), String>

从指定样式表删除规则

Source

pub fn get_stylesheet_for_layout(&self, name: &str) -> Option<Stylesheet>

获取用于 iris-layout 的样式表

这将返回 iris-layout 可以使用的内部样式表格式

Source

pub fn get_stylesheet_names(&self) -> Vec<String>

获取所有样式表的名称列表

Source

pub fn stylesheet_count(&self) -> usize

获取样式表数量

Source

pub fn clear_all(&mut self)

清空所有样式表

Trait Implementations§

Source§

impl Debug for CSSOMManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CSSOMManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.