Remove more IPC messages between script and layout (#32377)

Instead of bouncing messages from the compositor to script and then to
layout, just have script call methods on Layout. Additionally, we do not
need to send any followup messages to script for these messages. Instead
just execute code after calling the method on Layout.
This commit is contained in:
Martin Robinson 2024-05-27 09:30:51 +02:00 committed by GitHub
parent a7bf099cb1
commit 5f0866379a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 103 additions and 165 deletions

View file

@ -30,9 +30,8 @@ use pixels::{CorsStatus, Image, PixelFormat};
use profile_traits::time::{self as profile_time, profile, ProfilerCategory};
use script_traits::CompositorEvent::{MouseButtonEvent, MouseMoveEvent, TouchEvent, WheelEvent};
use script_traits::{
AnimationState, AnimationTickType, ConstellationControlMsg, LayoutControlMsg, MouseButton,
MouseEventType, ScrollState, TouchEventType, TouchId, WheelDelta, WindowSizeData,
WindowSizeType,
AnimationState, AnimationTickType, ConstellationControlMsg, MouseButton, MouseEventType,
ScrollState, TouchEventType, TouchId, WheelDelta, WindowSizeData, WindowSizeType,
};
use servo_geometry::{DeviceIndependentPixel, FramebufferUintLength};
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
@ -1940,10 +1939,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
});
if let Some(pipeline) = details.pipeline.as_ref() {
let message = ConstellationControlMsg::ForLayoutFromConstellation(
LayoutControlMsg::SetScrollStates(scroll_states),
*pipeline_id,
);
let message = ConstellationControlMsg::SetScrollStates(*pipeline_id, scroll_states);
let _ = pipeline.script_chan.send(message);
}
}
@ -2154,11 +2150,14 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
to_remove.push(*id);
if let Some(pipeline) = self.pipeline(*id) {
// and inform layout with the measured paint time.
let message = LayoutControlMsg::PaintMetric(epoch, paint_time);
let message =
ConstellationControlMsg::ForLayoutFromConstellation(message, *id);
if let Err(e) = pipeline.script_chan.send(message) {
warn!("Sending PaintMetric message to layout failed ({:?}).", e);
if let Err(e) =
pipeline
.script_chan
.send(ConstellationControlMsg::SetEpochPaintTime(
*id, epoch, paint_time,
))
{
warn!("Sending RequestLayoutPaintMetric message to layout failed ({e:?}).");
}
}
}