aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/compositing/compositor.rs40
-rw-r--r--components/compositing/lib.rs6
-rw-r--r--components/constellation/constellation.rs8
-rw-r--r--components/servo/lib.rs16
-rw-r--r--ports/gstplugin/servowebsrc.rs5
-rw-r--r--ports/libsimpleservo/api/src/lib.rs5
-rw-r--r--ports/winit/app.rs6
7 files changed, 47 insertions, 39 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index 73f71704f40..fd645f309de 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -23,7 +23,9 @@ use image::{DynamicImage, ImageFormat};
use ipc_channel::ipc;
use libc::c_void;
use log::warn;
-use msg::constellation_msg::{PipelineId, PipelineIndex, PipelineNamespaceId};
+use msg::constellation_msg::{
+ PipelineId, PipelineIndex, PipelineNamespaceId, TopLevelBrowsingContextId,
+};
use net_traits::image::base::Image;
use net_traits::image_cache::CorsStatus;
use num_traits::FromPrimitive;
@@ -104,6 +106,11 @@ impl FrameTreeId {
#[derive(Clone, Copy, Debug)]
enum LayerPixel {}
+struct RootPipeline {
+ top_level_browsing_context_id: TopLevelBrowsingContextId,
+ id: Option<PipelineId>,
+}
+
/// NB: Never block on the constellation, because sometimes the constellation blocks on us.
pub struct IOCompositor<Window: WindowMethods + ?Sized> {
/// The application window.
@@ -113,7 +120,7 @@ pub struct IOCompositor<Window: WindowMethods + ?Sized> {
port: CompositorReceiver,
/// The root pipeline.
- root_pipeline: Option<CompositionPipeline>,
+ root_pipeline: RootPipeline,
/// Tracks details about each active pipeline that the compositor knows about.
pipeline_details: HashMap<PipelineId, PipelineDetails>,
@@ -289,6 +296,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
is_running_problem_test: bool,
exit_after_load: bool,
convert_mouse_to_touch: bool,
+ top_level_browsing_context_id: TopLevelBrowsingContextId,
) -> Self {
let composite_target = match output_file {
Some(_) => CompositeTarget::PngFile,
@@ -299,7 +307,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
embedder_coordinates: window.get_coordinates(),
window,
port: state.receiver,
- root_pipeline: None,
+ root_pipeline: RootPipeline {
+ top_level_browsing_context_id,
+ id: None,
+ },
pipeline_details: HashMap::new(),
scale: Scale::new(1.0),
composition_request: CompositionRequest::NoCompositingNecessary,
@@ -342,6 +353,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
is_running_problem_test: bool,
exit_after_load: bool,
convert_mouse_to_touch: bool,
+ top_level_browsing_context_id: TopLevelBrowsingContextId,
) -> Self {
let mut compositor = IOCompositor::new(
window,
@@ -350,6 +362,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
is_running_problem_test,
exit_after_load,
convert_mouse_to_touch,
+ top_level_browsing_context_id,
);
// Make sure the GL state is OK
@@ -781,7 +794,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
frame_tree.pipeline.id
);
- self.root_pipeline = Some(frame_tree.pipeline.clone());
+ self.root_pipeline = RootPipeline {
+ top_level_browsing_context_id: frame_tree.pipeline.top_level_browsing_context_id,
+ id: Some(frame_tree.pipeline.id),
+ };
let pipeline_id = frame_tree.pipeline.id.to_webrender();
let mut txn = webrender_api::Transaction::new();
@@ -823,10 +839,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
initial_viewport: initial_viewport,
};
- let top_level_browsing_context_id = self
- .root_pipeline
- .as_ref()
- .map(|pipeline| pipeline.top_level_browsing_context_id);
+ let top_level_browsing_context_id = self.root_pipeline.top_level_browsing_context_id;
let msg = ConstellationMsg::WindowSize(top_level_browsing_context_id, data, size_type);
@@ -926,7 +939,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
}
fn dispatch_mouse_window_move_event_class(&mut self, cursor: DevicePoint) {
- let root_pipeline_id = match self.get_root_pipeline_id() {
+ let root_pipeline_id = match self.root_pipeline.id {
Some(root_pipeline_id) => root_pipeline_id,
None => return,
};
@@ -1204,10 +1217,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
}
fn constrain_viewport(&mut self, pipeline_id: PipelineId, constraints: ViewportConstraints) {
- let is_root = self
- .root_pipeline
- .as_ref()
- .map_or(false, |root_pipeline| root_pipeline.id == pipeline_id);
+ let is_root = self.root_pipeline.id == Some(pipeline_id);
if is_root {
self.viewport_zoom = constraints.initial_zoom;
@@ -1640,10 +1650,6 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
);
}
- fn get_root_pipeline_id(&self) -> Option<PipelineId> {
- self.root_pipeline.as_ref().map(|pipeline| pipeline.id)
- }
-
pub fn receive_messages(&mut self) -> bool {
// Check for new messages coming from the other threads in the system.
let mut compositor_messages = vec![];
diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs
index dbb835e8bbe..4f29cfc1662 100644
--- a/components/compositing/lib.rs
+++ b/components/compositing/lib.rs
@@ -76,11 +76,7 @@ pub enum ConstellationMsg {
/// Request to traverse the joint session history of the provided browsing context.
TraverseHistory(TopLevelBrowsingContextId, TraversalDirection),
/// Inform the constellation of a window being resized.
- WindowSize(
- Option<TopLevelBrowsingContextId>,
- WindowSizeData,
- WindowSizeType,
- ),
+ WindowSize(TopLevelBrowsingContextId, WindowSizeData, WindowSizeType),
/// Requests that the constellation instruct layout to begin a new tick of the animation.
TickAnimation(PipelineId, AnimationTickType),
/// Dispatch a webdriver command
diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs
index 6fbd449a236..d1cf5fed950 100644
--- a/components/constellation/constellation.rs
+++ b/components/constellation/constellation.rs
@@ -4983,7 +4983,7 @@ where
/// Called when the window is resized.
fn handle_window_size_msg(
&mut self,
- top_level_browsing_context_id: Option<TopLevelBrowsingContextId>,
+ top_level_browsing_context_id: TopLevelBrowsingContextId,
new_size: WindowSizeData,
size_type: WindowSizeType,
) {
@@ -4992,10 +4992,8 @@ where
new_size.initial_viewport.to_untyped()
);
- if let Some(top_level_browsing_context_id) = top_level_browsing_context_id {
- let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
- self.resize_browsing_context(new_size, size_type, browsing_context_id);
- }
+ let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
+ self.resize_browsing_context(new_size, size_type, browsing_context_id);
if let Some(resize_channel) = self.webdriver.resize_channel.take() {
let _ = resize_channel.send(new_size);
diff --git a/components/servo/lib.rs b/components/servo/lib.rs
index 018446457be..b33b244cb93 100644
--- a/components/servo/lib.rs
+++ b/components/servo/lib.rs
@@ -273,6 +273,11 @@ impl webrender_api::RenderNotifier for RenderNotifier {
}
}
+pub struct InitializedServo<Window: WindowMethods + 'static + ?Sized> {
+ pub servo: Servo<Window>,
+ pub browser_id: BrowserId,
+}
+
impl<Window> Servo<Window>
where
Window: WindowMethods + 'static + ?Sized,
@@ -281,7 +286,7 @@ where
mut embedder: Box<dyn EmbedderMethods>,
window: Rc<Window>,
user_agent: Option<String>,
- ) -> Servo<Window> {
+ ) -> InitializedServo<Window> {
// Global configuration options, parsed from the command line.
let opts = opts::get();
@@ -336,8 +341,9 @@ where
.unwrap_or(0);
webrender_gl.bind_framebuffer(gleam::gl::FRAMEBUFFER, framebuffer_object);
- // Reserving a namespace to create TopLevelBrowserContextId.
+ // Reserving a namespace to create TopLevelBrowsingContextId.
PipelineNamespace::install(PipelineNamespaceId(0));
+ let browser_id = BrowserId::new();
// Get both endpoints of a special channel for communication between
// the client window and the compositor. This channel is unique because
@@ -537,16 +543,18 @@ where
opts.is_running_problem_test,
opts.exit_after_load,
opts.convert_mouse_to_touch,
+ browser_id,
);
- Servo {
+ let servo = Servo {
compositor: compositor,
constellation_chan: constellation_chan,
embedder_receiver: embedder_receiver,
embedder_events: Vec::new(),
profiler_enabled: false,
_js_engine_setup: js_engine_setup,
- }
+ };
+ InitializedServo { servo, browser_id }
}
fn handle_window_event(&mut self, event: WindowEvent) -> bool {
diff --git a/ports/gstplugin/servowebsrc.rs b/ports/gstplugin/servowebsrc.rs
index 7c2b49deed5..29712b9a0fa 100644
--- a/ports/gstplugin/servowebsrc.rs
+++ b/ports/gstplugin/servowebsrc.rs
@@ -217,9 +217,10 @@ impl ServoThread {
.swap_chain()
.expect("Failed to get webrender swap chain")
.clone();
- let mut servo = Servo::new(embedder, window, None);
+ let servo = Servo::new(embedder, window, None);
+ let id = servo.top_level_browsing_context_id;
+ let mut servo = servo.servo;
- let id = TopLevelBrowsingContextId::new();
servo.handle_events(vec![WindowEvent::NewBrowser(url, id)]);
let swap_chain = match webxr_mode {
diff --git a/ports/libsimpleservo/api/src/lib.rs b/ports/libsimpleservo/api/src/lib.rs
index d6fbf01907f..7fade0fcf28 100644
--- a/ports/libsimpleservo/api/src/lib.rs
+++ b/ports/libsimpleservo/api/src/lib.rs
@@ -306,7 +306,7 @@ pub fn init(
SERVO.with(|s| {
let mut servo_glue = ServoGlue {
webrender_surfman,
- servo,
+ servo: servo.servo,
batch_mode: false,
callbacks: window_callbacks,
browser_id: None,
@@ -314,8 +314,7 @@ pub fn init(
events: vec![],
context_menu_sender: None,
};
- let browser_id = BrowserId::new();
- let _ = servo_glue.process_event(WindowEvent::NewBrowser(url, browser_id));
+ let _ = servo_glue.process_event(WindowEvent::NewBrowser(url, servo.browser_id));
*s.borrow_mut() = Some(servo_glue);
});
diff --git a/ports/winit/app.rs b/ports/winit/app.rs
index 72d844efd0a..89078b2acce 100644
--- a/ports/winit/app.rs
+++ b/ports/winit/app.rs
@@ -100,9 +100,9 @@ impl App {
xr_discovery,
));
- let mut servo = Servo::new(embedder, window.clone(), user_agent.clone());
- let browser_id = BrowserId::new();
- servo.handle_events(vec![WindowEvent::NewBrowser(get_default_url(), browser_id)]);
+ let servo_data = Servo::new(embedder, window.clone(), user_agent.clone());
+ let mut servo = servo_data.servo;
+ servo.handle_events(vec![WindowEvent::NewBrowser(get_default_url(), servo_data.browser_id)]);
servo.setup_logging();
register_window(window.clone());