Auto merge of #17839 - heycam:opacity-smil, r=hiro

style: allow out-of-range opacity values for SMIL animations

From https://bugzilla.mozilla.org/show_bug.cgi?id=1371150.

<!-- 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/17839)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-07-24 19:13:08 -07:00 committed by GitHub
commit bf16b146e8
8 changed files with 45 additions and 4 deletions

View file

@ -650,6 +650,7 @@ impl Expression {
in_media_query: true,
// TODO: pass the correct value here.
quirks_mode: quirks_mode,
for_smil_animation: false,
};
let required_value = match self.value {

View file

@ -2996,6 +2996,7 @@ where
cached_system_font: None,
in_media_query: false,
quirks_mode: quirks_mode,
for_smil_animation: false,
};
let ignore_colors = !device.use_document_colors();

View file

@ -246,6 +246,7 @@ impl Range<specified::Length> {
in_media_query: true,
cached_system_font: None,
quirks_mode: quirks_mode,
for_smil_animation: false,
};
match *self {

View file

@ -709,6 +709,7 @@ impl MaybeNew for ViewportConstraints {
cached_system_font: None,
in_media_query: false,
quirks_mode: quirks_mode,
for_smil_animation: false,
};
// DEVICE-ADAPT § 9.3 Resolving 'extend-to-zoom'

View file

@ -95,6 +95,12 @@ pub struct Context<'a> {
/// The quirks mode of this context.
pub quirks_mode: QuirksMode,
/// Whether this computation is being done for a SMIL animation.
///
/// This is used to allow certain properties to generate out-of-range
/// values, which SMIL allows.
pub for_smil_animation: bool,
}
impl<'a> Context<'a> {

View file

@ -566,7 +566,14 @@ impl ToComputedValue for Opacity {
#[inline]
fn to_computed_value(&self, context: &Context) -> CSSFloat {
self.0.to_computed_value(context).min(1.0).max(0.0)
let value = self.0.to_computed_value(context);
if context.for_smil_animation {
// SMIL expects to be able to interpolate between out-of-range
// opacity values.
value
} else {
value.min(1.0).max(0.0)
}
}
#[inline]