From 876483153313c84cfb6fa760b627ce0ca402fe96 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Sat, 14 Nov 2020 20:12:00 -0500 Subject: [PATCH] chore: cargo 1.47 changed the formatting algorithm --- .../flash/display/displayobjectcontainer.rs | 2 +- core/src/display_object.rs | 4 ++- core/src/display_object/container.rs | 26 ++++++++++++------- core/src/display_object/movie_clip.rs | 16 +++++++++--- core/src/prelude.rs | 4 +-- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/core/src/avm2/globals/flash/display/displayobjectcontainer.rs b/core/src/avm2/globals/flash/display/displayobjectcontainer.rs index 6cfe0a917..1e2f5056b 100644 --- a/core/src/avm2/globals/flash/display/displayobjectcontainer.rs +++ b/core/src/avm2/globals/flash/display/displayobjectcontainer.rs @@ -10,8 +10,8 @@ use crate::avm2::value::Value; use crate::avm2::Error; use crate::context::UpdateContext; use crate::display_object::{DisplayObject, TDisplayObject, TDisplayObjectContainer}; -use gc_arena::{GcCell, MutationContext}; use enumset::EnumSet; +use gc_arena::{GcCell, MutationContext}; use std::cmp::min; /// Implements `flash.display.DisplayObjectContainer`'s instance constructor. diff --git a/core/src/display_object.rs b/core/src/display_object.rs index 2fa34c452..f8ae31660 100644 --- a/core/src/display_object.rs +++ b/core/src/display_object.rs @@ -26,7 +26,9 @@ mod text; use crate::avm1::activation::Activation; use crate::backend::input::MouseCursor; -pub use crate::display_object::container::{DisplayObjectContainer, TDisplayObjectContainer, Lists}; +pub use crate::display_object::container::{ + DisplayObjectContainer, Lists, TDisplayObjectContainer, +}; use crate::events::{ClipEvent, ClipEventResult}; pub use bitmap::Bitmap; pub use button::Button; diff --git a/core/src/display_object/container.rs b/core/src/display_object/container.rs index 4c314cb6e..2de0d5058 100644 --- a/core/src/display_object/container.rs +++ b/core/src/display_object/container.rs @@ -5,25 +5,25 @@ use crate::display_object::button::Button; use crate::display_object::movie_clip::MovieClip; use crate::display_object::{Depth, DisplayObject, TDisplayObject}; use crate::string_utils::swf_string_eq_ignore_case; +use enumset::{EnumSet, EnumSetType}; use gc_arena::{Collect, MutationContext}; use ruffle_macros::enum_trait_object; -use enumset::{EnumSet, EnumSetType}; use std::cmp::Ordering; use std::collections::BTreeMap; use std::fmt::Debug; -use std::ops::{RangeBounds, Bound}; +use std::ops::{Bound, RangeBounds}; /// The three lists that a display object container is supposed to maintain. #[derive(EnumSetType)] pub enum Lists { /// The list that determines the order in which children are rendered. - /// + /// /// This is directly manipulated by AVM2 code. Render, /// 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, @@ -135,7 +135,7 @@ pub trait TDisplayObjectContainer<'gc>: /// /// If the child was found on any of the container's lists, this function /// will return `true`. - /// + /// /// You can control which lists a child should be removed from with the /// `from_lists` parameter. If a list is omitted from `from_lists`, then /// not only will the child remain, but the return code will also not take @@ -569,7 +569,11 @@ impl<'gc> ChildContainer<'gc> { None } - } else if let Some((_, above_child)) = self.depth_list.range((Bound::Excluded(depth), Bound::Unbounded)).next() { + } else if let Some((_, above_child)) = self + .depth_list + .range((Bound::Excluded(depth), Bound::Unbounded)) + .next() + { let position = self .render_list .iter() @@ -658,7 +662,7 @@ impl<'gc> ChildContainer<'gc> { /// /// If the child was found on any of the container's lists, this function /// will return `true`. - /// + /// /// You can control which lists a child should be removed from with the /// `from_lists` parameter. If a list is omitted from `from_lists`, then /// not only will the child remain, but the return code will also not take @@ -669,7 +673,8 @@ impl<'gc> ChildContainer<'gc> { child: DisplayObject<'gc>, from_lists: EnumSet, ) -> bool { - let removed_from_depth_list = from_lists.contains(Lists::Depth) && self.remove_child_from_depth_list(child); + let removed_from_depth_list = + from_lists.contains(Lists::Depth) && self.remove_child_from_depth_list(child); let removed_from_render_list = if from_lists.contains(Lists::Render) { let render_list_position = self @@ -689,8 +694,9 @@ impl<'gc> ChildContainer<'gc> { let removed_from_execution_list = if from_lists.contains(Lists::Execution) { let present_on_execution_list = child.prev_sibling().is_none() || child.next_sibling().is_none() - || (self.exec_list.is_some() && DisplayObject::ptr_eq(self.exec_list.unwrap(), child)); - + || (self.exec_list.is_some() + && DisplayObject::ptr_eq(self.exec_list.unwrap(), child)); + self.remove_child_from_exec_list(context, child); child.set_parent(context.gc_context, None); diff --git a/core/src/display_object/movie_clip.rs b/core/src/display_object/movie_clip.rs index 13fc61abe..90ee08965 100644 --- a/core/src/display_object/movie_clip.rs +++ b/core/src/display_object/movie_clip.rs @@ -1601,7 +1601,7 @@ impl<'gc> MovieClip<'gc> { pub fn set_focusable(self, focusable: bool, context: &mut UpdateContext<'_, 'gc, '_>) { self.0.write(context.gc_context).is_focusable = focusable; } - + /// Handle a RemoveObject tag when running a goto action. #[inline] fn goto_remove_object<'a>( @@ -1631,10 +1631,18 @@ impl<'gc> MovieClip<'gc> { if let Some(child) = read.container.get_depth(depth) { if !child.placed_by_script() { drop(read); - self.0.write(context.gc_context).container.remove_child(context, child, EnumSet::all()); + self.0.write(context.gc_context).container.remove_child( + context, + child, + EnumSet::all(), + ); } else { drop(read); - self.0.write(context.gc_context).container.remove_child(context, child, Lists::Depth.into()); + self.0.write(context.gc_context).container.remove_child( + context, + child, + Lists::Depth.into(), + ); } } } @@ -2842,7 +2850,7 @@ impl<'gc, 'a> MovieClip<'gc> { } else { reader.read_remove_object_2() }?; - + if let Some(child) = self.child_by_depth(remove_object.depth.into()) { if !child.placed_by_script() { self.remove_child(context, child, EnumSet::all()); diff --git a/core/src/prelude.rs b/core/src/prelude.rs index f340ea20c..751b5f273 100644 --- a/core/src/prelude.rs +++ b/core/src/prelude.rs @@ -1,16 +1,16 @@ pub use crate::bounding_box::BoundingBox; pub use crate::color_transform::ColorTransform; pub use crate::display_object::{ - DisplayObject, DisplayObjectContainer, TDisplayObject, TDisplayObjectContainer, Lists + DisplayObject, DisplayObjectContainer, Lists, TDisplayObject, TDisplayObjectContainer, }; pub use crate::{ impl_display_object, impl_display_object_container, impl_display_object_sansbounds, }; +pub use enumset::EnumSet; pub use log::{error, info, trace, warn}; pub use std::ops::RangeBounds; pub use swf::Matrix; pub use swf::{CharacterId, Color, Twips}; -pub use enumset::EnumSet; /// A depth for a Flash display object in AVM1. /// This is different than defined in `swf`; during execution, clips