mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Add SimulateColorScheme command and script thread handling (#36253)
Implements Steps 2-3 of #35867: - Adds `SimulateColorScheme` to `DevtoolScriptControlMsg` for light/dark mode simulation. - Handles it in `ScriptThread` with `handle_theme_change` to toggle themes. Testing: This PR does not require testing because it only adds infrastructure (command and handler) but doesn’t yet integrate with devtools actors. Fixes: Part of #35867 (https://github.com/servo/servo/issues/35867) --------- Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
This commit is contained in:
parent
8b23801a24
commit
fab7bbcd38
4 changed files with 13 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1618,6 +1618,7 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base",
|
"base",
|
||||||
"bitflags 2.9.0",
|
"bitflags 2.9.0",
|
||||||
|
"embedder_traits",
|
||||||
"http 1.3.1",
|
"http 1.3.1",
|
||||||
"ipc-channel",
|
"ipc-channel",
|
||||||
"malloc_size_of_derive",
|
"malloc_size_of_derive",
|
||||||
|
|
|
@ -2063,6 +2063,14 @@ impl ScriptThread {
|
||||||
DevtoolScriptControlMsg::GetCssDatabase(reply) => {
|
DevtoolScriptControlMsg::GetCssDatabase(reply) => {
|
||||||
devtools::handle_get_css_database(reply)
|
devtools::handle_get_css_database(reply)
|
||||||
},
|
},
|
||||||
|
DevtoolScriptControlMsg::SimulateColorScheme(id, theme) => {
|
||||||
|
match documents.find_window(id) {
|
||||||
|
Some(window) => {
|
||||||
|
window.handle_theme_change(theme);
|
||||||
|
},
|
||||||
|
None => warn!("Message sent to closed pipeline {}.", id),
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,3 +22,4 @@ net_traits = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
servo_url = { path = "../../url" }
|
servo_url = { path = "../../url" }
|
||||||
uuid = { workspace = true, features = ["serde"] }
|
uuid = { workspace = true, features = ["serde"] }
|
||||||
|
embedder_traits = { workspace = true }
|
||||||
|
|
|
@ -18,6 +18,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
use base::cross_process_instant::CrossProcessInstant;
|
use base::cross_process_instant::CrossProcessInstant;
|
||||||
use base::id::{BrowsingContextId, PipelineId, WebViewId};
|
use base::id::{BrowsingContextId, PipelineId, WebViewId};
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
|
use embedder_traits::Theme;
|
||||||
use http::{HeaderMap, Method};
|
use http::{HeaderMap, Method};
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use malloc_size_of_derive::MallocSizeOf;
|
use malloc_size_of_derive::MallocSizeOf;
|
||||||
|
@ -258,6 +259,8 @@ pub enum DevtoolScriptControlMsg {
|
||||||
Reload(PipelineId),
|
Reload(PipelineId),
|
||||||
/// Gets the list of all allowed CSS rules and possible values.
|
/// Gets the list of all allowed CSS rules and possible values.
|
||||||
GetCssDatabase(IpcSender<HashMap<String, CssDatabaseProperty>>),
|
GetCssDatabase(IpcSender<HashMap<String, CssDatabaseProperty>>),
|
||||||
|
/// Simulates a light or dark color scheme for the given pipeline
|
||||||
|
SimulateColorScheme(PipelineId, Theme),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue