core: Simplify core::do::container::Lists bitflags into boolean enum
Callsites only ever used two values, as children in the display list are always in the render list.
This commit is contained in:
parent
58e39623a5
commit
53010544db
|
@ -1204,7 +1204,7 @@ pub fn remove_display_object<'gc>(
|
|||
if depth >= AVM_DEPTH_BIAS && depth < AVM_MAX_REMOVE_DEPTH && !this.removed() {
|
||||
// Need a parent to remove from.
|
||||
if let Some(mut parent) = this.avm1_parent().and_then(|o| o.as_movie_clip()) {
|
||||
parent.remove_child(&mut activation.context, this, Lists::all());
|
||||
parent.remove_child(&mut activation.context, this, Lists::Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ fn remove_child_from_displaylist<'gc>(
|
|||
) {
|
||||
if let Some(parent) = child.parent() {
|
||||
if let Some(mut ctr) = parent.as_container() {
|
||||
ctr.remove_child(context, child, Lists::all());
|
||||
ctr.remove_child(context, child, Lists::Render);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ pub fn remove_child_at<'gc>(
|
|||
|
||||
let child = ctr.child_by_index(target_child as usize).unwrap();
|
||||
|
||||
ctr.remove_child(&mut activation.context, child, Lists::all());
|
||||
ctr.remove_child(&mut activation.context, child, Lists::Render);
|
||||
|
||||
return Ok(child.object2());
|
||||
}
|
||||
|
|
|
@ -1621,7 +1621,7 @@ bitflags! {
|
|||
const PLACED_BY_SCRIPT = 1 << 4;
|
||||
|
||||
/// Whether this object has been instantiated by a SWF tag.
|
||||
/// When this flag is set, changes from SWF `RemoveObject` tags are ignored.
|
||||
/// When this flag is set, attempts to change the object's name from AVM2 throw an exception.
|
||||
const INSTANTIATED_BY_TIMELINE = 1 << 5;
|
||||
|
||||
/// Whether this object is a "root", the top-most display object of a loaded SWF or Bitmap.
|
||||
|
|
|
@ -180,7 +180,7 @@ impl<'gc> Avm1Button<'gc> {
|
|||
// Kill children that no longer exist in this state.
|
||||
for depth in removed_depths {
|
||||
if let Some(child) = self.child_by_depth(depth) {
|
||||
self.remove_child(context, child, Lists::all());
|
||||
self.remove_child(context, child, Lists::Render);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@ impl<'gc> Avm2Button<'gc> {
|
|||
|
||||
if let Some(child) = child {
|
||||
if let Some(mut parent) = child.parent().and_then(|parent| parent.as_container()) {
|
||||
parent.remove_child(context, child, Lists::all());
|
||||
parent.remove_child(context, child, Lists::Render);
|
||||
}
|
||||
|
||||
if is_cur_state {
|
||||
|
|
|
@ -8,7 +8,6 @@ use crate::display_object::movie_clip::MovieClip;
|
|||
use crate::display_object::stage::Stage;
|
||||
use crate::display_object::{Depth, DisplayObject, TDisplayObject};
|
||||
use crate::string::WStr;
|
||||
use bitflags::bitflags;
|
||||
use gc_arena::{Collect, MutationContext};
|
||||
use ruffle_macros::enum_trait_object;
|
||||
use ruffle_render::commands::CommandHandler;
|
||||
|
@ -121,21 +120,22 @@ pub fn dispatch_added_event<'gc>(
|
|||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
/// The three lists that a display object container is supposed to maintain.
|
||||
pub struct Lists: u8 {
|
||||
/// The list that determines the order in which children are rendered.
|
||||
///
|
||||
/// This is directly manipulated by AVM2 code.
|
||||
const RENDER = 1 << 0;
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum Lists {
|
||||
/// The list that determines the identity of children according to the
|
||||
/// timeline and AVM1 code.
|
||||
///
|
||||
/// Manipulations of the depth list are generally propagated to the render
|
||||
/// list, except in cases where children have been reordered by AVM2.
|
||||
Depth,
|
||||
|
||||
/// The list that determines the identity of children according to the
|
||||
/// timeline and AVM1 code.
|
||||
///
|
||||
/// Manipulations of the depth list are generally propagated to the render
|
||||
/// list, except in cases where children have been reordered by AVM2.
|
||||
const DEPTH = 1 << 1;
|
||||
}
|
||||
/// The render list determines the order in which children are rendered.
|
||||
///
|
||||
/// Removing a child from the render list automatically removes it from the depth
|
||||
/// list.
|
||||
///
|
||||
/// It is directly manipulated by AVM2 code.
|
||||
Render,
|
||||
}
|
||||
|
||||
#[enum_trait_object(
|
||||
|
@ -278,7 +278,7 @@ pub trait TDisplayObjectContainer<'gc>:
|
|||
let parent_changed = if let Some(old_parent) = child.parent() {
|
||||
if !DisplayObject::ptr_eq(old_parent, this) {
|
||||
if let Some(mut old_parent) = old_parent.as_container() {
|
||||
old_parent.remove_child(context, child, Lists::all());
|
||||
old_parent.remove_child(context, child, Lists::Render);
|
||||
}
|
||||
|
||||
true
|
||||
|
@ -340,10 +340,11 @@ pub trait TDisplayObjectContainer<'gc>:
|
|||
|
||||
let mut write = self.raw_container_mut(context.gc_context);
|
||||
|
||||
let removed_from_depth_list =
|
||||
from_lists.contains(Lists::DEPTH) && write.remove_child_from_depth_list(child);
|
||||
let removed_from_render_list =
|
||||
from_lists.contains(Lists::RENDER) && write.remove_child_from_render_list(child);
|
||||
let removed_from_depth_list = write.remove_child_from_depth_list(child);
|
||||
let removed_from_render_list = match from_lists {
|
||||
Lists::Render => write.remove_child_from_render_list(child),
|
||||
Lists::Depth => false,
|
||||
};
|
||||
|
||||
drop(write);
|
||||
|
||||
|
|
|
@ -1742,9 +1742,9 @@ impl<'gc> MovieClip<'gc> {
|
|||
.collect();
|
||||
for child in children {
|
||||
if !child.placed_by_script() {
|
||||
self.remove_child(context, child, Lists::all());
|
||||
self.remove_child(context, child, Lists::Render);
|
||||
} else {
|
||||
self.remove_child(context, child, Lists::DEPTH);
|
||||
self.remove_child(context, child, Lists::Depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2107,9 +2107,9 @@ impl<'gc> MovieClip<'gc> {
|
|||
let child = self.child_by_depth(depth);
|
||||
if let Some(child) = child {
|
||||
if !child.placed_by_script() {
|
||||
self.remove_child(context, child, Lists::all());
|
||||
self.remove_child(context, child, Lists::Render);
|
||||
} else {
|
||||
self.remove_child(context, child, Lists::DEPTH);
|
||||
self.remove_child(context, child, Lists::Depth);
|
||||
}
|
||||
|
||||
removed_frame_scripts.push(child);
|
||||
|
@ -3700,9 +3700,9 @@ impl<'gc, 'a> MovieClip<'gc> {
|
|||
|
||||
if let Some(child) = self.child_by_depth(remove_object.depth.into()) {
|
||||
if !child.placed_by_script() {
|
||||
self.remove_child(context, child, Lists::all());
|
||||
self.remove_child(context, child, Lists::Render);
|
||||
} else {
|
||||
self.remove_child(context, child, Lists::DEPTH);
|
||||
self.remove_child(context, child, Lists::Depth);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue