mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
constellation: Rename messages sent to the Constellation
(#36341)
Messages that are sent to the `Constellation` have pretty ambiguous names. This change does two renames: - `ConstellationMsg` → `EmbedderToConstellationMessage` - `ScriptMsg` → `ScriptToConstellationMessage` This naming reflects that the `Constellation` stands in between the embedding layer and the script layer and can receive messages from both. Soon both of these message types will live in `constellation_traits`, reflecting the idea that the `_traits` variant for a crate is responsible for exposing the API for that crate. Testing: No new tests are necessary here as this just renames two enums. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
c7a7862574
commit
5a35e1faec
37 changed files with 415 additions and 364 deletions
|
@ -19,7 +19,7 @@ use std::{env, fmt, mem, process, thread};
|
|||
use base::id::{BrowsingContextId, WebViewId};
|
||||
use base64::Engine;
|
||||
use capabilities::ServoCapabilities;
|
||||
use constellation_traits::{ConstellationMsg, TraversalDirection};
|
||||
use constellation_traits::{EmbedderToConstellationMessage, TraversalDirection};
|
||||
use cookie::{CookieBuilder, Expiration};
|
||||
use crossbeam_channel::{Receiver, Sender, after, select, unbounded};
|
||||
use embedder_traits::{
|
||||
|
@ -100,7 +100,7 @@ fn cookie_msg_to_cookie(cookie: cookie::Cookie) -> Cookie {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn start_server(port: u16, constellation_chan: Sender<ConstellationMsg>) {
|
||||
pub fn start_server(port: u16, constellation_chan: Sender<EmbedderToConstellationMessage>) {
|
||||
let handler = Handler::new(constellation_chan);
|
||||
thread::Builder::new()
|
||||
.name("WebDriverHttpServer".to_owned())
|
||||
|
@ -188,7 +188,7 @@ struct Handler {
|
|||
/// will be forwarded to the load_status_receiver.
|
||||
load_status_sender: IpcSender<WebDriverLoadStatus>,
|
||||
session: Option<WebDriverSession>,
|
||||
constellation_chan: Sender<ConstellationMsg>,
|
||||
constellation_chan: Sender<EmbedderToConstellationMessage>,
|
||||
resize_timeout: u32,
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,7 @@ impl<'de> Visitor<'de> for TupleVecMapVisitor {
|
|||
}
|
||||
|
||||
impl Handler {
|
||||
pub fn new(constellation_chan: Sender<ConstellationMsg>) -> Handler {
|
||||
pub fn new(constellation_chan: Sender<EmbedderToConstellationMessage>) -> Handler {
|
||||
// Create a pair of both an IPC and a threaded channel,
|
||||
// keep the IPC sender to clone and pass to the constellation for each load,
|
||||
// and keep a threaded receiver to block on an incoming load-status.
|
||||
|
@ -425,7 +425,8 @@ impl Handler {
|
|||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
for _ in 0..iterations {
|
||||
let msg = ConstellationMsg::GetFocusTopLevelBrowsingContext(sender.clone());
|
||||
let msg =
|
||||
EmbedderToConstellationMessage::GetFocusTopLevelBrowsingContext(sender.clone());
|
||||
self.constellation_chan.send(msg).unwrap();
|
||||
// Wait until the document is ready before returning the top-level browsing context id.
|
||||
if let Some(x) = receiver.recv().unwrap() {
|
||||
|
@ -622,20 +623,18 @@ impl Handler {
|
|||
cmd_msg: WebDriverScriptCommand,
|
||||
) -> WebDriverResult<()> {
|
||||
let browsing_context_id = self.session()?.browsing_context_id;
|
||||
let msg = ConstellationMsg::WebDriverCommand(WebDriverCommandMsg::ScriptCommand(
|
||||
browsing_context_id,
|
||||
cmd_msg,
|
||||
));
|
||||
let msg = EmbedderToConstellationMessage::WebDriverCommand(
|
||||
WebDriverCommandMsg::ScriptCommand(browsing_context_id, cmd_msg),
|
||||
);
|
||||
self.constellation_chan.send(msg).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn top_level_script_command(&self, cmd_msg: WebDriverScriptCommand) -> WebDriverResult<()> {
|
||||
let browsing_context_id = BrowsingContextId::from(self.session()?.webview_id);
|
||||
let msg = ConstellationMsg::WebDriverCommand(WebDriverCommandMsg::ScriptCommand(
|
||||
browsing_context_id,
|
||||
cmd_msg,
|
||||
));
|
||||
let msg = EmbedderToConstellationMessage::WebDriverCommand(
|
||||
WebDriverCommandMsg::ScriptCommand(browsing_context_id, cmd_msg),
|
||||
);
|
||||
self.constellation_chan.send(msg).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
@ -656,7 +655,7 @@ impl Handler {
|
|||
let cmd_msg =
|
||||
WebDriverCommandMsg::LoadUrl(webview_id, url, self.load_status_sender.clone());
|
||||
self.constellation_chan
|
||||
.send(ConstellationMsg::WebDriverCommand(cmd_msg))
|
||||
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
||||
.unwrap();
|
||||
|
||||
self.wait_for_load()
|
||||
|
@ -692,7 +691,7 @@ impl Handler {
|
|||
let cmd_msg = WebDriverCommandMsg::GetWindowSize(webview_id, sender);
|
||||
|
||||
self.constellation_chan
|
||||
.send(ConstellationMsg::WebDriverCommand(cmd_msg))
|
||||
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
||||
.unwrap();
|
||||
|
||||
let window_size = receiver.recv().unwrap();
|
||||
|
@ -724,7 +723,7 @@ impl Handler {
|
|||
let cmd_msg = WebDriverCommandMsg::SetWindowSize(webview_id, size.to_i32(), sender.clone());
|
||||
|
||||
self.constellation_chan
|
||||
.send(ConstellationMsg::WebDriverCommand(cmd_msg))
|
||||
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
||||
.unwrap();
|
||||
|
||||
let timeout = self.resize_timeout;
|
||||
|
@ -735,7 +734,7 @@ impl Handler {
|
|||
thread::sleep(Duration::from_millis(timeout as u64));
|
||||
let cmd_msg = WebDriverCommandMsg::GetWindowSize(webview_id, sender);
|
||||
constellation_chan
|
||||
.send(ConstellationMsg::WebDriverCommand(cmd_msg))
|
||||
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
||||
.unwrap();
|
||||
});
|
||||
|
||||
|
@ -784,7 +783,7 @@ impl Handler {
|
|||
fn handle_go_back(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
let webview_id = self.session()?.webview_id;
|
||||
let direction = TraversalDirection::Back(1);
|
||||
let msg = ConstellationMsg::TraverseHistory(webview_id, direction);
|
||||
let msg = EmbedderToConstellationMessage::TraverseHistory(webview_id, direction);
|
||||
self.constellation_chan.send(msg).unwrap();
|
||||
Ok(WebDriverResponse::Void)
|
||||
}
|
||||
|
@ -792,7 +791,7 @@ impl Handler {
|
|||
fn handle_go_forward(&self) -> WebDriverResult<WebDriverResponse> {
|
||||
let webview_id = self.session()?.webview_id;
|
||||
let direction = TraversalDirection::Forward(1);
|
||||
let msg = ConstellationMsg::TraverseHistory(webview_id, direction);
|
||||
let msg = EmbedderToConstellationMessage::TraverseHistory(webview_id, direction);
|
||||
self.constellation_chan.send(msg).unwrap();
|
||||
Ok(WebDriverResponse::Void)
|
||||
}
|
||||
|
@ -802,7 +801,7 @@ impl Handler {
|
|||
|
||||
let cmd_msg = WebDriverCommandMsg::Refresh(webview_id, self.load_status_sender.clone());
|
||||
self.constellation_chan
|
||||
.send(ConstellationMsg::WebDriverCommand(cmd_msg))
|
||||
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
||||
.unwrap();
|
||||
|
||||
self.wait_for_load()
|
||||
|
@ -892,7 +891,7 @@ impl Handler {
|
|||
session.window_handles.remove(&session.webview_id);
|
||||
let cmd_msg = WebDriverCommandMsg::CloseWebView(session.webview_id);
|
||||
self.constellation_chan
|
||||
.send(ConstellationMsg::WebDriverCommand(cmd_msg))
|
||||
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
|
@ -919,7 +918,7 @@ impl Handler {
|
|||
self.load_status_sender.clone(),
|
||||
);
|
||||
self.constellation_chan
|
||||
.send(ConstellationMsg::WebDriverCommand(cmd_msg))
|
||||
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
||||
.unwrap();
|
||||
|
||||
let mut handle = self.session.as_ref().unwrap().id.to_string();
|
||||
|
@ -980,7 +979,7 @@ impl Handler {
|
|||
session.webview_id = webview_id;
|
||||
session.browsing_context_id = BrowsingContextId::from(webview_id);
|
||||
|
||||
let msg = ConstellationMsg::FocusWebView(webview_id);
|
||||
let msg = EmbedderToConstellationMessage::FocusWebView(webview_id);
|
||||
self.constellation_chan.send(msg).unwrap();
|
||||
Ok(WebDriverResponse::Void)
|
||||
} else {
|
||||
|
@ -1558,7 +1557,7 @@ impl Handler {
|
|||
let cmd = WebDriverScriptCommand::FocusElement(element.to_string(), sender);
|
||||
let cmd_msg = WebDriverCommandMsg::ScriptCommand(browsing_context_id, cmd);
|
||||
self.constellation_chan
|
||||
.send(ConstellationMsg::WebDriverCommand(cmd_msg))
|
||||
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
||||
.unwrap();
|
||||
|
||||
// TODO: distinguish the not found and not focusable cases
|
||||
|
@ -1574,7 +1573,7 @@ impl Handler {
|
|||
// so the constellation may have changed state between them.
|
||||
let cmd_msg = WebDriverCommandMsg::SendKeys(browsing_context_id, input_events);
|
||||
self.constellation_chan
|
||||
.send(ConstellationMsg::WebDriverCommand(cmd_msg))
|
||||
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
||||
.unwrap();
|
||||
|
||||
Ok(WebDriverResponse::Void)
|
||||
|
@ -1658,7 +1657,7 @@ impl Handler {
|
|||
let cmd_msg =
|
||||
WebDriverCommandMsg::TakeScreenshot(self.session()?.webview_id, rect, sender);
|
||||
self.constellation_chan
|
||||
.send(ConstellationMsg::WebDriverCommand(cmd_msg))
|
||||
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
|
||||
.unwrap();
|
||||
|
||||
if let Some(x) = receiver.recv().unwrap() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue