aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlformelement.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-07-18 14:22:03 -0400
committerGitHub <noreply@github.com>2019-07-18 14:22:03 -0400
commit2dfbbd0ca24ae17cb282a0f02289b42e9334947b (patch)
treef5536a48f0272523911293987dc84ca279a16940 /components/script/dom/htmlformelement.rs
parentdc1da02aa427d91da4946cef2296b18f893a525f (diff)
parent571beec179fe9fd5fff2c12b3c5dfa0a5d93df01 (diff)
downloadservo-2dfbbd0ca24ae17cb282a0f02289b42e9334947b.tar.gz
servo-2dfbbd0ca24ae17cb282a0f02289b42e9334947b.zip
Auto merge of #23368 - gterzian:clean_up_navigation, r=asajeffrey
Clean-up navigation <!-- Please describe your changes on the following line: --> 1. Navigation as a result of following a hyperlink should be done in a task: https://html.spec.whatwg.org/multipage/links.html#following-hyperlinks:dom-manipulation-task-source 2. The javascript url navigation should also be done in a task: https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigating-across-documents:dom-manipulation-task-source 3. In `window.load_url`, it seems there is no need to send a message to the script-thread(the entirety of `load_url` should instead be done in a task when appropriate), so we can just do that last part "sync" by calling a method on the script, which will send a message to the constellation(for the parallel navigation steps), or queue task(for the JS navigation), as appropriate. 4. Separate the "normal" navigation flow from the handling of "navigate an iframe" message from constellation, since doing everything in one method as was previously done with `handle_navigate`, is confusing. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- 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/23368) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/htmlformelement.rs')
-rwxr-xr-xcomponents/script/dom/htmlformelement.rs38
1 files changed, 28 insertions, 10 deletions
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs
index 006d2f5d20c..03e4b8b5195 100755
--- a/components/script/dom/htmlformelement.rs
+++ b/components/script/dom/htmlformelement.rs
@@ -3,6 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::cell::DomRefCell;
+use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrBinding::AttrMethods;
use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
@@ -12,6 +13,7 @@ use crate::dom::bindings::codegen::Bindings::HTMLFormElementBinding;
use crate::dom::bindings::codegen::Bindings::HTMLFormElementBinding::HTMLFormElementMethods;
use crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
use crate::dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
+use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use crate::dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
use crate::dom::bindings::refcounted::Trusted;
use crate::dom::bindings::reflector::DomObject;
@@ -46,7 +48,6 @@ use crate::dom::node::{UnbindContext, VecPreOrderInsertionHelper};
use crate::dom::validitystate::ValidationFlags;
use crate::dom::virtualmethods::VirtualMethods;
use crate::dom::window::Window;
-use crate::script_thread::MainThreadScriptMsg;
use crate::task_source::TaskSource;
use dom_struct::dom_struct;
use encoding_rs::{Encoding, UTF_8};
@@ -56,7 +57,7 @@ use hyper::Method;
use mime::{self, Mime};
use net_traits::http_percent_encode;
use net_traits::request::Referrer;
-use script_traits::LoadData;
+use script_traits::{HistoryEntryReplacement, LoadData, LoadOrigin};
use servo_rand::random;
use std::borrow::ToOwned;
use std::cell::Cell;
@@ -399,6 +400,7 @@ impl HTMLFormElement {
};
let target_window = target_document.window();
let mut load_data = LoadData::new(
+ LoadOrigin::Script(doc.origin().immutable().clone()),
action_components,
None,
Some(Referrer::ReferrerUrl(target_document.url())),
@@ -529,7 +531,7 @@ impl HTMLFormElement {
}
/// [Planned navigation](https://html.spec.whatwg.org/multipage/#planned-navigation)
- fn plan_to_navigate(&self, load_data: LoadData, target: &Window) {
+ fn plan_to_navigate(&self, mut load_data: LoadData, target: &Window) {
// Step 1
// Each planned navigation task is tagged with a generation ID, and
// before the task is handled, it first checks whether the HTMLFormElement's
@@ -537,19 +539,35 @@ impl HTMLFormElement {
let generation_id = GenerationId(self.generation_id.get().0 + 1);
self.generation_id.set(generation_id);
- // Step 2.
+ // Step 2
+ let elem = self.upcast::<Element>();
+ let referrer = match elem.get_attribute(&ns!(), &local_name!("rel")) {
+ Some(ref link_types) if link_types.Value().contains("noreferrer") => {
+ Referrer::NoReferrer
+ },
+ _ => Referrer::Client,
+ };
+
+ let referrer_policy = target.Document().get_referrer_policy();
let pipeline_id = target.upcast::<GlobalScope>().pipeline_id();
- let script_chan = target.main_thread_script_chan().clone();
+ load_data.creator_pipeline_id = Some(pipeline_id);
+ load_data.referrer = Some(referrer);
+ load_data.referrer_policy = referrer_policy;
+
+ // Step 4.
let this = Trusted::new(self);
+ let window = Trusted::new(target);
let task = 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();
+ window
+ .root()
+ .load_url(
+ HistoryEntryReplacement::Disabled,
+ false,
+ load_data,
+ );
});
// Step 3.