Auto merge of #10407 - mauricioc:issue10403, r=bholley

Move some CSS properties to match Gecko's representation

Fixes #10403. Animation had an extra transition-delay property, which was also moved to Box. Let me know if I should squash the commits.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10407)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-04-07 03:18:15 +05:30
commit 256b865055
10 changed files with 92 additions and 90 deletions

View file

@ -24,7 +24,7 @@ use properties::longhands::transition_timing_function::computed_value::{Transiti
use properties::longhands::vertical_align::computed_value::T as VerticalAlign;
use properties::longhands::visibility::computed_value::T as Visibility;
use properties::longhands::z_index::computed_value::T as ZIndex;
use properties::style_struct_traits::TAnimation;
use properties::style_struct_traits::TBox;
use properties::{ComputedValues, ServoComputedValues};
use std::cmp::Ordering;
use std::iter::repeat;
@ -74,7 +74,7 @@ impl PropertyAnimation {
-> Vec<PropertyAnimation> {
let mut result = Vec::new();
let transition_property =
new_style.as_servo().get_animation().transition_property.0[transition_index];
new_style.as_servo().get_box().transition_property.0[transition_index];
if transition_property != TransitionProperty::All {
if let Some(property_animation) =
PropertyAnimation::from_transition_property(transition_property,
@ -105,7 +105,7 @@ impl PropertyAnimation {
old_style: &ServoComputedValues,
new_style: &mut ServoComputedValues)
-> Option<PropertyAnimation> {
let animation_style = new_style.get_animation();
let box_style = new_style.get_box();
macro_rules! match_transition {
( $( [$name:ident; $structname:ident; $field:ident] ),* ) => {
match transition_property {
@ -128,8 +128,8 @@ impl PropertyAnimation {
new_style.get_inheritedtext().letter_spacing.0)
}
TransitionProperty::TextShadow => {
AnimatedProperty::TextShadow(old_style.get_effects().text_shadow.clone(),
new_style.get_effects().text_shadow.clone())
AnimatedProperty::TextShadow(old_style.get_inheritedtext().text_shadow.clone(),
new_style.get_inheritedtext().text_shadow.clone())
}
TransitionProperty::Transform => {
AnimatedProperty::Transform(old_style.get_effects().transform.clone(),
@ -154,21 +154,21 @@ impl PropertyAnimation {
[BorderSpacing; get_inheritedtable; border_spacing],
[BorderTopColor; get_border; border_top_color],
[BorderTopWidth; get_border; border_top_width],
[Bottom; get_positionoffsets; bottom],
[Bottom; get_position; bottom],
[Color; get_color; color],
[FontSize; get_font; font_size],
[FontWeight; get_font; font_weight],
[Height; get_box; height],
[Left; get_positionoffsets; left],
[LineHeight; get_inheritedbox; line_height],
[Left; get_position; left],
[LineHeight; get_inheritedtext; line_height],
[MarginBottom; get_margin; margin_bottom],
[MarginLeft; get_margin; margin_left],
[MarginRight; get_margin; margin_right],
[MarginTop; get_margin; margin_top],
[MaxHeight; get_box; max_height],
[MaxWidth; get_box; max_width],
[MinHeight; get_box; min_height],
[MinWidth; get_box; min_width],
[MaxHeight; get_position; max_height],
[MaxWidth; get_position; max_width],
[MinHeight; get_position; min_height],
[MinWidth; get_position; min_width],
[Opacity; get_effects; opacity],
[OutlineColor; get_outline; outline_color],
[OutlineWidth; get_outline; outline_width],
@ -176,19 +176,19 @@ impl PropertyAnimation {
[PaddingLeft; get_padding; padding_left],
[PaddingRight; get_padding; padding_right],
[PaddingTop; get_padding; padding_top],
[Right; get_positionoffsets; right],
[Right; get_position; right],
[TextIndent; get_inheritedtext; text_indent],
[Top; get_positionoffsets; top],
[Top; get_position; top],
[VerticalAlign; get_box; vertical_align],
[Visibility; get_inheritedbox; visibility],
[Width; get_box; width],
[ZIndex; get_box; z_index]);
[ZIndex; get_position; z_index]);
let property_animation = PropertyAnimation {
property: animated_property,
timing_function:
*animation_style.transition_timing_function.0.get_mod(transition_index),
duration: *animation_style.transition_duration.0.get_mod(transition_index),
*box_style.transition_timing_function.0.get_mod(transition_index),
duration: *box_style.transition_duration.0.get_mod(transition_index),
};
if property_animation.does_not_animate() {
None
@ -252,21 +252,21 @@ impl PropertyAnimation {
[BorderSpacing; mutate_inheritedtable; border_spacing],
[BorderTopColor; mutate_border; border_top_color],
[BorderTopWidth; mutate_border; border_top_width],
[Bottom; mutate_positionoffsets; bottom],
[Bottom; mutate_position; bottom],
[Color; mutate_color; color],
[FontSize; mutate_font; font_size],
[FontWeight; mutate_font; font_weight],
[Height; mutate_box; height],
[Left; mutate_positionoffsets; left],
[LineHeight; mutate_inheritedbox; line_height],
[Left; mutate_position; left],
[LineHeight; mutate_inheritedtext; line_height],
[MarginBottom; mutate_margin; margin_bottom],
[MarginLeft; mutate_margin; margin_left],
[MarginRight; mutate_margin; margin_right],
[MarginTop; mutate_margin; margin_top],
[MaxHeight; mutate_box; max_height],
[MaxWidth; mutate_box; max_width],
[MinHeight; mutate_box; min_height],
[MinWidth; mutate_box; min_width],
[MaxHeight; mutate_position; max_height],
[MaxWidth; mutate_position; max_width],
[MinHeight; mutate_position; min_height],
[MinWidth; mutate_position; min_width],
[Opacity; mutate_effects; opacity],
[OutlineColor; mutate_outline; outline_color],
[OutlineWidth; mutate_outline; outline_width],
@ -274,15 +274,15 @@ impl PropertyAnimation {
[PaddingLeft; mutate_padding; padding_left],
[PaddingRight; mutate_padding; padding_right],
[PaddingTop; mutate_padding; padding_top],
[Right; mutate_positionoffsets; right],
[Right; mutate_position; right],
[TextIndent; mutate_inheritedtext; text_indent],
[TextShadow; mutate_effects; text_shadow],
[Top; mutate_positionoffsets; top],
[TextShadow; mutate_inheritedtext; text_shadow],
[Top; mutate_position; top],
[Transform; mutate_effects; transform],
[VerticalAlign; mutate_box; vertical_align],
[Visibility; mutate_inheritedbox; visibility],
[Width; mutate_box; width],
[ZIndex; mutate_box; z_index]);
[ZIndex; mutate_position; z_index]);
}
#[inline]
@ -936,7 +936,7 @@ pub fn start_transitions_if_applicable<C: ComputedValues>(new_animations_sender:
new_style: &mut C)
-> bool {
let mut had_animations = false;
for i in 0..new_style.get_animation().transition_count() {
for i in 0..new_style.get_box().transition_count() {
// Create any property animations, if applicable.
let property_animations = PropertyAnimation::from_transition(i, old_style.as_servo(), new_style.as_servo_mut());
for property_animation in property_animations {
@ -945,15 +945,15 @@ pub fn start_transitions_if_applicable<C: ComputedValues>(new_animations_sender:
// Kick off the animation.
let now = time::precise_time_s();
let animation_style = new_style.as_servo().get_animation();
let box_style = new_style.as_servo().get_box();
let start_time =
now + (animation_style.transition_delay.0.get_mod(i).seconds() as f64);
now + (box_style.transition_delay.0.get_mod(i).seconds() as f64);
new_animations_sender.lock().unwrap().send(Animation {
node: node,
property_animation: property_animation,
start_time: start_time,
end_time: start_time +
(animation_style.transition_duration.0.get_mod(i).seconds() as f64),
(box_style.transition_duration.0.get_mod(i).seconds() as f64),
}).unwrap();
had_animations = true

View file

@ -460,7 +460,7 @@ pub mod longhands {
${predefined_type("outline-offset", "Length", "Au(0)")}
${new_style_struct("PositionOffsets", is_inherited=False, gecko_name="nsStylePosition")}
${new_style_struct("Position", is_inherited=False, gecko_name="nsStylePosition")}
% for side in ["top", "right", "bottom", "left"]:
${predefined_type(side, "LengthOrPercentageOrAuto",
@ -476,7 +476,8 @@ pub mod longhands {
"longhands::position::computed_value::T"),
Method("is_floated", "bool"),
Method("overflow_x_is_visible", "bool"),
Method("overflow_y_is_visible", "bool")])}
Method("overflow_y_is_visible", "bool"),
Method("transition_count", "usize")])}
// TODO(SimonSapin): don't parse `inline-table`, since we don't support it
<%self:longhand name="display" custom_cascade="True">
@ -588,6 +589,8 @@ pub mod longhands {
</%self:longhand>
${switch_to_style_struct("Position")}
<%self:longhand name="z-index">
use values::computed::ComputedValueAsSpecified;
@ -656,6 +659,8 @@ pub mod longhands {
"computed::LengthOrPercentageOrAuto::Auto",
"parse_non_negative")}
${switch_to_style_struct("Position")}
${predefined_type("min-width", "LengthOrPercentage",
"computed::LengthOrPercentage::Length(Au(0))",
"parse_non_negative")}
@ -670,7 +675,9 @@ pub mod longhands {
"computed::LengthOrPercentageOrNone::None",
"parse_non_negative")}
${switch_to_style_struct("InheritedBox")}
${new_style_struct("InheritedText", is_inherited=True, gecko_name="nsStyleText",
additional_methods=[Method("clone__servo_text_decorations_in_effect",
"longhands::_servo_text_decorations_in_effect::computed_value::T")])}
<%self:longhand name="line-height">
use cssparser::ToCss;
@ -904,7 +911,7 @@ pub mod longhands {
// CSS 2.1, Section 12 - Generated content, automatic numbering, and lists
${switch_to_style_struct("Box")}
${new_style_struct("Counters", is_inherited=False)}
<%self:longhand name="content">
use cssparser::Token;
@ -1217,7 +1224,7 @@ pub mod longhands {
}
</%self:longhand>
${new_style_struct("Counters", is_inherited=False)}
${switch_to_style_struct("Counters")}
<%self:longhand name="counter-increment">
use std::fmt;
@ -1973,9 +1980,7 @@ pub mod longhands {
// CSS 2.1, Section 16 - Text
${new_style_struct("InheritedText", is_inherited=True, gecko_name="nsStyleText",
additional_methods=[Method("clone__servo_text_decorations_in_effect",
"longhands::_servo_text_decorations_in_effect::computed_value::T")])}
${switch_to_style_struct("InheritedText")}
<%self:longhand name="text-align">
pub use self::computed_value::T as SpecifiedValue;
@ -2162,8 +2167,6 @@ pub mod longhands {
// TODO(pcwalton): Support `word-break: keep-all` once we have better CJK support.
${single_keyword("word-break", "normal break-all")}
${single_keyword("text-overflow", "clip ellipsis")}
// TODO(pcwalton): Support `text-justify: distribute`.
${single_keyword("text-justify", "auto none inter-word")}
@ -2172,6 +2175,8 @@ pub mod longhands {
Method("has_overline", "bool"),
Method("has_line_through", "bool")])}
${single_keyword("text-overflow", "clip ellipsis")}
${single_keyword("unicode-bidi", "normal embed isolate bidi-override isolate-override plaintext")}
<%self:longhand name="text-decoration" custom_cascade="True">
@ -2509,7 +2514,7 @@ pub mod longhands {
// CSS Basic User Interface Module Level 3
// http://dev.w3.org/csswg/css-ui/
${switch_to_style_struct("Box")}
${switch_to_style_struct("Position")}
${single_keyword("box-sizing", "content-box border-box")}
@ -3161,6 +3166,8 @@ pub mod longhands {
}
</%self:longhand>
${switch_to_style_struct("InheritedText")}
<%self:longhand name="text-shadow">
use cssparser::{self, ToCss};
use std::fmt;
@ -3339,6 +3346,8 @@ pub mod longhands {
}
</%self:longhand>
${switch_to_style_struct("Effects")}
<%self:longhand name="filter">
//pub use self::computed_value::T as SpecifiedValue;
use cssparser::ToCss;
@ -4327,8 +4336,7 @@ pub mod longhands {
}
</%self:longhand>
${new_style_struct("Animation", is_inherited=False,
additional_methods=[Method("transition_count", return_type="usize")])}
${switch_to_style_struct("Box")}
// TODO(pcwalton): Multiple transitions.
<%self:longhand name="transition-duration">
@ -4854,7 +4862,7 @@ pub mod longhands {
// CSS Flexible Box Layout Module Level 1
// http://www.w3.org/TR/css3-flexbox/
${new_style_struct("Flex", is_inherited=False)}
${switch_to_style_struct("Position")}
// Flex container properties
${single_keyword("flex-direction", "row row-reverse column column-reverse", experimental=True)}
@ -6174,11 +6182,7 @@ pub mod style_structs {
self.${longhand.ident} = other.${longhand.ident}.clone();
}
% endfor
% if style_struct.name == "Animation":
fn transition_count(&self) -> usize {
self.transition_property.0.len()
}
% elif style_struct.name == "Border":
% if style_struct.name == "Border":
% for side in ["top", "right", "bottom", "left"]:
fn border_${side}_is_none_or_hidden_and_has_nonzero_width(&self) -> bool {
self.border_${side}_style.none_or_hidden() &&
@ -6201,6 +6205,9 @@ pub mod style_structs {
fn overflow_y_is_visible(&self) -> bool {
self.overflow_y.0 == longhands::overflow_x::computed_value::T::visible
}
fn transition_count(&self) -> usize {
self.transition_property.0.len()
}
% elif style_struct.name == "Color":
fn clone_color(&self) -> longhands::color::computed_value::T {
self.color.clone()
@ -6402,26 +6409,26 @@ impl ServoComputedValues {
#[inline]
pub fn min_inline_size(&self) -> computed::LengthOrPercentage {
let box_style = self.get_box();
if self.writing_mode.is_vertical() { box_style.min_height } else { box_style.min_width }
let position_style = self.get_position();
if self.writing_mode.is_vertical() { position_style.min_height } else { position_style.min_width }
}
#[inline]
pub fn min_block_size(&self) -> computed::LengthOrPercentage {
let box_style = self.get_box();
if self.writing_mode.is_vertical() { box_style.min_width } else { box_style.min_height }
let position_style = self.get_position();
if self.writing_mode.is_vertical() { position_style.min_width } else { position_style.min_height }
}
#[inline]
pub fn max_inline_size(&self) -> computed::LengthOrPercentageOrNone {
let box_style = self.get_box();
if self.writing_mode.is_vertical() { box_style.max_height } else { box_style.max_width }
let position_style = self.get_position();
if self.writing_mode.is_vertical() { position_style.max_height } else { position_style.max_width }
}
#[inline]
pub fn max_block_size(&self) -> computed::LengthOrPercentageOrNone {
let box_style = self.get_box();
if self.writing_mode.is_vertical() { box_style.max_width } else { box_style.max_height }
let position_style = self.get_position();
if self.writing_mode.is_vertical() { position_style.max_width } else { position_style.max_height }
}
#[inline]
@ -6460,7 +6467,7 @@ impl ServoComputedValues {
#[inline]
pub fn logical_position(&self) -> LogicalMargin<computed::LengthOrPercentageOrAuto> {
// FIXME(SimonSapin): should be the writing mode of the containing block, maybe?
let position_style = self.get_positionoffsets();
let position_style = self.get_position();
LogicalMargin::from_physical(self.writing_mode, SideOffsets2D::new(
position_style.top,
position_style.right,
@ -7072,11 +7079,11 @@ pub fn modify_style_for_text(style: &mut Arc<ServoComputedValues>) {
// We leave the `position` property set to `relative` so that we'll still establish a
// containing block if needed. But we reset all position offsets to `auto`.
let mut style = Arc::make_mut(style);
let mut position_offsets = Arc::make_mut(&mut style.positionoffsets);
position_offsets.top = computed::LengthOrPercentageOrAuto::Auto;
position_offsets.right = computed::LengthOrPercentageOrAuto::Auto;
position_offsets.bottom = computed::LengthOrPercentageOrAuto::Auto;
position_offsets.left = computed::LengthOrPercentageOrAuto::Auto;
let mut position = Arc::make_mut(&mut style.position);
position.top = computed::LengthOrPercentageOrAuto::Auto;
position.right = computed::LengthOrPercentageOrAuto::Auto;
position.bottom = computed::LengthOrPercentageOrAuto::Auto;
position.left = computed::LengthOrPercentageOrAuto::Auto;
}
if style.padding.padding_top != computed::LengthOrPercentage::Length(Au(0)) ||