Move perspective and perspective-origin properties from effects to box.

This commit is contained in:
Nazım Can Altınova 2016-12-23 17:10:54 +03:00
parent dd2aa4195a
commit aeb5d34394
6 changed files with 101 additions and 98 deletions

View file

@ -1567,9 +1567,9 @@ impl FragmentDisplayListBuilding for Fragment {
let overflow = base_flow.overflow.paint.translate(&-border_box_offset); let overflow = base_flow.overflow.paint.translate(&-border_box_offset);
let transform = self.transform_matrix(&border_box); let transform = self.transform_matrix(&border_box);
let perspective = match self.style().get_effects().perspective { let perspective = match self.style().get_box().perspective {
Either::First(length) => { Either::First(length) => {
let perspective_origin = self.style().get_effects().perspective_origin; let perspective_origin = self.style().get_box().perspective_origin;
let perspective_origin = let perspective_origin =
Point2D::new(model::specified(perspective_origin.horizontal, Point2D::new(model::specified(perspective_origin.horizontal,
border_box.size.width).to_f32_px(), border_box.size.width).to_f32_px(),

View file

@ -2370,7 +2370,7 @@ impl Fragment {
// TODO(mrobinson): Determine if this is necessary, since blocks with // TODO(mrobinson): Determine if this is necessary, since blocks with
// transformations already create stacking contexts. // transformations already create stacking contexts.
if let Either::First(ref _length) = self.style().get_effects().perspective { if let Either::First(ref _length) = self.style().get_box().perspective {
return true return true
} }

View file

@ -1526,6 +1526,102 @@ ${helpers.single_keyword("resize",
products="gecko", products="gecko",
animatable=False)} animatable=False)}
// https://drafts.csswg.org/css-transforms/#perspective
${helpers.predefined_type("perspective",
"LengthOrNone",
"Either::Second(None_)",
products="servo",
animatable=True)}
// FIXME: This prop should be animatable
// https://drafts.csswg.org/css-transforms/#perspective-origin-property
<%helpers:longhand name="perspective-origin" products="servo" animatable="False">
use std::fmt;
use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::{LengthOrPercentage, Percentage};
pub mod computed_value {
use values::computed::LengthOrPercentage;
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T {
pub horizontal: LengthOrPercentage,
pub vertical: LengthOrPercentage,
}
}
impl ToCss for computed_value::T {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
try!(self.horizontal.to_css(dest));
try!(dest.write_str(" "));
self.vertical.to_css(dest)
}
}
impl HasViewportPercentage for SpecifiedValue {
fn has_viewport_percentage(&self) -> bool {
self.horizontal.has_viewport_percentage() || self.vertical.has_viewport_percentage()
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue {
horizontal: LengthOrPercentage,
vertical: LengthOrPercentage,
}
impl ToCss for SpecifiedValue {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
try!(self.horizontal.to_css(dest));
try!(dest.write_str(" "));
self.vertical.to_css(dest)
}
}
#[inline]
pub fn get_initial_value() -> computed_value::T {
computed_value::T {
horizontal: computed::LengthOrPercentage::Percentage(0.5),
vertical: computed::LengthOrPercentage::Percentage(0.5),
}
}
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
let result = try!(super::parse_origin(context, input));
match result.depth {
Some(_) => Err(()),
None => Ok(SpecifiedValue {
horizontal: result.horizontal.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
vertical: result.vertical.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
})
}
}
impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T;
#[inline]
fn to_computed_value(&self, context: &Context) -> computed_value::T {
computed_value::T {
horizontal: self.horizontal.to_computed_value(context),
vertical: self.vertical.to_computed_value(context),
}
}
#[inline]
fn from_computed_value(computed: &computed_value::T) -> Self {
SpecifiedValue {
horizontal: ToComputedValue::from_computed_value(&computed.horizontal),
vertical: ToComputedValue::from_computed_value(&computed.vertical),
}
}
}
</%helpers:longhand>
// Non-standard // Non-standard
${helpers.single_keyword("-moz-appearance", ${helpers.single_keyword("-moz-appearance",
"""none button button-arrow-down button-arrow-next button-arrow-previous button-arrow-up """none button button-arrow-down button-arrow-next button-arrow-previous button-arrow-up

View file

@ -810,99 +810,6 @@ ${helpers.single_keyword("transform-style",
} }
</%helpers:longhand> </%helpers:longhand>
${helpers.predefined_type("perspective",
"LengthOrNone",
"Either::Second(None_)",
products="servo",
animatable=True)}
// FIXME: This prop should be animatable
<%helpers:longhand name="perspective-origin" products="servo" animatable="False">
use std::fmt;
use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::{LengthOrPercentage, Percentage};
pub mod computed_value {
use values::computed::LengthOrPercentage;
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T {
pub horizontal: LengthOrPercentage,
pub vertical: LengthOrPercentage,
}
}
impl ToCss for computed_value::T {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
try!(self.horizontal.to_css(dest));
try!(dest.write_str(" "));
self.vertical.to_css(dest)
}
}
impl HasViewportPercentage for SpecifiedValue {
fn has_viewport_percentage(&self) -> bool {
self.horizontal.has_viewport_percentage() || self.vertical.has_viewport_percentage()
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue {
horizontal: LengthOrPercentage,
vertical: LengthOrPercentage,
}
impl ToCss for SpecifiedValue {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
try!(self.horizontal.to_css(dest));
try!(dest.write_str(" "));
self.vertical.to_css(dest)
}
}
#[inline]
pub fn get_initial_value() -> computed_value::T {
computed_value::T {
horizontal: computed::LengthOrPercentage::Percentage(0.5),
vertical: computed::LengthOrPercentage::Percentage(0.5),
}
}
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
let result = try!(super::parse_origin(context, input));
match result.depth {
Some(_) => Err(()),
None => Ok(SpecifiedValue {
horizontal: result.horizontal.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
vertical: result.vertical.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
})
}
}
impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T;
#[inline]
fn to_computed_value(&self, context: &Context) -> computed_value::T {
computed_value::T {
horizontal: self.horizontal.to_computed_value(context),
vertical: self.vertical.to_computed_value(context),
}
}
#[inline]
fn from_computed_value(computed: &computed_value::T) -> Self {
SpecifiedValue {
horizontal: ToComputedValue::from_computed_value(&computed.horizontal),
vertical: ToComputedValue::from_computed_value(&computed.vertical),
}
}
}
</%helpers:longhand>
${helpers.single_keyword("mix-blend-mode", ${helpers.single_keyword("mix-blend-mode",
"""normal multiply screen overlay darken lighten color-dodge """normal multiply screen overlay darken lighten color-dodge
color-burn hard-light soft-light difference exclusion hue color-burn hard-light soft-light difference exclusion hue

View file

@ -1340,7 +1340,7 @@ impl ComputedValues {
if box_.transform.0.is_some() { if box_.transform.0.is_some() {
return transform_style::T::flat; return transform_style::T::flat;
} }
if let Either::First(ref _length) = effects.perspective { if let Either::First(ref _length) = box_.perspective {
return transform_style::T::flat; return transform_style::T::flat;
} }
} }

View file

@ -228,7 +228,7 @@ fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> Servo
get_position.right, get_position.bottom, get_position.right, get_position.bottom,
get_effects.opacity, get_effects.opacity,
get_box.transform, get_effects.transform_style, get_effects.transform_origin, get_box.transform, get_effects.transform_style, get_effects.transform_origin,
get_effects.perspective, get_effects.perspective_origin get_box.perspective, get_box.perspective_origin
]) || add_if_not_equal!(old, new, damage, ]) || add_if_not_equal!(old, new, damage,
[REPAINT], [ [REPAINT], [
get_color.color, get_background.background_color, get_color.color, get_background.background_color,