mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
* CanGc fix for pagetransitionevent Signed-off-by: webbeef <me@webbeef.org> * CanGc fix for dom/node Signed-off-by: webbeef <me@webbeef.org> * CanGc fix for gamepad Signed-off-by: webbeef <me@webbeef.org> * CanGc fix for gpu Signed-off-by: webbeef <me@webbeef.org> * CanGc fix for dom/element Signed-off-by: webbeef <me@webbeef.org> * CanGc fix for xhr Signed-off-by: webbeef <me@webbeef.org> * CanGc fix for dom/worker Signed-off-by: webbeef <me@webbeef.org> * CanGc fix for rtcdatachannel Signed-off-by: webbeef <me@webbeef.org> * CanGc fix for rtcerror Signed-off-by: webbeef <me@webbeef.org> * Address review comments Signed-off-by: webbeef <me@webbeef.org> --------- Signed-off-by: webbeef <me@webbeef.org>
64 lines
1.9 KiB
Rust
64 lines
1.9 KiB
Rust
/* 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/. */
|
|
|
|
use dom_struct::dom_struct;
|
|
use js::jsval::JSVal;
|
|
use webgpu::ShaderCompilationInfo;
|
|
|
|
use super::bindings::codegen::Bindings::WebGPUBinding::GPUCompilationInfoMethods;
|
|
use super::bindings::import::module::DomRoot;
|
|
use super::bindings::reflector::reflect_dom_object_with_proto;
|
|
use super::bindings::utils::to_frozen_array;
|
|
use super::types::GPUCompilationMessage;
|
|
use crate::dom::bindings::reflector::Reflector;
|
|
use crate::dom::globalscope::GlobalScope;
|
|
use crate::script_runtime::{CanGc, JSContext};
|
|
|
|
#[dom_struct]
|
|
pub struct GPUCompilationInfo {
|
|
reflector_: Reflector,
|
|
// currently we only get one message from wgpu
|
|
msg: Vec<DomRoot<GPUCompilationMessage>>,
|
|
}
|
|
|
|
impl GPUCompilationInfo {
|
|
pub fn new_inherited(msg: Vec<DomRoot<GPUCompilationMessage>>) -> Self {
|
|
Self {
|
|
reflector_: Reflector::new(),
|
|
msg,
|
|
}
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub fn new(
|
|
global: &GlobalScope,
|
|
msg: Vec<DomRoot<GPUCompilationMessage>>,
|
|
can_gc: CanGc,
|
|
) -> DomRoot<Self> {
|
|
reflect_dom_object_with_proto(Box::new(Self::new_inherited(msg)), global, None, can_gc)
|
|
}
|
|
|
|
pub fn from(
|
|
global: &GlobalScope,
|
|
error: Option<ShaderCompilationInfo>,
|
|
can_gc: CanGc,
|
|
) -> DomRoot<Self> {
|
|
Self::new(
|
|
global,
|
|
if let Some(error) = error {
|
|
vec![GPUCompilationMessage::from(global, error)]
|
|
} else {
|
|
Vec::new()
|
|
},
|
|
can_gc,
|
|
)
|
|
}
|
|
}
|
|
|
|
impl GPUCompilationInfoMethods for GPUCompilationInfo {
|
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpucompilationinfo-messages>
|
|
fn Messages(&self, cx: JSContext) -> JSVal {
|
|
to_frozen_array(self.msg.as_slice(), cx)
|
|
}
|
|
}
|