Auto merge of #17228 - hiikezoe:shorthand-for-SMIL, r=birtles

Shorthand support for SMIL

<!-- Please describe your changes on the following line: -->
This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1358966

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [X] These changes do not require tests because it's for stylo

<!-- 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/17228)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-08 16:23:56 -07:00 committed by GitHub
commit 094c2c73ec
7 changed files with 4295 additions and 4245 deletions

View file

@ -19,8 +19,8 @@ use gecko_bindings::structs::RawGeckoKeyframeList;
use gecko_bindings::structs::RawGeckoComputedKeyframeValuesList;
use gecko_bindings::structs::RawGeckoFontFaceRuleList;
use gecko_bindings::structs::RawGeckoNode;
use gecko_bindings::structs::RawGeckoAnimationValueList;
use gecko_bindings::structs::RawServoAnimationValue;
use gecko_bindings::structs::RawGeckoServoAnimationValueList;
use gecko_bindings::structs::RawServoDeclarationBlock;
use gecko_bindings::structs::RawServoStyleRule;
use gecko_bindings::structs::RawGeckoPresContext;
@ -276,10 +276,6 @@ pub type RawGeckoAnimationPropertySegmentBorrowed<'a> = &'a RawGeckoAnimationPro
pub type RawGeckoAnimationPropertySegmentBorrowedOrNull<'a> = Option<&'a RawGeckoAnimationPropertySegment>;
pub type RawGeckoAnimationPropertySegmentBorrowedMut<'a> = &'a mut RawGeckoAnimationPropertySegment;
pub type RawGeckoAnimationPropertySegmentBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoAnimationPropertySegment>;
pub type RawGeckoAnimationValueListBorrowed<'a> = &'a RawGeckoAnimationValueList;
pub type RawGeckoAnimationValueListBorrowedOrNull<'a> = Option<&'a RawGeckoAnimationValueList>;
pub type RawGeckoAnimationValueListBorrowedMut<'a> = &'a mut RawGeckoAnimationValueList;
pub type RawGeckoAnimationValueListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoAnimationValueList>;
pub type RawGeckoComputedTimingBorrowed<'a> = &'a RawGeckoComputedTiming;
pub type RawGeckoComputedTimingBorrowedOrNull<'a> = Option<&'a RawGeckoComputedTiming>;
pub type RawGeckoComputedTimingBorrowedMut<'a> = &'a mut RawGeckoComputedTiming;
@ -304,6 +300,10 @@ pub type RawGeckoServoStyleRuleListBorrowed<'a> = &'a RawGeckoServoStyleRuleList
pub type RawGeckoServoStyleRuleListBorrowedOrNull<'a> = Option<&'a RawGeckoServoStyleRuleList>;
pub type RawGeckoServoStyleRuleListBorrowedMut<'a> = &'a mut RawGeckoServoStyleRuleList;
pub type RawGeckoServoStyleRuleListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoServoStyleRuleList>;
pub type RawGeckoServoAnimationValueListBorrowed<'a> = &'a RawGeckoServoAnimationValueList;
pub type RawGeckoServoAnimationValueListBorrowedOrNull<'a> = Option<&'a RawGeckoServoAnimationValueList>;
pub type RawGeckoServoAnimationValueListBorrowedMut<'a> = &'a mut RawGeckoServoAnimationValueList;
pub type RawGeckoServoAnimationValueListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoServoAnimationValueList>;
pub type ServoCssRulesStrong = ::gecko_bindings::sugar::ownership::Strong<ServoCssRules>;
pub type ServoCssRulesBorrowed<'a> = &'a ServoCssRules;
pub type ServoCssRulesBorrowedOrNull<'a> = Option<&'a ServoCssRules>;
@ -759,8 +759,6 @@ extern "C" {
ServoComputedValuesBorrowedOrNull,
aComputedValues:
ServoComputedValuesBorrowedOrNull,
aParentComputedValues:
ServoComputedValuesBorrowedOrNull,
aTasks: UpdateAnimationsTasks);
}
extern "C" {
@ -2254,6 +2252,15 @@ extern "C" {
progress: f64,
result: *mut RawGeckoGfxMatrix4x4);
}
extern "C" {
pub fn Servo_GetAnimationValues(declarations:
RawServoDeclarationBlockBorrowed,
element: RawGeckoElementBorrowed,
style: ServoComputedValuesBorrowed,
style_set: RawServoStyleSetBorrowed,
animation_values:
RawGeckoServoAnimationValueListBorrowedMut);
}
extern "C" {
pub fn Servo_AnimationValues_Interpolate(from:
RawServoAnimationValueBorrowed,
@ -2298,6 +2305,13 @@ extern "C" {
property: nsCSSPropertyID,
buffer: *mut nsAString);
}
extern "C" {
pub fn Servo_Shorthand_AnimationValues_Serialize(shorthand_property:
nsCSSPropertyID,
values:
RawGeckoServoAnimationValueListBorrowed,
buffer: *mut nsAString);
}
extern "C" {
pub fn Servo_AnimationValue_GetOpacity(value:
RawServoAnimationValueBorrowed)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -874,20 +874,12 @@ impl<'le> TElement for GeckoElement<'le> {
computed_data.as_ref().map(|d| d.styles().primary.values());
let computed_values_opt =
computed_values.map(|v| *HasArcFFI::arc_as_borrowed(v));
let parent_element = self.parent_element();
let parent_data =
parent_element.as_ref().and_then(|e| e.borrow_data());
let parent_values =
parent_data.as_ref().map(|d| d.styles().primary.values());
let parent_values_opt =
parent_values.map(|v| *HasArcFFI::arc_as_borrowed(v));
let before_change_values =
before_change_style.as_ref().map(|v| *HasArcFFI::arc_as_borrowed(v));
unsafe {
Gecko_UpdateAnimations(self.0,
before_change_values,
computed_values_opt,
parent_values_opt,
tasks.bits());
}
}

View file

@ -11,6 +11,7 @@ use cssparser::{DeclarationListParser, parse_important};
use cssparser::{Parser, AtRuleParser, DeclarationParser, Delimiter};
use error_reporting::ParseErrorReporter;
use parser::{PARSING_MODE_DEFAULT, ParsingMode, ParserContext, log_css_error};
use properties::animated_properties::AnimationValue;
use shared_lock::Locked;
use std::fmt;
use std::slice::Iter;
@ -18,6 +19,7 @@ use style_traits::ToCss;
use stylesheets::{CssRuleType, Origin, UrlExtraData};
use stylesheets::{MallocSizeOf, MallocSizeOfFn};
use super::*;
use values::computed::Context;
#[cfg(feature = "gecko")] use properties::animated_properties::AnimationValueMap;
/// The animation rules.
@ -102,6 +104,55 @@ impl<'a> Iterator for PropertyDeclarationIterator<'a> {
}
}
/// Iterator for AnimationValue to be generated from PropertyDeclarationBlock.
pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> {
iter: Iter<'a, (PropertyDeclaration, Importance)>,
context: &'cx mut Context<'cx_a>,
default_values: &'a Arc<ComputedValues>,
}
impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
fn new(declarations: &'a PropertyDeclarationBlock,
context: &'cx mut Context<'cx_a>,
default_values: &'a Arc<ComputedValues>) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
AnimationValueIterator {
iter: declarations.declarations().iter(),
context: context,
default_values: default_values,
}
}
}
impl<'a, 'cx, 'cx_a:'cx> Iterator for AnimationValueIterator<'a, 'cx, 'cx_a> {
type Item = (TransitionProperty, AnimationValue);
#[inline]
fn next(&mut self) -> Option<Self::Item> {
use properties::Importance;
loop {
let next = self.iter.next();
match next {
Some(&(ref decl, importance)) => {
if importance == Importance::Normal {
let property = TransitionProperty::from_declaration(decl);
let animation = AnimationValue::from_declaration(decl, &mut self.context,
self.default_values);
debug_assert!(property.is_none() == animation.is_none(),
"The failure condition of TransitionProperty::from_declaration \
and AnimationValue::from_declaration should be the same");
// Skip the property if either ::from_declaration fails.
match (property, animation) {
(Some(p), Some(a)) => return Some((p, a)),
(_, _) => {},
}
}
},
None => return None,
}
}
}
}
impl fmt::Debug for PropertyDeclarationBlock {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.declarations.fmt(f)
@ -148,6 +199,14 @@ impl PropertyDeclarationBlock {
}
}
/// Return an iterator of (TransitionProperty, AnimationValue).
pub fn to_animation_value_iter<'a, 'cx, 'cx_a:'cx>(&'a self,
context: &'cx mut Context<'cx_a>,
default_values: &'a Arc<ComputedValues>)
-> AnimationValueIterator<'a, 'cx, 'cx_a> {
AnimationValueIterator::new(self, context, default_values)
}
/// Returns whether this block contains any declaration with `!important`.
///
/// This is based on the `important_count` counter,

View file

@ -199,6 +199,16 @@ pub fn nscsspropertyid_is_animatable(property: nsCSSPropertyID) -> bool {
${helpers.to_nscsspropertyid(prop.ident)} => true,
% endif
% endfor
% for prop in data.shorthands_except_all():
<%
animatable = "false"
for sub in prop.sub_properties:
if sub.animatable:
animatable = "true"
break
%>
${helpers.to_nscsspropertyid(prop.ident)} => ${animatable},
% endfor
_ => false
}
}