mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Auto merge of #12465 - Manishearth:stylo-calc, r=heycam
Add bindings for calc() This adds bindings for dealing with refcounted calc() values. So far we can get/set them, but we don't yet have the ability to copy them around. I'll work on that next. Corresponding gecko bindings at https://github.com/servo/gecko-dev/compare/stylo...Manishearth:stylo-calc?expand=1 f? @emilio @heycam <!-- 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/12465) <!-- Reviewable:end -->
This commit is contained in:
commit
37604401d0
10 changed files with 147 additions and 23 deletions
36
components/style/gecko_conversions.rs
Normal file
36
components/style/gecko_conversions.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* 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/. */
|
||||
|
||||
//! This module contains conversion helpers between Servo and Gecko types
|
||||
//! Ideally, it would be in geckolib itself, but coherence
|
||||
//! forces us to keep the traits and implementations here
|
||||
|
||||
use app_units::Au;
|
||||
use gecko_bindings::structs::nsStyleCoord_CalcValue;
|
||||
use values::computed::CalcLengthOrPercentage;
|
||||
|
||||
impl From<CalcLengthOrPercentage> for nsStyleCoord_CalcValue {
|
||||
fn from(other: CalcLengthOrPercentage) -> nsStyleCoord_CalcValue {
|
||||
let has_percentage = other.percentage.is_some();
|
||||
nsStyleCoord_CalcValue {
|
||||
mLength: other.length.map_or(0, |l| l.0),
|
||||
mPercent: other.percentage.unwrap_or(0.0),
|
||||
mHasPercent: has_percentage,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<nsStyleCoord_CalcValue> for CalcLengthOrPercentage {
|
||||
fn from(other: nsStyleCoord_CalcValue) -> CalcLengthOrPercentage {
|
||||
let percentage = if other.mHasPercent {
|
||||
Some(other.mPercent)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
CalcLengthOrPercentage {
|
||||
length: Some(Au(other.mLength)),
|
||||
percentage: percentage,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -81,6 +81,8 @@ pub mod dom;
|
|||
pub mod element_state;
|
||||
pub mod error_reporting;
|
||||
pub mod font_face;
|
||||
#[cfg(feature = "gecko")]
|
||||
pub mod gecko_conversions;
|
||||
pub mod keyframes;
|
||||
pub mod logical_geometry;
|
||||
pub mod matching;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue