mirror of
https://github.com/servo/servo.git
synced 2025-08-12 17:05:33 +01:00
Add glue for calc values
This commit is contained in:
parent
b52b78c340
commit
67bcb96cea
4 changed files with 73 additions and 0 deletions
|
@ -3,4 +3,5 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
mod ns_style_auto_array;
|
||||
mod ns_style_coord;
|
||||
mod ns_t_array;
|
||||
|
|
34
ports/geckolib/gecko_bindings/sugar/ns_style_coord.rs
Normal file
34
ports/geckolib/gecko_bindings/sugar/ns_style_coord.rs
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use structs::{nsStyleCoord_CalcValue, nsStyleCoord_Calc, nsStyleUnit, nsStyleUnion};
|
||||
use bindings::{Gecko_ResetStyleCoord, Gecko_SetStyleCoordCalcValue};
|
||||
|
||||
// Functions here are unsafe because it is possible to use the wrong nsStyleUnit
|
||||
// FIXME we should be pairing up nsStyleUnion and nsStyleUnit somehow
|
||||
// nsStyleCoord is one way to do it, but there are other structs using pairs
|
||||
// of union and unit too
|
||||
|
||||
impl nsStyleUnion {
|
||||
/// Clean up any resources used by an nsStyleUnit
|
||||
/// Currently, this only happens if the nsStyleUnit
|
||||
/// is a Calc
|
||||
pub unsafe fn reset(&mut self, unit: &mut nsStyleUnit) {
|
||||
if *unit == nsStyleUnit::eStyleUnit_Calc {
|
||||
Gecko_ResetStyleCoord(unit, self);
|
||||
}
|
||||
}
|
||||
|
||||
/// Set internal value to a calc() value
|
||||
/// reset() the union before calling this
|
||||
pub unsafe fn set_calc_value(&mut self, unit: &mut nsStyleUnit, v: nsStyleCoord_CalcValue) {
|
||||
// Calc should have been cleaned up
|
||||
assert!(*unit != nsStyleUnit::eStyleUnit_Calc);
|
||||
Gecko_SetStyleCoordCalcValue(unit, self, v);
|
||||
}
|
||||
|
||||
pub unsafe fn get_calc(&self) -> nsStyleCoord_CalcValue {
|
||||
(*(*self.mPointer.as_ref() as *const nsStyleCoord_Calc))._base
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue