aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebbeef <me@webbeef.org>2025-02-08 00:16:21 -0800
committerGitHub <noreply@github.com>2025-02-08 08:16:21 +0000
commit827012fc08a178fbf812d7641fd396c56420c4a1 (patch)
tree7237fb8fcf3835aa110e54fb6058b492dc6c1cd8
parent654df4c8b7cc9e60881021e5e8986df245088ada (diff)
downloadservo-827012fc08a178fbf812d7641fd396c56420c4a1.tar.gz
servo-827012fc08a178fbf812d7641fd396c56420c4a1.zip
suppress build warnings when disabling webgpu and webxr (#35379)
Signed-off-by: webbeef <me@webbeef.org>
-rw-r--r--components/script/conversions.rs1
-rw-r--r--components/script/dom/bindings/buffer_source.rs21
-rw-r--r--components/script/dom/document.rs1
-rw-r--r--components/script/dom/gpucanvascontext.rs9
-rw-r--r--components/script/dom/mod.rs2
-rw-r--r--components/script/dom/webgl2renderingcontext.rs2
-rw-r--r--components/script/dom/webglrenderingcontext.rs2
-rw-r--r--components/script/messaging.rs3
8 files changed, 26 insertions, 15 deletions
diff --git a/components/script/conversions.rs b/components/script/conversions.rs
index 7bb5059831b..8c477b1ab78 100644
--- a/components/script/conversions.rs
+++ b/components/script/conversions.rs
@@ -14,6 +14,7 @@ pub(crate) trait Convert<T> {
/// to convert between two types that are not defined in the script crate.
/// This is intended to be used on dict/enum types generated from WebIDL once
/// those types are moved out of the script crate.
+#[cfg(feature = "webgpu")]
pub(crate) trait TryConvert<T> {
type Error;
diff --git a/components/script/dom/bindings/buffer_source.rs b/components/script/dom/bindings/buffer_source.rs
index 299b46a3c85..a319a7e0c2c 100644
--- a/components/script/dom/bindings/buffer_source.rs
+++ b/components/script/dom/bindings/buffer_source.rs
@@ -4,24 +4,29 @@
#![allow(unsafe_code)]
+#[cfg(feature = "webgpu")]
use std::ffi::c_void;
use std::marker::PhantomData;
+#[cfg(feature = "webgpu")]
use std::ops::Range;
use std::ptr;
+#[cfg(feature = "webgpu")]
use std::sync::Arc;
+#[cfg(feature = "webgpu")]
+use js::jsapi::NewExternalArrayBuffer;
use js::jsapi::{
GetArrayBufferByteLength, Heap, IsDetachedArrayBufferObject, JSObject,
JS_GetArrayBufferViewBuffer, JS_GetArrayBufferViewByteLength, JS_IsArrayBufferViewObject,
- JS_IsTypedArrayObject, NewExternalArrayBuffer,
+ JS_IsTypedArrayObject,
};
use js::rust::wrappers::DetachArrayBuffer;
use js::rust::{CustomAutoRooterGuard, Handle, MutableHandleObject};
-use js::typedarray::{
- ArrayBuffer, CreateWith, HeapArrayBuffer, TypedArray, TypedArrayElement,
- TypedArrayElementCreator,
-};
+#[cfg(feature = "webgpu")]
+use js::typedarray::{ArrayBuffer, HeapArrayBuffer};
+use js::typedarray::{CreateWith, TypedArray, TypedArrayElement, TypedArrayElementCreator};
+#[cfg(feature = "webgpu")]
use crate::dom::globalscope::GlobalScope;
use crate::script_runtime::JSContext;
@@ -372,6 +377,7 @@ where
}
}
+#[cfg(feature = "webgpu")]
#[derive(JSTraceable, MallocSizeOf)]
pub(crate) struct DataBlock {
#[ignore_malloc_size_of = "Arc"]
@@ -382,10 +388,12 @@ pub(crate) struct DataBlock {
/// Returns true if two non-inclusive ranges overlap
// https://stackoverflow.com/questions/3269434/whats-the-most-efficient-way-to-test-if-two-ranges-overlap
+#[cfg(feature = "webgpu")]
fn range_overlap<T: std::cmp::PartialOrd>(range1: &Range<T>, range2: &Range<T>) -> bool {
range1.start < range2.end && range2.start < range1.end
}
+#[cfg(feature = "webgpu")]
impl DataBlock {
pub(crate) fn new_zeroed(size: usize) -> Self {
let data = vec![0; size];
@@ -449,6 +457,7 @@ impl DataBlock {
}
}
+#[cfg(feature = "webgpu")]
#[derive(JSTraceable, MallocSizeOf)]
pub(crate) struct DataView {
#[no_trace]
@@ -457,12 +466,14 @@ pub(crate) struct DataView {
buffer: HeapArrayBuffer,
}
+#[cfg(feature = "webgpu")]
impl DataView {
pub(crate) fn array_buffer(&self) -> ArrayBuffer {
unsafe { ArrayBuffer::from(self.buffer.underlying_object().get()).unwrap() }
}
}
+#[cfg(feature = "webgpu")]
impl Drop for DataView {
#[allow(unsafe_code)]
fn drop(&mut self) {
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index c8e71aa01a4..87efd354fee 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -109,6 +109,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomGlobal};
use crate::dom::bindings::root::{Dom, DomRoot, DomSlice, LayoutDom, MutNullableDom};
use crate::dom::bindings::str::{DOMString, USVString};
use crate::dom::bindings::trace::{HashMapTracedValues, NoTrace};
+#[cfg(feature = "webgpu")]
use crate::dom::bindings::weakref::WeakRef;
use crate::dom::bindings::xmlname::XMLName::Invalid;
use crate::dom::bindings::xmlname::{
diff --git a/components/script/dom/gpucanvascontext.rs b/components/script/dom/gpucanvascontext.rs
index da59058fde7..5304d0f5d3b 100644
--- a/components/script/dom/gpucanvascontext.rs
+++ b/components/script/dom/gpucanvascontext.rs
@@ -8,9 +8,8 @@ use script_layout_interface::HTMLCanvasDataSource;
use crate::dom::bindings::codegen::Bindings::GPUCanvasContextBinding::GPUCanvasContextMethods;
use crate::dom::bindings::codegen::UnionTypes;
use crate::dom::bindings::reflector::Reflector;
-use crate::dom::bindings::root::{DomRoot, LayoutDom};
-use crate::dom::globalscope::GlobalScope;
-use crate::dom::htmlcanvaselement::{HTMLCanvasElement, LayoutCanvasRenderingContextHelpers};
+use crate::dom::bindings::root::LayoutDom;
+use crate::dom::htmlcanvaselement::LayoutCanvasRenderingContextHelpers;
#[dom_struct]
pub(crate) struct GPUCanvasContext {
@@ -22,10 +21,6 @@ impl GPUCanvasContext {
fn new_inherited() -> Self {
unimplemented!()
}
-
- pub(crate) fn new(_global: &GlobalScope, _canvas: &HTMLCanvasElement) -> DomRoot<Self> {
- unimplemented!()
- }
}
impl GPUCanvasContextMethods<crate::DomTypeHolder> for GPUCanvasContext {
diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs
index 9b59657ad9e..69e5ceb2b77 100644
--- a/components/script/dom/mod.rs
+++ b/components/script/dom/mod.rs
@@ -618,8 +618,6 @@ pub(crate) mod webgpu;
pub(crate) use self::webgpu::*;
#[cfg(not(feature = "webgpu"))]
pub(crate) mod gpucanvascontext;
-#[cfg(not(feature = "webgpu"))]
-pub(crate) use gpucanvascontext::GPUCanvasContext;
pub(crate) mod wheelevent;
#[allow(dead_code)]
pub(crate) mod window;
diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs
index b8c340e089a..da9c1d88f4a 100644
--- a/components/script/dom/webgl2renderingcontext.rs
+++ b/components/script/dom/webgl2renderingcontext.rs
@@ -5,6 +5,7 @@
use std::cell::Cell;
use std::cmp;
use std::ptr::{self, NonNull};
+#[cfg(feature = "webxr")]
use std::rc::Rc;
use bitflags::bitflags;
@@ -42,6 +43,7 @@ use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom};
use crate::dom::bindings::str::DOMString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::htmlcanvaselement::LayoutCanvasRenderingContextHelpers;
+#[cfg(feature = "webxr")]
use crate::dom::promise::Promise;
use crate::dom::webgl_validations::tex_image_2d::{
TexImage2DValidator, TexImage2DValidatorResult, TexStorageValidator, TexStorageValidatorResult,
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index 5aa8695c138..d71ee07ab39 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -5,6 +5,7 @@
use std::cell::Cell;
use std::cmp;
use std::ptr::{self, NonNull};
+#[cfg(feature = "webxr")]
use std::rc::Rc;
#[cfg(feature = "webgl_backtrace")]
@@ -58,6 +59,7 @@ use crate::dom::element::cors_setting_for_element;
use crate::dom::event::{Event, EventBubbles, EventCancelable};
use crate::dom::htmlcanvaselement::{utils as canvas_utils, LayoutCanvasRenderingContextHelpers};
use crate::dom::node::{Node, NodeDamage, NodeTraits};
+#[cfg(feature = "webxr")]
use crate::dom::promise::Promise;
use crate::dom::vertexarrayobject::VertexAttribData;
use crate::dom::webgl_extensions::WebGLExtensions;
diff --git a/components/script/messaging.rs b/components/script/messaging.rs
index 1392f65a5b6..7944a5e8ea4 100644
--- a/components/script/messaging.rs
+++ b/components/script/messaging.rs
@@ -3,6 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use core::fmt;
+#[cfg(feature = "webgpu")]
use std::cell::RefCell;
use std::option::Option;
use std::result::Result;
@@ -402,7 +403,7 @@ impl ScriptThreadReceivers {
}
#[cfg(not(feature = "webgpu"))]
{
- unreachable!("This should never be hit when webgpu is disabled");
+ unreachable!("This should never be hit when webgpu is disabled ({msg:?})");
}
}
}