auto merge of #1447 : june0cho/servo/fix_crash_on_local_bookmark, r=kmcallister

Local bookmark which is implemented in #1262 is not currently working when executing URL with hashtag(e.g. `test_local_bookmark.html#h3`, `acid2.html#top`).
Local bookmark has two matching processes(http://www.w3.org/TR/html5/browsers.html#scroll-to-fragid). Among two, this commit fixes the crash on ID attribute, and still has crash on `a` element with `name` attribute.
As a result, with this commit, `test_local_bookmark.html#h3` works well, but `acid2.html#top` still does not work.
This commit is contained in:
bors-servo 2014-01-03 10:40:28 -08:00
commit 6dbdcd55ac

View file

@ -93,7 +93,10 @@ pub struct IOCompositor {
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan,
/// The channel on which messages can be sent to the profiler. /// The channel on which messages can be sent to the profiler.
profiler_chan: ProfilerChan profiler_chan: ProfilerChan,
/// Pending scroll to fragment event, if any
fragment_point: Option<Point2D<f32>>
} }
impl IOCompositor { impl IOCompositor {
@ -129,7 +132,8 @@ impl IOCompositor {
zoom_time: 0f64, zoom_time: 0f64,
compositor_layer: None, compositor_layer: None,
constellation_chan: constellation_chan.clone(), constellation_chan: constellation_chan.clone(),
profiler_chan: profiler_chan profiler_chan: profiler_chan,
fragment_point: None
} }
} }
@ -329,21 +333,22 @@ impl IOCompositor {
id: PipelineId, id: PipelineId,
new_size: Size2D<f32>, new_size: Size2D<f32>,
epoch: Epoch) { epoch: Epoch) {
let ask: bool = match self.compositor_layer { let (ask, move): (bool, bool) = match self.compositor_layer {
Some(ref mut layer) => { Some(ref mut layer) => {
let window_size = &self.window_size; let window_size = &self.window_size;
let world_zoom = self.world_zoom; let world_zoom = self.world_zoom;
let page_window = Size2D(window_size.width as f32 / world_zoom, let page_window = Size2D(window_size.width as f32 / world_zoom,
window_size.height as f32 / world_zoom); window_size.height as f32 / world_zoom);
assert!(layer.resize(id, new_size, page_window, epoch)); assert!(layer.resize(id, new_size, page_window, epoch));
true let move = self.fragment_point.take().map_default(false, |point| layer.move(point, page_window));
}
None => { (true, move)
false
} }
None => (false, false)
}; };
if ask { if ask {
self.recomposite_if(move);
self.ask_for_tiles(); self.ask_for_tiles();
} }
} }
@ -431,19 +436,20 @@ impl IOCompositor {
let world_zoom = self.world_zoom; let world_zoom = self.world_zoom;
let page_window = Size2D(self.window_size.width as f32 / world_zoom, let page_window = Size2D(self.window_size.width as f32 / world_zoom,
self.window_size.height as f32 / world_zoom); self.window_size.height as f32 / world_zoom);
let ask: bool = match self.compositor_layer { let (ask, move): (bool, bool) = match self.compositor_layer {
Some(ref mut layer) if layer.pipeline.id == id => { Some(ref mut layer) if layer.pipeline.id == id && !layer.hidden => {
let recomposite = layer.move(point, page_window) | self.recomposite;
self.recomposite = recomposite;
true (true, layer.move(point, page_window))
} }
Some(_) | None => { Some(_) | None => {
false self.fragment_point = Some(point);
(false, false)
} }
}; };
if ask { if ask {
self.recomposite_if(move);
self.ask_for_tiles(); self.ask_for_tiles();
} }
} }
@ -535,10 +541,11 @@ impl IOCompositor {
cursor.y as f32 / world_zoom); cursor.y as f32 / world_zoom);
let page_window = Size2D(self.window_size.width as f32 / world_zoom, let page_window = Size2D(self.window_size.width as f32 / world_zoom,
self.window_size.height as f32 / world_zoom); self.window_size.height as f32 / world_zoom);
let mut scroll = false;
for layer in self.compositor_layer.mut_iter() { for layer in self.compositor_layer.mut_iter() {
let recomposite = layer.scroll(page_delta, page_cursor, page_window) || self.recomposite; scroll = layer.scroll(page_delta, page_cursor, page_window) || scroll;
self.recomposite = recomposite;
} }
self.recomposite_if(scroll);
self.ask_for_tiles(); self.ask_for_tiles();
} }
@ -650,4 +657,8 @@ impl IOCompositor {
self.done = true; self.done = true;
} }
} }
fn recomposite_if(&mut self, result: bool) {
self.recomposite = result || self.recomposite;
}
} }