mirror of
https://github.com/servo/servo.git
synced 2025-06-11 01:50:10 +00:00
Cleanups for future script crate split (#35987)
* script: Avoid direct impl blocks on generated dicts and unions. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Remove references to codegen-specific import module. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix tidy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
3ecd1c0699
commit
d35da38a2f
43 changed files with 211 additions and 146 deletions
|
@ -64,8 +64,13 @@ pub(crate) trait CanvasContext {
|
|||
}
|
||||
}
|
||||
|
||||
impl HTMLCanvasElementOrOffscreenCanvas {
|
||||
pub(crate) fn size(&self) -> Size2D<u64> {
|
||||
pub(crate) trait CanvasHelpers {
|
||||
fn size(&self) -> Size2D<u64>;
|
||||
fn canvas(&self) -> Option<&HTMLCanvasElement>;
|
||||
}
|
||||
|
||||
impl CanvasHelpers for HTMLCanvasElementOrOffscreenCanvas {
|
||||
fn size(&self) -> Size2D<u64> {
|
||||
match self {
|
||||
HTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(canvas) => {
|
||||
canvas.get_size().cast()
|
||||
|
@ -74,7 +79,7 @@ impl HTMLCanvasElementOrOffscreenCanvas {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn canvas(&self) -> Option<&HTMLCanvasElement> {
|
||||
fn canvas(&self) -> Option<&HTMLCanvasElement> {
|
||||
match self {
|
||||
HTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(canvas) => Some(canvas),
|
||||
HTMLCanvasElementOrOffscreenCanvas::OffscreenCanvas(canvas) => canvas.placeholder(),
|
||||
|
|
|
@ -11,7 +11,7 @@ use servo_media::audio::analyser_node::AnalysisEngine;
|
|||
use servo_media::audio::block::Block;
|
||||
use servo_media::audio::node::AudioNodeInit;
|
||||
|
||||
use crate::dom::audionode::AudioNode;
|
||||
use crate::dom::audionode::{AudioNode, AudioNodeOptionsHelper};
|
||||
use crate::dom::baseaudiocontext::BaseAudioContext;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::AnalyserNodeBinding::{
|
||||
|
|
|
@ -13,6 +13,7 @@ use servo_media::audio::buffer_source_node::{
|
|||
use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage, AudioNodeType};
|
||||
use servo_media::audio::param::ParamType;
|
||||
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::audiobuffer::AudioBuffer;
|
||||
use crate::dom::audioparam::AudioParam;
|
||||
use crate::dom::audioscheduledsourcenode::AudioScheduledSourceNode;
|
||||
|
@ -52,7 +53,7 @@ impl AudioBufferSourceNode {
|
|||
) -> Fallible<AudioBufferSourceNode> {
|
||||
let node_options = Default::default();
|
||||
let source_node = AudioScheduledSourceNode::new_inherited(
|
||||
AudioNodeInit::AudioBufferSourceNode(options.into()),
|
||||
AudioNodeInit::AudioBufferSourceNode(options.convert()),
|
||||
context,
|
||||
node_options,
|
||||
0, /* inputs */
|
||||
|
@ -274,18 +275,18 @@ impl AudioBufferSourceNodeMethods<crate::DomTypeHolder> for AudioBufferSourceNod
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a AudioBufferSourceOptions> for AudioBufferSourceNodeOptions {
|
||||
fn from(options: &'a AudioBufferSourceOptions) -> Self {
|
||||
Self {
|
||||
buffer: options
|
||||
impl Convert<AudioBufferSourceNodeOptions> for &AudioBufferSourceOptions {
|
||||
fn convert(self) -> AudioBufferSourceNodeOptions {
|
||||
AudioBufferSourceNodeOptions {
|
||||
buffer: self
|
||||
.buffer
|
||||
.as_ref()
|
||||
.and_then(|b| (*b.as_ref()?.get_channels()).clone()),
|
||||
detune: *options.detune,
|
||||
loop_enabled: options.loop_,
|
||||
loop_end: Some(*options.loopEnd),
|
||||
loop_start: Some(*options.loopStart),
|
||||
playback_rate: *options.playbackRate,
|
||||
detune: *self.detune,
|
||||
loop_enabled: self.loop_,
|
||||
loop_end: Some(*self.loopEnd),
|
||||
loop_start: Some(*self.loopStart),
|
||||
playback_rate: *self.playbackRate,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use dom_struct::dom_struct;
|
||||
|
||||
use crate::dom::audionode::{AudioNode, MAX_CHANNEL_COUNT};
|
||||
use crate::dom::audionode::{AudioNode, AudioNodeOptionsHelper, MAX_CHANNEL_COUNT};
|
||||
use crate::dom::baseaudiocontext::BaseAudioContext;
|
||||
use crate::dom::bindings::codegen::Bindings::AudioDestinationNodeBinding::AudioDestinationNodeMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{
|
||||
|
|
|
@ -387,8 +387,17 @@ impl Convert<ServoMediaChannelInterpretation> for ChannelInterpretation {
|
|||
}
|
||||
}
|
||||
|
||||
impl AudioNodeOptions {
|
||||
pub(crate) fn unwrap_or(
|
||||
pub(crate) trait AudioNodeOptionsHelper {
|
||||
fn unwrap_or(
|
||||
&self,
|
||||
count: u32,
|
||||
mode: ChannelCountMode,
|
||||
interpretation: ChannelInterpretation,
|
||||
) -> UnwrappedAudioNodeOptions;
|
||||
}
|
||||
|
||||
impl AudioNodeOptionsHelper for AudioNodeOptions {
|
||||
fn unwrap_or(
|
||||
&self,
|
||||
count: u32,
|
||||
mode: ChannelCountMode,
|
||||
|
|
|
@ -39,8 +39,7 @@ use js::typedarray::{
|
|||
TypedArray, TypedArrayElement, TypedArrayElementCreator,
|
||||
};
|
||||
|
||||
use crate::dom::bindings::error::Error;
|
||||
use crate::dom::bindings::import::module::Fallible;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
#[cfg(feature = "webgpu")]
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::script_runtime::{CanGc, JSContext};
|
||||
|
|
|
@ -36,7 +36,7 @@ macro_rules! native_raw_obj_fn {
|
|||
#[allow(clippy::macro_metavars_in_unsafe)]
|
||||
unsafe {
|
||||
let name: &std::ffi::CStr = $name;
|
||||
let raw_fun = $crate::dom::bindings::import::module::jsapi::JS_NewFunction(
|
||||
let raw_fun = js::jsapi::JS_NewFunction(
|
||||
*$cx,
|
||||
Some(wrapper),
|
||||
$nargs,
|
||||
|
@ -44,7 +44,7 @@ macro_rules! native_raw_obj_fn {
|
|||
name.as_ptr() as *const std::ffi::c_char,
|
||||
);
|
||||
assert!(!raw_fun.is_null());
|
||||
$crate::dom::bindings::import::module::jsapi::JS_GetFunctionObject(raw_fun)
|
||||
js::jsapi::JS_GetFunctionObject(raw_fun)
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage, AudioNodeType};
|
|||
use servo_media::audio::param::ParamType;
|
||||
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::audionode::AudioNode;
|
||||
use crate::dom::audionode::{AudioNode, AudioNodeOptionsHelper};
|
||||
use crate::dom::audioparam::AudioParam;
|
||||
use crate::dom::baseaudiocontext::BaseAudioContext;
|
||||
use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{
|
||||
|
|
|
@ -18,7 +18,7 @@ use super::bindings::error::Fallible;
|
|||
use super::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object_with_proto};
|
||||
use super::bindings::root::DomRoot;
|
||||
use super::types::GlobalScope;
|
||||
use crate::dom::bindings::import::module::get_dictionary_property;
|
||||
use crate::dom::bindings::utils::get_dictionary_property;
|
||||
use crate::native_fn;
|
||||
use crate::script_runtime::CanGc;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use profile_traits::ipc;
|
|||
use script_layout_interface::HTMLCanvasDataSource;
|
||||
use servo_url::ServoUrl;
|
||||
|
||||
use crate::canvas_context::{CanvasContext, LayoutCanvasRenderingContextHelpers};
|
||||
use crate::canvas_context::{CanvasContext, CanvasHelpers, LayoutCanvasRenderingContextHelpers};
|
||||
use crate::canvas_state::CanvasState;
|
||||
use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::{
|
||||
CanvasDirection, CanvasFillRule, CanvasImageSource, CanvasLineCap, CanvasLineJoin,
|
||||
|
|
|
@ -7,7 +7,8 @@ use js::rust::HandleObject;
|
|||
use servo_media::audio::channel_node::ChannelNodeOptions;
|
||||
use servo_media::audio::node::AudioNodeInit;
|
||||
|
||||
use crate::dom::audionode::{AudioNode, MAX_CHANNEL_COUNT};
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::audionode::{AudioNode, AudioNodeOptionsHelper, MAX_CHANNEL_COUNT};
|
||||
use crate::dom::baseaudiocontext::BaseAudioContext;
|
||||
use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{
|
||||
ChannelCountMode, ChannelInterpretation,
|
||||
|
@ -47,11 +48,12 @@ impl ChannelMergerNode {
|
|||
return Err(Error::IndexSize);
|
||||
}
|
||||
|
||||
let num_inputs = options.numberOfInputs;
|
||||
let node = AudioNode::new_inherited(
|
||||
AudioNodeInit::ChannelMergerNode(options.into()),
|
||||
AudioNodeInit::ChannelMergerNode(options.convert()),
|
||||
context,
|
||||
node_options,
|
||||
options.numberOfInputs, // inputs
|
||||
num_inputs, // inputs
|
||||
1, // outputs
|
||||
)?;
|
||||
Ok(ChannelMergerNode { node })
|
||||
|
@ -97,10 +99,10 @@ impl ChannelMergerNodeMethods<crate::DomTypeHolder> for ChannelMergerNode {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a ChannelMergerOptions> for ChannelNodeOptions {
|
||||
fn from(options: &'a ChannelMergerOptions) -> Self {
|
||||
Self {
|
||||
channels: options.numberOfInputs as u8,
|
||||
impl Convert<ChannelNodeOptions> for ChannelMergerOptions {
|
||||
fn convert(self) -> ChannelNodeOptions {
|
||||
ChannelNodeOptions {
|
||||
channels: self.numberOfInputs as u8,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use dom_struct::dom_struct;
|
|||
use js::rust::HandleObject;
|
||||
use servo_media::audio::node::AudioNodeInit;
|
||||
|
||||
use crate::dom::audionode::{AudioNode, MAX_CHANNEL_COUNT};
|
||||
use crate::dom::audionode::{AudioNode, AudioNodeOptionsHelper, MAX_CHANNEL_COUNT};
|
||||
use crate::dom::baseaudiocontext::BaseAudioContext;
|
||||
use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{
|
||||
ChannelCountMode, ChannelInterpretation,
|
||||
|
|
|
@ -10,6 +10,7 @@ use servo_media::audio::constant_source_node::ConstantSourceNodeOptions as Servo
|
|||
use servo_media::audio::node::{AudioNodeInit, AudioNodeType};
|
||||
use servo_media::audio::param::ParamType;
|
||||
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::audioparam::AudioParam;
|
||||
use crate::dom::audioscheduledsourcenode::AudioScheduledSourceNode;
|
||||
use crate::dom::baseaudiocontext::BaseAudioContext;
|
||||
|
@ -38,8 +39,9 @@ impl ConstantSourceNode {
|
|||
can_gc: CanGc,
|
||||
) -> Fallible<ConstantSourceNode> {
|
||||
let node_options = Default::default();
|
||||
let offset = *options.offset;
|
||||
let source_node = AudioScheduledSourceNode::new_inherited(
|
||||
AudioNodeInit::ConstantSourceNode(options.into()),
|
||||
AudioNodeInit::ConstantSourceNode(options.convert()),
|
||||
context,
|
||||
node_options, /* 2, MAX, Speakers */
|
||||
0, /* inputs */
|
||||
|
@ -53,7 +55,7 @@ impl ConstantSourceNode {
|
|||
AudioNodeType::ConstantSourceNode,
|
||||
ParamType::Offset,
|
||||
AutomationRate::A_rate,
|
||||
*options.offset,
|
||||
offset,
|
||||
f32::MIN,
|
||||
f32::MAX,
|
||||
can_gc,
|
||||
|
@ -110,10 +112,10 @@ impl ConstantSourceNodeMethods<crate::DomTypeHolder> for ConstantSourceNode {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a ConstantSourceOptions> for ServoMediaConstantSourceOptions {
|
||||
fn from(options: &'a ConstantSourceOptions) -> Self {
|
||||
Self {
|
||||
offset: *options.offset,
|
||||
impl Convert<ServoMediaConstantSourceOptions> for ConstantSourceOptions {
|
||||
fn convert(self) -> ServoMediaConstantSourceOptions {
|
||||
ServoMediaConstantSourceOptions {
|
||||
offset: *self.offset,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use js::rust::HandleValue as SafeHandleValue;
|
|||
|
||||
use super::bindings::root::{DomRoot, MutNullableDom};
|
||||
use super::types::{ReadableStream, ReadableStreamDefaultReader};
|
||||
use crate::dom::bindings::import::module::Error;
|
||||
use crate::dom::bindings::error::Error;
|
||||
use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object};
|
||||
use crate::dom::bindings::root::Dom;
|
||||
use crate::dom::defaultteereadrequest::DefaultTeeReadRequest;
|
||||
|
|
|
@ -25,6 +25,7 @@ use servo_url::ServoUrl;
|
|||
use style::str::HTML_SPACE_CHARACTERS;
|
||||
use stylo_atoms::Atom;
|
||||
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::beforeunloadevent::BeforeUnloadEvent;
|
||||
use crate::dom::bindings::callback::{CallbackContainer, CallbackFunction, ExceptionHandling};
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
|
@ -384,7 +385,7 @@ impl EventListeners {
|
|||
}
|
||||
|
||||
#[dom_struct]
|
||||
pub(crate) struct EventTarget {
|
||||
pub struct EventTarget {
|
||||
reflector_: Reflector,
|
||||
handlers: DomRefCell<HashMapTracedValues<Atom, EventListeners, BuildHasherDefault<FnvHasher>>>,
|
||||
}
|
||||
|
@ -944,7 +945,7 @@ impl EventTargetMethods<crate::DomTypeHolder> for EventTarget {
|
|||
listener: Option<Rc<EventListener>>,
|
||||
options: AddEventListenerOptionsOrBoolean,
|
||||
) {
|
||||
self.add_event_listener(ty, listener, options.into())
|
||||
self.add_event_listener(ty, listener, options.convert())
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
|
||||
|
@ -954,7 +955,7 @@ impl EventTargetMethods<crate::DomTypeHolder> for EventTarget {
|
|||
listener: Option<Rc<EventListener>>,
|
||||
options: EventListenerOptionsOrBoolean,
|
||||
) {
|
||||
self.remove_event_listener(ty, listener, options.into())
|
||||
self.remove_event_listener(ty, listener, options.convert())
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
|
||||
|
@ -976,11 +977,11 @@ impl VirtualMethods for EventTarget {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<AddEventListenerOptionsOrBoolean> for AddEventListenerOptions {
|
||||
fn from(options: AddEventListenerOptionsOrBoolean) -> Self {
|
||||
match options {
|
||||
impl Convert<AddEventListenerOptions> for AddEventListenerOptionsOrBoolean {
|
||||
fn convert(self) -> AddEventListenerOptions {
|
||||
match self {
|
||||
AddEventListenerOptionsOrBoolean::AddEventListenerOptions(options) => options,
|
||||
AddEventListenerOptionsOrBoolean::Boolean(capture) => Self {
|
||||
AddEventListenerOptionsOrBoolean::Boolean(capture) => AddEventListenerOptions {
|
||||
parent: EventListenerOptions { capture },
|
||||
once: false,
|
||||
passive: None,
|
||||
|
@ -989,11 +990,11 @@ impl From<AddEventListenerOptionsOrBoolean> for AddEventListenerOptions {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<EventListenerOptionsOrBoolean> for EventListenerOptions {
|
||||
fn from(options: EventListenerOptionsOrBoolean) -> Self {
|
||||
match options {
|
||||
impl Convert<EventListenerOptions> for EventListenerOptionsOrBoolean {
|
||||
fn convert(self) -> EventListenerOptions {
|
||||
match self {
|
||||
EventListenerOptionsOrBoolean::EventListenerOptions(options) => options,
|
||||
EventListenerOptionsOrBoolean::Boolean(capture) => Self { capture },
|
||||
EventListenerOptionsOrBoolean::Boolean(capture) => EventListenerOptions { capture },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ use servo_media::audio::gain_node::GainNodeOptions;
|
|||
use servo_media::audio::node::{AudioNodeInit, AudioNodeType};
|
||||
use servo_media::audio::param::ParamType;
|
||||
|
||||
use crate::dom::audionode::AudioNode;
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::audionode::{AudioNode, AudioNodeOptionsHelper};
|
||||
use crate::dom::audioparam::AudioParam;
|
||||
use crate::dom::baseaudiocontext::BaseAudioContext;
|
||||
use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{
|
||||
|
@ -42,8 +43,9 @@ impl GainNode {
|
|||
options
|
||||
.parent
|
||||
.unwrap_or(2, ChannelCountMode::Max, ChannelInterpretation::Speakers);
|
||||
let gain = *options.gain;
|
||||
let node = AudioNode::new_inherited(
|
||||
AudioNodeInit::GainNode(options.into()),
|
||||
AudioNodeInit::GainNode(options.convert()),
|
||||
context,
|
||||
node_options,
|
||||
1, // inputs
|
||||
|
@ -56,7 +58,7 @@ impl GainNode {
|
|||
AudioNodeType::GainNode,
|
||||
ParamType::Gain,
|
||||
AutomationRate::A_rate,
|
||||
*options.gain, // default value
|
||||
gain, // default value
|
||||
f32::MIN, // min value
|
||||
f32::MAX, // max value
|
||||
can_gc,
|
||||
|
@ -112,10 +114,8 @@ impl GainNodeMethods<crate::DomTypeHolder> for GainNode {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a GainOptions> for GainNodeOptions {
|
||||
fn from(options: &'a GainOptions) -> Self {
|
||||
Self {
|
||||
gain: *options.gain,
|
||||
}
|
||||
impl Convert<GainNodeOptions> for GainOptions {
|
||||
fn convert(self) -> GainNodeOptions {
|
||||
GainNodeOptions { gain: *self.gain }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,9 @@ use style::attr::AttrValue;
|
|||
|
||||
use crate::canvas_context::CanvasContext as _;
|
||||
pub(crate) use crate::canvas_context::*;
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::attr::Attr;
|
||||
use crate::dom::bindings::callback::ExceptionHandling;
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref, ref_filter_map};
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::{
|
||||
BlobCallback, HTMLCanvasElementMethods, RenderingContext,
|
||||
|
@ -39,7 +41,6 @@ use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGL
|
|||
use crate::dom::bindings::codegen::UnionTypes::HTMLCanvasElementOrOffscreenCanvas;
|
||||
use crate::dom::bindings::conversions::ConversionResult;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::import::module::ExceptionHandling;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::num::Finite;
|
||||
use crate::dom::bindings::refcounted::Trusted;
|
||||
|
@ -342,9 +343,9 @@ impl HTMLCanvasElement {
|
|||
fn get_gl_attributes(cx: JSContext, options: HandleValue) -> Option<GLContextAttributes> {
|
||||
unsafe {
|
||||
match WebGLContextAttributes::new(cx, options) {
|
||||
Ok(ConversionResult::Success(ref attrs)) => Some(From::from(attrs)),
|
||||
Ok(ConversionResult::Failure(ref error)) => {
|
||||
throw_type_error(*cx, error);
|
||||
Ok(ConversionResult::Success(attrs)) => Some(attrs.convert()),
|
||||
Ok(ConversionResult::Failure(error)) => {
|
||||
throw_type_error(*cx, &error);
|
||||
None
|
||||
},
|
||||
_ => {
|
||||
|
@ -702,15 +703,15 @@ impl VirtualMethods for HTMLCanvasElement {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a WebGLContextAttributes> for GLContextAttributes {
|
||||
fn from(attrs: &'a WebGLContextAttributes) -> GLContextAttributes {
|
||||
impl Convert<GLContextAttributes> for WebGLContextAttributes {
|
||||
fn convert(self) -> GLContextAttributes {
|
||||
GLContextAttributes {
|
||||
alpha: attrs.alpha,
|
||||
depth: attrs.depth,
|
||||
stencil: attrs.stencil,
|
||||
antialias: attrs.antialias,
|
||||
premultiplied_alpha: attrs.premultipliedAlpha,
|
||||
preserve_drawing_buffer: attrs.preserveDrawingBuffer,
|
||||
alpha: self.alpha,
|
||||
depth: self.depth,
|
||||
stencil: self.stencil,
|
||||
antialias: self.antialias,
|
||||
premultiplied_alpha: self.premultipliedAlpha,
|
||||
preserve_drawing_buffer: self.preserveDrawingBuffer,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ use js::typedarray::Float32Array;
|
|||
use servo_media::audio::iir_filter_node::{IIRFilterNode as IIRFilter, IIRFilterNodeOptions};
|
||||
use servo_media::audio::node::AudioNodeInit;
|
||||
|
||||
use crate::dom::audionode::AudioNode;
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::audionode::{AudioNode, AudioNodeOptionsHelper};
|
||||
use crate::dom::baseaudiocontext::BaseAudioContext;
|
||||
use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{
|
||||
ChannelCountMode, ChannelInterpretation,
|
||||
|
@ -53,7 +54,9 @@ impl IIRFilterNode {
|
|||
options
|
||||
.parent
|
||||
.unwrap_or(2, ChannelCountMode::Max, ChannelInterpretation::Speakers);
|
||||
let init_options = options.into();
|
||||
let feedforward = (*options.feedforward).to_vec();
|
||||
let feedback = (*options.feedback).to_vec();
|
||||
let init_options = options.clone().convert();
|
||||
let node = AudioNode::new_inherited(
|
||||
AudioNodeInit::IIRFilterNode(init_options),
|
||||
context,
|
||||
|
@ -63,8 +66,8 @@ impl IIRFilterNode {
|
|||
)?;
|
||||
Ok(IIRFilterNode {
|
||||
node,
|
||||
feedforward: (*options.feedforward).to_vec(),
|
||||
feedback: (*options.feedback).to_vec(),
|
||||
feedforward,
|
||||
feedback,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -139,12 +142,11 @@ impl IIRFilterNodeMethods<crate::DomTypeHolder> for IIRFilterNode {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a IIRFilterOptions> for IIRFilterNodeOptions {
|
||||
fn from(options: &'a IIRFilterOptions) -> Self {
|
||||
let feedforward: Vec<f64> =
|
||||
(*options.feedforward.iter().map(|v| **v).collect_vec()).to_vec();
|
||||
let feedback: Vec<f64> = (*options.feedback.iter().map(|v| **v).collect_vec()).to_vec();
|
||||
Self {
|
||||
impl Convert<IIRFilterNodeOptions> for IIRFilterOptions {
|
||||
fn convert(self) -> IIRFilterNodeOptions {
|
||||
let feedforward: Vec<f64> = (*self.feedforward.iter().map(|v| **v).collect_vec()).to_vec();
|
||||
let feedback: Vec<f64> = (*self.feedback.iter().map(|v| **v).collect_vec()).to_vec();
|
||||
IIRFilterNodeOptions {
|
||||
feedforward: Arc::new(feedforward),
|
||||
feedback: Arc::new(feedback),
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ use super::intersectionobserverrootmargin::IntersectionObserverRootMargin;
|
|||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::IntersectionObserverBinding::IntersectionObserverInit;
|
||||
use crate::dom::bindings::codegen::UnionTypes::{DoubleOrDoubleSequence, ElementOrDocument};
|
||||
use crate::dom::bindings::error::Error;
|
||||
use crate::dom::bindings::import::module::Fallible;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::num::Finite;
|
||||
use crate::dom::bindings::reflector::{Reflector, reflect_dom_object_with_proto};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
|
|
|
@ -9,7 +9,7 @@ use servo_media::audio::node::AudioNodeInit;
|
|||
use servo_media::streams::MediaStreamType;
|
||||
|
||||
use crate::dom::audiocontext::AudioContext;
|
||||
use crate::dom::audionode::AudioNode;
|
||||
use crate::dom::audionode::{AudioNode, AudioNodeOptionsHelper};
|
||||
use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{
|
||||
AudioNodeOptions, ChannelCountMode, ChannelInterpretation,
|
||||
};
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* 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 std::rc::Rc;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
|
@ -24,8 +25,7 @@ use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::{
|
|||
PermissionDescriptor, PermissionName, PermissionState,
|
||||
};
|
||||
use crate::dom::bindings::codegen::UnionTypes::UnsignedLongOrUnsignedLongSequence;
|
||||
use crate::dom::bindings::error::Error;
|
||||
use crate::dom::bindings::import::module::{Fallible, Rc};
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
|
|
|
@ -15,6 +15,7 @@ use servo_media::audio::oscillator_node::{
|
|||
use servo_media::audio::param::ParamType;
|
||||
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::audionode::AudioNodeOptionsHelper;
|
||||
use crate::dom::audioparam::AudioParam;
|
||||
use crate::dom::audioscheduledsourcenode::AudioScheduledSourceNode;
|
||||
use crate::dom::baseaudiocontext::BaseAudioContext;
|
||||
|
|
|
@ -14,7 +14,7 @@ use servo_media::audio::panner_node::{
|
|||
use servo_media::audio::param::{ParamDir, ParamType};
|
||||
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::audionode::AudioNode;
|
||||
use crate::dom::audionode::{AudioNode, AudioNodeOptionsHelper};
|
||||
use crate::dom::audioparam::AudioParam;
|
||||
use crate::dom::baseaudiocontext::BaseAudioContext;
|
||||
use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
|
||||
|
@ -63,9 +62,3 @@ impl PermissionStatusMethods<crate::DomTypeHolder> for PermissionStatus {
|
|||
// https://w3c.github.io/permissions/#dom-permissionstatus-onchange
|
||||
event_handler!(change, GetOnchange, SetOnchange);
|
||||
}
|
||||
|
||||
impl Display for PermissionName {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.as_str())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,8 @@ use crate::dom::bindings::buffer_source::{
|
|||
Constructor, byte_size, create_array_buffer_with_size, create_buffer_source_with_constructor,
|
||||
};
|
||||
use crate::dom::bindings::codegen::Bindings::ReadableByteStreamControllerBinding::ReadableByteStreamControllerMethods;
|
||||
use crate::dom::bindings::error::ErrorToJsval;
|
||||
use crate::dom::bindings::import::module::UnionTypes::ReadableStreamDefaultControllerOrReadableByteStreamController as Controller;
|
||||
use crate::dom::bindings::import::module::{Error, Fallible};
|
||||
use crate::dom::bindings::codegen::UnionTypes::ReadableStreamDefaultControllerOrReadableByteStreamController as Controller;
|
||||
use crate::dom::bindings::error::{Error, ErrorToJsval, Fallible};
|
||||
use crate::dom::bindings::reflector::{DomGlobal, Reflector};
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::trace::RootedTraceableBox;
|
||||
|
|
|
@ -24,8 +24,7 @@ use crate::dom::bindings::codegen::Bindings::ReadableStreamDefaultReaderBinding:
|
|||
use crate::dom::bindings::codegen::Bindings::ReadableStreamDefaultControllerBinding::ReadableStreamDefaultController_Binding::ReadableStreamDefaultControllerMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::UnderlyingSourceBinding::UnderlyingSource as JsUnderlyingSource;
|
||||
use crate::dom::bindings::conversions::{ConversionBehavior, ConversionResult};
|
||||
use crate::dom::bindings::error::{Error, ErrorToJsval};
|
||||
use crate::dom::bindings::import::module::Fallible;
|
||||
use crate::dom::bindings::error::{Error, ErrorToJsval, Fallible};
|
||||
use crate::dom::bindings::codegen::UnionTypes::ReadableStreamDefaultReaderOrReadableStreamBYOBReader as ReadableStreamReader;
|
||||
use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object_with_proto};
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom, Dom};
|
||||
|
|
|
@ -21,8 +21,7 @@ use super::bindings::reflector::reflect_dom_object;
|
|||
use super::readablestreamgenericreader::ReadableStreamGenericReader;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::ReadableStreamBYOBReaderBinding::ReadableStreamBYOBReaderMethods;
|
||||
use crate::dom::bindings::error::{Error, ErrorToJsval};
|
||||
use crate::dom::bindings::import::module::Fallible;
|
||||
use crate::dom::bindings::error::{Error, ErrorToJsval, Fallible};
|
||||
use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object_with_proto};
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::trace::RootedTraceableBox;
|
||||
|
|
|
@ -11,7 +11,7 @@ use super::bindings::cell::DomRefCell;
|
|||
use super::bindings::reflector::reflect_dom_object;
|
||||
use super::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::codegen::Bindings::ReadableStreamBYOBRequestBinding::ReadableStreamBYOBRequestMethods;
|
||||
use crate::dom::bindings::import::module::{Error, Fallible};
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::reflector::Reflector;
|
||||
use crate::dom::bindings::root::MutNullableDom;
|
||||
use crate::dom::readablebytestreamcontroller::ReadableByteStreamController;
|
||||
|
|
|
@ -20,8 +20,7 @@ use crate::dom::bindings::cell::DomRefCell;
|
|||
use crate::dom::bindings::codegen::Bindings::ReadableStreamDefaultReaderBinding::{
|
||||
ReadableStreamDefaultReaderMethods, ReadableStreamReadResult,
|
||||
};
|
||||
use crate::dom::bindings::error::{Error, ErrorToJsval};
|
||||
use crate::dom::bindings::import::module::Fallible;
|
||||
use crate::dom::bindings::error::{Error, ErrorToJsval, Fallible};
|
||||
use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object_with_proto};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::trace::RootedTraceableBox;
|
||||
|
|
|
@ -9,8 +9,7 @@ use js::rust::HandleValue as SafeHandleValue;
|
|||
|
||||
use super::readablestream::ReaderType;
|
||||
use super::types::ReadableStream;
|
||||
use crate::dom::bindings::error::{Error, ErrorToJsval};
|
||||
use crate::dom::bindings::import::module::Fallible;
|
||||
use crate::dom::bindings::error::{Error, ErrorToJsval, Fallible};
|
||||
use crate::dom::bindings::reflector::DomGlobal;
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
|
|
|
@ -8,6 +8,8 @@ use servo_media::audio::node::{AudioNodeInit, AudioNodeType};
|
|||
use servo_media::audio::param::ParamType;
|
||||
use servo_media::audio::stereo_panner::StereoPannerOptions as ServoMediaStereoPannerOptions;
|
||||
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::audionode::AudioNodeOptionsHelper;
|
||||
use crate::dom::audioparam::AudioParam;
|
||||
use crate::dom::audioscheduledsourcenode::AudioScheduledSourceNode;
|
||||
use crate::dom::baseaudiocontext::BaseAudioContext;
|
||||
|
@ -48,8 +50,9 @@ impl StereoPannerNode {
|
|||
if node_options.count > 2 || node_options.count == 0 {
|
||||
return Err(Error::NotSupported);
|
||||
}
|
||||
let pan = *options.pan;
|
||||
let source_node = AudioScheduledSourceNode::new_inherited(
|
||||
AudioNodeInit::StereoPannerNode(options.into()),
|
||||
AudioNodeInit::StereoPannerNode(options.convert()),
|
||||
context,
|
||||
node_options,
|
||||
1, /* inputs */
|
||||
|
@ -63,7 +66,7 @@ impl StereoPannerNode {
|
|||
AudioNodeType::StereoPannerNode,
|
||||
ParamType::Pan,
|
||||
AutomationRate::A_rate,
|
||||
*options.pan,
|
||||
pan,
|
||||
-1.,
|
||||
1.,
|
||||
CanGc::note(),
|
||||
|
@ -120,8 +123,8 @@ impl StereoPannerNodeMethods<crate::DomTypeHolder> for StereoPannerNode {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a StereoPannerOptions> for ServoMediaStereoPannerOptions {
|
||||
fn from(options: &'a StereoPannerOptions) -> Self {
|
||||
Self { pan: *options.pan }
|
||||
impl Convert<ServoMediaStereoPannerOptions> for StereoPannerOptions {
|
||||
fn convert(self) -> ServoMediaStereoPannerOptions {
|
||||
ServoMediaStereoPannerOptions { pan: *self.pan }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ use crate::dom::bindings::codegen::UnionTypes::{
|
|||
ArrayBufferViewOrArrayBuffer, ArrayBufferViewOrArrayBufferOrJsonWebKey,
|
||||
};
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::import::module::SafeJSContext;
|
||||
use crate::dom::bindings::refcounted::{Trusted, TrustedPromise};
|
||||
use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
|
@ -258,7 +257,7 @@ impl SubtleCryptoMethods<crate::DomTypeHolder> for SubtleCrypto {
|
|||
/// <https://w3c.github.io/webcrypto/#SubtleCrypto-method-sign>
|
||||
fn Sign(
|
||||
&self,
|
||||
cx: SafeJSContext,
|
||||
cx: JSContext,
|
||||
algorithm: AlgorithmIdentifier,
|
||||
key: &CryptoKey,
|
||||
data: ArrayBufferViewOrArrayBuffer,
|
||||
|
@ -341,7 +340,7 @@ impl SubtleCryptoMethods<crate::DomTypeHolder> for SubtleCrypto {
|
|||
/// <https://w3c.github.io/webcrypto/#SubtleCrypto-method-verify>
|
||||
fn Verify(
|
||||
&self,
|
||||
cx: SafeJSContext,
|
||||
cx: JSContext,
|
||||
algorithm: AlgorithmIdentifier,
|
||||
key: &CryptoKey,
|
||||
signature: ArrayBufferViewOrArrayBuffer,
|
||||
|
@ -429,7 +428,7 @@ impl SubtleCryptoMethods<crate::DomTypeHolder> for SubtleCrypto {
|
|||
/// <https://w3c.github.io/webcrypto/#SubtleCrypto-method-digest>
|
||||
fn Digest(
|
||||
&self,
|
||||
cx: SafeJSContext,
|
||||
cx: JSContext,
|
||||
algorithm: AlgorithmIdentifier,
|
||||
data: ArrayBufferViewOrArrayBuffer,
|
||||
comp: InRealm,
|
||||
|
@ -533,7 +532,7 @@ impl SubtleCryptoMethods<crate::DomTypeHolder> for SubtleCrypto {
|
|||
/// <https://w3c.github.io/webcrypto/#SubtleCrypto-method-deriveKey>
|
||||
fn DeriveKey(
|
||||
&self,
|
||||
cx: SafeJSContext,
|
||||
cx: JSContext,
|
||||
algorithm: AlgorithmIdentifier,
|
||||
base_key: &CryptoKey,
|
||||
derived_key_type: AlgorithmIdentifier,
|
||||
|
@ -663,7 +662,7 @@ impl SubtleCryptoMethods<crate::DomTypeHolder> for SubtleCrypto {
|
|||
/// <https://w3c.github.io/webcrypto/#dfn-SubtleCrypto-method-deriveBits>
|
||||
fn DeriveBits(
|
||||
&self,
|
||||
cx: SafeJSContext,
|
||||
cx: JSContext,
|
||||
algorithm: AlgorithmIdentifier,
|
||||
base_key: &CryptoKey,
|
||||
length: Option<u32>,
|
||||
|
@ -2631,7 +2630,11 @@ fn data_to_jwk_params(alg: &str, size: &str, key: &[u8]) -> (DOMString, DOMStrin
|
|||
(jwk_alg, DOMString::from(data))
|
||||
}
|
||||
|
||||
impl KeyAlgorithm {
|
||||
trait AlgorithmFromName {
|
||||
fn from_name(name: DOMString, out: MutableHandleObject, cx: JSContext);
|
||||
}
|
||||
|
||||
impl AlgorithmFromName for KeyAlgorithm {
|
||||
/// Fill the object referenced by `out` with an [KeyAlgorithm]
|
||||
/// of the specified name and size.
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -2644,7 +2647,16 @@ impl KeyAlgorithm {
|
|||
}
|
||||
}
|
||||
|
||||
impl HmacKeyAlgorithm {
|
||||
trait AlgorithmFromLengthAndHash {
|
||||
fn from_length_and_hash(
|
||||
length: u32,
|
||||
hash: DigestAlgorithm,
|
||||
out: MutableHandleObject,
|
||||
cx: JSContext,
|
||||
);
|
||||
}
|
||||
|
||||
impl AlgorithmFromLengthAndHash for HmacKeyAlgorithm {
|
||||
#[allow(unsafe_code)]
|
||||
fn from_length_and_hash(
|
||||
length: u32,
|
||||
|
@ -2666,7 +2678,11 @@ impl HmacKeyAlgorithm {
|
|||
}
|
||||
}
|
||||
|
||||
impl AesKeyAlgorithm {
|
||||
trait AlgorithmFromNameAndSize {
|
||||
fn from_name_and_size(name: DOMString, size: u16, out: MutableHandleObject, cx: JSContext);
|
||||
}
|
||||
|
||||
impl AlgorithmFromNameAndSize for AesKeyAlgorithm {
|
||||
/// Fill the object referenced by `out` with an [AesKeyAlgorithm]
|
||||
/// of the specified name and size.
|
||||
#[allow(unsafe_code)]
|
||||
|
|
|
@ -12,8 +12,8 @@ use js::rust::{Handle as SafeHandle, HandleObject, HandleValue as SafeHandleValu
|
|||
|
||||
use crate::dom::bindings::callback::ExceptionHandling;
|
||||
use crate::dom::bindings::codegen::Bindings::UnderlyingSourceBinding::UnderlyingSource as JsUnderlyingSource;
|
||||
use crate::dom::bindings::import::module::Error;
|
||||
use crate::dom::bindings::import::module::UnionTypes::ReadableStreamDefaultControllerOrReadableByteStreamController as Controller;
|
||||
use crate::dom::bindings::codegen::UnionTypes::ReadableStreamDefaultControllerOrReadableByteStreamController as Controller;
|
||||
use crate::dom::bindings::error::Error;
|
||||
use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object_with_proto};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::defaultteeunderlyingsource::DefaultTeeUnderlyingSource;
|
||||
|
|
|
@ -19,7 +19,7 @@ use webrender_api::units::DeviceIntSize;
|
|||
|
||||
use super::gpuconvert::convert_texture_descriptor;
|
||||
use super::gputexture::GPUTexture;
|
||||
use crate::canvas_context::CanvasContext;
|
||||
use crate::canvas_context::{CanvasContext, CanvasHelpers};
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::bindings::codegen::Bindings::GPUCanvasContextBinding::GPUCanvasContextMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUTexture_Binding::GPUTextureMethods;
|
||||
|
|
|
@ -7,8 +7,8 @@ use js::rust::MutableHandleValue;
|
|||
use webgpu::ShaderCompilationInfo;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUCompilationInfoMethods;
|
||||
use crate::dom::bindings::import::module::DomRoot;
|
||||
use crate::dom::bindings::reflector::{Reflector, reflect_dom_object_with_proto};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::utils::to_frozen_array;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::types::GPUCompilationMessage;
|
||||
|
|
|
@ -21,6 +21,7 @@ use webgpu::{
|
|||
|
||||
use super::gpu::AsyncWGPUListener;
|
||||
use super::gpudevicelostinfo::GPUDeviceLostInfo;
|
||||
use super::gpuerror::AsWebGpu;
|
||||
use super::gpupipelineerror::GPUPipelineError;
|
||||
use super::gpusupportedlimits::GPUSupportedLimits;
|
||||
use crate::conversions::Convert;
|
||||
|
|
|
@ -90,8 +90,12 @@ impl Convert<GPUErrorFilter> for ErrorFilter {
|
|||
}
|
||||
}
|
||||
|
||||
impl GPUErrorFilter {
|
||||
pub(crate) fn as_webgpu(&self) -> ErrorFilter {
|
||||
pub(crate) trait AsWebGpu {
|
||||
fn as_webgpu(&self) -> ErrorFilter;
|
||||
}
|
||||
|
||||
impl AsWebGpu for GPUErrorFilter {
|
||||
fn as_webgpu(&self) -> ErrorFilter {
|
||||
match self {
|
||||
GPUErrorFilter::Validation => ErrorFilter::Validation,
|
||||
GPUErrorFilter::Out_of_memory => ErrorFilter::OutOfMemory,
|
||||
|
|
|
@ -16,7 +16,7 @@ use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
|||
GPUIndexFormat, GPURenderBundleDescriptor, GPURenderBundleEncoderDescriptor,
|
||||
GPURenderBundleEncoderMethods,
|
||||
};
|
||||
use crate::dom::bindings::import::module::Fallible;
|
||||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::str::USVString;
|
||||
|
|
|
@ -11,6 +11,7 @@ use js::rust::HandleObject;
|
|||
use webxr_api::{ContextId as WebXRContextId, LayerId, LayerInit, Viewport};
|
||||
|
||||
use crate::canvas_context::CanvasContext as _;
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::{
|
||||
|
@ -35,15 +36,15 @@ use crate::dom::xrview::XRView;
|
|||
use crate::dom::xrviewport::XRViewport;
|
||||
use crate::script_runtime::CanGc;
|
||||
|
||||
impl<'a> From<&'a XRWebGLLayerInit> for LayerInit {
|
||||
fn from(init: &'a XRWebGLLayerInit) -> LayerInit {
|
||||
impl Convert<LayerInit> for XRWebGLLayerInit {
|
||||
fn convert(self) -> LayerInit {
|
||||
LayerInit::WebGLLayer {
|
||||
alpha: init.alpha,
|
||||
antialias: init.antialias,
|
||||
depth: init.depth,
|
||||
stencil: init.stencil,
|
||||
framebuffer_scale_factor: *init.framebufferScaleFactor as f32,
|
||||
ignore_depth_values: init.ignoreDepthValues,
|
||||
alpha: self.alpha,
|
||||
antialias: self.antialias,
|
||||
depth: self.depth,
|
||||
stencil: self.stencil,
|
||||
framebuffer_scale_factor: *self.framebufferScaleFactor as f32,
|
||||
ignore_depth_values: self.ignoreDepthValues,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +272,7 @@ impl XRWebGLLayerMethods<crate::DomTypeHolder> for XRWebGLLayer {
|
|||
// Step 9.3. "Allocate and initialize resources compatible with session’s XR device,
|
||||
// including GPU accessible memory buffers, as required to support the compositing of layer."
|
||||
let context_id = WebXRContextId::from(context.context_id());
|
||||
let layer_init = LayerInit::from(init);
|
||||
let layer_init: LayerInit = init.convert();
|
||||
let layer_id = session
|
||||
.with_session(|session| session.create_layer(context_id, layer_init))
|
||||
.map_err(|_| Error::Operation)?;
|
||||
|
|
|
@ -21,8 +21,7 @@ use crate::dom::bindings::codegen::Bindings::QueuingStrategyBinding::QueuingStra
|
|||
use crate::dom::bindings::codegen::Bindings::UnderlyingSinkBinding::UnderlyingSink;
|
||||
use crate::dom::bindings::codegen::Bindings::WritableStreamBinding::WritableStreamMethods;
|
||||
use crate::dom::bindings::conversions::ConversionResult;
|
||||
use crate::dom::bindings::error::Error;
|
||||
use crate::dom::bindings::import::module::Fallible;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::reflector::{Reflector, reflect_dom_object_with_proto};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||
use crate::dom::countqueuingstrategy::{extract_high_water_mark, extract_size_algorithm};
|
||||
|
|
|
@ -49,6 +49,7 @@ pub(crate) struct SecurityPolicyViolationReport {
|
|||
line_number: u32,
|
||||
column_number: u32,
|
||||
original_policy: String,
|
||||
#[serde(serialize_with = "serialize_disposition")]
|
||||
disposition: SecurityPolicyViolationEventDisposition,
|
||||
}
|
||||
|
||||
|
@ -170,11 +171,12 @@ impl Convert<SecurityPolicyViolationEventInit> for SecurityPolicyViolationReport
|
|||
}
|
||||
}
|
||||
|
||||
impl Serialize for SecurityPolicyViolationEventDisposition {
|
||||
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
match self {
|
||||
Self::Report => serializer.serialize_str("report"),
|
||||
Self::Enforce => serializer.serialize_str("enforce"),
|
||||
}
|
||||
fn serialize_disposition<S: serde::Serializer>(
|
||||
val: &SecurityPolicyViolationEventDisposition,
|
||||
serializer: S,
|
||||
) -> Result<S::Ok, S::Error> {
|
||||
match val {
|
||||
SecurityPolicyViolationEventDisposition::Report => serializer.serialize_str("report"),
|
||||
SecurityPolicyViolationEventDisposition::Enforce => serializer.serialize_str("enforce"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -673,10 +673,26 @@ DOMInterfaces = {
|
|||
}
|
||||
|
||||
Dictionaries = {
|
||||
'AudioNodeOptions': {
|
||||
'derives': ['Clone', 'Copy'],
|
||||
},
|
||||
|
||||
'ChannelMergerOptions': {
|
||||
'derives': ['Clone', 'Copy'],
|
||||
},
|
||||
|
||||
'ConstantSourceOptions': {
|
||||
'derives': ['Clone', 'Copy'],
|
||||
},
|
||||
|
||||
'FontFaceDescriptors': {
|
||||
'derives': ['Clone', 'MallocSizeOf']
|
||||
},
|
||||
|
||||
'GainOptions': {
|
||||
'derives': ['Clone', 'Copy'],
|
||||
},
|
||||
|
||||
'GPUCanvasConfiguration': {
|
||||
'derives': ['Clone']
|
||||
},
|
||||
|
@ -696,6 +712,18 @@ Dictionaries = {
|
|||
'HeadersInit': {
|
||||
'derives': ["Clone"],
|
||||
},
|
||||
|
||||
'IIRFilterOptions': {
|
||||
'derives': ['Clone'],
|
||||
},
|
||||
|
||||
'StereoPannerOptions': {
|
||||
'derives': ['Clone', 'Copy'],
|
||||
},
|
||||
|
||||
'XRWebGLLayerInit': {
|
||||
'derives': ['Clone', 'Copy'],
|
||||
},
|
||||
}
|
||||
|
||||
Enums = {
|
||||
|
|
|
@ -7334,6 +7334,7 @@ impl{self.generic} Clone for {self.makeClassName(self.dictionary)}{self.genericS
|
|||
"}\n"
|
||||
"\n"
|
||||
f"impl{self.generic} {selfName}{self.genericSuffix} {{\n"
|
||||
" #[allow(clippy::wrong_self_convention)]\n"
|
||||
" pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {\n"
|
||||
f"{CGIndenter(CGList(memberInserts), indentLevel=8).define()} }}\n"
|
||||
"}\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue