diff --git a/components/style/gecko/conversions.rs b/components/style/gecko/conversions.rs index 5f5ee296d3a..7262a2f7f85 100644 --- a/components/style/gecko/conversions.rs +++ b/components/style/gecko/conversions.rs @@ -297,10 +297,10 @@ impl nsStyleImage { }, }; - let mut coord: nsStyleCoord = nsStyleCoord::null(); for (index, stop) in gradient.stops.iter().enumerate() { // NB: stops are guaranteed to be none in the gecko side by // default. + let mut coord: nsStyleCoord = nsStyleCoord::null(); coord.set(stop.position); let color = match stop.color { CSSColor::CurrentColor => { @@ -322,7 +322,7 @@ impl nsStyleImage { stop.mColor = color; stop.mIsInterpolationHint = false; - stop.mLocation.copy_from(&coord); + stop.mLocation.move_from(coord); } unsafe { diff --git a/components/style/gecko_bindings/sugar/ns_style_coord.rs b/components/style/gecko_bindings/sugar/ns_style_coord.rs index 84ea7d68456..be6a2a6f80b 100644 --- a/components/style/gecko_bindings/sugar/ns_style_coord.rs +++ b/components/style/gecko_bindings/sugar/ns_style_coord.rs @@ -264,6 +264,15 @@ pub trait CoordDataMut : CoordData { } } + #[inline] + /// Moves the unit and value from another `CoordData` type. + fn move_from(&mut self, other: T) { + unsafe { + self.reset(); + self.copy_from_unchecked(&other); + } + } + #[inline] /// Copies the unit and value from another `CoordData` type without checking /// the type of the value (so refcounted values like calc may leak).