diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 38896677800..f01988ce2ba 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -35,7 +35,7 @@ use logical_geometry::WritingMode; use properties::CascadePropertyFn; use properties::longhands; use std::fmt::{self, Debug}; -use std::mem::{transmute, uninitialized, zeroed}; +use std::mem::{transmute, zeroed}; use std::ptr; use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering}; use std::sync::Arc; @@ -1133,7 +1133,7 @@ fn static_assert() { } } - let mut coord: nsStyleCoord = unsafe { uninitialized() }; + 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. diff --git a/ports/geckolib/gecko_bindings/sugar/ns_style_coord.rs b/ports/geckolib/gecko_bindings/sugar/ns_style_coord.rs index 74d20ff3a58..881da7e0e39 100644 --- a/ports/geckolib/gecko_bindings/sugar/ns_style_coord.rs +++ b/ports/geckolib/gecko_bindings/sugar/ns_style_coord.rs @@ -3,9 +3,20 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use bindings::{Gecko_ResetStyleCoord, Gecko_SetStyleCoordCalcValue, Gecko_AddRefCalcArbitraryThread}; +use std::mem; use structs::{nsStyleCoord_Calc, nsStyleUnit, nsStyleUnion, nsStyleCoord, nsStyleSides, nsStyleCorners}; use structs::{nsStyleCoord_CalcValue, nscoord}; +impl nsStyleCoord { + #[inline] + pub fn null() -> Self { + // Can't construct directly because it has private fields + let mut coord: Self = unsafe { mem::zeroed() }; + coord.leaky_set_null(); + coord + } +} + impl CoordData for nsStyleCoord { #[inline] fn unit(&self) -> nsStyleUnit {