diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-02-18 02:29:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-18 02:29:44 -0800 |
commit | eb6082fd7877fd3a14d14369f107a8b840f128d5 (patch) | |
tree | 89e118b0f9a2cdac85c5e56518699786c5fb7b89 | |
parent | 47ebeaa95cec1c975c3b0b807fe9ddf188452492 (diff) | |
parent | 5531e38c22475c5bd53584effff0f88eee1b5930 (diff) | |
download | servo-eb6082fd7877fd3a14d14369f107a8b840f128d5.tar.gz servo-eb6082fd7877fd3a14d14369f107a8b840f128d5.zip |
Auto merge of #15630 - heycam:calc, r=Manishearth
stylo: Don't leak nsStyleCoord::Calc objects when setting gradients.
Fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1340509. My initial inclination was to add a Drop impl to nsStyleCoord but I'm not sure if that's a good idea with the FFI types.
r? @Manishearth
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15630)
<!-- Reviewable:end -->
-rw-r--r-- | components/style/gecko/conversions.rs | 4 | ||||
-rw-r--r-- | components/style/gecko_bindings/sugar/ns_style_coord.rs | 9 |
2 files changed, 11 insertions, 2 deletions
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 @@ -265,6 +265,15 @@ pub trait CoordDataMut : CoordData { } #[inline] + /// Moves the unit and value from another `CoordData` type. + fn move_from<T: CoordData>(&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). unsafe fn copy_from_unchecked<T: CoordData>(&mut self, other: &T) { |