aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlformelement.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-09-21 13:20:29 -0500
committerGitHub <noreply@github.com>2017-09-21 13:20:29 -0500
commit5c797d194346d5be3c55da51d82bfcd1031a51f5 (patch)
tree3574171aeabb18e4144b5f9c1213a2fe38b15733 /components/script/dom/htmlformelement.rs
parent581f0bf09a8ec35dadd5de207777f79138255e1a (diff)
parent8b33e0f60e4bb2f089f93412bf84fe17c38e714b (diff)
downloadservo-5c797d194346d5be3c55da51d82bfcd1031a51f5.tar.gz
servo-5c797d194346d5be3c55da51d82bfcd1031a51f5.zip
Auto merge of #18059 - sendilkumarn:mito, r=nox
Using OnceCell<T> from Mitochondria <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13402 (github issue number if applicable). <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18059) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/htmlformelement.rs')
-rwxr-xr-xcomponents/script/dom/htmlformelement.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs
index f396bc51715..9b63d1fca66 100755
--- a/components/script/dom/htmlformelement.rs
+++ b/components/script/dom/htmlformelement.rs
@@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::HTMLFormElementBinding::HTMLFormElementMet
use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
-use dom::bindings::js::{JS, MutNullableJS, Root, RootedReference};
+use dom::bindings::js::{JS, OnceCellJS, Root, RootedReference};
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::DomObject;
use dom::bindings::str::DOMString;
@@ -64,7 +64,7 @@ pub struct GenerationId(u32);
pub struct HTMLFormElement {
htmlelement: HTMLElement,
marked_for_reset: Cell<bool>,
- elements: MutNullableJS<HTMLFormControlsCollection>,
+ elements: OnceCellJS<HTMLFormControlsCollection>,
generation_id: Cell<GenerationId>,
controls: DOMRefCell<Vec<JS<Element>>>,
}
@@ -166,10 +166,6 @@ impl HTMLFormElementMethods for HTMLFormElement {
// https://html.spec.whatwg.org/multipage/#dom-form-elements
fn Elements(&self) -> Root<HTMLFormControlsCollection> {
- if let Some(elements) = self.elements.get() {
- return elements;
- }
-
#[derive(HeapSizeOf, JSTraceable)]
struct ElementsFilter {
form: Root<HTMLFormElement>
@@ -220,11 +216,11 @@ impl HTMLFormElementMethods for HTMLFormElement {
}
}
}
- let filter = box ElementsFilter { form: Root::from_ref(self) };
- let window = window_from_node(self);
- let elements = HTMLFormControlsCollection::new(&window, self.upcast(), filter);
- self.elements.set(Some(&elements));
- elements
+ Root::from_ref(self.elements.init_once(|| {
+ let filter = box ElementsFilter { form: Root::from_ref(self) };
+ let window = window_from_node(self);
+ HTMLFormControlsCollection::new(&window, self.upcast(), filter)
+ }))
}
// https://html.spec.whatwg.org/multipage/#dom-form-length