aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmloptionscollection.rs
diff options
context:
space:
mode:
authorchansuke <chansuke@georepublic.de>2018-09-18 23:24:15 +0900
committerJosh Matthews <josh@joshmatthews.net>2018-09-19 17:40:47 -0400
commitc37a345dc9f4dda6ea29c42f96f6c7201c42cbac (patch)
tree1f05b49bac02318455a59d5b143c186fd872bdb9 /components/script/dom/htmloptionscollection.rs
parent2ca7a134736bb4759ff209c1bc0b6dc3cc1984c9 (diff)
downloadservo-c37a345dc9f4dda6ea29c42f96f6c7201c42cbac.tar.gz
servo-c37a345dc9f4dda6ea29c42f96f6c7201c42cbac.zip
Format script component
Diffstat (limited to 'components/script/dom/htmloptionscollection.rs')
-rw-r--r--components/script/dom/htmloptionscollection.rs50
1 files changed, 32 insertions, 18 deletions
diff --git a/components/script/dom/htmloptionscollection.rs b/components/script/dom/htmloptionscollection.rs
index 98c0440d43a..1d296cccda8 100644
--- a/components/script/dom/htmloptionscollection.rs
+++ b/components/script/dom/htmloptionscollection.rs
@@ -28,18 +28,25 @@ pub struct HTMLOptionsCollection {
}
impl HTMLOptionsCollection {
- fn new_inherited(select: &HTMLSelectElement, filter: Box<CollectionFilter + 'static>) -> HTMLOptionsCollection {
+ fn new_inherited(
+ select: &HTMLSelectElement,
+ filter: Box<CollectionFilter + 'static>,
+ ) -> HTMLOptionsCollection {
HTMLOptionsCollection {
collection: HTMLCollection::new_inherited(select.upcast(), filter),
}
}
- pub fn new(window: &Window, select: &HTMLSelectElement, filter: Box<CollectionFilter + 'static>)
- -> DomRoot<HTMLOptionsCollection>
- {
- reflect_dom_object(Box::new(HTMLOptionsCollection::new_inherited(select, filter)),
- window,
- HTMLOptionsCollectionBinding::Wrap)
+ pub fn new(
+ window: &Window,
+ select: &HTMLSelectElement,
+ filter: Box<CollectionFilter + 'static>,
+ ) -> DomRoot<HTMLOptionsCollection> {
+ reflect_dom_object(
+ Box::new(HTMLOptionsCollection::new_inherited(select, filter)),
+ window,
+ HTMLOptionsCollectionBinding::Wrap,
+ )
}
fn add_new_elements(&self, count: u32) -> ErrorResult {
@@ -50,7 +57,7 @@ impl HTMLOptionsCollection {
let element = HTMLOptionElement::new(local_name!("option"), None, &document);
let node = element.upcast::<Node>();
root.AppendChild(node)?;
- };
+ }
Ok(())
}
}
@@ -132,12 +139,20 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection {
}
// https://html.spec.whatwg.org/multipage/#dom-htmloptionscollection-add
- fn Add(&self, element: HTMLOptionElementOrHTMLOptGroupElement, before: Option<HTMLElementOrLong>) -> ErrorResult {
+ fn Add(
+ &self,
+ element: HTMLOptionElementOrHTMLOptGroupElement,
+ before: Option<HTMLElementOrLong>,
+ ) -> ErrorResult {
let root = self.upcast().root_node();
let node: &Node = match element {
- HTMLOptionElementOrHTMLOptGroupElement::HTMLOptionElement(ref element) => element.upcast(),
- HTMLOptionElementOrHTMLOptGroupElement::HTMLOptGroupElement(ref element) => element.upcast(),
+ HTMLOptionElementOrHTMLOptGroupElement::HTMLOptionElement(ref element) => {
+ element.upcast()
+ },
+ HTMLOptionElementOrHTMLOptGroupElement::HTMLOptGroupElement(ref element) => {
+ element.upcast()
+ },
};
// Step 1
@@ -159,13 +174,12 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection {
}
// Step 4
- let reference_node = before.and_then(|before| {
- match before {
- HTMLElementOrLong::HTMLElement(element) => Some(DomRoot::upcast::<Node>(element)),
- HTMLElementOrLong::Long(index) => {
- self.upcast().IndexedGetter(index as u32).map(DomRoot::upcast::<Node>)
- }
- }
+ let reference_node = before.and_then(|before| match before {
+ HTMLElementOrLong::HTMLElement(element) => Some(DomRoot::upcast::<Node>(element)),
+ HTMLElementOrLong::Long(index) => self
+ .upcast()
+ .IndexedGetter(index as u32)
+ .map(DomRoot::upcast::<Node>),
});
// Step 5