Rust upgrade to rustc hash b03a2755193cd756583bcf5831cf4545d75ecb8a

This commit is contained in:
Jack Moffitt 2014-11-05 12:33:11 -07:00 committed by Glenn Watson
parent 26045d7fcb
commit d1b433a3b3
160 changed files with 1427 additions and 1162 deletions

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use compositor_layer::{CompositorData, CompositorLayer, DoesntWantScrollEvents};
use compositor_layer::{ScrollPositionChanged, WantsScrollEvents};
use compositor_layer::WantsScrollEvents;
use compositor_task::{ChangeReadyState, ChangeRenderState, CompositorEventListener};
use compositor_task::{CompositorProxy, CompositorReceiver, CompositorTask};
use compositor_task::{CreateOrUpdateDescendantLayer, CreateOrUpdateRootLayer, Exit};
@ -50,9 +50,11 @@ use servo_util::memory::MemoryProfilerChan;
use servo_util::opts;
use servo_util::time::{profile, TimeProfilerChan};
use servo_util::{memory, time};
use std::collections::hashmap::HashMap;
use std::collections::HashMap;
use std::collections::hash_map::{Occupied, Vacant};
use std::path::Path;
use std::rc::Rc;
use std::slice::bytes::copy_memory;
use time::{precise_time_ns, precise_time_s};
use url::Url;
@ -236,7 +238,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn handle_browser_message(&mut self, msg: Msg) -> bool {
match (msg, self.shutdown_state) {
(_, FinishedShuttingDown) =>
fail!("compositor shouldn't be handling messages after shutting down"),
panic!("compositor shouldn't be handling messages after shutting down"),
(Exit(chan), _) => {
debug!("shutting down the constellation");
@ -332,9 +334,14 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
fn change_ready_state(&mut self, pipeline_id: PipelineId, ready_state: ReadyState) {
self.ready_states.insert_or_update_with(pipeline_id,
ready_state,
|_key, value| *value = ready_state);
match self.ready_states.entry(pipeline_id) {
Occupied(entry) => {
*entry.into_mut() = ready_state;
}
Vacant(entry) => {
entry.set(ready_state);
}
}
self.window.set_ready_state(self.get_earliest_pipeline_ready_state());
// If we're rendering in headless mode, schedule a recomposite.
@ -352,9 +359,15 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
fn change_render_state(&mut self, pipeline_id: PipelineId, render_state: RenderState) {
self.render_states.insert_or_update_with(pipeline_id,
render_state,
|_key, value| *value = render_state);
match self.render_states.entry(pipeline_id) {
Occupied(entry) => {
*entry.into_mut() = render_state;
}
Vacant(entry) => {
entry.set(render_state);
}
}
self.window.set_render_state(render_state);
}
@ -486,7 +499,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn find_pipeline_root_layer(&self, pipeline_id: PipelineId) -> Rc<Layer<CompositorData>> {
match self.find_layer_with_pipeline_and_layer_id(pipeline_id, LayerId::null()) {
Some(ref layer) => layer.clone(),
None => fail!("Tried to create or update layer for unknown pipeline"),
None => panic!("Tried to create or update layer for unknown pipeline"),
}
}
@ -578,7 +591,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
match self.fragment_point.take() {
Some(point) => {
if !self.move_layer(pipeline_id, layer_id, Point2D::from_untyped(&point)) {
fail!("Compositor: Tried to scroll to fragment with unknown layer.");
panic!("Compositor: Tried to scroll to fragment with unknown layer.");
}
self.start_scrolling_timer_if_necessary();
@ -606,7 +619,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
Some(ref layer) => {
layer.bounds.borrow_mut().origin = Point2D::from_untyped(&new_origin)
}
None => fail!("Compositor received SetLayerOrigin for nonexistent layer"),
None => panic!("Compositor received SetLayerOrigin for nonexistent layer"),
};
self.send_buffer_requests_for_all_layers();
@ -636,7 +649,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
// FIXME: This may potentially be triggered by a race condition where a
// buffers are being rendered but the layer is removed before rendering
// completes.
fail!("compositor given paint command for non-existent layer");
panic!("compositor given paint command for non-existent layer");
}
}
}
@ -725,7 +738,6 @@ impl<Window: WindowMethods> IOCompositor<Window> {
return;
}
debug!("osmain: window resized to {:?}", new_size);
self.window_size = new_size;
self.scene.set_root_layer_size(new_size.as_f32());
@ -737,7 +749,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.got_load_complete_message = false;
let root_pipeline_id = match self.scene.root {
Some(ref layer) => layer.extra_data.borrow().pipeline.id.clone(),
None => fail!("Compositor: Received LoadUrlWindowEvent without initialized compositor \
None => panic!("Compositor: Received LoadUrlWindowEvent without initialized compositor \
layers"),
};
@ -783,12 +795,12 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let delta = scroll_event.delta / self.scene.scale;
let cursor = scroll_event.cursor.as_f32() / self.scene.scale;
let scrolled = match self.scene.root {
match self.scene.root {
Some(ref mut layer) => {
layer.handle_scroll_event(delta, cursor) == ScrollPositionChanged
layer.handle_scroll_event(delta, cursor);
}
None => false,
};
None => {}
}
self.start_scrolling_timer_if_necessary();
self.send_buffer_requests_for_all_layers();
@ -876,10 +888,17 @@ impl<Window: WindowMethods> IOCompositor<Window> {
HashMap<PipelineId, (RenderChan, Vec<RenderRequest>)> = HashMap::new();
for (layer, mut layer_requests) in requests.into_iter() {
let pipeline_id = layer.extra_data.borrow().pipeline.id;
let &(_, ref mut vec) = results.find_or_insert_with(pipeline_id, |_| {
(layer.extra_data.borrow().pipeline.render_chan.clone(), Vec::new())
});
let &(_, ref mut vec) =
match results.entry(layer.extra_data.borrow().pipeline.id) {
Occupied(mut entry) => {
*entry.get_mut() =
(layer.extra_data.borrow().pipeline.render_chan.clone(), vec!());
entry.into_mut()
}
Vacant(entry) => {
entry.set((layer.extra_data.borrow().pipeline.render_chan.clone(), vec!()))
}
};
// All the BufferRequests are in layer/device coordinates, but the render task
// wants to know the page coordinates. We scale them before sending them.
@ -1045,11 +1064,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
for y in range(0, height) {
let dst_start = y * stride;
let src_start = (height - y - 1) * stride;
unsafe {
let src_slice = orig_pixels.slice(src_start, src_start + stride);
pixels.slice_mut(dst_start, dst_start + stride)
.copy_memory(src_slice.slice_to(stride));
}
let src_slice = orig_pixels.slice(src_start, src_start + stride);
copy_memory(pixels.slice_mut(dst_start, dst_start + stride),
src_slice.slice_to(stride));
}
let mut img = png::Image {
width: width as u32,
@ -1234,4 +1251,3 @@ impl<Window> CompositorEventListener for IOCompositor<Window> where Window: Wind
self.scrolling_timer.shutdown();
}
}

View file

@ -189,7 +189,7 @@ impl CompositorLayer for Layer<CompositorData> {
// layer buffer set is consumed, and None is returned.
fn add_buffers(&self, new_buffers: Box<LayerBufferSet>, epoch: Epoch) -> bool {
if self.extra_data.borrow().epoch != epoch {
debug!("add_buffers: compositor epoch mismatch: {:?} != {:?}, id: {:?}",
debug!("add_buffers: compositor epoch mismatch: {} != {}, id: {}",
self.extra_data.borrow().epoch,
epoch,
self.extra_data.borrow().pipeline.id);
@ -357,4 +357,3 @@ impl CompositorLayer for Layer<CompositorData> {
}
}

View file

@ -30,7 +30,7 @@ use servo_util::opts;
use servo_util::task::spawn_named;
use servo_util::time::TimeProfilerChan;
use std::cell::{Cell, RefCell};
use std::collections::hashmap::{HashMap, HashSet};
use std::collections::{HashMap, HashSet};
use std::io;
use std::mem::replace;
use std::rc::Rc;
@ -267,7 +267,7 @@ impl NavigationContext {
/// Loads a new set of page frames, returning all evicted frame trees
fn load(&mut self, frame_tree: Rc<FrameTree>) -> Vec<Rc<FrameTree>> {
debug!("navigating to {:?}", frame_tree.pipeline.id);
debug!("navigating to {}", frame_tree.pipeline.id);
let evicted = replace(&mut self.next, vec!());
if self.current.is_some() {
self.previous.push(self.current.take().unwrap());
@ -465,7 +465,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
fn handle_failure_msg(&mut self, pipeline_id: PipelineId, subpage_id: Option<SubpageId>) {
debug!("handling failure message from pipeline {:?}, {:?}", pipeline_id, subpage_id);
debug!("handling failure message from pipeline {}, {}", pipeline_id, subpage_id);
if opts::get().hard_fail {
// It's quite difficult to make Servo exit cleanly if some tasks have failed.
@ -476,7 +476,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
unsafe { libc::exit(1); }
}
let old_pipeline = match self.pipelines.find(&pipeline_id) {
let old_pipeline = match self.pipelines.get(&pipeline_id) {
None => {
debug!("no existing pipeline found; bailing out of failure recovery.");
return; // already failed?
@ -536,7 +536,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
fn handle_frame_rect_msg(&mut self, pipeline_id: PipelineId, subpage_id: SubpageId,
rect: TypedRect<PagePx, f32>) {
debug!("Received frame rect {:?} from {:?}, {:?}", rect, pipeline_id, subpage_id);
debug!("Received frame rect {} from {}, {}", rect, pipeline_id, subpage_id);
let mut already_sent = HashSet::new();
// Returns true if a child frame tree's subpage id matches the given subpage id
@ -635,16 +635,16 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// and add the new pipeline to their sub frames.
let frame_trees = self.find_all(source_pipeline_id);
if frame_trees.is_empty() {
fail!("Constellation: source pipeline id of ScriptLoadedURLInIFrameMsg is not in
navigation context, nor is it in a pending frame. This should be
impossible.");
panic!("Constellation: source pipeline id of ScriptLoadedURLInIFrameMsg is not in
navigation context, nor is it in a pending frame. This should be
impossible.");
}
let next_pipeline_id = self.get_next_pipeline_id();
// Compare the pipeline's url to the new url. If the origin is the same,
// then reuse the script task in creating the new pipeline
let source_pipeline = self.pipelines.find(&source_pipeline_id).expect("Constellation:
let source_pipeline = self.pipelines.get(&source_pipeline_id).expect("Constellation:
source Id of ScriptLoadedURLInIFrameMsg does have an associated pipeline in
constellation. This should be impossible.").clone();
@ -655,10 +655,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// FIXME(tkuehn): Need to follow the standardized spec for checking same-origin
// Reuse the script task if the URL is same-origin
let script_pipeline = if same_script {
debug!("Constellation: loading same-origin iframe at {:?}", url);
debug!("Constellation: loading same-origin iframe at {}", url);
Some(source_pipeline.clone())
} else {
debug!("Constellation: loading cross-origin iframe at {:?}", url);
debug!("Constellation: loading cross-origin iframe at {}", url);
None
};
@ -669,7 +669,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
LoadData::new(url)
);
let rect = self.pending_sizes.pop(&(source_pipeline_id, subpage_id));
let rect = self.pending_sizes.remove(&(source_pipeline_id, subpage_id));
for frame_tree in frame_trees.iter() {
frame_tree.children.borrow_mut().push(ChildFrameTree::new(
Rc::new(FrameTree::new(pipeline.clone(), Some(source_pipeline.clone()))),
@ -716,7 +716,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
fn handle_navigate_msg(&mut self, direction: constellation_msg::NavigationDirection) {
debug!("received message to navigate {:?}", direction);
debug!("received message to navigate {}", direction);
// TODO(tkuehn): what is the "critical point" beyond which pending frames
// should not be cleared? Currently, the behavior is that forward/back
@ -762,7 +762,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
fn handle_renderer_ready_msg(&mut self, pipeline_id: PipelineId) {
debug!("Renderer {:?} ready to send paint msg", pipeline_id);
debug!("Renderer {} ready to send paint msg", pipeline_id);
// This message could originate from a pipeline in the navigation context or
// from a pending frame. The only time that we will grant paint permission is
// when the message originates from a pending frame or the current frame.
@ -795,7 +795,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// If there are frames to revoke permission from, do so now.
match frame_change.before {
Some(revoke_id) if self.current_frame().is_some() => {
debug!("Constellation: revoking permission from {:?}", revoke_id);
debug!("Constellation: revoking permission from {}", revoke_id);
let current_frame = self.current_frame().as_ref().unwrap();
let to_revoke = current_frame.find(revoke_id).expect(
@ -812,7 +812,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let mut flag = false;
{
if to_add.parent.borrow().is_some() {
debug!("Constellation: replacing {:?} with {:?} in {:?}",
debug!("Constellation: replacing {} with {} in {}",
revoke_id, to_add.pipeline.id,
next_frame_tree.pipeline.id);
flag = true;
@ -830,7 +830,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let subpage_id = to_add.pipeline.subpage_id
.expect("Constellation:
Child frame's subpage id is None. This should be impossible.");
let rect = self.pending_sizes.pop(&(parent.id, subpage_id));
let rect = self.pending_sizes.remove(&(parent.id, subpage_id));
let parent = next_frame_tree.find(parent.id).expect(
"Constellation: pending frame has a parent frame that is not
active. This is a bug.");
@ -870,7 +870,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
for change in self.pending_frames.iter() {
let frame_tree = &change.after;
if frame_tree.parent.borrow().is_none() {
debug!("constellation sending resize message to pending outer frame ({:?})",
debug!("constellation sending resize message to pending outer frame ({})",
frame_tree.pipeline.id);
let ScriptControlChan(ref chan) = frame_tree.pipeline.script_chan;
let _ = chan.send_opt(ResizeMsg(frame_tree.pipeline.id, new_size));
@ -990,4 +990,3 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
}
}

View file

@ -7,13 +7,12 @@
#![feature(globs, phase, macro_rules)]
#![deny(unused_imports, unused_variable)]
#![deny(unused_imports)]
#![deny(unused_variables)]
#[phase(plugin, link)]
extern crate log;
extern crate debug;
extern crate alert;
extern crate azure;
extern crate devtools_traits;

View file

@ -168,7 +168,7 @@ impl Pipeline {
}
pub fn exit(&self) {
debug!("pipeline {:?} exiting", self.id);
debug!("pipeline {} exiting", self.id);
// Script task handles shutting down layout, and layout handles shutting down the renderer.
// For now, if the script task has failed, we give up on clean shutdown.
@ -189,4 +189,3 @@ impl Pipeline {
}
}
}