Fix inheritance of DOM structs (#1)

The incorrect inheritance ends up overlapping EventTarget fields with
other fields causing some DOMRefCells to start out broken and panic.
This commit is contained in:
Manish Goregaokar 2018-06-29 00:09:29 -07:00 committed by Fernando Jiménez Moreno
parent 07c0450e29
commit 885addfaae
2 changed files with 6 additions and 6 deletions

View file

@ -6,9 +6,9 @@ use dom::baseaudiocontext::BaseAudioContext;
use dom::bindings::codegen::Bindings::AudioNodeBinding::{AudioNodeMethods, AudioNodeOptions};
use dom::bindings::codegen::Bindings::AudioNodeBinding::{ChannelCountMode, ChannelInterpretation};
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::reflector::Reflector;
use dom::bindings::root::DomRoot;
use dom::audioparam::AudioParam;
use dom::eventtarget::EventTarget;
use dom_struct::dom_struct;
use servo_media::audio::graph::NodeId;
use servo_media::audio::node::{AudioNodeMessage, AudioNodeType};
@ -21,7 +21,7 @@ pub static MAX_CHANNEL_COUNT: u32 = 32;
#[dom_struct]
pub struct AudioNode {
reflector_: Reflector,
eventtarget: EventTarget,
#[ignore_malloc_size_of = "servo_media"]
node_id: NodeId,
context: DomRoot<BaseAudioContext>,
@ -43,7 +43,7 @@ impl AudioNode {
context.audio_context_impl().create_node(node_type)
});
AudioNode {
reflector_: Reflector::new(),
eventtarget: EventTarget::new_inherited(),
node_id,
context: DomRoot::from_ref(context),
number_of_inputs,

View file

@ -13,7 +13,7 @@ use dom::bindings::error::{Error, ErrorResult};
use dom::bindings::inheritance::Castable;
use dom::bindings::num::Finite;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{DomObject, Reflector};
use dom::bindings::reflector::DomObject;
use dom::bindings::root::DomRoot;
use dom::eventtarget::EventTarget;
use dom::globalscope::GlobalScope;
@ -38,7 +38,7 @@ pub enum BaseAudioContextOptions {
#[dom_struct]
pub struct BaseAudioContext {
reflector_: Reflector,
eventtarget: EventTarget,
#[ignore_malloc_size_of = "servo_media"]
audio_context_impl: AudioContext,
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-destination
@ -74,7 +74,7 @@ impl BaseAudioContext {
let sample_rate = options.sample_rate;
let mut context = BaseAudioContext {
reflector_: Reflector::new(),
eventtarget: EventTarget::new_inherited(),
audio_context_impl: ServoMedia::get().unwrap().create_audio_context(options.into()),
destination: None,
in_flight_resume_promises_queue: Default::default(),