diff options
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/bindings/trace.rs | 6 | ||||
-rw-r--r-- | components/script/dom/document.rs | 33 | ||||
-rw-r--r-- | components/script/dom/domimplementation.rs | 4 | ||||
-rw-r--r-- | components/script/dom/domparser.rs | 4 | ||||
-rw-r--r-- | components/script/dom/htmliframeelement.rs | 2 | ||||
-rw-r--r-- | components/script/dom/node.rs | 2 | ||||
-rw-r--r-- | components/script/dom/servoparser/mod.rs | 2 | ||||
-rw-r--r-- | components/script/dom/window.rs | 11 | ||||
-rw-r--r-- | components/script/dom/xmldocument.rs | 7 | ||||
-rw-r--r-- | components/script/dom/xmlhttprequest.rs | 2 |
10 files changed, 36 insertions, 37 deletions
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index aeddcdabe4b..0e605780a20 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -79,7 +79,7 @@ use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType}; use selectors::matching::ElementSelectorFlags; use serde::{Deserialize, Serialize}; use servo_atoms::Atom; -use servo_url::ServoUrl; +use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; use smallvec::SmallVec; use std::cell::{Cell, RefCell, UnsafeCell}; use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; @@ -104,7 +104,6 @@ use style::stylesheets::SupportsRule; use style::values::specified::Length; use style::viewport::ViewportRule; use time::Duration; -use url::Origin as UrlOrigin; use uuid::Uuid; use webrender_traits::{WebGLBufferId, WebGLError, WebGLFramebufferId, WebGLProgramId}; use webrender_traits::{WebGLRenderbufferId, WebGLShaderId, WebGLTextureId}; @@ -317,9 +316,10 @@ unsafe impl<A: JSTraceable, B: JSTraceable, C: JSTraceable> JSTraceable for (A, } } -unsafe_no_jsmanaged_fields!(bool, f32, f64, String, ServoUrl, AtomicBool, AtomicUsize, UrlOrigin, Uuid, char); +unsafe_no_jsmanaged_fields!(bool, f32, f64, String, AtomicBool, AtomicUsize, Uuid, char); unsafe_no_jsmanaged_fields!(usize, u8, u16, u32, u64); unsafe_no_jsmanaged_fields!(isize, i8, i16, i32, i64); +unsafe_no_jsmanaged_fields!(ServoUrl, ImmutableOrigin, MutableOrigin); unsafe_no_jsmanaged_fields!(Image, ImageMetadata, ImageCacheChan, ImageCacheThread); unsafe_no_jsmanaged_fields!(Metadata); unsafe_no_jsmanaged_fields!(NetworkError); diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 56053555f7c..c836a46f1da 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -105,7 +105,6 @@ use net_traits::CoreResourceMsg::{GetCookiesForUrl, SetCookiesForUrl}; use net_traits::request::RequestInit; use net_traits::response::HttpsState; use num_traits::ToPrimitive; -use origin::Origin; use script_layout_interface::message::{Msg, ReflowQueryType}; use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory}; use script_thread::{MainThreadScriptMsg, Runnable}; @@ -116,7 +115,7 @@ use script_traits::{TouchEventType, TouchId}; use script_traits::UntrustedNodeAddress; use servo_atoms::Atom; use servo_config::prefs::PREFS; -use servo_url::ServoUrl; +use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cell::{Cell, Ref, RefMut}; @@ -136,6 +135,7 @@ use style::str::{HTML_SPACE_CHARACTERS, split_html_space_chars, str_join}; use style::stylesheets::Stylesheet; use task_source::TaskSource; use time; +use url::Host; use url::percent_encoding::percent_decode; pub enum TouchEventResult { @@ -277,7 +277,7 @@ pub struct Document { https_state: Cell<HttpsState>, touchpad_pressure_phase: Cell<TouchpadPressurePhase>, /// The document's origin. - origin: Origin, + origin: MutableOrigin, /// https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-states referrer_policy: Cell<Option<ReferrerPolicy>>, /// https://html.spec.whatwg.org/multipage/#dom-document-referrer @@ -424,7 +424,7 @@ impl Document { } } - pub fn origin(&self) -> &Origin { + pub fn origin(&self) -> &MutableOrigin { &self.origin } @@ -1949,7 +1949,7 @@ impl Document { pub fn new_inherited(window: &Window, has_browsing_context: HasBrowsingContext, url: Option<ServoUrl>, - origin: Origin, + origin: MutableOrigin, is_html_document: IsHTMLDocument, content_type: Option<DOMString>, last_modified: Option<String>, @@ -2053,7 +2053,7 @@ impl Document { Ok(Document::new(window, HasBrowsingContext::No, None, - doc.origin().alias(), + doc.origin().clone(), IsHTMLDocument::NonHTMLDocument, None, None, @@ -2067,7 +2067,7 @@ impl Document { pub fn new(window: &Window, has_browsing_context: HasBrowsingContext, url: Option<ServoUrl>, - origin: Origin, + origin: MutableOrigin, doctype: IsHTMLDocument, content_type: Option<DOMString>, last_modified: Option<String>, @@ -2154,7 +2154,7 @@ impl Document { HasBrowsingContext::No, None, // https://github.com/whatwg/html/issues/2109 - Origin::opaque_identifier(), + MutableOrigin::new(ImmutableOrigin::new_opaque()), doctype, None, None, @@ -2411,16 +2411,17 @@ impl DocumentMethods for Document { // https://html.spec.whatwg.org/multipage/#relaxing-the-same-origin-restriction fn Domain(&self) -> DOMString { // Step 1. - if self.browsing_context().is_none() { + if !self.has_browsing_context { return DOMString::new(); } - if let Some(host) = self.origin.host() { - // Step 4. - DOMString::from(host.to_string()) - } else { + // Step 2. + match self.origin.effective_domain() { // Step 3. - DOMString::new() + None => DOMString::new(), + // Step 4. + Some(Host::Domain(domain)) => DOMString::from(domain), + Some(host) => DOMString::from(host.to_string()), } } @@ -3077,7 +3078,7 @@ impl DocumentMethods for Document { return Ok(DOMString::new()); } - if !self.origin.is_scheme_host_port_tuple() { + if !self.origin.is_tuple() { return Err(Error::Security); } @@ -3097,7 +3098,7 @@ impl DocumentMethods for Document { return Ok(()); } - if !self.origin.is_scheme_host_port_tuple() { + if !self.origin.is_tuple() { return Err(Error::Security); } diff --git a/components/script/dom/domimplementation.rs b/components/script/dom/domimplementation.rs index 4ec27cc5b36..1de0a24863b 100644 --- a/components/script/dom/domimplementation.rs +++ b/components/script/dom/domimplementation.rs @@ -80,7 +80,7 @@ impl DOMImplementationMethods for DOMImplementation { let doc = XMLDocument::new(win, HasBrowsingContext::No, None, - self.document.origin().alias(), + self.document.origin().clone(), IsHTMLDocument::NonHTMLDocument, Some(DOMString::from(content_type)), None, @@ -127,7 +127,7 @@ impl DOMImplementationMethods for DOMImplementation { let doc = Document::new(win, HasBrowsingContext::No, None, - self.document.origin().alias(), + self.document.origin().clone(), IsHTMLDocument::HTMLDocument, None, None, diff --git a/components/script/dom/domparser.rs b/components/script/dom/domparser.rs index d89ec3c1595..67d16934c66 100644 --- a/components/script/dom/domparser.rs +++ b/components/script/dom/domparser.rs @@ -61,7 +61,7 @@ impl DOMParserMethods for DOMParser { let document = Document::new(&self.window, HasBrowsingContext::No, Some(url.clone()), - doc.origin().alias(), + doc.origin().clone(), IsHTMLDocument::HTMLDocument, Some(content_type), None, @@ -79,7 +79,7 @@ impl DOMParserMethods for DOMParser { let document = Document::new(&self.window, HasBrowsingContext::No, Some(url.clone()), - doc.origin().alias(), + doc.origin().clone(), IsHTMLDocument::NonHTMLDocument, Some(content_type), None, diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 3a1c9daf1c9..4ab82735384 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -167,7 +167,7 @@ impl HTMLIFrameElement { layout_threads: PREFS.get("layout.threads").as_u64().expect("count") as usize, }; - ScriptThread::process_attach_layout(new_layout_info, document.origin().alias()); + ScriptThread::process_attach_layout(new_layout_info, document.origin().clone()); } else { let load_info = IFrameLoadInfoWithData { info: load_info, diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index df335be75a6..96d3fceaff5 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1729,7 +1729,7 @@ impl Node { let document = Document::new(window, HasBrowsingContext::No, Some(document.url()), // https://github.com/whatwg/dom/issues/378 - document.origin().alias(), + document.origin().clone(), is_html_doc, None, None, DocumentActivity::Inactive, DocumentSource::NotFromParser, loader, diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs index 39077930200..149957576a2 100644 --- a/components/script/dom/servoparser/mod.rs +++ b/components/script/dom/servoparser/mod.rs @@ -110,7 +110,7 @@ impl ServoParser { let document = Document::new(window, HasBrowsingContext::No, Some(url.clone()), - context_document.origin().alias(), + context_document.origin().clone(), IsHTMLDocument::HTMLDocument, None, None, diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 1fbe57ba165..b6392fbdd19 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -62,7 +62,6 @@ use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread}; use net_traits::storage_thread::StorageType; use num_traits::ToPrimitive; use open; -use origin::Origin; use profile_traits::mem::ProfilerChan as MemProfilerChan; use profile_traits::time::ProfilerChan as TimeProfilerChan; use rustc_serialize::base64::{FromBase64, STANDARD, ToBase64}; @@ -83,7 +82,7 @@ use servo_atoms::Atom; use servo_config::opts; use servo_config::prefs::PREFS; use servo_geometry::{f32_rect_to_au_rect, max_rect}; -use servo_url::ServoUrl; +use servo_url::{ImmutableOrigin, ServoUrl}; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cell::Cell; @@ -660,10 +659,10 @@ impl WindowMethods for Window { "/" => { // TODO(#12715): Should be the origin of the incumbent settings // object, not self's. - Some(self.Document().origin().copy()) + Some(self.Document().origin().immutable().clone()) }, url => match ServoUrl::parse(&url) { - Ok(url) => Some(Origin::new(&url)), + Ok(url) => Some(url.origin().clone()), Err(_) => return Err(Error::Syntax), } }; @@ -1793,13 +1792,13 @@ fn debug_reflow_events(id: PipelineId, goal: &ReflowGoal, query_type: &ReflowQue struct PostMessageHandler { destination: Trusted<Window>, - origin: Option<Origin>, + origin: Option<ImmutableOrigin>, message: StructuredCloneData, } impl PostMessageHandler { fn new(window: &Window, - origin: Option<Origin>, + origin: Option<ImmutableOrigin>, message: StructuredCloneData) -> PostMessageHandler { PostMessageHandler { destination: Trusted::new(window), diff --git a/components/script/dom/xmldocument.rs b/components/script/dom/xmldocument.rs index eaf90fbfe01..c832e018360 100644 --- a/components/script/dom/xmldocument.rs +++ b/components/script/dom/xmldocument.rs @@ -15,9 +15,8 @@ use dom::location::Location; use dom::node::Node; use dom::window::Window; use js::jsapi::{JSContext, JSObject}; -use origin::Origin; use script_traits::DocumentActivity; -use servo_url::ServoUrl; +use servo_url::{MutableOrigin, ServoUrl}; // https://dom.spec.whatwg.org/#xmldocument #[dom_struct] @@ -29,7 +28,7 @@ impl XMLDocument { fn new_inherited(window: &Window, has_browsing_context: HasBrowsingContext, url: Option<ServoUrl>, - origin: Origin, + origin: MutableOrigin, is_html_document: IsHTMLDocument, content_type: Option<DOMString>, last_modified: Option<String>, @@ -55,7 +54,7 @@ impl XMLDocument { pub fn new(window: &Window, has_browsing_context: HasBrowsingContext, url: Option<ServoUrl>, - origin: Origin, + origin: MutableOrigin, doctype: IsHTMLDocument, content_type: Option<DOMString>, last_modified: Option<String>, diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 6fe89476994..c5c3c635129 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -1225,7 +1225,7 @@ impl XMLHttpRequest { Document::new(win, HasBrowsingContext::No, parsed_url, - doc.origin().alias(), + doc.origin().clone(), is_html_document, content_type, None, |