styling: added preliminary styling application
This commit is contained in:
29
src/dom.rs
29
src/dom.rs
@@ -1,4 +1,4 @@
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap,HashSet};
|
||||
use std;
|
||||
|
||||
use css;
|
||||
@@ -7,17 +7,30 @@ pub struct Attr {
|
||||
attrs: HashMap<String, String>,
|
||||
}
|
||||
|
||||
struct EData {
|
||||
name: String,
|
||||
attr: Attr,
|
||||
pub struct EData {
|
||||
pub name: String,
|
||||
pub attr: Attr,
|
||||
}
|
||||
|
||||
struct SData {
|
||||
impl EData {
|
||||
pub fn id(&self) -> Option<&String> {
|
||||
self.attr.attrs.get("id")
|
||||
}
|
||||
|
||||
pub fn classes(&self) -> HashSet<&str> {
|
||||
match self.attr.attrs.get("class") {
|
||||
Some(classlist) => classlist.split(' ').collect(),
|
||||
None => HashSet::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SData {
|
||||
attr: Attr,
|
||||
content: css::Stylesheet,
|
||||
}
|
||||
|
||||
enum NType {
|
||||
pub enum NType {
|
||||
Text(String),
|
||||
Comment(String),
|
||||
Element(EData),
|
||||
@@ -25,8 +38,8 @@ enum NType {
|
||||
}
|
||||
|
||||
pub struct Node {
|
||||
children: Vec<Node>,
|
||||
ntype: NType,
|
||||
pub children: Vec<Node>,
|
||||
pub ntype: NType,
|
||||
}
|
||||
|
||||
pub fn text(d: String) -> Node {
|
||||
|
Reference in New Issue
Block a user