Navigation Menu

Skip to content

Commit

Permalink
Make the needs_reflow method actually work correctly.
Browse files Browse the repository at this point in the history
The document node is always dirty because layout never clears the bit;
instead, check the dirty bit of the root element.
  • Loading branch information
eefriedman committed Nov 21, 2015
1 parent ea690a2 commit 31c0138
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 10 additions & 3 deletions components/script/dom/document.rs
Expand Up @@ -329,9 +329,16 @@ impl Document {
}

pub fn needs_reflow(&self) -> bool {
self.GetDocumentElement().is_some() &&
(self.upcast::<Node>().get_has_dirty_descendants() ||
!self.modified_elements.borrow().is_empty())
// FIXME: This should check the dirty bit on the document,
// not the document element. Needs some layout changes to make
// that workable.
match self.GetDocumentElement() {
Some(root) => {
root.upcast::<Node>().get_has_dirty_descendants() ||
!self.modified_elements.borrow().is_empty()
}
None => false,
}
}

/// Returns the first `base` element in the DOM that has an `href` attribute.
Expand Down
6 changes: 5 additions & 1 deletion components/script/dom/window.rs
Expand Up @@ -966,7 +966,11 @@ impl Window {
return
}

self.force_reflow(goal, query_type, reason)
self.force_reflow(goal, query_type, reason);

// If window_size is `None`, we don't reflow, so the document stays dirty.
// Otherwise, we shouldn't need a reflow immediately after a reflow.
assert!(!self.Document().needs_reflow() || self.window_size.get().is_none());
}

pub fn layout(&self) -> &LayoutRPC {
Expand Down

0 comments on commit 31c0138

Please sign in to comment.