mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Remove recursiveness from directionality search
This commit is contained in:
parent
7e2107b1a5
commit
edb940e613
4 changed files with 35 additions and 26 deletions
|
@ -434,16 +434,25 @@ impl Node {
|
|||
}
|
||||
|
||||
pub fn parent_directionality(&self) -> String {
|
||||
match self.GetParentNode() {
|
||||
Some(parent) => {
|
||||
if let Some(parent_html) = parent.downcast::<Element>() {
|
||||
parent_html.directionality()
|
||||
} else {
|
||||
parent.parent_directionality()
|
||||
}
|
||||
},
|
||||
None => "ltr".to_owned(),
|
||||
let mut current = self.GetParentNode();
|
||||
|
||||
loop {
|
||||
match current {
|
||||
Some(parent) => {
|
||||
if let Some(directionality) = parent
|
||||
.downcast::<HTMLElement>()
|
||||
.and_then(|html_element| html_element.directionality())
|
||||
{
|
||||
return directionality;
|
||||
} else {
|
||||
current = parent.GetParentNode();
|
||||
}
|
||||
},
|
||||
None => break,
|
||||
}
|
||||
}
|
||||
|
||||
"ltr".to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue