From 65da9b5acbd788517e39cd70ad69fdf0acd245b3 Mon Sep 17 00:00:00 2001 From: CYBAI Date: Tue, 20 Mar 2018 21:59:32 +0800 Subject: [PATCH] Make `type` argument as optional and ignore it in open method --- components/script/dom/document.rs | 20 ++++--------------- components/script/dom/webidls/Document.webidl | 2 +- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 49bc45b27c1f..01b234e5cc08 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -132,7 +132,7 @@ use style::invalidation::element::restyle_hints::RestyleHint; use style::media_queries::{Device, MediaList, MediaType}; use style::selector_parser::{RestyleDamage, Snapshot}; use style::shared_lock::{SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuard}; -use style::str::{HTML_SPACE_CHARACTERS, split_html_space_chars, str_join}; +use style::str::{split_html_space_chars, str_join}; use style::stylesheet_set::DocumentStylesheetSet; use style::stylesheets::{Stylesheet, StylesheetContents, Origin, OriginSet}; use task_source::TaskSource; @@ -3675,7 +3675,7 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-open - fn Open(&self, type_: DOMString, replace: DOMString) -> Fallible> { + fn Open(&self, _type: Option, replace: DOMString) -> Fallible> { if !self.is_html_document() { // Step 1. return Err(Error::InvalidState); @@ -3709,8 +3709,6 @@ impl DocumentMethods for Document { // Step 6. // TODO: ignore-opens-during-unload counter check. - // Step 7: first argument already bound to `type_`. - // Step 8. // TODO: check session history's state. let replace = replace.eq_ignore_ascii_case("replace"); @@ -3777,22 +3775,12 @@ impl DocumentMethods for Document { // Step 24. // TODO: mute iframe load. - // Step 27. - let type_ = if type_.eq_ignore_ascii_case("replace") { - "text/html" - } else if let Some(position) = type_.find(';') { - &type_[0..position] - } else { - &*type_ - }; - let type_ = type_.trim_matches(HTML_SPACE_CHARACTERS); - // Step 25. let resource_threads = self.window.upcast::().resource_threads().clone(); *self.loader.borrow_mut() = DocumentLoader::new_with_threads(resource_threads, Some(url.clone())); - ServoParser::parse_html_script_input(self, url, type_); + ServoParser::parse_html_script_input(self, url, "text/html"); // Step 26. self.ready_state.set(DocumentReadyState::Interactive); @@ -3851,7 +3839,7 @@ impl DocumentMethods for Document { return Ok(()); } // Step 5. - self.Open("text/html".into(), "".into())?; + self.Open(None, "".into())?; self.get_current_parser().unwrap() } }; diff --git a/components/script/dom/webidls/Document.webidl b/components/script/dom/webidls/Document.webidl index 40df23b734c1..fbb4787ab89d 100644 --- a/components/script/dom/webidls/Document.webidl +++ b/components/script/dom/webidls/Document.webidl @@ -118,7 +118,7 @@ partial /*sealed*/ interface Document { // dynamic markup insertion [CEReactions, Throws] - Document open(optional DOMString type = "text/html", optional DOMString replace = ""); + Document open(optional DOMString type, optional DOMString replace = ""); // WindowProxy open(DOMString url, DOMString name, DOMString features, optional boolean replace = false); [CEReactions, Throws] void close();