Update rustc to revision 3dcd2157403163789aaf21a9ab3c4d30a7c6494d.

This commit is contained in:
Ms2ger 2014-12-17 10:42:52 +01:00 committed by Josh Matthews
parent b8900782b0
commit 466faac2a5
223 changed files with 4414 additions and 4105 deletions

View file

@ -54,3 +54,6 @@ git = "https://github.com/servo/rust-core-text"
[dependencies.gleam]
git = "https://github.com/servo/gleam"
[dependencies.time]
git = "https://github.com/rust-lang/time"

View file

@ -2,25 +2,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use compositor_layer::{CompositorData, CompositorLayer, DoesntWantScrollEvents};
use compositor_layer::{WantsScrollEvents};
use compositor_task;
use compositor_task::{ChangePageLoadData, ChangePageTitle, ChangePaintState, ChangeReadyState};
use compositor_task::{CompositorEventListener, CompositorProxy, CompositorReceiver};
use compositor_task::{CompositorTask, CreateOrUpdateDescendantLayer, CreateOrUpdateRootLayer};
use compositor_task::{Exit, FrameTreeUpdateMsg, GetGraphicsMetadata, LayerProperties};
use compositor_task::{LoadComplete, Msg, Paint, PaintMsgDiscarded, ScrollFragmentPoint};
use compositor_task::{ScrollTimeout, SetIds, SetLayerOrigin, ShutdownComplete};
use compositor_layer::{CompositorData, CompositorLayer, WantsScrollEventsFlag};
use compositor_task::{CompositorEventListener, CompositorProxy, CompositorReceiver, CompositorTask};
use compositor_task::{LayerProperties, Msg};
use constellation::{FrameId, FrameTreeDiff, SendableFrameTree};
use pipeline::CompositionPipeline;
use scrolling::ScrollingTimerProxy;
use windowing;
use windowing::{IdleWindowEvent, InitializeCompositingWindowEvent};
use windowing::{KeyEvent, LoadUrlWindowEvent, MouseWindowClickEvent, MouseWindowEvent};
use windowing::{MouseWindowEventClass, MouseWindowMouseDownEvent, MouseWindowMouseUpEvent};
use windowing::{MouseWindowMoveEventClass, NavigationWindowEvent, PinchZoomWindowEvent};
use windowing::{QuitWindowEvent, RefreshWindowEvent, ResizeWindowEvent, ScrollWindowEvent};
use windowing::{WindowEvent, WindowMethods, WindowNavigateMsg, ZoomWindowEvent};
use windowing::{MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};
use azure::azure_hl;
use std::cmp;
@ -54,6 +43,7 @@ use servo_util::{memory, time};
use std::collections::HashMap;
use std::collections::hash_map::{Occupied, Vacant};
use std::path::Path;
use std::num::FloatMath;
use std::rc::Rc;
use std::slice::bytes::copy_memory;
use time::{precise_time_ns, precise_time_s};
@ -192,9 +182,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
window_size: window_size,
hidpi_factor: hidpi_factor,
scrolling_timer: ScrollingTimerProxy::new(sender),
composition_request: NoCompositingNecessary,
composition_request: CompositionRequest::NoCompositingNecessary,
pending_scroll_events: Vec::new(),
shutdown_state: NotShuttingDown,
shutdown_state: ShutdownState::NotShuttingDown,
page_zoom: ScaleFactor(1.0),
viewport_zoom: ScaleFactor(1.0),
zoom_action: false,
@ -237,83 +227,88 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn handle_browser_message(&mut self, msg: Msg) -> bool {
match (msg, self.shutdown_state) {
(_, FinishedShuttingDown) =>
(_, ShutdownState::FinishedShuttingDown) =>
panic!("compositor shouldn't be handling messages after shutting down"),
(Exit(chan), _) => {
(Msg::Exit(chan), _) => {
debug!("shutting down the constellation");
let ConstellationChan(ref con_chan) = self.constellation_chan;
con_chan.send(ExitMsg);
chan.send(());
self.shutdown_state = ShuttingDown;
self.shutdown_state = ShutdownState::ShuttingDown;
}
(ShutdownComplete, _) => {
(Msg::ShutdownComplete, _) => {
debug!("constellation completed shutdown");
self.shutdown_state = FinishedShuttingDown;
self.shutdown_state = ShutdownState::FinishedShuttingDown;
return false;
}
(ChangeReadyState(pipeline_id, ready_state), NotShuttingDown) => {
(Msg::ChangeReadyState(pipeline_id, ready_state), ShutdownState::NotShuttingDown) => {
self.change_ready_state(pipeline_id, ready_state);
}
(ChangePaintState(pipeline_id, paint_state), NotShuttingDown) => {
(Msg::ChangePaintState(pipeline_id, paint_state), ShutdownState::NotShuttingDown) => {
self.change_paint_state(pipeline_id, paint_state);
}
(ChangePageTitle(pipeline_id, title), NotShuttingDown) => {
(Msg::ChangePageTitle(pipeline_id, title), ShutdownState::NotShuttingDown) => {
self.change_page_title(pipeline_id, title);
}
(ChangePageLoadData(frame_id, load_data), NotShuttingDown) => {
(Msg::ChangePageLoadData(frame_id, load_data), ShutdownState::NotShuttingDown) => {
self.change_page_load_data(frame_id, load_data);
}
(PaintMsgDiscarded, NotShuttingDown) => {
(Msg::PaintMsgDiscarded, ShutdownState::NotShuttingDown) => {
self.remove_outstanding_paint_msg();
}
(SetIds(frame_tree, response_chan, new_constellation_chan), NotShuttingDown) => {
(Msg::SetIds(frame_tree, response_chan, new_constellation_chan),
ShutdownState::NotShuttingDown) => {
self.set_frame_tree(&frame_tree,
response_chan,
new_constellation_chan);
self.send_viewport_rects_for_all_layers();
}
(FrameTreeUpdateMsg(frame_tree_diff, response_channel), NotShuttingDown) => {
(Msg::FrameTreeUpdate(frame_tree_diff, response_channel),
ShutdownState::NotShuttingDown) => {
self.update_frame_tree(&frame_tree_diff);
response_channel.send(());
}
(CreateOrUpdateRootLayer(layer_properties), NotShuttingDown) => {
(Msg::CreateOrUpdateRootLayer(layer_properties), ShutdownState::NotShuttingDown) => {
self.create_or_update_root_layer(layer_properties);
}
(CreateOrUpdateDescendantLayer(layer_properties), NotShuttingDown) => {
(Msg::CreateOrUpdateDescendantLayer(layer_properties),
ShutdownState::NotShuttingDown) => {
self.create_or_update_descendant_layer(layer_properties);
}
(GetGraphicsMetadata(chan), NotShuttingDown) => {
(Msg::GetGraphicsMetadata(chan), ShutdownState::NotShuttingDown) => {
chan.send(Some(self.window.native_metadata()));
}
(SetLayerOrigin(pipeline_id, layer_id, origin), NotShuttingDown) => {
(Msg::SetLayerOrigin(pipeline_id, layer_id, origin),
ShutdownState::NotShuttingDown) => {
self.set_layer_origin(pipeline_id, layer_id, origin);
}
(Paint(pipeline_id, epoch, replies), NotShuttingDown) => {
(Msg::Paint(pipeline_id, epoch, replies), ShutdownState::NotShuttingDown) => {
for (layer_id, new_layer_buffer_set) in replies.into_iter() {
self.paint(pipeline_id, layer_id, new_layer_buffer_set, epoch);
}
self.remove_outstanding_paint_msg();
}
(ScrollFragmentPoint(pipeline_id, layer_id, point), NotShuttingDown) => {
(Msg::ScrollFragmentPoint(pipeline_id, layer_id, point),
ShutdownState::NotShuttingDown) => {
self.scroll_fragment_to_point(pipeline_id, layer_id, point);
}
(LoadComplete, NotShuttingDown) => {
(Msg::LoadComplete, ShutdownState::NotShuttingDown) => {
self.got_load_complete_message = true;
// If we're painting in headless mode, schedule a recomposite.
@ -327,24 +322,26 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.window.load_end();
}
(ScrollTimeout(timestamp), NotShuttingDown) => {
(Msg::ScrollTimeout(timestamp), ShutdownState::NotShuttingDown) => {
debug!("scroll timeout, drawing unpainted content!");
match self.composition_request {
CompositeOnScrollTimeout(this_timestamp) if timestamp == this_timestamp => {
self.composition_request = CompositeNow
CompositionRequest::CompositeOnScrollTimeout(this_timestamp) => {
if timestamp == this_timestamp {
self.composition_request = CompositionRequest::CompositeNow
}
}
_ => {}
}
}
(compositor_task::KeyEvent(key, modified), NotShuttingDown) => {
(Msg::KeyEvent(key, modified), ShutdownState::NotShuttingDown) => {
self.window.handle_key(key, modified);
}
// When we are shutting_down, we need to avoid performing operations
// such as Paint that may crash because we have begun tearing down
// the rest of our resources.
(_, ShuttingDown) => { }
(_, ShutdownState::ShuttingDown) => { }
}
true
@ -502,10 +499,11 @@ impl<Window: WindowMethods> IOCompositor<Window> {
root_layer.update_layer_except_size(layer_properties);
let root_layer_pipeline = root_layer.extra_data.borrow().pipeline.clone();
let first_child = CompositorData::new_layer(root_layer_pipeline.clone(),
layer_properties,
DoesntWantScrollEvents,
opts::get().tile_size);
let first_child = CompositorData::new_layer(
root_layer_pipeline.clone(),
layer_properties,
WantsScrollEventsFlag::DoesntWantScrollEvents,
opts::get().tile_size);
// Add the first child / base layer to the front of the child list, so that
// child iframe layers are painted on top of the base layer. These iframe
@ -533,7 +531,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let root_layer_pipeline = root_layer.extra_data.borrow().pipeline.clone();
let new_layer = CompositorData::new_layer(root_layer_pipeline,
layer_properties,
DoesntWantScrollEvents,
WantsScrollEventsFlag::DoesntWantScrollEvents,
root_layer.tile_size);
root_layer.add_child(new_layer);
}
@ -558,7 +556,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
-> bool {
match self.find_layer_with_pipeline_and_layer_id(pipeline_id, layer_id) {
Some(ref layer) => {
if layer.extra_data.borrow().wants_scroll_events == WantsScrollEvents {
if layer.wants_scroll_events() == WantsScrollEventsFlag::WantsScrollEvents {
layer.clamp_scroll_offset_and_scroll_layer(TypedPoint2D(0f32, 0f32) - origin);
}
true
@ -584,13 +582,14 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn start_scrolling_timer_if_necessary(&mut self) {
match self.composition_request {
CompositeNow | CompositeOnScrollTimeout(_) => return,
NoCompositingNecessary => {}
CompositionRequest::CompositeNow | CompositionRequest::CompositeOnScrollTimeout(_) =>
return,
CompositionRequest::NoCompositingNecessary => {}
}
let timestamp = precise_time_ns();
self.scrolling_timer.scroll_event_processed(timestamp);
self.composition_request = CompositeOnScrollTimeout(timestamp);
self.composition_request = CompositionRequest::CompositeOnScrollTimeout(timestamp);
}
fn set_layer_origin(&mut self,
@ -651,57 +650,57 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn handle_window_message(&mut self, event: WindowEvent) {
match event {
IdleWindowEvent => {}
WindowEvent::Idle => {}
RefreshWindowEvent => {
WindowEvent::Refresh => {
self.composite();
}
InitializeCompositingWindowEvent => {
WindowEvent::InitializeCompositing => {
self.initialize_compositing();
}
ResizeWindowEvent(size) => {
WindowEvent::Resize(size) => {
self.on_resize_window_event(size);
}
LoadUrlWindowEvent(url_string) => {
WindowEvent::LoadUrl(url_string) => {
self.on_load_url_window_event(url_string);
}
MouseWindowEventClass(mouse_window_event) => {
WindowEvent::MouseWindowEventClass(mouse_window_event) => {
self.on_mouse_window_event_class(mouse_window_event);
}
MouseWindowMoveEventClass(cursor) => {
WindowEvent::MouseWindowMoveEventClass(cursor) => {
self.on_mouse_window_move_event_class(cursor);
}
ScrollWindowEvent(delta, cursor) => {
WindowEvent::Scroll(delta, cursor) => {
self.on_scroll_window_event(delta, cursor);
}
ZoomWindowEvent(magnification) => {
WindowEvent::Zoom(magnification) => {
self.on_zoom_window_event(magnification);
}
PinchZoomWindowEvent(magnification) => {
WindowEvent::PinchZoom(magnification) => {
self.on_pinch_zoom_window_event(magnification);
}
NavigationWindowEvent(direction) => {
WindowEvent::Navigation(direction) => {
self.on_navigation_window_event(direction);
}
KeyEvent(key, state, modifiers) => {
WindowEvent::KeyEvent(key, state, modifiers) => {
self.on_key_event(key, state, modifiers);
}
QuitWindowEvent => {
debug!("shutting down the constellation for QuitWindowEvent");
WindowEvent::Quit => {
debug!("shutting down the constellation for WindowEvent::Quit");
let ConstellationChan(ref chan) = self.constellation_chan;
chan.send(ExitMsg);
self.shutdown_state = ShuttingDown;
self.shutdown_state = ShutdownState::ShuttingDown;
}
}
}
@ -731,7 +730,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 => panic!("Compositor: Received LoadUrlWindowEvent without initialized compositor \
None => panic!("Compositor: Received WindowEvent::LoadUrl without initialized compositor \
layers"),
};
@ -743,9 +742,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn on_mouse_window_event_class(&self, mouse_window_event: MouseWindowEvent) {
let point = match mouse_window_event {
MouseWindowClickEvent(_, p) => p,
MouseWindowMouseDownEvent(_, p) => p,
MouseWindowMouseUpEvent(_, p) => p,
MouseWindowEvent::MouseWindowClickEvent(_, p) => p,
MouseWindowEvent::MouseWindowMouseDownEvent(_, p) => p,
MouseWindowEvent::MouseWindowMouseUpEvent(_, p) => p,
};
match self.find_topmost_layer_at_point(point / self.scene.scale) {
Some(result) => result.layer.send_mouse_event(mouse_window_event, result.point),
@ -853,8 +852,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn on_navigation_window_event(&self, direction: WindowNavigateMsg) {
let direction = match direction {
windowing::Forward => constellation_msg::Forward,
windowing::Back => constellation_msg::Back,
windowing::WindowNavigateMsg::Forward => constellation_msg::Forward,
windowing::WindowNavigateMsg::Back => constellation_msg::Back,
};
let ConstellationChan(ref chan) = self.constellation_chan;
chan.send(NavigateMsg(direction))
@ -1077,7 +1076,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
debug!("shutting down the constellation after generating an output file");
let ConstellationChan(ref chan) = self.constellation_chan;
chan.send(ExitMsg);
self.shutdown_state = ShuttingDown;
self.shutdown_state = ShutdownState::ShuttingDown;
}
// Perform the page flip. This will likely block for a while.
@ -1085,13 +1084,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.last_composite_time = precise_time_ns();
self.composition_request = NoCompositingNecessary;
self.composition_request = CompositionRequest::NoCompositingNecessary;
self.process_pending_scroll_events();
}
fn composite_if_necessary(&mut self) {
if self.composition_request == NoCompositingNecessary {
self.composition_request = CompositeNow
if self.composition_request == CompositionRequest::NoCompositingNecessary {
self.composition_request = CompositionRequest::CompositeNow
}
}
@ -1208,7 +1207,7 @@ fn create_root_layer_for_pipeline_and_rect(pipeline: &CompositionPipeline,
let root_layer = CompositorData::new_layer(pipeline.clone(),
layer_properties,
WantsScrollEvents,
WantsScrollEventsFlag::WantsScrollEvents,
opts::get().tile_size);
// All root layers mask to bounds.
@ -1239,7 +1238,7 @@ impl<Window> CompositorEventListener for IOCompositor<Window> where Window: Wind
}
}
if self.shutdown_state == FinishedShuttingDown {
if self.shutdown_state == ShutdownState::FinishedShuttingDown {
// We have exited the compositor and passing window
// messages to script may crash.
debug!("Exiting the compositor due to a request from script.");
@ -1257,11 +1256,11 @@ impl<Window> CompositorEventListener for IOCompositor<Window> where Window: Wind
}
match self.composition_request {
NoCompositingNecessary | CompositeOnScrollTimeout(_) => {}
CompositeNow => self.composite(),
CompositionRequest::NoCompositingNecessary | CompositionRequest::CompositeOnScrollTimeout(_) => {}
CompositionRequest::CompositeNow => self.composite(),
}
self.shutdown_state != FinishedShuttingDown
self.shutdown_state != ShutdownState::FinishedShuttingDown
}
/// Repaints and recomposites synchronously. You must be careful when calling this, as if a
@ -1269,10 +1268,10 @@ impl<Window> CompositorEventListener for IOCompositor<Window> where Window: Wind
///
/// This is used when resizing the window.
fn repaint_synchronously(&mut self) {
while self.shutdown_state != ShuttingDown {
while self.shutdown_state != ShutdownState::ShuttingDown {
let msg = self.port.recv_compositor_msg();
let is_paint = match msg {
Paint(..) => true,
Msg::Paint(..) => true,
_ => false,
};
let keep_going = self.handle_browser_message(msg);
@ -1299,10 +1298,10 @@ impl<Window> CompositorEventListener for IOCompositor<Window> where Window: Wind
// Tell the profiler, memory profiler, and scrolling timer to shut down.
let TimeProfilerChan(ref time_profiler_chan) = self.time_profiler_chan;
time_profiler_chan.send(time::ExitMsg);
time_profiler_chan.send(time::TimeProfilerMsg::Exit);
let MemoryProfilerChan(ref memory_profiler_chan) = self.memory_profiler_chan;
memory_profiler_chan.send(memory::ExitMsg);
memory_profiler_chan.send(memory::MemoryProfilerMsg::Exit);
self.scrolling_timer.shutdown();
}

View file

@ -4,9 +4,7 @@
use compositor_task::LayerProperties;
use pipeline::CompositionPipeline;
use windowing::{MouseWindowEvent, MouseWindowClickEvent, MouseWindowMouseDownEvent};
use windowing::MouseWindowMouseUpEvent;
use windowing::WindowMethods;
use windowing::{MouseWindowEvent, WindowMethods};
use azure::azure_hl;
use geom::length::Length;
@ -22,6 +20,8 @@ use layers::platform::surface::NativeSurfaceMethods;
use script_traits::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent, SendEventMsg};
use script_traits::{ScriptControlChan};
use servo_msg::compositor_msg::{Epoch, FixedPosition, LayerId, ScrollPolicy};
use std::num::Float;
use std::num::FloatMath;
use std::rc::Rc;
pub struct CompositorData {
@ -117,6 +117,9 @@ pub trait CompositorLayer {
fn scroll_layer_and_all_child_layers(&self,
new_offset: TypedPoint2D<LayerPixel, f32>)
-> bool;
/// Return a flag describing how this layer deals with scroll events.
fn wants_scroll_events(&self) -> WantsScrollEventsFlag;
}
#[deriving(PartialEq, Clone)]
@ -260,8 +263,8 @@ impl CompositorLayer for Layer<CompositorData> {
-> ScrollEventResult {
// If this layer doesn't want scroll events, neither it nor its children can handle scroll
// events.
if self.extra_data.borrow().wants_scroll_events != WantsScrollEvents {
return ScrollEventUnhandled;
if self.wants_scroll_events() != WantsScrollEventsFlag::WantsScrollEvents {
return ScrollEventResult::ScrollEventUnhandled;
}
//// Allow children to scroll.
@ -271,7 +274,7 @@ impl CompositorLayer for Layer<CompositorData> {
let child_bounds = child.bounds.borrow();
if child_bounds.contains(&new_cursor) {
let result = child.handle_scroll_event(delta, new_cursor - child_bounds.origin);
if result != ScrollEventUnhandled {
if result != ScrollEventResult::ScrollEventUnhandled {
return result;
}
}
@ -292,7 +295,7 @@ impl CompositorLayer for Layer<CompositorData> {
Length(new_offset.y.get().clamp(&min_y, &0.0)));
if self.extra_data.borrow().scroll_offset == new_offset {
return ScrollPositionUnchanged;
return ScrollEventResult::ScrollPositionUnchanged;
}
// The scroll offset is just a record of the scroll position of this scrolling root,
@ -305,9 +308,9 @@ impl CompositorLayer for Layer<CompositorData> {
}
if result {
return ScrollPositionChanged;
return ScrollEventResult::ScrollPositionChanged;
} else {
return ScrollPositionUnchanged;
return ScrollEventResult::ScrollPositionUnchanged;
}
}
@ -316,9 +319,12 @@ impl CompositorLayer for Layer<CompositorData> {
cursor: TypedPoint2D<LayerPixel, f32>) {
let event_point = cursor.to_untyped();
let message = match event {
MouseWindowClickEvent(button, _) => ClickEvent(button, event_point),
MouseWindowMouseDownEvent(button, _) => MouseDownEvent(button, event_point),
MouseWindowMouseUpEvent(button, _) => MouseUpEvent(button, event_point),
MouseWindowEvent::MouseWindowClickEvent(button, _) =>
ClickEvent(button, event_point),
MouseWindowEvent::MouseWindowMouseDownEvent(button, _) =>
MouseDownEvent(button, event_point),
MouseWindowEvent::MouseWindowMouseUpEvent(button, _) =>
MouseUpEvent(button, event_point),
};
let pipeline = &self.extra_data.borrow().pipeline;
let ScriptControlChan(ref chan) = pipeline.script_chan;
@ -356,4 +362,8 @@ impl CompositorLayer for Layer<CompositorData> {
return result;
}
fn wants_scroll_events(&self) -> WantsScrollEventsFlag {
self.extra_data.borrow().wants_scroll_events
}
}

View file

@ -62,7 +62,7 @@ impl CompositorReceiver for Receiver<Msg> {
/// Implementation of the abstract `ScriptListener` interface.
impl ScriptListener for Box<CompositorProxy+'static+Send> {
fn set_ready_state(&mut self, pipeline_id: PipelineId, ready_state: ReadyState) {
let msg = ChangeReadyState(pipeline_id, ready_state);
let msg = Msg::ChangeReadyState(pipeline_id, ready_state);
self.send(msg);
}
@ -70,12 +70,12 @@ impl ScriptListener for Box<CompositorProxy+'static+Send> {
pipeline_id: PipelineId,
layer_id: LayerId,
point: Point2D<f32>) {
self.send(ScrollFragmentPoint(pipeline_id, layer_id, point));
self.send(Msg::ScrollFragmentPoint(pipeline_id, layer_id, point));
}
fn close(&mut self) {
let (chan, port) = channel();
self.send(Exit(chan));
self.send(Msg::Exit(chan));
port.recv();
}
@ -84,12 +84,12 @@ impl ScriptListener for Box<CompositorProxy+'static+Send> {
}
fn set_title(&mut self, pipeline_id: PipelineId, title: Option<String>) {
self.send(ChangePageTitle(pipeline_id, title))
self.send(Msg::ChangePageTitle(pipeline_id, title))
}
fn send_key_event(&mut self, key: Key, state: KeyState, modifiers: KeyModifiers) {
if state == Pressed {
self.send(KeyEvent(key, modifiers));
self.send(Msg::KeyEvent(key, modifiers));
}
}
}
@ -124,7 +124,7 @@ impl LayerProperties {
impl PaintListener for Box<CompositorProxy+'static+Send> {
fn get_graphics_metadata(&mut self) -> Option<NativeGraphicsMetadata> {
let (chan, port) = channel();
self.send(GetGraphicsMetadata(chan));
self.send(Msg::GetGraphicsMetadata(chan));
port.recv()
}
@ -132,7 +132,7 @@ impl PaintListener for Box<CompositorProxy+'static+Send> {
pipeline_id: PipelineId,
epoch: Epoch,
replies: Vec<(LayerId, Box<LayerBufferSet>)>) {
self.send(Paint(pipeline_id, epoch, replies));
self.send(Msg::Paint(pipeline_id, epoch, replies));
}
fn initialize_layers_for_pipeline(&mut self,
@ -146,20 +146,20 @@ impl PaintListener for Box<CompositorProxy+'static+Send> {
for metadata in metadata.iter() {
let layer_properties = LayerProperties::new(pipeline_id, epoch, metadata);
if first {
self.send(CreateOrUpdateRootLayer(layer_properties));
self.send(Msg::CreateOrUpdateRootLayer(layer_properties));
first = false
} else {
self.send(CreateOrUpdateDescendantLayer(layer_properties));
self.send(Msg::CreateOrUpdateDescendantLayer(layer_properties));
}
}
}
fn paint_msg_discarded(&mut self) {
self.send(PaintMsgDiscarded);
self.send(Msg::PaintMsgDiscarded);
}
fn set_paint_state(&mut self, pipeline_id: PipelineId, paint_state: PaintState) {
self.send(ChangePaintState(pipeline_id, paint_state))
self.send(Msg::ChangePaintState(pipeline_id, paint_state))
}
}
@ -205,7 +205,7 @@ pub enum Msg {
/// Sets the channel to the current layout and paint tasks, along with their ID.
SetIds(SendableFrameTree, Sender<()>, ConstellationChan),
/// Sends an updated version of the frame tree.
FrameTreeUpdateMsg(FrameTreeDiff, Sender<()>),
FrameTreeUpdate(FrameTreeDiff, Sender<()>),
/// The load of a page has completed.
LoadComplete,
/// Indicates that the scrolling timeout with the given starting timestamp has happened and a
@ -218,24 +218,24 @@ pub enum Msg {
impl Show for Msg {
fn fmt(&self, f: &mut Formatter) -> Result<(),FormatError> {
match *self {
Exit(..) => write!(f, "Exit"),
ShutdownComplete(..) => write!(f, "ShutdownComplete"),
GetGraphicsMetadata(..) => write!(f, "GetGraphicsMetadata"),
CreateOrUpdateRootLayer(..) => write!(f, "CreateOrUpdateRootLayer"),
CreateOrUpdateDescendantLayer(..) => write!(f, "CreateOrUpdateDescendantLayer"),
SetLayerOrigin(..) => write!(f, "SetLayerOrigin"),
ScrollFragmentPoint(..) => write!(f, "ScrollFragmentPoint"),
Paint(..) => write!(f, "Paint"),
ChangeReadyState(..) => write!(f, "ChangeReadyState"),
ChangePaintState(..) => write!(f, "ChangePaintState"),
ChangePageTitle(..) => write!(f, "ChangePageTitle"),
ChangePageLoadData(..) => write!(f, "ChangePageLoadData"),
PaintMsgDiscarded(..) => write!(f, "PaintMsgDiscarded"),
SetIds(..) => write!(f, "SetIds"),
FrameTreeUpdateMsg(..) => write!(f, "FrameTreeUpdateMsg"),
LoadComplete => write!(f, "LoadComplete"),
ScrollTimeout(..) => write!(f, "ScrollTimeout"),
KeyEvent(..) => write!(f, "KeyEvent"),
Msg::Exit(..) => write!(f, "Exit"),
Msg::ShutdownComplete(..) => write!(f, "ShutdownComplete"),
Msg::GetGraphicsMetadata(..) => write!(f, "GetGraphicsMetadata"),
Msg::CreateOrUpdateRootLayer(..) => write!(f, "CreateOrUpdateRootLayer"),
Msg::CreateOrUpdateDescendantLayer(..) => write!(f, "CreateOrUpdateDescendantLayer"),
Msg::SetLayerOrigin(..) => write!(f, "SetLayerOrigin"),
Msg::ScrollFragmentPoint(..) => write!(f, "ScrollFragmentPoint"),
Msg::Paint(..) => write!(f, "Paint"),
Msg::ChangeReadyState(..) => write!(f, "ChangeReadyState"),
Msg::ChangePaintState(..) => write!(f, "ChangePaintState"),
Msg::ChangePageTitle(..) => write!(f, "ChangePageTitle"),
Msg::ChangePageLoadData(..) => write!(f, "ChangePageLoadData"),
Msg::PaintMsgDiscarded(..) => write!(f, "PaintMsgDiscarded"),
Msg::SetIds(..) => write!(f, "SetIds"),
Msg::FrameTreeUpdate(..) => write!(f, "FrameTreeUpdateMsg"),
Msg::LoadComplete => write!(f, "LoadComplete"),
Msg::ScrollTimeout(..) => write!(f, "ScrollTimeout"),
Msg::KeyEvent(..) => write!(f, "KeyEvent"),
}
}
}

View file

@ -4,8 +4,8 @@
use pipeline::{Pipeline, CompositionPipeline};
use compositor_task::{ChangePageLoadData, ChangePageTitle, CompositorProxy, FrameTreeUpdateMsg};
use compositor_task::{LoadComplete, SetLayerOrigin, SetIds, ShutdownComplete};
use compositor_task::CompositorProxy;
use compositor_task::Msg as CompositorMsg;
use devtools_traits;
use devtools_traits::DevtoolsControlChan;
use geom::rect::{Rect, TypedRect};
@ -22,9 +22,10 @@ use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, FailureMsg, Failu
use servo_msg::constellation_msg::{GetPipelineTitleMsg};
use servo_msg::constellation_msg::{IFrameSandboxState, IFrameUnsandboxed, InitLoadUrlMsg};
use servo_msg::constellation_msg::{KeyEvent, Key, KeyState, KeyModifiers, LoadCompleteMsg};
use servo_msg::constellation_msg::{LoadData, LoadUrlMsg, Msg, NavigateMsg, NavigationType};
use servo_msg::constellation_msg::{LoadData, LoadUrlMsg, NavigateMsg, NavigationType};
use servo_msg::constellation_msg::{PainterReadyMsg, PipelineId, ResizedWindowMsg};
use servo_msg::constellation_msg::{ScriptLoadedURLInIFrameMsg, SubpageId, WindowSizeData};
use servo_msg::constellation_msg::Msg as ConstellationMsg;
use servo_msg::constellation_msg;
use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
use servo_net::resource_task::ResourceTask;
@ -48,7 +49,7 @@ pub struct Constellation<LTF, STF> {
pub chan: ConstellationChan,
/// Receives messages.
pub request_port: Receiver<Msg>,
pub request_port: Receiver<ConstellationMsg>,
/// A channel (the implementation of which is port-specific) through which messages can be sent
/// to the compositor.
@ -203,12 +204,12 @@ impl FrameTreeTraversal for Rc<FrameTree> {
match child {
Some(child) => {
*new_child.parent.borrow_mut() = child.frame_tree.parent.borrow().clone();
return ReplacedNode(replace(&mut child.frame_tree, new_child));
return ReplaceResult::ReplacedNode(replace(&mut child.frame_tree, new_child));
}
None => (),
}
}
OriginalNode(new_child)
ReplaceResult::OriginalNode(new_child)
}
fn iter(&self) -> FrameTreeIterator {
@ -333,8 +334,9 @@ impl NavigationContext {
/// compositor of the new URLs.
fn set_current(&mut self, new_frame: Rc<FrameTree>, compositor_proxy: &mut CompositorProxy) {
self.current = Some(new_frame.clone());
compositor_proxy.send(ChangePageLoadData(new_frame.id,
new_frame.pipeline.load_data.clone()));
compositor_proxy.send(CompositorMsg::ChangePageLoadData(
new_frame.id,
new_frame.pipeline.load_data.clone()));
}
}
@ -442,7 +444,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
/// Handles loading pages, navigation, and granting access to the compositor
fn handle_request(&mut self, request: Msg) -> bool {
fn handle_request(&mut self, request: ConstellationMsg) -> bool {
match request {
ExitMsg => {
debug!("constellation exiting");
@ -481,7 +483,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// script, and reflow messages have been sent.
LoadCompleteMsg => {
debug!("constellation got load complete message");
self.compositor_proxy.send(LoadComplete);
self.compositor_proxy.send(CompositorMsg::LoadComplete);
}
// Handle a forward or back request
NavigateMsg(direction) => {
@ -520,7 +522,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
});
self.storage_task.send(storage_task::Exit);
self.font_cache_task.exit();
self.compositor_proxy.send(ShutdownComplete);
self.compositor_proxy.send(CompositorMsg::ShutdownComplete);
}
fn handle_failure_msg(&mut self, pipeline_id: PipelineId, subpage_id: Option<SubpageId>) {
@ -681,9 +683,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
initial_viewport: rect.size * ScaleFactor(1.0),
device_pixel_ratio: device_pixel_ratio,
}));
compositor_proxy.send(SetLayerOrigin(pipeline.id,
LayerId::null(),
rect.to_untyped().origin));
compositor_proxy.send(CompositorMsg::SetLayerOrigin(
pipeline.id,
LayerId::null(),
rect.to_untyped().origin));
} else {
already_sent.insert(pipeline.id);
}
@ -843,7 +846,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
fn handle_get_pipeline_title_msg(&mut self, pipeline_id: PipelineId) {
match self.pipelines.get(&pipeline_id) {
None => self.compositor_proxy.send(ChangePageTitle(pipeline_id, None)),
None => self.compositor_proxy.send(CompositorMsg::ChangePageTitle(pipeline_id, None)),
Some(pipeline) => {
let ScriptControlChan(ref script_channel) = pipeline.script_chan;
script_channel.send(GetTitleMsg(pipeline_id));
@ -1018,7 +1021,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
fn set_ids(&mut self, frame_tree: &Rc<FrameTree>) {
let (chan, port) = channel();
debug!("Constellation sending SetIds");
self.compositor_proxy.send(SetIds(frame_tree.to_sendable(), chan, self.chan.clone()));
self.compositor_proxy.send(CompositorMsg::SetIds(frame_tree.to_sendable(),
chan,
self.chan.clone()));
match port.recv_opt() {
Ok(()) => {
let mut iter = frame_tree.iter();
@ -1075,7 +1080,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
};
let (chan, port) = channel();
self.compositor_proxy.send(FrameTreeUpdateMsg(sendable_frame_tree_diff, chan));
self.compositor_proxy.send(CompositorMsg::FrameTreeUpdate(sendable_frame_tree_diff, chan));
match port.recv_opt() {
Ok(()) => {
child.frame_tree.has_compositor_layer.set(true);

View file

@ -2,11 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use compositor_task::{GetGraphicsMetadata, CreateOrUpdateRootLayer, CreateOrUpdateDescendantLayer};
use compositor_task::{Exit, ChangeReadyState, LoadComplete, Paint, ScrollFragmentPoint, SetIds};
use compositor_task::{SetLayerOrigin, ShutdownComplete, ChangePaintState, PaintMsgDiscarded};
use compositor_task::{CompositorEventListener, CompositorReceiver, ScrollTimeout, ChangePageTitle};
use compositor_task::{ChangePageLoadData, FrameTreeUpdateMsg, KeyEvent};
use compositor_task::{CompositorEventListener, CompositorReceiver, Msg};
use windowing::WindowEvent;
use geom::scale_factor::ScaleFactor;
@ -73,27 +69,27 @@ impl NullCompositor {
impl CompositorEventListener for NullCompositor {
fn handle_event(&mut self, _: WindowEvent) -> bool {
match self.port.recv_compositor_msg() {
Exit(chan) => {
Msg::Exit(chan) => {
debug!("shutting down the constellation");
let ConstellationChan(ref con_chan) = self.constellation_chan;
con_chan.send(ExitMsg);
chan.send(());
}
ShutdownComplete => {
Msg::ShutdownComplete => {
debug!("constellation completed shutdown");
return false
}
GetGraphicsMetadata(chan) => {
Msg::GetGraphicsMetadata(chan) => {
chan.send(None);
}
SetIds(_, response_chan, _) => {
Msg::SetIds(_, response_chan, _) => {
response_chan.send(());
}
FrameTreeUpdateMsg(_, response_channel) => {
Msg::FrameTreeUpdate(_, response_channel) => {
response_channel.send(());
}
@ -101,12 +97,12 @@ impl CompositorEventListener for NullCompositor {
// we'll notice and think about whether it needs a response, like
// SetIds.
CreateOrUpdateRootLayer(..) |
CreateOrUpdateDescendantLayer(..) |
SetLayerOrigin(..) | Paint(..) |
ChangeReadyState(..) | ChangePaintState(..) | ScrollFragmentPoint(..) |
LoadComplete | PaintMsgDiscarded(..) | ScrollTimeout(..) | ChangePageTitle(..) |
ChangePageLoadData(..) | KeyEvent(..) => ()
Msg::CreateOrUpdateRootLayer(..) |
Msg::CreateOrUpdateDescendantLayer(..) |
Msg::SetLayerOrigin(..) | Msg::Paint(..) |
Msg::ChangeReadyState(..) | Msg::ChangePaintState(..) | Msg::ScrollFragmentPoint(..) |
Msg::LoadComplete | Msg::PaintMsgDiscarded(..) | Msg::ScrollTimeout(..) | Msg::ChangePageTitle(..) |
Msg::ChangePageLoadData(..) | Msg::KeyEvent(..) => ()
}
true
}
@ -118,8 +114,8 @@ impl CompositorEventListener for NullCompositor {
// another task from finishing (i.e. SetIds)
while self.port.try_recv_compositor_msg().is_some() {}
self.time_profiler_chan.send(time::ExitMsg);
self.memory_profiler_chan.send(memory::ExitMsg);
self.time_profiler_chan.send(time::TimeProfilerMsg::Exit);
self.memory_profiler_chan.send(memory::MemoryProfilerMsg::Exit);
}
fn pinch_zoom_level(&self) -> f32 {

View file

@ -4,7 +4,7 @@
//! A timer thread that gives the painting task a little time to catch up when the user scrolls.
use compositor_task::{CompositorProxy, ScrollTimeout};
use compositor_task::{CompositorProxy, Msg};
use native::task::NativeTaskBuilder;
use std::io::timer;
@ -47,11 +47,11 @@ impl ScrollingTimerProxy {
}
pub fn scroll_event_processed(&mut self, timestamp: u64) {
self.sender.send(ScrollEventProcessedMsg(timestamp))
self.sender.send(ToScrollingTimerMsg::ScrollEventProcessedMsg(timestamp))
}
pub fn shutdown(&mut self) {
self.sender.send(ExitMsg);
self.sender.send(ToScrollingTimerMsg::ExitMsg);
}
}
@ -59,13 +59,13 @@ impl ScrollingTimer {
pub fn run(&mut self) {
loop {
match self.receiver.recv_opt() {
Ok(ScrollEventProcessedMsg(timestamp)) => {
Ok(ToScrollingTimerMsg::ScrollEventProcessedMsg(timestamp)) => {
let target = timestamp as i64 + TIMEOUT;
let delta = target - (time::precise_time_ns() as i64);
timer::sleep(Duration::nanoseconds(delta));
self.compositor_proxy.send(ScrollTimeout(timestamp));
self.compositor_proxy.send(Msg::ScrollTimeout(timestamp));
}
Ok(ExitMsg) | Err(_) => break,
Ok(ToScrollingTimerMsg::ExitMsg) | Err(_) => break,
}
}
}

View file

@ -36,32 +36,32 @@ pub enum WindowEvent {
/// FIXME(pcwalton): This is kind of ugly and may not work well with multiprocess Servo.
/// It's possible that this should be something like
/// `CompositorMessageWindowEvent(compositor_task::Msg)` instead.
IdleWindowEvent,
Idle,
/// Sent when part of the window is marked dirty and needs to be redrawn. Before sending this
/// message, the window must make the same GL context as in `PrepareRenderingEvent` current.
RefreshWindowEvent,
Refresh,
/// Sent to initialize the GL context. The windowing system must have a valid, current GL
/// context when this message is sent.
InitializeCompositingWindowEvent,
InitializeCompositing,
/// Sent when the window is resized.
ResizeWindowEvent(TypedSize2D<DevicePixel, uint>),
Resize(TypedSize2D<DevicePixel, uint>),
/// Sent when a new URL is to be loaded.
LoadUrlWindowEvent(String),
LoadUrl(String),
/// Sent when a mouse hit test is to be performed.
MouseWindowEventClass(MouseWindowEvent),
/// Sent when a mouse move.
MouseWindowMoveEventClass(TypedPoint2D<DevicePixel, f32>),
/// Sent when the user scrolls. The first point is the delta and the second point is the
/// origin.
ScrollWindowEvent(TypedPoint2D<DevicePixel, f32>, TypedPoint2D<DevicePixel, i32>),
Scroll(TypedPoint2D<DevicePixel, f32>, TypedPoint2D<DevicePixel, i32>),
/// Sent when the user zooms.
ZoomWindowEvent(f32),
Zoom(f32),
/// Simulated "pinch zoom" gesture for non-touch platforms (e.g. ctrl-scrollwheel).
PinchZoomWindowEvent(f32),
PinchZoom(f32),
/// Sent when the user uses chrome navigation (i.e. backspace or shift-backspace).
NavigationWindowEvent(WindowNavigateMsg),
Navigation(WindowNavigateMsg),
/// Sent when the user quits the application
QuitWindowEvent,
Quit,
/// Sent when a key input state changes
KeyEvent(Key, KeyState, KeyModifiers),
}
@ -69,19 +69,19 @@ pub enum WindowEvent {
impl Show for WindowEvent {
fn fmt(&self, f: &mut Formatter) -> Result<(),FormatError> {
match *self {
IdleWindowEvent => write!(f, "Idle"),
RefreshWindowEvent => write!(f, "Refresh"),
InitializeCompositingWindowEvent => write!(f, "InitializeCompositing"),
ResizeWindowEvent(..) => write!(f, "Resize"),
KeyEvent(..) => write!(f, "Key"),
LoadUrlWindowEvent(..) => write!(f, "LoadUrl"),
MouseWindowEventClass(..) => write!(f, "Mouse"),
MouseWindowMoveEventClass(..) => write!(f, "MouseMove"),
ScrollWindowEvent(..) => write!(f, "Scroll"),
ZoomWindowEvent(..) => write!(f, "Zoom"),
PinchZoomWindowEvent(..) => write!(f, "PinchZoom"),
NavigationWindowEvent(..) => write!(f, "Navigation"),
QuitWindowEvent => write!(f, "Quit"),
WindowEvent::Idle => write!(f, "Idle"),
WindowEvent::Refresh => write!(f, "Refresh"),
WindowEvent::InitializeCompositing => write!(f, "InitializeCompositing"),
WindowEvent::Resize(..) => write!(f, "Resize"),
WindowEvent::KeyEvent(..) => write!(f, "Key"),
WindowEvent::LoadUrl(..) => write!(f, "LoadUrl"),
WindowEvent::MouseWindowEventClass(..) => write!(f, "Mouse"),
WindowEvent::MouseWindowMoveEventClass(..) => write!(f, "MouseMove"),
WindowEvent::Scroll(..) => write!(f, "Scroll"),
WindowEvent::Zoom(..) => write!(f, "Zoom"),
WindowEvent::PinchZoom(..) => write!(f, "PinchZoom"),
WindowEvent::Navigation(..) => write!(f, "Navigation"),
WindowEvent::Quit => write!(f, "Quit"),
}
}
}