script: Fix double borrow error when going back. Closes #4402.

I have verified that back and forward work once again.
This commit is contained in:
Patrick Walton 2014-12-16 21:54:43 -08:00
parent b8900782b0
commit 4f6c732b54

View file

@ -727,15 +727,24 @@ impl ScriptTask {
message for a layout channel that is not associated with this script task. This message for a layout channel that is not associated with this script task. This
is a bug."); is a bug.");
let last_url = match &mut *page.mut_url() { // Are we reloading?
&Some((ref mut loaded, ref mut needs_reflow)) if *loaded == url => { let reloading = match *page.url() {
if replace(needs_reflow, false) { Some((ref loaded, _)) => *loaded == url,
_ => false,
};
if reloading {
// Pull out the `needs_reflow` flag explicitly because `reflow` can ask for the page's
// URL, and we can't be holding a borrow on that URL (#4402).
let needed_reflow = match &mut *page.mut_url() {
&Some((_, ref mut needs_reflow)) => replace(needs_reflow, false),
_ => panic!("can't reload a page with no URL!")
};
if needed_reflow {
self.force_reflow(&*page); self.force_reflow(&*page);
} }
return; return
}, }
url => replace(url, None).map(|(loaded, _)| loaded), let last_url = replace(&mut *page.mut_url(), None).map(|(last_url, _)| last_url);
};
let is_javascript = url.scheme.as_slice() == "javascript"; let is_javascript = url.scheme.as_slice() == "javascript";