aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmltableelement.rs
diff options
context:
space:
mode:
authorAnthony Ramine <nox@nox.paris>2020-03-31 18:46:49 +0200
committerAnthony Ramine <nox@nox.paris>2020-03-31 18:46:49 +0200
commit5ff931d1717ac0e7a6e5d9d63f0cfa47c1f3cd50 (patch)
tree920e4e9ef442fa5091834d70f31086c3ccfcf21f /components/script/dom/htmltableelement.rs
parent0bda1748230b4d54c274a014d770daf461fec50f (diff)
downloadservo-5ff931d1717ac0e7a6e5d9d63f0cfa47c1f3cd50.tar.gz
servo-5ff931d1717ac0e7a6e5d9d63f0cfa47c1f3cd50.zip
Introduce <LayoutDom<Element>>::attrs()
This safe method is the basic block to access element attributes from layout. We reuse it in the other attr-related layout methods to remove a pretty big source of rampant unsafe code between script and layout.
Diffstat (limited to 'components/script/dom/htmltableelement.rs')
-rw-r--r--components/script/dom/htmltableelement.rs24
1 files changed, 9 insertions, 15 deletions
diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs
index 6f19fe0f909..f42e72b5247 100644
--- a/components/script/dom/htmltableelement.rs
+++ b/components/script/dom/htmltableelement.rs
@@ -413,14 +413,11 @@ pub trait HTMLTableElementLayoutHelpers {
}
impl HTMLTableElementLayoutHelpers for LayoutDom<'_, HTMLTableElement> {
- #[allow(unsafe_code)]
fn get_background_color(self) -> Option<RGBA> {
- unsafe {
- self.upcast::<Element>()
- .get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
- .and_then(AttrValue::as_color)
- .cloned()
- }
+ self.upcast::<Element>()
+ .get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
+ .and_then(AttrValue::as_color)
+ .cloned()
}
#[allow(unsafe_code)]
@@ -433,15 +430,12 @@ impl HTMLTableElementLayoutHelpers for LayoutDom<'_, HTMLTableElement> {
unsafe { (*self.unsafe_get()).cellspacing.get() }
}
- #[allow(unsafe_code)]
fn get_width(self) -> LengthOrPercentageOrAuto {
- unsafe {
- self.upcast::<Element>()
- .get_attr_for_layout(&ns!(), &local_name!("width"))
- .map(AttrValue::as_dimension)
- .cloned()
- .unwrap_or(LengthOrPercentageOrAuto::Auto)
- }
+ self.upcast::<Element>()
+ .get_attr_for_layout(&ns!(), &local_name!("width"))
+ .map(AttrValue::as_dimension)
+ .cloned()
+ .unwrap_or(LengthOrPercentageOrAuto::Auto)
}
}