aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlhrelement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/htmlhrelement.rs')
-rw-r--r--components/script/dom/htmlhrelement.rs91
1 files changed, 47 insertions, 44 deletions
diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs
index f1d5774dbe9..69fa8887bb1 100644
--- a/components/script/dom/htmlhrelement.rs
+++ b/components/script/dom/htmlhrelement.rs
@@ -1,19 +1,19 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use crate::dom::bindings::codegen::Bindings::HTMLHRElementBinding::HTMLHRElementMethods;
+use crate::dom::bindings::inheritance::Castable;
+use crate::dom::bindings::root::{DomRoot, LayoutDom};
+use crate::dom::bindings::str::DOMString;
+use crate::dom::document::Document;
+use crate::dom::element::{Element, LayoutElementHelpers};
+use crate::dom::htmlelement::HTMLElement;
+use crate::dom::node::Node;
+use crate::dom::virtualmethods::VirtualMethods;
use cssparser::RGBA;
-use dom::bindings::codegen::Bindings::HTMLHRElementBinding::{self, HTMLHRElementMethods};
-use dom::bindings::inheritance::Castable;
-use dom::bindings::js::{LayoutJS, Root};
-use dom::bindings::str::DOMString;
-use dom::document::Document;
-use dom::element::{Element, RawLayoutElementHelpers};
-use dom::htmlelement::HTMLElement;
-use dom::node::Node;
-use dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
-use html5ever_atoms::LocalName;
+use html5ever::{LocalName, Prefix};
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
#[dom_struct]
@@ -22,19 +22,26 @@ pub struct HTMLHRElement {
}
impl HTMLHRElement {
- fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLHRElement {
+ fn new_inherited(
+ local_name: LocalName,
+ prefix: Option<Prefix>,
+ document: &Document,
+ ) -> HTMLHRElement {
HTMLHRElement {
- htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
+ htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
}
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: LocalName,
- prefix: Option<DOMString>,
- document: &Document) -> Root<HTMLHRElement> {
- Node::reflect_node(box HTMLHRElement::new_inherited(local_name, prefix, document),
- document,
- HTMLHRElementBinding::Wrap)
+ pub fn new(
+ local_name: LocalName,
+ prefix: Option<Prefix>,
+ document: &Document,
+ ) -> DomRoot<HTMLHRElement> {
+ Node::reflect_node(
+ Box::new(HTMLHRElement::new_inherited(local_name, prefix, document)),
+ document,
+ )
}
}
@@ -59,37 +66,30 @@ impl HTMLHRElementMethods for HTMLHRElement {
}
pub trait HTMLHRLayoutHelpers {
- fn get_color(&self) -> Option<RGBA>;
- fn get_width(&self) -> LengthOrPercentageOrAuto;
+ fn get_color(self) -> Option<RGBA>;
+ fn get_width(self) -> LengthOrPercentageOrAuto;
}
-impl HTMLHRLayoutHelpers for LayoutJS<HTMLHRElement> {
- #[allow(unsafe_code)]
- fn get_color(&self) -> Option<RGBA> {
- unsafe {
- (&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &local_name!("color"))
- .and_then(AttrValue::as_color)
- .cloned()
- }
+impl HTMLHRLayoutHelpers for LayoutDom<'_, HTMLHRElement> {
+ fn get_color(self) -> Option<RGBA> {
+ self.upcast::<Element>()
+ .get_attr_for_layout(&ns!(), &local_name!("color"))
+ .and_then(AttrValue::as_color)
+ .cloned()
}
- #[allow(unsafe_code)]
- fn get_width(&self) -> LengthOrPercentageOrAuto {
- unsafe {
- (&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &local_name!("width"))
- .map(AttrValue::as_dimension)
- .cloned()
- .unwrap_or(LengthOrPercentageOrAuto::Auto)
- }
+ fn get_width(self) -> LengthOrPercentageOrAuto {
+ self.upcast::<Element>()
+ .get_attr_for_layout(&ns!(), &local_name!("width"))
+ .map(AttrValue::as_dimension)
+ .cloned()
+ .unwrap_or(LengthOrPercentageOrAuto::Auto)
}
}
-
impl VirtualMethods for HTMLHRElement {
- fn super_type(&self) -> Option<&VirtualMethods> {
- Some(self.upcast::<HTMLElement>() as &VirtualMethods)
+ fn super_type(&self) -> Option<&dyn VirtualMethods> {
+ Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods)
}
fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
@@ -97,7 +97,10 @@ impl VirtualMethods for HTMLHRElement {
&local_name!("align") => AttrValue::from_dimension(value.into()),
&local_name!("color") => AttrValue::from_legacy_color(value.into()),
&local_name!("width") => AttrValue::from_dimension(value.into()),
- _ => self.super_type().unwrap().parse_plain_attribute(name, value),
+ _ => self
+ .super_type()
+ .unwrap()
+ .parse_plain_attribute(name, value),
}
}
}