aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/browsingcontext.rs27
-rw-r--r--components/script/dom/document.rs19
-rw-r--r--components/script/dom/domimplementation.rs1
-rw-r--r--components/script/dom/domparser.rs2
-rw-r--r--components/script/dom/node.rs12
-rw-r--r--components/script/dom/virtualmethods.rs2
-rw-r--r--components/script/dom/window.rs9
-rw-r--r--components/script/dom/xmldocument.rs1
-rw-r--r--components/script/dom/xmlhttprequest.rs1
-rw-r--r--components/script/parse/html.rs2
-rw-r--r--components/script/script_thread.rs11
-rw-r--r--components/servo/Cargo.lock2
-rw-r--r--ports/cef/Cargo.lock2
-rw-r--r--ports/gonk/Cargo.lock2
14 files changed, 64 insertions, 29 deletions
diff --git a/components/script/dom/browsingcontext.rs b/components/script/dom/browsingcontext.rs
index 7cd856cad7c..603b2c27f80 100644
--- a/components/script/dom/browsingcontext.rs
+++ b/components/script/dom/browsingcontext.rs
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use dom::bindings::cell::DOMRefCell;
use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject};
use dom::bindings::js::{JS, Root, RootedReference};
use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor};
@@ -25,26 +26,24 @@ use js::jsval::{ObjectValue, UndefinedValue, PrivateValue};
#[dom_struct]
pub struct BrowsingContext {
reflector: Reflector,
- history: Vec<SessionHistoryEntry>,
+ history: DOMRefCell<Vec<SessionHistoryEntry>>,
active_index: usize,
frame_element: Option<JS<Element>>,
}
impl BrowsingContext {
- pub fn new_inherited(document: &Document, frame_element: Option<&Element>) -> BrowsingContext {
+ pub fn new_inherited(frame_element: Option<&Element>) -> BrowsingContext {
BrowsingContext {
reflector: Reflector::new(),
- history: vec![SessionHistoryEntry::new(document)],
+ history: DOMRefCell::new(vec![]),
active_index: 0,
frame_element: frame_element.map(JS::from_ref),
}
}
#[allow(unsafe_code)]
- pub fn new(document: &Document, frame_element: Option<&Element>) -> Root<BrowsingContext> {
+ pub fn new(window: &Window, frame_element: Option<&Element>) -> Root<BrowsingContext> {
unsafe {
- let window = document.window();
-
let WindowProxyHandler(handler) = window.windowproxy_handler();
assert!(!handler.is_null());
@@ -58,7 +57,7 @@ impl BrowsingContext {
NewWindowProxy(cx, parent, handler));
assert!(!window_proxy.ptr.is_null());
- let object = box BrowsingContext::new_inherited(document, frame_element);
+ let object = box BrowsingContext::new_inherited(frame_element);
let raw = Box::into_raw(object);
SetProxyExtra(window_proxy.ptr, 0, PrivateValue(raw as *const _));
@@ -69,12 +68,18 @@ impl BrowsingContext {
}
}
- pub fn active_document(&self) -> &Document {
- &*self.history[self.active_index].document
+ pub fn init(&self, document: &Document) {
+ assert!(self.history.borrow().is_empty());
+ assert_eq!(self.active_index, 0);
+ self.history.borrow_mut().push(SessionHistoryEntry::new(document));
+ }
+
+ pub fn active_document(&self) -> Root<Document> {
+ Root::from_ref(&*self.history.borrow()[self.active_index].document)
}
- pub fn active_window(&self) -> &Window {
- self.active_document().window()
+ pub fn active_window(&self) -> Root<Window> {
+ Root::from_ref(self.active_document().window())
}
pub fn frame_element(&self) -> Option<&Element> {
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index c77eaf7c2c7..9fdff62aabb 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -30,6 +30,7 @@ use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::trace::RootedVec;
use dom::bindings::xmlname::XMLName::InvalidXMLName;
use dom::bindings::xmlname::{validate_and_extract, namespace_from_domstring, xml_name_type};
+use dom::browsingcontext::BrowsingContext;
use dom::comment::Comment;
use dom::customevent::CustomEvent;
use dom::documentfragment::DocumentFragment;
@@ -129,6 +130,8 @@ enum ParserBlockedByScript {
pub struct Document {
node: Node,
window: JS<Window>,
+ /// https://html.spec.whatwg.org/multipage/#concept-document-bc
+ browsing_context: Option<JS<BrowsingContext>>,
implementation: MutNullableHeap<JS<DOMImplementation>>,
location: MutNullableHeap<JS<Location>>,
content_type: DOMString,
@@ -279,6 +282,12 @@ impl Document {
self.loader.borrow_mut()
}
+ /// https://html.spec.whatwg.org/multipage/#concept-document-bc
+ #[inline]
+ pub fn browsing_context(&self) -> Option<&BrowsingContext> {
+ self.browsing_context.as_ref().map(|browsing_context| &**browsing_context)
+ }
+
#[inline]
pub fn window(&self) -> &Window {
&*self.window
@@ -309,7 +318,7 @@ impl Document {
let browsing_context = browsing_context.as_ref().unwrap();
let active_document = browsing_context.active_document();
- if self != active_document {
+ if self != &*active_document {
return false;
}
// FIXME: It should also check whether the browser context is top-level or not
@@ -1507,6 +1516,7 @@ impl LayoutDocumentHelpers for LayoutJS<Document> {
impl Document {
pub fn new_inherited(window: &Window,
+ browsing_context: Option<&BrowsingContext>,
url: Option<Url>,
is_html_document: IsHTMLDocument,
content_type: Option<DOMString>,
@@ -1525,6 +1535,7 @@ impl Document {
Document {
node: Node::new_document_node(),
window: JS::from_ref(window),
+ browsing_context: browsing_context.map(JS::from_ref),
implementation: Default::default(),
location: Default::default(),
content_type: match content_type {
@@ -1594,6 +1605,7 @@ impl Document {
let docloader = DocumentLoader::new(&*doc.loader());
Ok(Document::new(win,
None,
+ None,
IsHTMLDocument::NonHTMLDocument,
None,
None,
@@ -1602,6 +1614,7 @@ impl Document {
}
pub fn new(window: &Window,
+ browsing_context: Option<&BrowsingContext>,
url: Option<Url>,
doctype: IsHTMLDocument,
content_type: Option<DOMString>,
@@ -1610,6 +1623,7 @@ impl Document {
doc_loader: DocumentLoader)
-> Root<Document> {
let document = reflect_dom_object(box Document::new_inherited(window,
+ browsing_context,
url,
doctype,
content_type,
@@ -1673,6 +1687,7 @@ impl Document {
};
let new_doc = Document::new(self.window(),
None,
+ None,
doctype,
None,
None,
@@ -1761,7 +1776,7 @@ impl DocumentMethods for Document {
// Step 2.
let candidate = browsing_context.active_document();
// Step 3.
- if candidate == target {
+ if &*candidate == target {
true
} else {
false //TODO Step 4.
diff --git a/components/script/dom/domimplementation.rs b/components/script/dom/domimplementation.rs
index d994b111b69..01cd8acb7df 100644
--- a/components/script/dom/domimplementation.rs
+++ b/components/script/dom/domimplementation.rs
@@ -116,6 +116,7 @@ impl DOMImplementationMethods for DOMImplementation {
// Step 1-2.
let doc = Document::new(win,
None,
+ None,
IsHTMLDocument::HTMLDocument,
None,
None,
diff --git a/components/script/dom/domparser.rs b/components/script/dom/domparser.rs
index 21b0fcf0730..1a3fb7f3793 100644
--- a/components/script/dom/domparser.rs
+++ b/components/script/dom/domparser.rs
@@ -59,6 +59,7 @@ impl DOMParserMethods for DOMParser {
match ty {
Text_html => {
let document = Document::new(&self.window,
+ None,
Some(url.clone()),
IsHTMLDocument::HTMLDocument,
Some(content_type),
@@ -72,6 +73,7 @@ impl DOMParserMethods for DOMParser {
Text_xml => {
// FIXME: this should probably be FromParser when we actually parse the string (#3756).
let document = Document::new(&self.window,
+ None,
Some(url.clone()),
IsHTMLDocument::NonHTMLDocument,
Some(content_type),
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index c42635a3762..c2221408b13 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -1551,12 +1551,15 @@ impl Node {
Some(index)
}
};
- // Step 6.
+ // Step 6. pre-removing steps for node iterators
+ // Step 7.
let old_previous_sibling = node.GetPreviousSibling();
- // Steps 7-8: mutation observers.
- // Step 9.
+ // Step 8.
let old_next_sibling = node.GetNextSibling();
+ // Steps 9-10 are handled in unbind_from_tree.
parent.remove_child(node, cached_index);
+ // Step 11. transient registered observers
+ // Step 12.
if let SuppressObserver::Unsuppressed = suppress_observers {
vtable_for(&parent).children_changed(
&ChildrenMutation::replace(old_previous_sibling.r(),
@@ -1602,7 +1605,8 @@ impl Node {
};
let window = document.window();
let loader = DocumentLoader::new(&*document.loader());
- let document = Document::new(window, Some((*document.url()).clone()),
+ let document = Document::new(window, None,
+ Some((*document.url()).clone()),
is_html_doc, None,
None, DocumentSource::NotFromParser, loader);
Root::upcast::<Node>(document)
diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs
index 2e8391671a8..e3def582ae4 100644
--- a/components/script/dom/virtualmethods.rs
+++ b/components/script/dom/virtualmethods.rs
@@ -83,6 +83,8 @@ pub trait VirtualMethods {
/// Called when a Node is removed from a tree, where 'tree_in_doc'
/// indicates whether the tree is part of a Document.
+ /// Implements removing steps:
+ /// https://dom.spec.whatwg.org/#concept-node-remove-ext
fn unbind_from_tree(&self, context: &UnbindContext) {
if let Some(ref s) = self.super_type() {
s.unbind_from_tree(context);
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 4f55942111a..5e933ec6868 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -426,7 +426,7 @@ impl WindowMethods for Window {
// https://html.spec.whatwg.org/multipage/#dom-document-2
fn Document(&self) -> Root<Document> {
- Root::from_ref(self.browsing_context().as_ref().unwrap().active_document())
+ self.browsing_context().as_ref().unwrap().active_document()
}
// https://html.spec.whatwg.org/multipage/#dom-location
@@ -1095,8 +1095,9 @@ impl Window {
(element, response.rect)
}
- pub fn init_browsing_context(&self, doc: &Document, frame_element: Option<&Element>) {
- self.browsing_context.set(Some(&BrowsingContext::new(doc, frame_element)));
+ pub fn init_browsing_context(&self, browsing_context: &BrowsingContext) {
+ assert!(self.browsing_context.get().is_none());
+ self.browsing_context.set(Some(&browsing_context));
}
/// Commence a new URL load which will either replace this window or scroll to a fragment.
@@ -1283,7 +1284,7 @@ impl Window {
browsing_context.frame_element().map(|frame_element| {
let window = window_from_node(frame_element);
let context = window.browsing_context();
- Root::from_ref(context.unwrap().active_window())
+ context.unwrap().active_window()
})
}
}
diff --git a/components/script/dom/xmldocument.rs b/components/script/dom/xmldocument.rs
index 6f73ecbf8ea..200480d4fc0 100644
--- a/components/script/dom/xmldocument.rs
+++ b/components/script/dom/xmldocument.rs
@@ -35,6 +35,7 @@ impl XMLDocument {
doc_loader: DocumentLoader) -> XMLDocument {
XMLDocument {
document: Document::new_inherited(window,
+ None,
url,
is_html_document,
content_type,
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index a2bd552485a..355cd989e93 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -1243,6 +1243,7 @@ impl XMLHttpRequest {
DOMString::from(format!("{}", mime))
});
Document::new(win,
+ None,
parsed_url,
is_html_document,
content_type,
diff --git a/components/script/parse/html.rs b/components/script/parse/html.rs
index d4ea3cf2093..2d7f71eed15 100644
--- a/components/script/parse/html.rs
+++ b/components/script/parse/html.rs
@@ -275,7 +275,7 @@ pub fn parse_html_fragment(context_node: &Node,
// Step 1.
let loader = DocumentLoader::new(&*context_document.loader());
- let document = Document::new(window.r(), Some(url.clone()),
+ let document = Document::new(window.r(), None, Some(url.clone()),
IsHTMLDocument::HTMLDocument,
None, None,
DocumentSource::FromParser,
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 330bee776d3..1f4a82ec02d 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -32,6 +32,7 @@ use dom::bindings::js::{RootCollectionPtr, RootedReference};
use dom::bindings::refcounted::{LiveDOMReferences, Trusted, TrustedReference, trace_refcounted_objects};
use dom::bindings::trace::{JSTraceable, RootedVec, trace_traceables};
use dom::bindings::utils::{DOM_CALLBACKS, WRAP_CALLBACKS};
+use dom::browsingcontext::BrowsingContext;
use dom::document::{Document, DocumentProgressHandler, DocumentSource, FocusType, IsHTMLDocument};
use dom::element::Element;
use dom::event::{Event, EventBubbles, EventCancelable};
@@ -1795,6 +1796,10 @@ impl ScriptThread {
incomplete.parent_info,
incomplete.window_size);
+ let frame_element = frame_element.r().map(Castable::upcast);
+ let browsing_context = BrowsingContext::new(&window, frame_element);
+ window.init_browsing_context(&browsing_context);
+
let last_modified = metadata.headers.as_ref().and_then(|headers| {
headers.get().map(|&LastModified(HttpDate(ref tm))| dom_last_modified(tm))
});
@@ -1822,16 +1827,14 @@ impl ScriptThread {
};
let document = Document::new(window.r(),
+ Some(&browsing_context),
Some(final_url.clone()),
is_html_document,
content_type,
last_modified,
DocumentSource::FromParser,
loader);
-
- let frame_element = frame_element.r().map(Castable::upcast);
- window.init_browsing_context(document.r(), frame_element);
-
+ browsing_context.init(&document);
document.set_ready_state(DocumentReadyState::Loading);
// Create the root frame
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 9c4a7af6185..b14579ff98f 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -2209,7 +2209,7 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.1.0"
-source = "git+https://github.com/glennw/webrender#90cd6afdd64cdb48f606dbe0ce5d1ac352329004"
+source = "git+https://github.com/glennw/webrender#463d6e361a0b29d4b0f0f972510cf588d0bc27b0"
dependencies = [
"app_units 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index e81d1997c68..5247365b490 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -2095,7 +2095,7 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.1.0"
-source = "git+https://github.com/glennw/webrender#90cd6afdd64cdb48f606dbe0ce5d1ac352329004"
+source = "git+https://github.com/glennw/webrender#463d6e361a0b29d4b0f0f972510cf588d0bc27b0"
dependencies = [
"app_units 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock
index 43c8639fc52..6c9af5448b1 100644
--- a/ports/gonk/Cargo.lock
+++ b/ports/gonk/Cargo.lock
@@ -2043,7 +2043,7 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.1.0"
-source = "git+https://github.com/glennw/webrender#90cd6afdd64cdb48f606dbe0ce5d1ac352329004"
+source = "git+https://github.com/glennw/webrender#463d6e361a0b29d4b0f0f972510cf588d0bc27b0"
dependencies = [
"app_units 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",