core: Simplify `DisplayObjectContainer::highest_depth`
The `less_than` parameter remained just `Depth::MAX` since #7199, which makes it useless. As such it can be removed.
This commit is contained in:
parent
e9697439de
commit
3645061910
|
@ -983,13 +983,10 @@ fn get_next_highest_depth<'gc>(
|
||||||
_args: &[Value<'gc>],
|
_args: &[Value<'gc>],
|
||||||
) -> Result<Value<'gc>, Error<'gc>> {
|
) -> Result<Value<'gc>, Error<'gc>> {
|
||||||
if activation.swf_version() >= 7 {
|
if activation.swf_version() >= 7 {
|
||||||
let depth = std::cmp::max(
|
let depth = movie_clip
|
||||||
movie_clip
|
.highest_depth()
|
||||||
.highest_depth(Depth::MAX)
|
.wrapping_sub(AVM_DEPTH_BIAS - 1)
|
||||||
.unwrap_or(0)
|
.max(0);
|
||||||
.wrapping_sub(AVM_DEPTH_BIAS - 1),
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
Ok(depth.into())
|
Ok(depth.into())
|
||||||
} else {
|
} else {
|
||||||
Ok(Value::Undefined)
|
Ok(Value::Undefined)
|
||||||
|
|
|
@ -174,9 +174,8 @@ pub trait TDisplayObjectContainer<'gc>:
|
||||||
/// Returns the number of children on the render list.
|
/// Returns the number of children on the render list.
|
||||||
fn num_children(self) -> usize;
|
fn num_children(self) -> usize;
|
||||||
|
|
||||||
/// Returns the highest depth on the render list, or `None` if no children
|
/// Returns the highest depth among children.
|
||||||
/// have a depth less than the provided value.
|
fn highest_depth(self) -> Depth;
|
||||||
fn highest_depth(self, less_than: Depth) -> Option<Depth>;
|
|
||||||
|
|
||||||
/// Insert a child display object into the container at a specific position
|
/// Insert a child display object into the container at a specific position
|
||||||
/// in the depth list, removing any child already at that position.
|
/// in the depth list, removing any child already at that position.
|
||||||
|
@ -349,8 +348,8 @@ macro_rules! impl_display_object_container {
|
||||||
self.0.read().$field.num_children()
|
self.0.read().$field.num_children()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn highest_depth(self, less_than: Depth) -> Option<Depth> {
|
fn highest_depth(self) -> Depth {
|
||||||
self.0.read().$field.highest_depth(less_than)
|
self.0.read().$field.highest_depth()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn replace_at_depth(
|
fn replace_at_depth(
|
||||||
|
@ -669,14 +668,9 @@ impl<'gc> ChildContainer<'gc> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the highest depth on the render list, or `None` if no children
|
/// Returns the highest depth among children.
|
||||||
/// have a depth less than the provided value.
|
pub fn highest_depth(&self) -> Depth {
|
||||||
pub fn highest_depth(&self, less_than: Depth) -> Option<Depth> {
|
self.depth_list.keys().next_back().copied().unwrap_or(0)
|
||||||
self.depth_list
|
|
||||||
.range(..less_than)
|
|
||||||
.rev()
|
|
||||||
.map(|(k, _v)| *k)
|
|
||||||
.next()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determine if the render list is empty.
|
/// Determine if the render list is empty.
|
||||||
|
|
Loading…
Reference in New Issue