Make WebBluetooth an optional feature. (#35479)

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-02-17 23:13:43 -05:00 committed by GitHub
parent 32f19c1eae
commit 1d606bb85c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 124 additions and 37 deletions

View file

@ -12,6 +12,7 @@ name = "constellation"
path = "lib.rs"
[features]
bluetooth = ["bluetooth_traits"]
default = []
multiview = []
tracing = ["dep:tracing"]
@ -22,7 +23,7 @@ background_hang_monitor_api = { workspace = true }
background_hang_monitor = { path = "../background_hang_monitor" }
backtrace = { workspace = true }
base = { workspace = true }
bluetooth_traits = { workspace = true }
bluetooth_traits = { workspace = true, optional = true }
canvas_traits = { workspace = true }
compositing_traits = { workspace = true }
crossbeam-channel = { workspace = true }

View file

@ -103,6 +103,7 @@ use base::id::{
PipelineNamespaceRequest, TopLevelBrowsingContextId, WebViewId,
};
use base::Epoch;
#[cfg(feature = "bluetooth")]
use bluetooth_traits::BluetoothRequest;
use canvas_traits::canvas::{CanvasId, CanvasMsg};
use canvas_traits::webgl::WebGLThreads;
@ -351,6 +352,7 @@ pub struct Constellation<STF, SWF> {
/// An IPC channel for the constellation to send messages to the
/// bluetooth thread.
#[cfg(feature = "bluetooth")]
bluetooth_ipc_sender: IpcSender<BluetoothRequest>,
/// A map of origin to sender to a Service worker manager.
@ -493,6 +495,7 @@ pub struct InitialConstellationState {
pub devtools_sender: Option<Sender<DevtoolsControlMsg>>,
/// A channel to the bluetooth thread.
#[cfg(feature = "bluetooth")]
pub bluetooth_thread: IpcSender<BluetoothRequest>,
/// A proxy to the `SystemFontService` which manages the list of system fonts.
@ -711,6 +714,7 @@ where
compositor_proxy: state.compositor_proxy,
webviews: WebViewManager::default(),
devtools_sender: state.devtools_sender,
#[cfg(feature = "bluetooth")]
bluetooth_ipc_sender: state.bluetooth_thread,
public_resource_threads: state.public_resource_threads,
private_resource_threads: state.private_resource_threads,
@ -987,6 +991,7 @@ where
layout_factory: self.layout_factory.clone(),
compositor_proxy: self.compositor_proxy.clone(),
devtools_sender: self.devtools_sender.clone(),
#[cfg(feature = "bluetooth")]
bluetooth_thread: self.bluetooth_ipc_sender.clone(),
swmanager_thread: self.swmanager_ipc_sender.clone(),
system_font_service: self.system_font_service.clone(),
@ -2629,10 +2634,13 @@ where
warn!("Exit storage thread failed ({})", e);
}
#[cfg(feature = "bluetooth")]
{
debug!("Exiting bluetooth thread.");
if let Err(e) = self.bluetooth_ipc_sender.send(BluetoothRequest::Exit) {
warn!("Exit bluetooth thread failed ({})", e);
}
}
debug!("Exiting service worker manager thread.");
for (_, mgr) in self.sw_managers.drain() {

View file

@ -16,6 +16,7 @@ use base::id::{
PipelineNamespaceRequest, TopLevelBrowsingContextId,
};
use base::Epoch;
#[cfg(feature = "bluetooth")]
use bluetooth_traits::BluetoothRequest;
use canvas_traits::webgl::WebGLPipeline;
use compositing_traits::{CompositionPipeline, CompositorMsg, CompositorProxy};
@ -145,6 +146,7 @@ pub struct InitialPipelineState {
pub devtools_sender: Option<Sender<DevtoolsControlMsg>>,
/// A channel to the bluetooth thread.
#[cfg(feature = "bluetooth")]
pub bluetooth_thread: IpcSender<BluetoothRequest>,
/// A channel to the service worker manager thread
@ -269,6 +271,7 @@ impl Pipeline {
.clone(),
bhm_control_port: None,
devtools_ipc_sender: script_to_devtools_ipc_sender,
#[cfg(feature = "bluetooth")]
bluetooth_thread: state.bluetooth_thread,
swmanager_thread: state.swmanager_thread,
system_font_service: state.system_font_service.to_sender(),
@ -477,6 +480,7 @@ pub struct UnprivilegedPipelineContent {
bhm_control_port: Option<IpcReceiver<BackgroundHangMonitorControlMsg>>,
layout_to_constellation_chan: IpcSender<LayoutMsg>,
devtools_ipc_sender: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
#[cfg(feature = "bluetooth")]
bluetooth_thread: IpcSender<BluetoothRequest>,
swmanager_thread: IpcSender<SWManagerMsg>,
system_font_service: SystemFontServiceProxySender,
@ -527,6 +531,7 @@ impl UnprivilegedPipelineContent {
pipeline_to_constellation_sender: self.script_to_constellation_chan.clone(),
background_hang_monitor_register: background_hang_monitor_register.clone(),
layout_to_constellation_ipc_sender: self.layout_to_constellation_chan.clone(),
#[cfg(feature = "bluetooth")]
bluetooth_sender: self.bluetooth_thread,
resource_threads: self.resource_threads,
image_cache: image_cache.clone(),

View file

@ -233,6 +233,7 @@ mod from_script {
target_variant!("NotifyLoadStatusChanged(LoadStatus::Complete")
},
Self::Panic(..) => target_variant!("Panic"),
#[cfg(feature = "bluetooth")]
Self::GetSelectedBluetoothDevice(..) => {
target_variant!("GetSelectedBluetoothDevice")
},

View file

@ -13,6 +13,7 @@ name = "script"
path = "lib.rs"
[features]
bluetooth = ['bluetooth_traits', 'script_bindings/bluetooth']
crown = ['js/crown']
debugmozjs = ['js/debugmozjs']
jitspew = ['js/jitspew']
@ -41,7 +42,7 @@ base = { workspace = true }
base64 = { workspace = true }
bincode = { workspace = true }
bitflags = { workspace = true }
bluetooth_traits = { workspace = true }
bluetooth_traits = { workspace = true, optional = true }
canvas_traits = { workspace = true }
cbc = { workspace = true }
cipher = { workspace = true }

View file

@ -0,0 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
pub(crate) use self::bluetooth::*;
pub(crate) mod bluetooth;
pub(crate) mod bluetoothadvertisingevent;
pub(crate) mod bluetoothcharacteristicproperties;
pub(crate) mod bluetoothdevice;
pub(crate) mod bluetoothpermissionresult;
pub(crate) mod bluetoothremotegattcharacteristic;
pub(crate) mod bluetoothremotegattdescriptor;
pub(crate) mod bluetoothremotegattserver;
pub(crate) mod bluetoothremotegattservice;
pub(crate) mod bluetoothuuid;
pub(crate) mod testrunner;

View file

@ -233,16 +233,11 @@ pub(crate) mod beforeunloadevent;
pub(crate) mod bindings;
pub(crate) mod biquadfilternode;
pub(crate) mod blob;
#[cfg(feature = "bluetooth")]
#[allow(clippy::module_inception)]
pub(crate) mod bluetooth;
pub(crate) mod bluetoothadvertisingevent;
pub(crate) mod bluetoothcharacteristicproperties;
pub(crate) mod bluetoothdevice;
pub(crate) mod bluetoothpermissionresult;
pub(crate) mod bluetoothremotegattcharacteristic;
pub(crate) mod bluetoothremotegattdescriptor;
pub(crate) mod bluetoothremotegattserver;
pub(crate) mod bluetoothremotegattservice;
pub(crate) mod bluetoothuuid;
#[cfg(feature = "bluetooth")]
pub(crate) use self::bluetooth::*;
pub(crate) mod broadcastchannel;
pub(crate) mod bytelengthqueuingstrategy;
pub(crate) mod canvasgradient;
@ -552,7 +547,6 @@ pub(crate) mod testbindingpairiterable;
pub(crate) mod testbindingproxy;
pub(crate) mod testbindingsetlike;
pub(crate) mod testns;
pub(crate) mod testrunner;
pub(crate) mod testworklet;
pub(crate) mod testworkletglobalscope;
pub(crate) mod text;

View file

@ -16,6 +16,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object, DomGlobal, Reflector};
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
use crate::dom::bindings::str::DOMString;
use crate::dom::bindings::utils::to_frozen_array;
#[cfg(feature = "bluetooth")]
use crate::dom::bluetooth::Bluetooth;
use crate::dom::gamepad::Gamepad;
use crate::dom::gamepadevent::GamepadEventType;
@ -42,6 +43,7 @@ pub(super) fn hardware_concurrency() -> u64 {
#[dom_struct]
pub(crate) struct Navigator {
reflector_: Reflector,
#[cfg(feature = "bluetooth")]
bluetooth: MutNullableDom<Bluetooth>,
plugins: MutNullableDom<PluginArray>,
mime_types: MutNullableDom<MimeTypeArray>,
@ -63,6 +65,7 @@ impl Navigator {
fn new_inherited() -> Navigator {
Navigator {
reflector_: Reflector::new(),
#[cfg(feature = "bluetooth")]
bluetooth: Default::default(),
plugins: Default::default(),
mime_types: Default::default(),
@ -195,6 +198,7 @@ impl NavigatorMethods<crate::DomTypeHolder> for Navigator {
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-navigator-bluetooth
#[cfg(feature = "bluetooth")]
fn Bluetooth(&self) -> DomRoot<Bluetooth> {
self.bluetooth.or_init(|| Bluetooth::new(&self.global()))
}

View file

@ -23,7 +23,9 @@ use crate::dom::bindings::codegen::Bindings::WindowBinding::Window_Binding::Wind
use crate::dom::bindings::error::Error;
use crate::dom::bindings::reflector::{reflect_dom_object, DomGlobal, Reflector};
use crate::dom::bindings::root::DomRoot;
#[cfg(feature = "bluetooth")]
use crate::dom::bluetooth::Bluetooth;
#[cfg(feature = "bluetooth")]
use crate::dom::bluetoothpermissionresult::BluetoothPermissionResult;
use crate::dom::globalscope::GlobalScope;
use crate::dom::permissionstatus::PermissionStatus;
@ -116,6 +118,7 @@ impl Permissions {
// (Query, Request, Revoke) Step 2.
match root_desc.name {
#[cfg(feature = "bluetooth")]
PermissionName::Bluetooth => {
let bluetooth_desc = match Bluetooth::create_descriptor(cx, permissionDesc) {
Ok(descriptor) => descriptor,

View file

@ -18,6 +18,7 @@ use backtrace::Backtrace;
use base::cross_process_instant::CrossProcessInstant;
use base::id::{BrowsingContextId, PipelineId, WebViewId};
use base64::Engine;
#[cfg(feature = "bluetooth")]
use bluetooth_traits::BluetoothRequest;
use canvas_traits::webgl::WebGLChan;
use crossbeam_channel::{unbounded, Sender};
@ -113,6 +114,7 @@ use crate::dom::bindings::structuredclone;
use crate::dom::bindings::trace::{CustomTraceable, JSTraceable, RootedTraceableBox};
use crate::dom::bindings::utils::GlobalStaticData;
use crate::dom::bindings::weakref::DOMTracker;
#[cfg(feature = "bluetooth")]
use crate::dom::bluetooth::BluetoothExtraPermissionData;
use crate::dom::crypto::Crypto;
use crate::dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
@ -137,6 +139,7 @@ use crate::dom::promise::Promise;
use crate::dom::screen::Screen;
use crate::dom::selection::Selection;
use crate::dom::storage::Storage;
#[cfg(feature = "bluetooth")]
use crate::dom::testrunner::TestRunner;
use crate::dom::types::UIEvent;
use crate::dom::webglrenderingcontext::WebGLCommandSender;
@ -273,8 +276,10 @@ pub(crate) struct Window {
/// A handle for communicating messages to the bluetooth thread.
#[no_trace]
#[cfg(feature = "bluetooth")]
bluetooth_thread: IpcSender<BluetoothRequest>,
#[cfg(feature = "bluetooth")]
bluetooth_extra_permission_data: BluetoothExtraPermissionData,
/// An enlarged rectangle around the page contents visible in the viewport, used
@ -307,6 +312,7 @@ pub(crate) struct Window {
/// All the MediaQueryLists we need to update
media_query_lists: DOMTracker<MediaQueryList>,
#[cfg(feature = "bluetooth")]
test_runner: MutNullableDom<TestRunner>,
/// A handle for communicating messages to the WebGL thread, if available.
@ -504,10 +510,12 @@ impl Window {
})
}
#[cfg(feature = "bluetooth")]
pub(crate) fn bluetooth_thread(&self) -> IpcSender<BluetoothRequest> {
self.bluetooth_thread.clone()
}
#[cfg(feature = "bluetooth")]
pub(crate) fn bluetooth_extra_permission_data(&self) -> &BluetoothExtraPermissionData {
&self.bluetooth_extra_permission_data
}
@ -1425,6 +1433,7 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
fetch::Fetch(self.upcast(), input, init, comp, can_gc)
}
#[cfg(feature = "bluetooth")]
fn TestRunner(&self) -> DomRoot<TestRunner> {
self.test_runner.or_init(|| TestRunner::new(self.upcast()))
}
@ -2733,7 +2742,7 @@ impl Window {
image_cache_sender: IpcSender<PendingImageResponse>,
image_cache: Arc<dyn ImageCache>,
resource_threads: ResourceThreads,
bluetooth_thread: IpcSender<BluetoothRequest>,
#[cfg(feature = "bluetooth")] bluetooth_thread: IpcSender<BluetoothRequest>,
mem_profiler_chan: MemProfilerChan,
time_profiler_chan: TimeProfilerChan,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
@ -2809,7 +2818,9 @@ impl Window {
parent_info,
dom_static: GlobalStaticData::new(),
js_runtime: DomRefCell::new(Some(runtime.clone())),
#[cfg(feature = "bluetooth")]
bluetooth_thread,
#[cfg(feature = "bluetooth")]
bluetooth_extra_permission_data: BluetoothExtraPermissionData::new(),
page_clip_rect: Cell::new(MaxRect::max_rect()),
unhandled_resize_event: Default::default(),
@ -2823,6 +2834,7 @@ impl Window {
error_reporter,
scroll_offsets: Default::default(),
media_query_lists: DOMTracker::new(),
#[cfg(feature = "bluetooth")]
test_runner: Default::default(),
webgl_chan,
#[cfg(feature = "webxr")]

View file

@ -9,6 +9,7 @@ use std::option::Option;
use std::result::Result;
use base::id::PipelineId;
#[cfg(feature = "bluetooth")]
use bluetooth_traits::BluetoothRequest;
use crossbeam_channel::{select, Receiver, SendError, Sender};
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg};
@ -305,6 +306,7 @@ pub(crate) struct ScriptThreadSenders {
/// A handle to the bluetooth thread.
#[no_trace]
#[cfg(feature = "bluetooth")]
pub(crate) bluetooth_sender: IpcSender<BluetoothRequest>,
/// A [`Sender`] that sends messages to the `Constellation`.

View file

@ -900,6 +900,7 @@ impl ScriptThread {
let senders = ScriptThreadSenders {
self_sender,
#[cfg(feature = "bluetooth")]
bluetooth_sender: state.bluetooth_sender,
constellation_sender: state.constellation_sender,
pipeline_to_constellation_sender: state.pipeline_to_constellation_sender.sender.clone(),
@ -3075,6 +3076,7 @@ impl ScriptThread {
self.senders.image_cache_sender.clone(),
self.image_cache.clone(),
self.resource_threads.clone(),
#[cfg(feature = "bluetooth")]
self.senders.bluetooth_sender.clone(),
self.senders.memory_profiler_sender.clone(),
self.senders.time_profiler_sender.clone(),

View file

@ -37,6 +37,7 @@ servo_config = { path = "../config" }
style = { workspace = true }
[features]
bluetooth = []
webgpu = []
webxr = []

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_BLUETOOTH
// https://webbluetoothcg.github.io/web-bluetooth/#bluetooth
dictionary BluetoothDataFilterInit {
@ -40,3 +42,15 @@ interface Bluetooth : EventTarget {
// Bluetooth includes BluetoothDeviceEventHandlers;
// Bluetooth includes CharacteristicEventHandlers;
// Bluetooth includes ServiceEventHandlers;
// https://webbluetoothcg.github.io/web-bluetooth/#navigator-extensions
partial interface Navigator {
[SameObject, Pref="dom_bluetooth_enabled"] readonly attribute Bluetooth bluetooth;
};
// https://webbluetoothcg.github.io/web-bluetooth/tests#test-interfaces
partial interface Window {
[Pref="dom_bluetooth_testing_enabled", Exposed=Window]
readonly attribute TestRunner testRunner;
//readonly attribute EventSender eventSender;
};

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_BLUETOOTH
// https://webbluetoothcg.github.io/web-bluetooth/#advertising-events
/*interface BluetoothManufacturerDataMap {

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_BLUETOOTH
// https://webbluetoothcg.github.io/web-bluetooth/#characteristicproperties
[Exposed=Window, Pref="dom_bluetooth_enabled"]

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_BLUETOOTH
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdevice
[Exposed=Window, Pref="dom_bluetooth_enabled"]

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_BLUETOOTH
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothpermissionresult
dictionary BluetoothPermissionDescriptor : PermissionDescriptor {

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_BLUETOOTH
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattcharacteristic
[Exposed=Window, Pref="dom_bluetooth_enabled"]

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_BLUETOOTH
// http://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattdescriptor
[Exposed=Window, Pref="dom_bluetooth_enabled"]

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_BLUETOOTH
//https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattserver
[Exposed=Window, Pref="dom_bluetooth_enabled"]

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_BLUETOOTH
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattservice
[Exposed=Window, Pref="dom_bluetooth_enabled"]

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_BLUETOOTH
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothuuid
[Exposed=Window, Pref="dom_bluetooth_enabled"]

View file

@ -31,11 +31,6 @@ interface mixin NavigatorID {
[Exposed=Window] readonly attribute DOMString vendorSub; // constant ""
};
// https://webbluetoothcg.github.io/web-bluetooth/#navigator-extensions
partial interface Navigator {
[SameObject, Pref="dom_bluetooth_enabled"] readonly attribute Bluetooth bluetooth;
};
// https://w3c.github.io/ServiceWorker/#navigator-service-worker
partial interface Navigator {
[SameObject, Pref="dom_serviceworker_enabled"] readonly attribute ServiceWorkerContainer serviceWorker;

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_BLUETOOTH
// https://webbluetoothcg.github.io/web-bluetooth/tests#test-runner
// callback BluetoothManualChooserEventsCallback = void(sequence<DOMString> events);

View file

@ -166,13 +166,6 @@ Window includes WindowLocalStorage;
// http://w3c.github.io/animation-timing/#framerequestcallback
callback FrameRequestCallback = undefined (DOMHighResTimeStamp time);
// https://webbluetoothcg.github.io/web-bluetooth/tests#test-interfaces
partial interface Window {
[Pref="dom_bluetooth_testing_enabled", Exposed=Window]
readonly attribute TestRunner testRunner;
//readonly attribute EventSender eventSender;
};
partial interface Window {
[Pref="css_animations_testing_enabled"]
readonly attribute unsigned long runningAnimationCount;

View file

@ -13,6 +13,13 @@ path = "lib.rs"
crate-type = ["rlib"]
[features]
bluetooth = [
"bluetooth_traits",
"dep:bluetooth",
"constellation/bluetooth",
"script/bluetooth",
"script_traits/bluetooth",
]
default = ["clipboard"]
clipboard = ["dep:arboard"]
crown = ["script/crown"]
@ -51,8 +58,8 @@ webgpu = [
[dependencies]
background_hang_monitor = { path = "../background_hang_monitor" }
base = { workspace = true }
bluetooth = { path = "../bluetooth" }
bluetooth_traits = { workspace = true }
bluetooth = { path = "../bluetooth", optional = true }
bluetooth_traits = { workspace = true, optional = true }
canvas = { path = "../canvas", default-features = false }
canvas_traits = { workspace = true }
cfg-if = { workspace = true }

View file

@ -34,7 +34,9 @@ use std::thread;
pub use base::id::TopLevelBrowsingContextId;
use base::id::{PipelineId, PipelineNamespace, PipelineNamespaceId, WebViewId};
#[cfg(feature = "bluetooth")]
use bluetooth::BluetoothThreadFactory;
#[cfg(feature = "bluetooth")]
use bluetooth_traits::BluetoothRequest;
use canvas::canvas_paint_thread::CanvasPaintThread;
use canvas::WebGLComm;
@ -108,12 +110,13 @@ use webview::WebViewInner;
#[cfg(feature = "webxr")]
pub use webxr;
pub use {
background_hang_monitor, base, bluetooth, bluetooth_traits, canvas, canvas_traits, compositing,
devtools, devtools_traits, euclid, fonts, ipc_channel, layout_thread_2020, media, net,
net_traits, profile, profile_traits, script, script_layout_interface, script_traits,
servo_config as config, servo_config, servo_geometry, servo_url, style, style_traits,
webrender_api, webrender_traits,
background_hang_monitor, base, canvas, canvas_traits, compositing, devtools, devtools_traits,
euclid, fonts, ipc_channel, layout_thread_2020, media, net, net_traits, profile,
profile_traits, script, script_layout_interface, script_traits, servo_config as config,
servo_config, servo_geometry, servo_url, style, style_traits, webrender_api, webrender_traits,
};
#[cfg(feature = "bluetooth")]
pub use {bluetooth, bluetooth_traits};
use crate::proxies::ConstellationProxy;
pub use crate::servo_delegate::{ServoDelegate, ServoError};
@ -1099,6 +1102,7 @@ fn create_constellation(
// Global configuration options, parsed from the command line.
let opts = opts::get();
#[cfg(feature = "bluetooth")]
let bluetooth_thread: IpcSender<BluetoothRequest> =
BluetoothThreadFactory::new(embedder_proxy.clone());
@ -1128,6 +1132,7 @@ fn create_constellation(
compositor_proxy,
embedder_proxy,
devtools_sender,
#[cfg(feature = "bluetooth")]
bluetooth_thread,
system_font_service,
public_resource_threads,

View file

@ -12,13 +12,14 @@ name = "script_traits"
path = "lib.rs"
[features]
bluetooth = ["bluetooth_traits"]
webgpu = []
[dependencies]
background_hang_monitor_api = { workspace = true }
base = { workspace = true }
bitflags = { workspace = true }
bluetooth_traits = { workspace = true }
bluetooth_traits = { workspace = true, optional = true }
canvas_traits = { workspace = true }
cookie = { workspace = true }
crossbeam-channel = { workspace = true }

View file

@ -27,6 +27,7 @@ use base::id::{
};
use base::Epoch;
use bitflags::bitflags;
#[cfg(feature = "bluetooth")]
use bluetooth_traits::BluetoothRequest;
use canvas_traits::webgl::WebGLPipeline;
use crossbeam_channel::{RecvTimeoutError, Sender};
@ -517,6 +518,7 @@ pub struct InitialScriptState {
/// A channel to the resource manager thread.
pub resource_threads: ResourceThreads,
/// A channel to the bluetooth thread.
#[cfg(feature = "bluetooth")]
pub bluetooth_sender: IpcSender<BluetoothRequest>,
/// The image cache for this script thread.
pub image_cache: Arc<dyn ImageCache>,

View file

@ -59,7 +59,7 @@ webgpu = ["libservo/webgpu"]
[dependencies]
euclid = { workspace = true }
libc = { workspace = true }
libservo = { path = "../../components/servo", features = ["background_hang_monitor"] }
libservo = { path = "../../components/servo", features = ["background_hang_monitor", "bluetooth"] }
cfg-if = { workspace = true }
keyboard-types = { workspace = true }
log = { workspace = true }