mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #14703 - canaltinova:perspective-transform, r=Wafflespeanut
Add gecko glue for perspective/transform properties <!-- Please describe your changes on the following line: --> To be able to add glue for these properties, we needed to change their structs. They are moved from effects to box and added stylo glue. This PR covers these properties: - perspective - perspective-origin - backface-visibility - transform-box - transform-style - transform-origin --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] These changes do not require tests because they are stylo changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/14703) <!-- Reviewable:end -->
This commit is contained in:
commit
a6d206eb66
8 changed files with 282 additions and 226 deletions
|
@ -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(),
|
||||||
|
@ -1822,7 +1822,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
Some(ref operations) => operations,
|
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,
|
let transform_origin_x = model::specified(transform_origin.horizontal,
|
||||||
stacking_relative_border_box.size
|
stacking_relative_border_box.size
|
||||||
.width).to_f32_px();
|
.width).to_f32_px();
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use cssparser::RGBA;
|
||||||
use gecko_bindings::structs::{nsStyleCoord, StyleShapeRadius};
|
use gecko_bindings::structs::{nsStyleCoord, StyleShapeRadius};
|
||||||
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
|
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use values::{Auto, Either};
|
use values::{Auto, Either, None_};
|
||||||
use values::computed::{Angle, LengthOrPercentageOrNone, Number};
|
use values::computed::{Angle, LengthOrPercentageOrNone, Number};
|
||||||
use values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
use values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||||
use values::computed::basic_shape::ShapeRadius;
|
use values::computed::basic_shape::ShapeRadius;
|
||||||
|
@ -207,6 +207,20 @@ impl GeckoStyleCoordConvertible for Auto {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GeckoStyleCoordConvertible for None_ {
|
||||||
|
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||||
|
coord.set_value(CoordDataValue::None)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
|
||||||
|
if let CoordDataValue::None = coord.as_value() {
|
||||||
|
Some(None_)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
|
pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
|
||||||
(((rgba.alpha * 255.0).round() as u32) << 24) |
|
(((rgba.alpha * 255.0).round() as u32) << 24) |
|
||||||
(((rgba.blue * 255.0).round() as u32) << 16) |
|
(((rgba.blue * 255.0).round() as u32) << 16) |
|
||||||
|
|
|
@ -475,8 +475,6 @@ impl Debug for ${style_struct.gecko_struct_name} {
|
||||||
# Make a list of types we can't auto-generate.
|
# Make a list of types we can't auto-generate.
|
||||||
#
|
#
|
||||||
force_stub = [];
|
force_stub = [];
|
||||||
# These are currently being shuffled to a different style struct on the gecko side.
|
|
||||||
force_stub += ["backface-visibility", "transform-box", "transform-style"]
|
|
||||||
# These live in an nsFont member in Gecko. Should be straightforward to do manually.
|
# These live in an nsFont member in Gecko. Should be straightforward to do manually.
|
||||||
force_stub += ["font-variant"]
|
force_stub += ["font-variant"]
|
||||||
# These have unusual representations in gecko.
|
# These have unusual representations in gecko.
|
||||||
|
@ -505,6 +503,7 @@ impl Debug for ${style_struct.gecko_struct_name} {
|
||||||
"LengthOrPercentage": impl_style_coord,
|
"LengthOrPercentage": impl_style_coord,
|
||||||
"LengthOrPercentageOrAuto": impl_style_coord,
|
"LengthOrPercentageOrAuto": impl_style_coord,
|
||||||
"LengthOrPercentageOrNone": impl_style_coord,
|
"LengthOrPercentageOrNone": impl_style_coord,
|
||||||
|
"LengthOrNone": impl_style_coord,
|
||||||
"Number": impl_simple,
|
"Number": impl_simple,
|
||||||
"Opacity": impl_simple,
|
"Opacity": impl_simple,
|
||||||
"CSSColor": impl_color,
|
"CSSColor": impl_color,
|
||||||
|
@ -1053,7 +1052,7 @@ fn static_assert() {
|
||||||
<% skip_box_longhands= """display overflow-y vertical-align
|
<% skip_box_longhands= """display overflow-y vertical-align
|
||||||
-moz-binding page-break-before page-break-after
|
-moz-binding page-break-before page-break-after
|
||||||
scroll-snap-points-x scroll-snap-points-y transform
|
scroll-snap-points-x scroll-snap-points-y transform
|
||||||
scroll-snap-type-y""" %>
|
scroll-snap-type-y perspective-origin transform-origin""" %>
|
||||||
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
|
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
|
||||||
|
|
||||||
// We manually-implement the |display| property until we get general
|
// We manually-implement the |display| property until we get general
|
||||||
|
@ -1325,6 +1324,40 @@ fn static_assert() {
|
||||||
|
|
||||||
${impl_keyword('scroll_snap_type_y', 'mScrollSnapTypeY', scroll_snap_type_keyword, need_clone=False)}
|
${impl_keyword('scroll_snap_type_y', 'mScrollSnapTypeY', scroll_snap_type_keyword, need_clone=False)}
|
||||||
|
|
||||||
|
pub fn set_perspective_origin(&mut self, v: longhands::perspective_origin::computed_value::T) {
|
||||||
|
self.gecko.mPerspectiveOrigin[0].set(v.horizontal);
|
||||||
|
self.gecko.mPerspectiveOrigin[1].set(v.vertical);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn copy_perspective_origin_from(&mut self, other: &Self) {
|
||||||
|
self.gecko.mPerspectiveOrigin[0].copy_from(&other.gecko.mPerspectiveOrigin[0]);
|
||||||
|
self.gecko.mPerspectiveOrigin[1].copy_from(&other.gecko.mPerspectiveOrigin[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_transform_origin(&mut self, v: longhands::transform_origin::computed_value::T) {
|
||||||
|
self.gecko.mTransformOrigin[0].set(v.horizontal);
|
||||||
|
self.gecko.mTransformOrigin[1].set(v.vertical);
|
||||||
|
self.gecko.mTransformOrigin[2].set(v.depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn copy_transform_origin_from(&mut self, other: &Self) {
|
||||||
|
self.gecko.mTransformOrigin[0].copy_from(&other.gecko.mTransformOrigin[0]);
|
||||||
|
self.gecko.mTransformOrigin[1].copy_from(&other.gecko.mTransformOrigin[1]);
|
||||||
|
self.gecko.mTransformOrigin[2].copy_from(&other.gecko.mTransformOrigin[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clone_transform_origin(&self) -> longhands::transform_origin::computed_value::T {
|
||||||
|
use properties::longhands::transform_origin::computed_value::T;
|
||||||
|
use values::computed::LengthOrPercentage;
|
||||||
|
T {
|
||||||
|
horizontal: LengthOrPercentage::from_gecko_style_coord(&self.gecko.mTransformOrigin[0])
|
||||||
|
.expect("clone for LengthOrPercentage failed"),
|
||||||
|
vertical: LengthOrPercentage::from_gecko_style_coord(&self.gecko.mTransformOrigin[1])
|
||||||
|
.expect("clone for LengthOrPercentage failed"),
|
||||||
|
depth: Au::from_gecko_style_coord(&self.gecko.mTransformOrigin[2])
|
||||||
|
.expect("clone for Length failed"),
|
||||||
|
}
|
||||||
|
}
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
<%def name="simple_image_array_property(name, shorthand, field_name)">
|
<%def name="simple_image_array_property(name, shorthand, field_name)">
|
||||||
|
|
|
@ -1526,6 +1526,228 @@ ${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_)",
|
||||||
|
gecko_ffi_name="mChildPerspective",
|
||||||
|
animatable=True)}
|
||||||
|
|
||||||
|
// FIXME: This prop should be animatable
|
||||||
|
// https://drafts.csswg.org/css-transforms/#perspective-origin-property
|
||||||
|
<%helpers:longhand name="perspective-origin" 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>
|
||||||
|
|
||||||
|
// 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" if product == "servo" else
|
||||||
|
"flat preserve-3d",
|
||||||
|
animatable=False)}
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/css-transforms/#transform-origin-property
|
||||||
|
<%helpers:longhand name="transform-origin" 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
|
// 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
|
||||||
|
|
|
@ -690,219 +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.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
|
||||||
|
|
|
@ -1343,17 +1343,17 @@ impl ComputedValues {
|
||||||
return transform_style::T::flat;
|
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() {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the computed value if not overridden by the above exceptions
|
// Return the computed value if not overridden by the above exceptions
|
||||||
effects.transform_style
|
box_.transform_style
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn transform_requires_layer(&self) -> bool {
|
pub fn transform_requires_layer(&self) -> bool {
|
||||||
|
|
|
@ -227,8 +227,8 @@ fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> Servo
|
||||||
get_position.top, get_position.left,
|
get_position.top, get_position.left,
|
||||||
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_box.transform_style, get_box.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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue