diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2014-12-16 21:54:43 -0800 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2014-12-16 21:54:43 -0800 |
commit | 4f6c732b5412a180f9290a0a08898ede966fc065 (patch) | |
tree | b79957b22d5401056e8dc3028d038ecc882c2402 /components/script/script_task.rs | |
parent | b8900782b0fcb409f37189bdc08eb7f8b3564a5f (diff) | |
download | servo-4f6c732b5412a180f9290a0a08898ede966fc065.tar.gz servo-4f6c732b5412a180f9290a0a08898ede966fc065.zip |
script: Fix double borrow error when going back. Closes #4402.
I have verified that back and forward work once again.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r-- | components/script/script_task.rs | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 4e9fe1a93c2..4e14bc76c8e 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -727,15 +727,24 @@ impl ScriptTask { message for a layout channel that is not associated with this script task. This is a bug."); - let last_url = match &mut *page.mut_url() { - &Some((ref mut loaded, ref mut needs_reflow)) if *loaded == url => { - if replace(needs_reflow, false) { - self.force_reflow(&*page); - } - return; - }, - url => replace(url, None).map(|(loaded, _)| loaded), + // Are we reloading? + let reloading = match *page.url() { + 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); + } + return + } + let last_url = replace(&mut *page.mut_url(), None).map(|(last_url, _)| last_url); let is_javascript = url.scheme.as_slice() == "javascript"; |