aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/document.rs21
-rw-r--r--components/script/dom/node.rs50
-rw-r--r--components/script/dom/window.rs16
3 files changed, 48 insertions, 39 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 28edce553ad..78ccbbdf1f5 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -376,6 +376,7 @@ impl Document {
// that workable.
match self.GetDocumentElement() {
Some(root) => {
+ root.upcast::<Node>().is_dirty() ||
root.upcast::<Node>().has_dirty_descendants() ||
!self.modified_elements.borrow().is_empty()
}
@@ -1371,6 +1372,7 @@ impl Document {
}
pub fn finish_load(&self, load: LoadType) {
+ debug!("Document got finish_load: {:?}", load);
// The parser might need the loader, so restrict the lifetime of the borrow.
{
let mut loader = self.loader.borrow_mut();
@@ -1396,9 +1398,9 @@ impl Document {
// If we don't have a parser, and the reflow timer has been reset, explicitly
// trigger a reflow.
if let LoadType::Stylesheet(_) = load {
- self.window().reflow(ReflowGoal::ForDisplay,
- ReflowQueryType::NoQuery,
- ReflowReason::StylesheetLoaded);
+ self.window.reflow(ReflowGoal::ForDisplay,
+ ReflowQueryType::NoQuery,
+ ReflowReason::StylesheetLoaded);
}
}
@@ -1487,24 +1489,25 @@ impl Document {
return;
}
self.domcontentloaded_dispatched.set(true);
+ assert!(self.ReadyState() != DocumentReadyState::Complete,
+ "Complete before DOMContentLoaded?");
update_with_current_time_ms(&self.dom_content_loaded_event_start);
let window = self.window();
window.dom_manipulation_task_source().queue_event(self.upcast(), atom!("DOMContentLoaded"),
EventBubbles::Bubbles, EventCancelable::NotCancelable, window);
+
window.reflow(ReflowGoal::ForDisplay,
ReflowQueryType::NoQuery,
ReflowReason::DOMContentLoaded);
-
update_with_current_time_ms(&self.dom_content_loaded_event_end);
}
pub fn notify_constellation_load(&self) {
let pipeline_id = self.window.pipeline();
- let event = ConstellationMsg::DOMLoad(pipeline_id);
- self.window.constellation_chan().send(event).unwrap();
-
+ let load_event = ConstellationMsg::LoadComplete(pipeline_id);
+ self.window.constellation_chan().send(load_event).unwrap();
}
pub fn set_current_parser(&self, script: Option<ParserRef>) {
@@ -2908,16 +2911,18 @@ impl DocumentProgressHandler {
// http://w3c.github.io/navigation-timing/#widl-PerformanceNavigationTiming-loadEventStart
update_with_current_time_ms(&document.load_event_start);
+ debug!("About to dispatch load for {:?}", document.url());
let _ = wintarget.dispatch_event_with_target(document.upcast(), &event);
// http://w3c.github.io/navigation-timing/#widl-PerformanceNavigationTiming-loadEventEnd
update_with_current_time_ms(&document.load_event_end);
- document.notify_constellation_load();
window.reflow(ReflowGoal::ForDisplay,
ReflowQueryType::NoQuery,
ReflowReason::DocumentLoaded);
+
+ document.notify_constellation_load();
}
}
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 37495be3ba3..2769b7503bc 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -479,19 +479,7 @@ impl Node {
return
}
- // 2. Dirty descendants.
- fn dirty_subtree(node: &Node) {
- // Stop if this subtree is already dirty.
- if node.is_dirty() { return }
-
- node.set_flag(IS_DIRTY | HAS_DIRTY_DESCENDANTS, true);
-
- for kid in node.children() {
- dirty_subtree(kid.r());
- }
- }
-
- dirty_subtree(self);
+ self.set_flag(IS_DIRTY, true);
// 4. Dirty ancestors.
for ancestor in self.ancestors() {
@@ -1299,22 +1287,17 @@ impl TreeIterator {
depth: 0,
}
}
-}
-impl Iterator for TreeIterator {
- type Item = Root<Node>;
-
- // https://dom.spec.whatwg.org/#concept-tree-order
- fn next(&mut self) -> Option<Root<Node>> {
+ pub fn next_skipping_children(&mut self) -> Option<Root<Node>> {
let current = match self.current.take() {
None => return None,
Some(current) => current,
};
- if let Some(first_child) = current.GetFirstChild() {
- self.current = Some(first_child);
- self.depth += 1;
- return Some(current);
- };
+
+ self.next_skipping_children_impl(current)
+ }
+
+ fn next_skipping_children_impl(&mut self, current: Root<Node>) -> Option<Root<Node>> {
for ancestor in current.inclusive_ancestors() {
if self.depth == 0 {
break;
@@ -1331,6 +1314,25 @@ impl Iterator for TreeIterator {
}
}
+impl Iterator for TreeIterator {
+ type Item = Root<Node>;
+
+ // https://dom.spec.whatwg.org/#concept-tree-order
+ fn next(&mut self) -> Option<Root<Node>> {
+ let current = match self.current.take() {
+ None => return None,
+ Some(current) => current,
+ };
+ if let Some(first_child) = current.GetFirstChild() {
+ self.current = Some(first_child);
+ self.depth += 1;
+ return Some(current);
+ };
+
+ self.next_skipping_children_impl(current)
+ }
+}
+
/// Specifies whether children must be recursively cloned or not.
#[derive(Copy, Clone, PartialEq, HeapSizeOf)]
pub enum CloneChildrenFlag {
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index f28f823dab4..ebd9550d117 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -450,13 +450,15 @@ impl WindowMethods for Window {
// Right now, just print to the console
// Ensure that stderr doesn't trample through the alert() we use to
// communicate test results (see executorservo.py in wptrunner).
- let stderr = stderr();
- let mut stderr = stderr.lock();
- let stdout = stdout();
- let mut stdout = stdout.lock();
- writeln!(&mut stdout, "ALERT: {}", s).unwrap();
- stdout.flush().unwrap();
- stderr.flush().unwrap();
+ {
+ let stderr = stderr();
+ let mut stderr = stderr.lock();
+ let stdout = stdout();
+ let mut stdout = stdout.lock();
+ writeln!(&mut stdout, "ALERT: {}", s).unwrap();
+ stdout.flush().unwrap();
+ stderr.flush().unwrap();
+ }
let (sender, receiver) = ipc::channel().unwrap();
self.constellation_chan().send(ConstellationMsg::Alert(self.pipeline(), s.to_string(), sender)).unwrap();