mirror of
https://github.com/servo/servo.git
synced 2025-06-23 16:44:33 +01:00
Bug 1328787 - Part 9: Set Keyframe.mPropertyValues for the case where keyframe is specified. r=heycam
MozReview-Commit-ID: Ayt7IsYShl4
This commit is contained in:
parent
e20a3ad9b5
commit
aa6372d99d
4 changed files with 75 additions and 20 deletions
|
@ -665,3 +665,20 @@
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
<%def name="alias_to_nscsspropertyid(alias)">
|
||||||
|
<%
|
||||||
|
if alias == "word-wrap":
|
||||||
|
return "nsCSSPropertyID_eCSSPropertyAlias_WordWrap"
|
||||||
|
return "nsCSSPropertyID::eCSSPropertyAlias_%s" % to_camel_case(alias)
|
||||||
|
%>
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
<%def name="to_nscsspropertyid(ident)">
|
||||||
|
<%
|
||||||
|
if ident == "float":
|
||||||
|
ident = "float_"
|
||||||
|
return "nsCSSPropertyID::eCSSProperty_%s" % ident
|
||||||
|
%>
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,12 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
<%namespace name="helpers" file="/helpers.mako.rs" />
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use cssparser::{Color as CSSParserColor, Parser, RGBA};
|
use cssparser::{Color as CSSParserColor, Parser, RGBA};
|
||||||
use euclid::{Point2D, Size2D};
|
use euclid::{Point2D, Size2D};
|
||||||
|
#[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSPropertyID;
|
||||||
use properties::{DeclaredValue, PropertyDeclaration};
|
use properties::{DeclaredValue, PropertyDeclaration};
|
||||||
use properties::longhands;
|
use properties::longhands;
|
||||||
use properties::longhands::background_position_x::computed_value::T as BackgroundPositionX;
|
use properties::longhands::background_position_x::computed_value::T as BackgroundPositionX;
|
||||||
|
@ -101,6 +104,23 @@ impl ToCss for TransitionProperty {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert to nsCSSPropertyID.
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
#[allow(non_upper_case_globals)]
|
||||||
|
impl From<TransitionProperty> for nsCSSPropertyID {
|
||||||
|
fn from(transition_property: TransitionProperty) -> nsCSSPropertyID {
|
||||||
|
match transition_property {
|
||||||
|
% for prop in data.longhands:
|
||||||
|
% if prop.animatable:
|
||||||
|
TransitionProperty::${prop.camel_case}
|
||||||
|
=> ${helpers.to_nscsspropertyid(prop.ident)},
|
||||||
|
% endif
|
||||||
|
% endfor
|
||||||
|
TransitionProperty::All => nsCSSPropertyID::eCSSPropertyExtra_all_properties,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// An animated property interpolation between two computed values for that
|
/// An animated property interpolation between two computed values for that
|
||||||
/// property.
|
/// property.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
|
|
|
@ -737,16 +737,6 @@ enum StaticId {
|
||||||
Shorthand(ShorthandId),
|
Shorthand(ShorthandId),
|
||||||
}
|
}
|
||||||
include!(concat!(env!("OUT_DIR"), "/static_ids.rs"));
|
include!(concat!(env!("OUT_DIR"), "/static_ids.rs"));
|
||||||
<%
|
|
||||||
def alias_to_nscsspropertyid(alias):
|
|
||||||
if alias == "word-wrap":
|
|
||||||
return "nsCSSPropertyID_eCSSPropertyAlias_WordWrap"
|
|
||||||
return "nsCSSPropertyID::eCSSPropertyAlias_%s" % to_camel_case(alias)
|
|
||||||
def to_nscsspropertyid(ident):
|
|
||||||
if ident == "float":
|
|
||||||
ident = "float_"
|
|
||||||
return "nsCSSPropertyID::eCSSProperty_%s" % ident
|
|
||||||
%>
|
|
||||||
impl PropertyId {
|
impl PropertyId {
|
||||||
/// Returns a given property from the string `s`.
|
/// Returns a given property from the string `s`.
|
||||||
///
|
///
|
||||||
|
@ -771,21 +761,21 @@ impl PropertyId {
|
||||||
use gecko_bindings::structs::*;
|
use gecko_bindings::structs::*;
|
||||||
match id {
|
match id {
|
||||||
% for property in data.longhands:
|
% for property in data.longhands:
|
||||||
${to_nscsspropertyid(property.ident)} => {
|
${helpers.to_nscsspropertyid(property.ident)} => {
|
||||||
Ok(PropertyId::Longhand(LonghandId::${property.camel_case}))
|
Ok(PropertyId::Longhand(LonghandId::${property.camel_case}))
|
||||||
}
|
}
|
||||||
% for alias in property.alias:
|
% for alias in property.alias:
|
||||||
${alias_to_nscsspropertyid(alias)} => {
|
${helpers.alias_to_nscsspropertyid(alias)} => {
|
||||||
Ok(PropertyId::Longhand(LonghandId::${property.camel_case}))
|
Ok(PropertyId::Longhand(LonghandId::${property.camel_case}))
|
||||||
}
|
}
|
||||||
% endfor
|
% endfor
|
||||||
% endfor
|
% endfor
|
||||||
% for property in data.shorthands:
|
% for property in data.shorthands:
|
||||||
${to_nscsspropertyid(property.ident)} => {
|
${helpers.to_nscsspropertyid(property.ident)} => {
|
||||||
Ok(PropertyId::Shorthand(ShorthandId::${property.camel_case}))
|
Ok(PropertyId::Shorthand(ShorthandId::${property.camel_case}))
|
||||||
}
|
}
|
||||||
% for alias in property.alias:
|
% for alias in property.alias:
|
||||||
${alias_to_nscsspropertyid(alias)} => {
|
${helpers.alias_to_nscsspropertyid(alias)} => {
|
||||||
Ok(PropertyId::Shorthand(ShorthandId::${property.camel_case}))
|
Ok(PropertyId::Shorthand(ShorthandId::${property.camel_case}))
|
||||||
}
|
}
|
||||||
% endfor
|
% endfor
|
||||||
|
@ -804,14 +794,14 @@ impl PropertyId {
|
||||||
PropertyId::Longhand(id) => match id {
|
PropertyId::Longhand(id) => match id {
|
||||||
% for property in data.longhands:
|
% for property in data.longhands:
|
||||||
LonghandId::${property.camel_case} => {
|
LonghandId::${property.camel_case} => {
|
||||||
Ok(${to_nscsspropertyid(property.ident)})
|
Ok(${helpers.to_nscsspropertyid(property.ident)})
|
||||||
}
|
}
|
||||||
% endfor
|
% endfor
|
||||||
},
|
},
|
||||||
PropertyId::Shorthand(id) => match id {
|
PropertyId::Shorthand(id) => match id {
|
||||||
% for property in data.shorthands:
|
% for property in data.shorthands:
|
||||||
ShorthandId::${property.camel_case} => {
|
ShorthandId::${property.camel_case} => {
|
||||||
Ok(${to_nscsspropertyid(property.ident)})
|
Ok(${helpers.to_nscsspropertyid(property.ident)})
|
||||||
}
|
}
|
||||||
% endfor
|
% endfor
|
||||||
},
|
},
|
||||||
|
@ -921,7 +911,7 @@ impl ToCss for PropertyDeclaration {
|
||||||
pref_ident = "float_"
|
pref_ident = "float_"
|
||||||
%>
|
%>
|
||||||
if structs::root::mozilla::SERVO_PREF_ENABLED_${pref_ident} {
|
if structs::root::mozilla::SERVO_PREF_ENABLED_${pref_ident} {
|
||||||
let id = structs::${to_nscsspropertyid(property.ident)};
|
let id = structs::${helpers.to_nscsspropertyid(property.ident)};
|
||||||
let enabled = unsafe { bindings::Gecko_PropertyId_IsPrefEnabled(id) };
|
let enabled = unsafe { bindings::Gecko_PropertyId_IsPrefEnabled(id) };
|
||||||
if !enabled {
|
if !enabled {
|
||||||
return PropertyDeclarationParseResult::ExperimentalProperty
|
return PropertyDeclarationParseResult::ExperimentalProperty
|
||||||
|
|
|
@ -58,12 +58,13 @@ use style::gecko_bindings::structs::nsresult;
|
||||||
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, HasBoxFFI};
|
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, HasBoxFFI};
|
||||||
use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
|
use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
|
||||||
use style::gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
|
use style::gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
|
||||||
|
use style::keyframes::KeyframesStepValue;
|
||||||
use style::parallel;
|
use style::parallel;
|
||||||
use style::parser::{ParserContext, ParserContextExtraData};
|
use style::parser::{ParserContext, ParserContextExtraData};
|
||||||
use style::properties::{CascadeFlags, ComputedValues, Importance, PropertyDeclaration};
|
use style::properties::{CascadeFlags, ComputedValues, Importance, PropertyDeclaration};
|
||||||
use style::properties::{PropertyDeclarationParseResult, PropertyDeclarationBlock, PropertyId};
|
use style::properties::{PropertyDeclarationParseResult, PropertyDeclarationBlock, PropertyId};
|
||||||
use style::properties::{apply_declarations, parse_one_declaration};
|
use style::properties::{apply_declarations, parse_one_declaration};
|
||||||
use style::properties::animated_properties::{AnimationValue, Interpolate};
|
use style::properties::animated_properties::{AnimationValue, Interpolate, TransitionProperty};
|
||||||
use style::restyle_hints::RestyleHint;
|
use style::restyle_hints::RestyleHint;
|
||||||
use style::selector_parser::PseudoElementCascadeType;
|
use style::selector_parser::PseudoElementCascadeType;
|
||||||
use style::sequential;
|
use style::sequential;
|
||||||
|
@ -1162,12 +1163,39 @@ pub extern "C" fn Servo_StyleSet_FillKeyframesForName(raw_data: RawServoStyleSet
|
||||||
*style_timing_function
|
*style_timing_function
|
||||||
};
|
};
|
||||||
|
|
||||||
let _keyframe = unsafe {
|
let keyframe = unsafe {
|
||||||
Gecko_AnimationAppendKeyframe(keyframes,
|
Gecko_AnimationAppendKeyframe(keyframes,
|
||||||
step.start_percentage.0 as f32,
|
step.start_percentage.0 as f32,
|
||||||
&timing_function)
|
&timing_function)
|
||||||
};
|
};
|
||||||
// Set each PropertyValuePair.
|
|
||||||
|
match step.value {
|
||||||
|
KeyframesStepValue::ComputedValues => {
|
||||||
|
unimplemented!();
|
||||||
|
},
|
||||||
|
KeyframesStepValue::Declarations { ref block } => {
|
||||||
|
let guard = block.read();
|
||||||
|
// Filter out non-animatable properties.
|
||||||
|
let animatable =
|
||||||
|
guard.declarations
|
||||||
|
.iter()
|
||||||
|
.filter(|&&(ref declaration, _)| {
|
||||||
|
declaration.is_animatable()
|
||||||
|
});
|
||||||
|
for (index, &(ref declaration, _)) in animatable.enumerate() {
|
||||||
|
unsafe {
|
||||||
|
(*keyframe).mPropertyValues.set_len((index + 1) as u32);
|
||||||
|
(*keyframe).mPropertyValues[index].mProperty =
|
||||||
|
TransitionProperty::from_declaration(declaration).unwrap().into();
|
||||||
|
(*keyframe).mPropertyValues[index].mServoDeclarationBlock.set_arc_leaky(
|
||||||
|
Arc::new(RwLock::new(
|
||||||
|
PropertyDeclarationBlock { declarations: vec![ (declaration.clone(),
|
||||||
|
Importance::Normal) ],
|
||||||
|
important_count: 0 })));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue