aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlelement.rs
diff options
context:
space:
mode:
authorDmitry Kolupaev <dmitry.klpv@gmail.com>2020-02-16 19:14:40 +0300
committerDmitry Kolupaev <dmitry.klpv@gmail.com>2020-02-25 01:18:21 +0300
commitedb940e6139ecf167af1b3191ef4ba03e2f2d43a (patch)
tree8651c2c5a283c7066660f99336700fc1aab89c11 /components/script/dom/htmlelement.rs
parent7e2107b1a583eed1d7cbc87bf3f6a28874a08720 (diff)
downloadservo-edb940e6139ecf167af1b3191ef4ba03e2f2d43a.tar.gz
servo-edb940e6139ecf167af1b3191ef4ba03e2f2d43a.zip
Remove recursiveness from directionality search
Diffstat (limited to 'components/script/dom/htmlelement.rs')
-rw-r--r--components/script/dom/htmlelement.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index 7c2181e2c96..9384fba1472 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -774,17 +774,17 @@ impl HTMLElement {
.count() as u32
}
- pub fn directionality(&self) -> String {
- println!("HTMLElement#directionality");
+ // returns Some if can infer direction by itself or from child nodes
+ // returns None if requires to go up to parent
+ pub fn directionality(&self) -> Option<String> {
let element_direction: &str = &self.Dir();
- println!("HTMLElement#element_direction={}", element_direction);
if element_direction == "ltr" {
- return "ltr".to_owned();
+ return Some("ltr".to_owned());
}
if element_direction == "rtl" {
- return "rtl".to_owned();
+ return Some("rtl".to_owned());
}
if element_direction == "auto" {
@@ -792,11 +792,11 @@ impl HTMLElement {
.downcast::<HTMLInputElement>()
.and_then(|input| input.auto_directionality())
{
- return directionality;
+ return Some(directionality);
}
if let Some(area) = self.downcast::<HTMLTextAreaElement>() {
- return area.auto_directionality();
+ return Some(area.auto_directionality());
}
}
@@ -806,8 +806,7 @@ impl HTMLElement {
// (i.e. it is not present or has an invalid value)
// Requires bdi element implementation (https://html.spec.whatwg.org/multipage/#the-bdi-element)
- let node = self.upcast::<Node>();
- node.parent_directionality()
+ None
}
}