aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rwxr-xr-xcomponents/script/dom/htmlformelement.rs53
1 files changed, 19 insertions, 34 deletions
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs
index ca14df723b8..81b9cdb44a1 100755
--- a/components/script/dom/htmlformelement.rs
+++ b/components/script/dom/htmlformelement.rs
@@ -48,16 +48,13 @@ use encoding::label::encoding_from_whatwg_label;
use html5ever::{LocalName, Prefix};
use hyper::header::{Charset, ContentDisposition, ContentType, DispositionParam, DispositionType};
use hyper::method::Method;
-use msg::constellation_msg::PipelineId;
use script_thread::MainThreadScriptMsg;
use script_traits::LoadData;
use servo_rand::random;
use std::borrow::ToOwned;
use std::cell::Cell;
-use std::sync::mpsc::Sender;
use style::attr::AttrValue;
use style::str::split_html_space_chars;
-use task::Task;
use task_source::TaskSource;
#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)]
@@ -436,20 +433,26 @@ impl HTMLFormElement {
// Each planned navigation task is tagged with a generation ID, and
// before the task is handled, it first checks whether the HTMLFormElement's
// generation ID is the same as its own generation ID.
- let GenerationId(prev_id) = self.generation_id.get();
- self.generation_id.set(GenerationId(prev_id + 1));
-
- // Step 2
- let nav = box PlannedNavigation {
- load_data: load_data,
- pipeline_id: window.upcast::<GlobalScope>().pipeline_id(),
- script_chan: window.main_thread_script_chan().clone(),
- generation_id: self.generation_id.get(),
- form: Trusted::new(self)
- };
+ let generation_id = GenerationId(self.generation_id.get().0 + 1);
+ self.generation_id.set(generation_id);
+
+ // Step 2.
+ let pipeline_id = window.upcast::<GlobalScope>().pipeline_id();
+ let script_chan = window.main_thread_script_chan().clone();
+ let this = Trusted::new(self);
+ let task = box task!(navigate_to_form_planned_navigation: move || {
+ if generation_id != this.root().generation_id.get() {
+ return;
+ }
+ script_chan.send(MainThreadScriptMsg::Navigate(
+ pipeline_id,
+ load_data,
+ false,
+ )).unwrap();
+ });
- // Step 3
- window.dom_manipulation_task_source().queue(nav, window.upcast()).unwrap();
+ // Step 3.
+ window.dom_manipulation_task_source().queue(task, window.upcast()).unwrap();
}
/// Interactively validate the constraints of form elements
@@ -1108,24 +1111,6 @@ impl FormControlElementHelpers for Element {
}
}
-struct PlannedNavigation {
- load_data: LoadData,
- pipeline_id: PipelineId,
- script_chan: Sender<MainThreadScriptMsg>,
- generation_id: GenerationId,
- form: Trusted<HTMLFormElement>
-}
-
-impl Task for PlannedNavigation {
- fn run(self: Box<Self>) {
- if self.generation_id == self.form.root().generation_id.get() {
- let script_chan = self.script_chan.clone();
- script_chan.send(MainThreadScriptMsg::Navigate(self.pipeline_id, self.load_data, false)).unwrap();
- }
- }
-}
-
-
// https://html.spec.whatwg.org/multipage/#multipart/form-data-encoding-algorithm
pub fn encode_multipart_form_data(form_data: &mut Vec<FormDatum>,
boundary: String, encoding: EncodingRef) -> Vec<u8> {