mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #22645 - emilio:gecko-sync, r=emilio,mbrubeck
style: Sync changes from mozilla-central. See each individual commit for details. <!-- 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/22645) <!-- Reviewable:end -->
This commit is contained in:
commit
a0ba56cdf0
82 changed files with 1277 additions and 1844 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
use cssparser::RGBA;
|
||||
use style::values::animated::{Animate, Procedure, ToAnimatedValue};
|
||||
use style::values::computed::Percentage;
|
||||
use style::values::generics::transform::{Transform, TransformOperation};
|
||||
|
||||
fn interpolate_rgba(from: RGBA, to: RGBA, progress: f64) -> RGBA {
|
||||
|
@ -83,60 +82,6 @@ fn test_rgba_color_interepolation_out_of_range_clamped_2() {
|
|||
);
|
||||
}
|
||||
|
||||
// Transform
|
||||
#[test]
|
||||
fn test_transform_interpolation_on_translate() {
|
||||
use style::values::computed::{CalcLengthOrPercentage, Length, LengthOrPercentage};
|
||||
|
||||
let from = Transform(vec![TransformOperation::Translate3D(
|
||||
LengthOrPercentage::Length(Length::new(0.)),
|
||||
LengthOrPercentage::Length(Length::new(100.)),
|
||||
Length::new(25.),
|
||||
)]);
|
||||
let to = Transform(vec![TransformOperation::Translate3D(
|
||||
LengthOrPercentage::Length(Length::new(100.)),
|
||||
LengthOrPercentage::Length(Length::new(0.)),
|
||||
Length::new(75.),
|
||||
)]);
|
||||
assert_eq!(
|
||||
from.animate(&to, Procedure::Interpolate { progress: 0.5 })
|
||||
.unwrap(),
|
||||
Transform(vec![TransformOperation::Translate3D(
|
||||
LengthOrPercentage::Length(Length::new(50.)),
|
||||
LengthOrPercentage::Length(Length::new(50.)),
|
||||
Length::new(50.),
|
||||
)])
|
||||
);
|
||||
|
||||
let from = Transform(vec![TransformOperation::Translate3D(
|
||||
LengthOrPercentage::Percentage(Percentage(0.5)),
|
||||
LengthOrPercentage::Percentage(Percentage(1.0)),
|
||||
Length::new(25.),
|
||||
)]);
|
||||
let to = Transform(vec![TransformOperation::Translate3D(
|
||||
LengthOrPercentage::Length(Length::new(100.)),
|
||||
LengthOrPercentage::Length(Length::new(50.)),
|
||||
Length::new(75.),
|
||||
)]);
|
||||
assert_eq!(
|
||||
from.animate(&to, Procedure::Interpolate { progress: 0.5 })
|
||||
.unwrap(),
|
||||
Transform(vec![TransformOperation::Translate3D(
|
||||
// calc(50px + 25%)
|
||||
LengthOrPercentage::Calc(CalcLengthOrPercentage::new(
|
||||
Length::new(50.),
|
||||
Some(Percentage(0.25))
|
||||
)),
|
||||
// calc(25px + 50%)
|
||||
LengthOrPercentage::Calc(CalcLengthOrPercentage::new(
|
||||
Length::new(25.),
|
||||
Some(Percentage(0.5))
|
||||
)),
|
||||
Length::new(50.),
|
||||
)])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_transform_interpolation_on_scale() {
|
||||
let from = Transform(vec![TransformOperation::Scale3D(1.0, 2.0, 1.0)]);
|
||||
|
@ -197,29 +142,3 @@ fn test_transform_interpolation_on_skew() {
|
|||
)])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_transform_interpolation_on_mismatched_lists() {
|
||||
use style::values::computed::{Angle, Length, LengthOrPercentage};
|
||||
|
||||
let from = Transform(vec![TransformOperation::Rotate3D(
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
Angle::from_radians(100.0),
|
||||
)]);
|
||||
let to = Transform(vec![TransformOperation::Translate3D(
|
||||
LengthOrPercentage::Length(Length::new(100.)),
|
||||
LengthOrPercentage::Length(Length::new(0.)),
|
||||
Length::new(0.),
|
||||
)]);
|
||||
assert_eq!(
|
||||
from.animate(&to, Procedure::Interpolate { progress: 0.5 })
|
||||
.unwrap(),
|
||||
Transform(vec![TransformOperation::InterpolateMatrix {
|
||||
from_list: from.clone(),
|
||||
to_list: to.clone(),
|
||||
progress: Percentage(0.5),
|
||||
}])
|
||||
);
|
||||
}
|
||||
|
|
|
@ -4,19 +4,6 @@
|
|||
|
||||
use app_units::Au;
|
||||
use style::attr::{parse_length, AttrValue, LengthOrPercentageOrAuto};
|
||||
use style::values::computed::{CalcLengthOrPercentage, Percentage};
|
||||
|
||||
#[test]
|
||||
fn test_length_calc() {
|
||||
let calc = CalcLengthOrPercentage::new(Au(10).into(), Some(Percentage(0.2)));
|
||||
assert_eq!(calc.to_used_value(Some(Au(10))), Some(Au(12)));
|
||||
assert_eq!(calc.to_used_value(Some(Au(0))), Some(Au(10)));
|
||||
assert_eq!(calc.to_used_value(None), None);
|
||||
|
||||
let calc = CalcLengthOrPercentage::new(Au(10).into(), None);
|
||||
assert_eq!(calc.to_used_value(Some(Au(0))), Some(Au(10)));
|
||||
assert_eq!(calc.to_used_value(None), Some(Au(10)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_double() {
|
||||
|
|
|
@ -20,10 +20,10 @@ fn negative_letter_spacing_should_parse_properly() {
|
|||
#[test]
|
||||
fn negative_word_spacing_should_parse_properly() {
|
||||
use style::properties::longhands::word_spacing;
|
||||
use style::values::specified::length::{FontRelativeLength, LengthOrPercentage, NoCalcLength};
|
||||
use style::values::specified::length::{FontRelativeLength, LengthPercentage, NoCalcLength};
|
||||
|
||||
let negative_value = parse_longhand!(word_spacing, "-0.5em");
|
||||
let expected = Spacing::Value(LengthOrPercentage::Length(NoCalcLength::FontRelative(
|
||||
let expected = Spacing::Value(LengthPercentage::Length(NoCalcLength::FontRelative(
|
||||
FontRelativeLength::Em(-0.5),
|
||||
)));
|
||||
assert_eq!(negative_value, expected);
|
||||
|
|
|
@ -4,13 +4,11 @@
|
|||
|
||||
use crate::properties::{parse, parse_input};
|
||||
use crate::stylesheets::block_from;
|
||||
use style::computed_values::display::T as Display;
|
||||
use style::properties::declaration_block::PropertyDeclarationBlock;
|
||||
use style::properties::parse_property_declaration_list;
|
||||
use style::properties::{Importance, PropertyDeclaration};
|
||||
use style::values::specified::url::SpecifiedUrl;
|
||||
use style::values::specified::NoCalcLength;
|
||||
use style::values::specified::{Length, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use style::values::specified::Length;
|
||||
use style_traits::ToCss;
|
||||
|
||||
trait ToCssString {
|
||||
|
@ -25,53 +23,6 @@ impl ToCssString for PropertyDeclarationBlock {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn property_declaration_block_should_serialize_correctly() {
|
||||
use style::properties::longhands::overflow_x::SpecifiedValue as OverflowValue;
|
||||
|
||||
let declarations = vec![
|
||||
(
|
||||
PropertyDeclaration::Width(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(
|
||||
70f32,
|
||||
))),
|
||||
Importance::Normal,
|
||||
),
|
||||
(
|
||||
PropertyDeclaration::MinHeight(LengthOrPercentage::Length(NoCalcLength::from_px(
|
||||
20f32,
|
||||
))),
|
||||
Importance::Normal,
|
||||
),
|
||||
(
|
||||
PropertyDeclaration::Height(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(
|
||||
20f32,
|
||||
))),
|
||||
Importance::Important,
|
||||
),
|
||||
(
|
||||
PropertyDeclaration::Display(Display::InlineBlock),
|
||||
Importance::Normal,
|
||||
),
|
||||
(
|
||||
PropertyDeclaration::OverflowX(OverflowValue::Auto),
|
||||
Importance::Normal,
|
||||
),
|
||||
(
|
||||
PropertyDeclaration::OverflowY(OverflowValue::Auto),
|
||||
Importance::Normal,
|
||||
),
|
||||
];
|
||||
|
||||
let block = block_from(declarations);
|
||||
|
||||
let css_string = block.to_css_string();
|
||||
|
||||
assert_eq!(
|
||||
css_string,
|
||||
"width: 70px; min-height: 20px; height: 20px !important; display: inline-block; overflow: auto;"
|
||||
);
|
||||
}
|
||||
|
||||
mod shorthand_serialization {
|
||||
pub use super::*;
|
||||
|
||||
|
|
|
@ -17,20 +17,16 @@ use std::sync::atomic::AtomicBool;
|
|||
use style::context::QuirksMode;
|
||||
use style::error_reporting::{ContextualParseError, ParseErrorReporter};
|
||||
use style::media_queries::MediaList;
|
||||
use style::properties::longhands::{self, animation_timing_function};
|
||||
use style::properties::longhands;
|
||||
use style::properties::{CSSWideKeyword, CustomDeclaration};
|
||||
use style::properties::{CustomDeclarationValue, Importance};
|
||||
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock};
|
||||
use style::shared_lock::SharedRwLock;
|
||||
use style::stylesheets::keyframes_rule::{Keyframe, KeyframePercentage, KeyframeSelector};
|
||||
use style::stylesheets::{
|
||||
CssRule, CssRules, KeyframesRule, NamespaceRule, StyleRule, Stylesheet, StylesheetContents,
|
||||
CssRule, CssRules, NamespaceRule, StyleRule, Stylesheet, StylesheetContents,
|
||||
};
|
||||
use style::stylesheets::{Namespaces, Origin};
|
||||
use style::values::computed::Percentage;
|
||||
use style::values::specified::TimingFunction;
|
||||
use style::values::specified::{LengthOrPercentageOrAuto, PositionComponent};
|
||||
use style::values::{CustomIdent, KeyframesName};
|
||||
use style::values::specified::PositionComponent;
|
||||
|
||||
pub fn block_from<I>(iterable: I) -> PropertyDeclarationBlock
|
||||
where
|
||||
|
@ -61,14 +57,6 @@ fn test_parse_stylesheet() {
|
|||
display: block;
|
||||
}
|
||||
#d1 > .ok { background: blue; }
|
||||
@keyframes foo {
|
||||
from { width: 0% }
|
||||
to {
|
||||
width: 100%;
|
||||
width: 50% !important; /* !important not allowed here */
|
||||
animation-name: 'foo'; /* animation properties not allowed here */
|
||||
animation-timing-function: ease; /* … except animation-timing-function */
|
||||
}
|
||||
}";
|
||||
let url = ServoUrl::parse("about::test").unwrap();
|
||||
let lock = SharedRwLock::new();
|
||||
|
@ -278,56 +266,6 @@ fn test_parse_stylesheet() {
|
|||
column: 9,
|
||||
},
|
||||
}))),
|
||||
CssRule::Keyframes(Arc::new(stylesheet.shared_lock.wrap(KeyframesRule {
|
||||
name: KeyframesName::Ident(CustomIdent("foo".into())),
|
||||
keyframes: vec![
|
||||
Arc::new(stylesheet.shared_lock.wrap(Keyframe {
|
||||
selector: KeyframeSelector::new_for_unit_testing(vec![
|
||||
KeyframePercentage::new(0.),
|
||||
]),
|
||||
block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![(
|
||||
PropertyDeclaration::Width(
|
||||
LengthOrPercentageOrAuto::Percentage(Percentage(0.)),
|
||||
),
|
||||
Importance::Normal,
|
||||
)]))),
|
||||
source_location: SourceLocation {
|
||||
line: 17,
|
||||
column: 13,
|
||||
},
|
||||
})),
|
||||
Arc::new(stylesheet.shared_lock.wrap(Keyframe {
|
||||
selector: KeyframeSelector::new_for_unit_testing(vec![
|
||||
KeyframePercentage::new(1.),
|
||||
]),
|
||||
block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![
|
||||
(
|
||||
PropertyDeclaration::Width(
|
||||
LengthOrPercentageOrAuto::Percentage(Percentage(1.)),
|
||||
),
|
||||
Importance::Normal,
|
||||
),
|
||||
(
|
||||
PropertyDeclaration::AnimationTimingFunction(
|
||||
animation_timing_function::SpecifiedValue(vec![
|
||||
TimingFunction::ease(),
|
||||
]),
|
||||
),
|
||||
Importance::Normal,
|
||||
),
|
||||
]))),
|
||||
source_location: SourceLocation {
|
||||
line: 18,
|
||||
column: 13,
|
||||
},
|
||||
})),
|
||||
],
|
||||
vendor_prefix: None,
|
||||
source_location: SourceLocation {
|
||||
line: 16,
|
||||
column: 19,
|
||||
},
|
||||
}))),
|
||||
],
|
||||
&stylesheet.shared_lock,
|
||||
),
|
||||
|
|
|
@ -14,7 +14,8 @@ use style::parser::ParserContext;
|
|||
use style::shared_lock::{SharedRwLock, StylesheetGuards};
|
||||
use style::stylesheets::viewport_rule::*;
|
||||
use style::stylesheets::{CssRuleType, Origin, Stylesheet, StylesheetInDocument};
|
||||
use style::values::specified::LengthOrPercentageOrAuto::{self, Auto};
|
||||
use style::values::specified::LengthPercentage;
|
||||
use style::values::specified::LengthPercentageOrAuto::{self, Auto};
|
||||
use style::values::specified::NoCalcLength::{self, ViewportPercentage};
|
||||
use style::values::specified::ViewportPercentageLength::Vw;
|
||||
use style_traits::viewport::*;
|
||||
|
@ -96,14 +97,14 @@ macro_rules! assert_decl_len {
|
|||
|
||||
macro_rules! viewport_length {
|
||||
($value:expr, px) => {
|
||||
ViewportLength::Specified(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(
|
||||
$value,
|
||||
)))
|
||||
ViewportLength::Specified(LengthPercentageOrAuto::LengthPercentage(
|
||||
LengthPercentage::Length(NoCalcLength::from_px($value)),
|
||||
))
|
||||
};
|
||||
($value:expr, vw) => {
|
||||
ViewportLength::Specified(LengthOrPercentageOrAuto::Length(ViewportPercentage(Vw(
|
||||
$value,
|
||||
))))
|
||||
ViewportLength::Specified(LengthPercentageOrAuto::LengthPercentage(
|
||||
LengthPercentage::Length(ViewportPercentage(Vw($value))),
|
||||
))
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
[variable-substitution-replaced-size.html]
|
||||
[height on IFRAME]
|
||||
expected: FAIL
|
||||
|
||||
[width on INPUT]
|
||||
expected: FAIL
|
||||
|
@ -8,6 +6,3 @@
|
|||
[height on INPUT]
|
||||
expected: FAIL
|
||||
|
||||
[height on CANVAS]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue