mirror of
https://github.com/servo/servo.git
synced 2025-08-14 18:05:36 +01:00
Don't use mem::uninitialized() for making calc values
We had code relying on `nsStyleCoord::set()` being leaky (like it was before we patched up the calc bindings). Added `nsStyleCoord::null()` for this use case since it's not possible to construct directly anymore.
This commit is contained in:
parent
78baf21c54
commit
5ec2226f5b
2 changed files with 13 additions and 2 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue