mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Move perspective and perspective-origin properties from effects to box.
This commit is contained in:
parent
dd2aa4195a
commit
aeb5d34394
6 changed files with 101 additions and 98 deletions
|
@ -1567,9 +1567,9 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
let overflow = base_flow.overflow.paint.translate(&-border_box_offset);
|
||||
|
||||
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) => {
|
||||
let perspective_origin = self.style().get_effects().perspective_origin;
|
||||
let perspective_origin = self.style().get_box().perspective_origin;
|
||||
let perspective_origin =
|
||||
Point2D::new(model::specified(perspective_origin.horizontal,
|
||||
border_box.size.width).to_f32_px(),
|
||||
|
|
|
@ -2370,7 +2370,7 @@ impl Fragment {
|
|||
|
||||
// TODO(mrobinson): Determine if this is necessary, since blocks with
|
||||
// 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
|
||||
}
|
||||
|
||||
|
|
|
@ -1526,6 +1526,102 @@ ${helpers.single_keyword("resize",
|
|||
products="gecko",
|
||||
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
|
||||
${helpers.single_keyword("-moz-appearance",
|
||||
"""none button button-arrow-down button-arrow-next button-arrow-previous button-arrow-up
|
||||
|
|
|
@ -810,99 +810,6 @@ ${helpers.single_keyword("transform-style",
|
|||
}
|
||||
</%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",
|
||||
"""normal multiply screen overlay darken lighten color-dodge
|
||||
color-burn hard-light soft-light difference exclusion hue
|
||||
|
|
|
@ -1340,7 +1340,7 @@ impl ComputedValues {
|
|||
if box_.transform.0.is_some() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> Servo
|
|||
get_position.right, get_position.bottom,
|
||||
get_effects.opacity,
|
||||
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,
|
||||
[REPAINT], [
|
||||
get_color.color, get_background.background_color,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue