mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
style: Fix servo build and tidy lints.
This commit is contained in:
parent
a51b4e754c
commit
05f9f10a1c
9 changed files with 28 additions and 117 deletions
|
@ -27,8 +27,8 @@ use std::sync::mpsc::Sender;
|
|||
use stylesheets::keyframes_rule::{KeyframesAnimation, KeyframesStep, KeyframesStepValue};
|
||||
use timer::Timer;
|
||||
use values::computed::Time;
|
||||
use values::computed::box_::TransitionProperty;
|
||||
use values::computed::TimingFunction;
|
||||
use values::computed::box_::TransitionProperty;
|
||||
use values::generics::box_::AnimationIterationCount;
|
||||
use values::generics::easing::{StepPosition, TimingFunction as GenericTimingFunction};
|
||||
|
||||
|
|
|
@ -1032,13 +1032,13 @@ impl TrackSize<LengthOrPercentage> {
|
|||
match *self {
|
||||
TrackSize::FitContent(ref lop) => {
|
||||
// Gecko sets min value to None and max value to the actual value in fit-content
|
||||
// https://searchfox.org/mozilla-central/rev/c05d9d61188d32b8209dfe4295944c0f1e0ce621/layout/style/nsRuleNode.cpp#7910
|
||||
// https://searchfox.org/mozilla-central/rev/c05d9d61188d32b8/layout/style/nsRuleNode.cpp#7910
|
||||
gecko_min.set_value(CoordDataValue::None);
|
||||
lop.to_gecko_style_coord(gecko_max);
|
||||
},
|
||||
TrackSize::Breadth(ref breadth) => {
|
||||
// Set the value to both fields if there's one breadth value
|
||||
// https://searchfox.org/mozilla-central/rev/c05d9d61188d32b8209dfe4295944c0f1e0ce621/layout/style/nsRuleNode.cpp#7919
|
||||
// https://searchfox.org/mozilla-central/rev/c05d9d61188d32b8/layout/style/nsRuleNode.cpp#7919
|
||||
breadth.to_gecko_style_coord(gecko_min);
|
||||
breadth.to_gecko_style_coord(gecko_max);
|
||||
},
|
||||
|
|
|
@ -2394,7 +2394,7 @@ fn static_assert() {
|
|||
/// from the parent.
|
||||
///
|
||||
/// This is a port of Gecko's old ComputeScriptLevelSize function:
|
||||
/// https://searchfox.org/mozilla-central/rev/c05d9d61188d32b8209dfe4295944c0f1e0ce621/layout/style/nsRuleNode.cpp#3103
|
||||
/// https://searchfox.org/mozilla-central/rev/c05d9d61188d32b8/layout/style/nsRuleNode.cpp#3103
|
||||
///
|
||||
/// scriptlevel is a property that affects how font-size is inherited. If scriptlevel is
|
||||
/// +1, for example, it will inherit as the script size multiplier times
|
||||
|
|
|
@ -9,10 +9,8 @@ use app_units::Au;
|
|||
use dom::TElement;
|
||||
use properties::{self, ComputedValues, StyleBuilder};
|
||||
use properties::computed_value_flags::ComputedValueFlags;
|
||||
use properties::longhands::_moz_appearance::computed_value::T as Appearance;
|
||||
use properties::longhands::display::computed_value::T as Display;
|
||||
use properties::longhands::float::computed_value::T as Float;
|
||||
use properties::longhands::line_height::computed_value::T as LineHeight;
|
||||
use properties::longhands::overflow_x::computed_value::T as Overflow;
|
||||
use properties::longhands::position::computed_value::T as Position;
|
||||
|
||||
|
@ -700,22 +698,28 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
/// the computed value of 'line-height' is 'normal'.
|
||||
///
|
||||
/// https://github.com/w3c/csswg-drafts/issues/3257
|
||||
#[cfg(feature = "gecko")]
|
||||
fn adjust_for_appearance<E>(&mut self, element: Option<E>)
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
if self.style.get_box().clone__moz_appearance() == Appearance::Menulist &&
|
||||
self.style.get_inherited_text().clone_line_height() != LineHeight::normal() {
|
||||
if self.style.pseudo.is_some() {
|
||||
return;
|
||||
}
|
||||
let is_html_select_element =
|
||||
element.map_or(false, |e| e.is_html_element() && e.local_name() == &*local_name!("select"));
|
||||
if !is_html_select_element {
|
||||
return;
|
||||
}
|
||||
self.style.mutate_inherited_text().set_line_height(LineHeight::normal());
|
||||
use properties::longhands::_moz_appearance::computed_value::T as Appearance;
|
||||
use properties::longhands::line_height::computed_value::T as LineHeight;
|
||||
|
||||
if self.style.get_box().clone__moz_appearance() == Appearance::Menulist {
|
||||
if self.style.get_inherited_text().clone_line_height() == LineHeight::normal() {
|
||||
return;
|
||||
}
|
||||
if self.style.pseudo.is_some() {
|
||||
return;
|
||||
}
|
||||
let is_html_select_element =
|
||||
element.map_or(false, |e| e.is_html_element() && e.local_name() == &*local_name!("select"));
|
||||
if !is_html_select_element {
|
||||
return;
|
||||
}
|
||||
self.style.mutate_inherited_text().set_line_height(LineHeight::normal());
|
||||
}
|
||||
}
|
||||
|
||||
/// Adjusts the style to account for various fixups that don't fit naturally
|
||||
|
@ -779,7 +783,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
{
|
||||
self.adjust_for_text_decorations_in_effect();
|
||||
}
|
||||
self.adjust_for_appearance(element);
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
self.adjust_for_appearance(element);
|
||||
}
|
||||
self.set_bits();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
//! Generic types for CSS Easing Functions.
|
||||
//! https://drafts.csswg.org/css-easing/#timing-functions
|
||||
|
||||
use values::CSSFloat;
|
||||
use parser::ParserContext;
|
||||
use values::CSSFloat;
|
||||
|
||||
/// A generic easing function.
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
|
||||
|
|
|
@ -753,7 +753,7 @@ impl ToComputedValue for KeywordSize {
|
|||
// The tables in this function are originally from
|
||||
// nsRuleNode::CalcFontPointSize in Gecko:
|
||||
//
|
||||
// https://searchfox.org/mozilla-central/rev/c05d9d61188d32b8209dfe4295944c0f1e0ce621/layout/style/nsRuleNode.cpp#3150
|
||||
// https://searchfox.org/mozilla-central/rev/c05d9d61188d32b8/layout/style/nsRuleNode.cpp#3150
|
||||
//
|
||||
// Mapping from base size and HTML size to pixels
|
||||
// The first index is (base_size - 9), the second is the
|
||||
|
|
|
@ -35,19 +35,3 @@ fn test_steps() {
|
|||
assert!(parse(transition_timing_function::parse, "steps(-1)").is_err());
|
||||
assert!(parse(transition_timing_function::parse, "steps(1, middle)").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_frames() {
|
||||
assert_roundtrip_with_context!(transition_timing_function::parse, "frames( 2 )", "frames(2)");
|
||||
assert_roundtrip_with_context!(transition_timing_function::parse, "frames(10000)");
|
||||
|
||||
// Frames number must be an integer greater than 1
|
||||
assert!(parse(transition_timing_function::parse, "frames(1)").is_err());
|
||||
assert!(parse(transition_timing_function::parse, "frames(-2)").is_err());
|
||||
assert!(parse(transition_timing_function::parse, "frames()").is_err());
|
||||
assert!(parse(transition_timing_function::parse, "frames(,)").is_err());
|
||||
assert!(parse(transition_timing_function::parse, "frames(a)").is_err());
|
||||
assert!(parse(transition_timing_function::parse, "frames(2.0)").is_err());
|
||||
assert!(parse(transition_timing_function::parse, "frames(2.5)").is_err());
|
||||
assert!(parse(transition_timing_function::parse, "frames(2 3)").is_err());
|
||||
}
|
||||
|
|
|
@ -707,86 +707,6 @@ mod shorthand_serialization {
|
|||
}
|
||||
}
|
||||
|
||||
mod transition {
|
||||
pub use super::*;
|
||||
|
||||
#[test]
|
||||
fn transition_should_serialize_all_available_properties() {
|
||||
let block_text = "transition-property: margin-left; \
|
||||
transition-duration: 3s; \
|
||||
transition-delay: 4s; \
|
||||
transition-timing-function: cubic-bezier(0.2, 5, 0.5, 2);";
|
||||
|
||||
let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
|
||||
|
||||
let serialization = block.to_css_string();
|
||||
|
||||
assert_eq!(serialization, "transition: margin-left 3s cubic-bezier(0.2, 5, 0.5, 2) 4s;");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_multiple_transitions() {
|
||||
let block_text = "transition-property: margin-left, width; \
|
||||
transition-duration: 3s, 2s; \
|
||||
transition-delay: 4s, 5s; \
|
||||
transition-timing-function: cubic-bezier(0.2, 5, 0.5, 2), ease;";
|
||||
|
||||
let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
|
||||
|
||||
let serialization = block.to_css_string();
|
||||
|
||||
assert_eq!(serialization, "transition: \
|
||||
margin-left 3s cubic-bezier(0.2, 5, 0.5, 2) 4s, \
|
||||
width 2s ease 5s;");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_multiple_transitions_unequal_property_lists() {
|
||||
// When the lengths of property values are different, the shorthand serialization
|
||||
// should not be used. Previously the implementation cycled values if the lists were
|
||||
// uneven. This is incorrect, in that we should serialize to a shorthand only when the
|
||||
// lists have the same length (this affects background, transition and animation).
|
||||
// https://github.com/servo/servo/issues/15398 )
|
||||
// The duration below has 1 extra value.
|
||||
let block_text = "transition-property: margin-left, width; \
|
||||
transition-duration: 3s, 2s, 4s; \
|
||||
transition-delay: 4s, 5s; \
|
||||
transition-timing-function: cubic-bezier(0.2, 5, 0.5, 2), ease;";
|
||||
|
||||
let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
|
||||
|
||||
let serialization = block.to_css_string();
|
||||
|
||||
assert_eq!(serialization, block_text);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transition_should_serialize_acceptable_step_timing_function() {
|
||||
let block_text = "transition-property: margin-left; \
|
||||
transition-duration: 3s; \
|
||||
transition-delay: 4s; \
|
||||
transition-timing-function: steps(2, start);";
|
||||
let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
|
||||
|
||||
let serialization = block.to_css_string();
|
||||
|
||||
assert_eq!(serialization, "transition: margin-left 3s steps(2, start) 4s;");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transition_should_serialize_acceptable_frames_timing_function() {
|
||||
let block_text = "transition-property: margin-left; \
|
||||
transition-duration: 3s; \
|
||||
transition-delay: 4s; \
|
||||
transition-timing-function: frames(2);";
|
||||
let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
|
||||
|
||||
let serialization = block.to_css_string();
|
||||
|
||||
assert_eq!(serialization, "transition: margin-left 3s frames(2) 4s;");
|
||||
}
|
||||
}
|
||||
|
||||
mod keywords {
|
||||
pub use super::*;
|
||||
#[test]
|
||||
|
|
|
@ -28,7 +28,7 @@ use style::stylesheets::keyframes_rule::{Keyframe, KeyframeSelector, KeyframePer
|
|||
use style::values::{KeyframesName, CustomIdent};
|
||||
use style::values::computed::Percentage;
|
||||
use style::values::specified::{LengthOrPercentageOrAuto, PositionComponent};
|
||||
use style::values::specified::transform::TimingFunction;
|
||||
use style::values::specified::TimingFunction;
|
||||
|
||||
pub fn block_from<I>(iterable: I) -> PropertyDeclarationBlock
|
||||
where I: IntoIterator<Item=(PropertyDeclaration, Importance)> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue