mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Move transform related properties from effects to box.
This commit is contained in:
parent
ed7945e747
commit
2e9d4df223
5 changed files with 129 additions and 124 deletions
|
@ -1822,7 +1822,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
Some(ref operations) => operations,
|
||||
};
|
||||
|
||||
let transform_origin = &self.style.get_effects().transform_origin;
|
||||
let transform_origin = &self.style.get_box().transform_origin;
|
||||
let transform_origin_x = model::specified(transform_origin.horizontal,
|
||||
stacking_relative_border_box.size
|
||||
.width).to_f32_px();
|
||||
|
|
|
@ -1622,6 +1622,131 @@ ${helpers.predefined_type("perspective",
|
|||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
// https://drafts.csswg.org/css-transforms/#backface-visibility-property
|
||||
${helpers.single_keyword("backface-visibility",
|
||||
"visible hidden",
|
||||
animatable=False)}
|
||||
|
||||
// https://drafts.csswg.org/css-transforms/#transform-box
|
||||
${helpers.single_keyword("transform-box",
|
||||
"border-box fill-box view-box",
|
||||
products="gecko",
|
||||
animatable=False)}
|
||||
|
||||
// `auto` keyword is not supported in gecko yet.
|
||||
// https://drafts.csswg.org/css-transforms/#transform-style-property
|
||||
${helpers.single_keyword("transform-style",
|
||||
"auto flat preserve-3d",
|
||||
animatable=False)}
|
||||
|
||||
// https://drafts.csswg.org/css-transforms/#transform-origin-property
|
||||
<%helpers:longhand name="transform-origin" products="servo" animatable="True">
|
||||
use app_units::Au;
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use values::HasViewportPercentage;
|
||||
use values::specified::{Length, LengthOrPercentage, Percentage};
|
||||
|
||||
pub mod computed_value {
|
||||
use properties::animated_properties::Interpolate;
|
||||
use values::computed::{Length, LengthOrPercentage};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct T {
|
||||
pub horizontal: LengthOrPercentage,
|
||||
pub vertical: LengthOrPercentage,
|
||||
pub depth: Length,
|
||||
}
|
||||
|
||||
impl Interpolate for T {
|
||||
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
|
||||
Ok(T {
|
||||
horizontal: try!(self.horizontal.interpolate(&other.horizontal, time)),
|
||||
vertical: try!(self.vertical.interpolate(&other.vertical, time)),
|
||||
depth: try!(self.depth.interpolate(&other.depth, time)),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
self.horizontal.has_viewport_percentage() ||
|
||||
self.vertical.has_viewport_percentage() ||
|
||||
self.depth.has_viewport_percentage()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue {
|
||||
horizontal: LengthOrPercentage,
|
||||
vertical: LengthOrPercentage,
|
||||
depth: Length,
|
||||
}
|
||||
|
||||
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(" "));
|
||||
try!(self.vertical.to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
self.depth.to_css(dest)
|
||||
}
|
||||
}
|
||||
|
||||
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(" "));
|
||||
try!(self.vertical.to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
self.depth.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),
|
||||
depth: Au(0),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||
let result = try!(super::parse_origin(context, input));
|
||||
Ok(SpecifiedValue {
|
||||
horizontal: result.horizontal.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
|
||||
vertical: result.vertical.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
|
||||
depth: result.depth.unwrap_or(Length::Absolute(Au(0))),
|
||||
})
|
||||
}
|
||||
|
||||
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),
|
||||
depth: self.depth.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),
|
||||
depth: ToComputedValue::from_computed_value(&computed.depth),
|
||||
}
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
// Non-standard
|
||||
${helpers.single_keyword("-moz-appearance",
|
||||
"""none button button-arrow-down button-arrow-next button-arrow-previous button-arrow-up
|
||||
|
|
|
@ -690,126 +690,6 @@ pub fn parse_origin(context: &ParserContext, input: &mut Parser) -> Result<Origi
|
|||
}
|
||||
}
|
||||
|
||||
${helpers.single_keyword("backface-visibility",
|
||||
"visible hidden",
|
||||
animatable=False)}
|
||||
|
||||
${helpers.single_keyword("transform-box",
|
||||
"border-box fill-box view-box",
|
||||
products="gecko",
|
||||
animatable=False)}
|
||||
|
||||
${helpers.single_keyword("transform-style",
|
||||
"auto flat preserve-3d",
|
||||
animatable=False)}
|
||||
|
||||
<%helpers:longhand name="transform-origin" products="servo" animatable="True">
|
||||
use app_units::Au;
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use values::HasViewportPercentage;
|
||||
use values::specified::{Length, LengthOrPercentage, Percentage};
|
||||
|
||||
pub mod computed_value {
|
||||
use properties::animated_properties::Interpolate;
|
||||
use values::computed::{Length, LengthOrPercentage};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct T {
|
||||
pub horizontal: LengthOrPercentage,
|
||||
pub vertical: LengthOrPercentage,
|
||||
pub depth: Length,
|
||||
}
|
||||
|
||||
impl Interpolate for T {
|
||||
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
|
||||
Ok(T {
|
||||
horizontal: try!(self.horizontal.interpolate(&other.horizontal, time)),
|
||||
vertical: try!(self.vertical.interpolate(&other.vertical, time)),
|
||||
depth: try!(self.depth.interpolate(&other.depth, time)),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
self.horizontal.has_viewport_percentage() ||
|
||||
self.vertical.has_viewport_percentage() ||
|
||||
self.depth.has_viewport_percentage()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue {
|
||||
horizontal: LengthOrPercentage,
|
||||
vertical: LengthOrPercentage,
|
||||
depth: Length,
|
||||
}
|
||||
|
||||
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(" "));
|
||||
try!(self.vertical.to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
self.depth.to_css(dest)
|
||||
}
|
||||
}
|
||||
|
||||
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(" "));
|
||||
try!(self.vertical.to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
self.depth.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),
|
||||
depth: Au(0),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||
let result = try!(super::parse_origin(context, input));
|
||||
Ok(SpecifiedValue {
|
||||
horizontal: result.horizontal.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
|
||||
vertical: result.vertical.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
|
||||
depth: result.depth.unwrap_or(Length::Absolute(Au(0))),
|
||||
})
|
||||
}
|
||||
|
||||
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),
|
||||
depth: self.depth.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),
|
||||
depth: ToComputedValue::from_computed_value(&computed.depth),
|
||||
}
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
${helpers.single_keyword("mix-blend-mode",
|
||||
"""normal multiply screen overlay darken lighten color-dodge
|
||||
color-burn hard-light soft-light difference exclusion hue
|
||||
|
|
|
@ -1336,7 +1336,7 @@ impl ComputedValues {
|
|||
return transform_style::T::flat;
|
||||
}
|
||||
|
||||
if effects.transform_style == transform_style::T::auto {
|
||||
if box_.transform_style == transform_style::T::auto {
|
||||
if box_.transform.0.is_some() {
|
||||
return transform_style::T::flat;
|
||||
}
|
||||
|
@ -1346,7 +1346,7 @@ impl ComputedValues {
|
|||
}
|
||||
|
||||
// Return the computed value if not overridden by the above exceptions
|
||||
effects.transform_style
|
||||
box_.transform_style
|
||||
}
|
||||
|
||||
pub fn transform_requires_layer(&self) -> bool {
|
||||
|
|
|
@ -227,7 +227,7 @@ fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> Servo
|
|||
get_position.top, get_position.left,
|
||||
get_position.right, get_position.bottom,
|
||||
get_effects.opacity,
|
||||
get_box.transform, get_effects.transform_style, get_effects.transform_origin,
|
||||
get_box.transform, get_box.transform_style, get_box.transform_origin,
|
||||
get_box.perspective, get_box.perspective_origin
|
||||
]) || add_if_not_equal!(old, new, damage,
|
||||
[REPAINT], [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue