mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Support css class selection (2)
This commit is contained in:
parent
97b5f5cdd6
commit
8c92b8accd
1 changed files with 21 additions and 1 deletions
|
@ -94,7 +94,27 @@ impl SelectHandler<AbstractNode<LayoutView>> for NodeSelectHandler {
|
||||||
f(element_n.get_attr("class"))
|
f(element_n.get_attr("class"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn node_has_class(&self, node: &AbstractNode<LayoutView>, class: &str) -> bool {
|
||||||
|
if !node.is_element() {
|
||||||
|
fail!(~"attempting to style non-element node");
|
||||||
|
}
|
||||||
|
do node.with_imm_element |element_n| {
|
||||||
|
match element_n.get_attr("class") {
|
||||||
|
None => false,
|
||||||
|
Some(existing_classes) => {
|
||||||
|
let mut ret = false;
|
||||||
|
for str::each_split_char(existing_classes, ' ') |s| {
|
||||||
|
if s == class {
|
||||||
|
ret = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn with_node_id<R>(&self, node: &AbstractNode<LayoutView>, f: &fn(Option<&str>) -> R) -> R {
|
fn with_node_id<R>(&self, node: &AbstractNode<LayoutView>, f: &fn(Option<&str>) -> R) -> R {
|
||||||
if !node.is_element() {
|
if !node.is_element() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue