style: Generate StyleTimingFunction and drop ns_timing_function.rs.

First, we generate StyleComputedTimingFunction by cbindgen from Rust, and use
it in nsTimingFunction, so we could copy it directly without handling
the different memory layout. However, we have to rewrite the
nsTimingFunction and mozilla::ComputedTimingFunction for this.

Second, the rust-bindgen seems cannot generate the correct generic members
from complex C++ templates, especially for the nested template struct,
(https://github.com/rust-lang-nursery/rust-bindgen/issues/1429)
So we have to hide StyleTimingFunction to avoid the compilation errors.

Differential Revision: https://phabricator.services.mozilla.com/D9313
This commit is contained in:
Boris Chiou 2018-10-26 18:03:35 +00:00 committed by Emilio Cobos Álvarez
parent 2bbcb5c633
commit 3723042937
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
7 changed files with 42 additions and 146 deletions

View file

@ -8,6 +8,7 @@ use cssparser::Parser;
use parser::{Parse, ParserContext};
use selectors::parser::SelectorParseErrorKind;
use style_traits::{ParseError, StyleParseErrorKind};
use values::computed::easing::TimingFunction as ComputedTimingFunction;
use values::generics::easing::{StepPosition, TimingKeyword};
use values::generics::easing::TimingFunction as GenericTimingFunction;
use values::specified::{Integer, Number};
@ -71,3 +72,26 @@ impl Parse for TimingFunction {
})
}
}
// We need this for converting the specified TimingFunction into computed TimingFunction without
// Context (for some FFIs in glue.rs). In fact, we don't really need Context to get the computed
// value of TimingFunction.
impl TimingFunction {
/// Generate the ComputedTimingFunction without Context.
pub fn to_computed_value_without_context(&self) -> ComputedTimingFunction {
match *self {
GenericTimingFunction::Steps(steps, pos) => {
GenericTimingFunction::Steps(steps.value(), pos)
},
GenericTimingFunction::CubicBezier { x1, y1, x2, y2 } => {
GenericTimingFunction::CubicBezier {
x1: x1.get(),
y1: y1.get(),
x2: x2.get(),
y2: y2.get(),
}
},
GenericTimingFunction::Keyword(keyword) => GenericTimingFunction::Keyword(keyword),
}
}
}