mirror of
https://github.com/servo/servo.git
synced 2025-08-10 07:55:33 +01:00
Only restyle viewport-relative nodes on viewport size change
This commit is contained in:
parent
e7a55ae55e
commit
f754cacbd5
28 changed files with 515 additions and 11 deletions
|
@ -15,6 +15,7 @@ ${helpers.predefined_type("background-color", "CSSColor",
|
|||
use std::fmt;
|
||||
use values::specified::Image;
|
||||
use values::LocalToCss;
|
||||
use values::NoViewportPercentage;
|
||||
|
||||
pub mod computed_value {
|
||||
use values::computed;
|
||||
|
@ -34,6 +35,8 @@ ${helpers.predefined_type("background-color", "CSSColor",
|
|||
}
|
||||
}
|
||||
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue(pub Option<Image>);
|
||||
|
@ -76,6 +79,7 @@ ${helpers.predefined_type("background-color", "CSSColor",
|
|||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::LocalToCss;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
pub mod computed_value {
|
||||
use values::computed::LengthOrPercentage;
|
||||
|
@ -88,6 +92,12 @@ ${helpers.predefined_type("background-color", "CSSColor",
|
|||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
return self.horizontal.has_viewport_percentage() || self.vertical.has_viewport_percentage();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Copy)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue {
|
||||
|
@ -207,6 +217,7 @@ ${helpers.single_keyword("background-origin",
|
|||
use cssparser::{ToCss, Token};
|
||||
use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
pub mod computed_value {
|
||||
use values::computed::LengthOrPercentageOrAuto;
|
||||
|
@ -237,6 +248,12 @@ ${helpers.single_keyword("background-origin",
|
|||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedExplicitSize {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
return self.width.has_viewport_percentage() || self.height.has_viewport_percentage();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedExplicitSize {
|
||||
|
@ -260,6 +277,14 @@ ${helpers.single_keyword("background-origin",
|
|||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
match *self {
|
||||
SpecifiedValue::Explicit(ref explicit_size) => explicit_size.has_viewport_percentage(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
use app_units::Au;
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
|
@ -41,6 +42,14 @@
|
|||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue(pub specified::Length);
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
let &SpecifiedValue(length) = self;
|
||||
length.has_viewport_percentage()
|
||||
}
|
||||
}
|
||||
|
||||
pub mod computed_value {
|
||||
use app_units::Au;
|
||||
pub type T = Au;
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
pub use self::computed_value::T as SpecifiedValue;
|
||||
use values::computed::{Context, ComputedValueAsSpecified};
|
||||
|
||||
use values::NoViewportPercentage;
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
pub mod computed_value {
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Clone, Eq, PartialEq, Copy, Hash, RustcEncodable, Debug)]
|
||||
|
@ -94,7 +97,10 @@ ${helpers.single_keyword("position", "static absolute relative fixed",
|
|||
<%helpers:single_keyword_computed name="float"
|
||||
values="none left right"
|
||||
animatable="False"
|
||||
need_clone="True">
|
||||
need_clone="True"
|
||||
gecko_ffi_name="mFloat">
|
||||
use values::NoViewportPercentage;
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
impl ToComputedValue for SpecifiedValue {
|
||||
type ComputedValue = computed_value::T;
|
||||
|
||||
|
@ -146,6 +152,16 @@ ${helpers.single_keyword("clear", "none left right both",
|
|||
extra_gecko_values="middle-with-baseline") %>
|
||||
<% vertical_align_keywords = vertical_align.keyword.values_for(product) %>
|
||||
|
||||
use values::HasViewportPercentage;
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
match *self {
|
||||
SpecifiedValue::LengthOrPercentage(length) => length.has_viewport_percentage(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Debug, Clone, PartialEq, Copy)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -252,6 +268,9 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
|
||||
pub use self::computed_value::T as SpecifiedValue;
|
||||
|
||||
use values::NoViewportPercentage;
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.0.to_css(dest)
|
||||
|
@ -291,6 +310,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
|
||||
pub use self::computed_value::T as SpecifiedValue;
|
||||
pub use values::specified::Time as SingleSpecifiedValue;
|
||||
use values::NoViewportPercentage;
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
pub mod computed_value {
|
||||
use cssparser::ToCss;
|
||||
|
@ -469,6 +490,9 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
}
|
||||
}
|
||||
|
||||
use values::NoViewportPercentage;
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
impl ToComputedValue for SpecifiedValue {
|
||||
type ComputedValue = computed_value::T;
|
||||
|
||||
|
@ -592,6 +616,9 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
Ok(SpecifiedValue(try!(input.parse_comma_separated(SingleSpecifiedValue::parse))))
|
||||
}
|
||||
|
||||
use values::NoViewportPercentage;
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
impl ToComputedValue for SpecifiedValue {
|
||||
type ComputedValue = computed_value::T;
|
||||
|
||||
|
@ -615,6 +642,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
need_index="True"
|
||||
animatable="False">
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
use values::NoViewportPercentage;
|
||||
|
||||
pub mod computed_value {
|
||||
use cssparser::ToCss;
|
||||
|
@ -646,6 +674,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
}
|
||||
|
||||
pub use self::computed_value::T as SpecifiedValue;
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
pub use string_cache::Atom as SingleSpecifiedValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -696,6 +725,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
need_index="True"
|
||||
animatable="False">
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
use values::NoViewportPercentage;
|
||||
|
||||
pub mod computed_value {
|
||||
use cssparser::ToCss;
|
||||
|
@ -742,6 +772,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
pub use self::computed_value::AnimationIterationCount;
|
||||
pub use self::computed_value::AnimationIterationCount as SingleSpecifiedValue;
|
||||
pub use self::computed_value::T as SpecifiedValue;
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
#[inline]
|
||||
pub fn get_initial_single_value() -> AnimationIterationCount {
|
||||
|
@ -885,6 +916,7 @@ ${helpers.single_keyword("-moz-appearance",
|
|||
use std::fmt::{self, Write};
|
||||
use url::Url;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
use values::NoViewportPercentage;
|
||||
|
||||
#[derive(PartialEq, Clone, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -902,6 +934,7 @@ ${helpers.single_keyword("-moz-appearance",
|
|||
}
|
||||
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
|
|
|
@ -11,6 +11,16 @@
|
|||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::LocalToCss;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
match *self {
|
||||
SpecifiedValue::Specified(length) => length.has_viewport_percentage(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -75,6 +85,9 @@
|
|||
<%helpers:longhand name="column-count" experimental="True" animatable="False">
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::NoViewportPercentage;
|
||||
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -144,6 +157,16 @@
|
|||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::LocalToCss;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
match *self {
|
||||
SpecifiedValue::Specified(length) => length.has_viewport_percentage(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
use cssparser::Token;
|
||||
use std::ascii::AsciiExt;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
use values::NoViewportPercentage;
|
||||
|
||||
use super::list_style_type;
|
||||
|
||||
|
@ -17,6 +18,7 @@
|
|||
pub use self::computed_value::ContentItem;
|
||||
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
pub mod computed_value {
|
||||
use super::super::list_style_type;
|
||||
|
@ -174,6 +176,7 @@
|
|||
<%helpers:longhand name="counter-increment" animatable="False">
|
||||
use std::fmt;
|
||||
use super::content;
|
||||
use values::NoViewportPercentage;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
|
||||
use cssparser::{ToCss, Token, serialize_identifier};
|
||||
|
@ -193,6 +196,7 @@
|
|||
}
|
||||
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
|
|
|
@ -16,6 +16,7 @@ ${helpers.predefined_type("opacity",
|
|||
use cssparser::{self, ToCss};
|
||||
use std::fmt;
|
||||
use values::LocalToCss;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -28,6 +29,15 @@ ${helpers.predefined_type("opacity",
|
|||
pub inset: bool,
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
self.offset_x.has_viewport_percentage() ||
|
||||
self.offset_y.has_viewport_percentage() ||
|
||||
self.blur_radius.has_viewport_percentage() ||
|
||||
self.spread_radius.has_viewport_percentage()
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
if self.inset {
|
||||
|
@ -169,6 +179,7 @@ ${helpers.predefined_type("opacity",
|
|||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::LocalToCss;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
// NB: `top` and `left` are 0 if `auto` per CSS 2.1 11.1.2.
|
||||
|
||||
|
@ -219,6 +230,15 @@ ${helpers.predefined_type("opacity",
|
|||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedClipRect {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
self.top.has_viewport_percentage() ||
|
||||
self.right.map_or(false, |x| x.has_viewport_percentage()) ||
|
||||
self.bottom.map_or(false, |x| x.has_viewport_percentage()) ||
|
||||
self.left.has_viewport_percentage()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Copy)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedClipRect {
|
||||
|
@ -228,6 +248,13 @@ ${helpers.predefined_type("opacity",
|
|||
pub left: specified::Length,
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
let &SpecifiedValue(clip) = self;
|
||||
clip.map_or(false, |x| x.has_viewport_percentage())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Copy)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue(Option<SpecifiedClipRect>);
|
||||
|
@ -343,12 +370,29 @@ ${helpers.predefined_type("opacity",
|
|||
use std::fmt;
|
||||
use values::LocalToCss;
|
||||
use values::CSSFloat;
|
||||
use values::HasViewportPercentage;
|
||||
use values::specified::{Angle, Length};
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
let &SpecifiedValue(ref vec) = self;
|
||||
vec.iter().any(|ref x| x.has_viewport_percentage())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue(Vec<SpecifiedFilter>);
|
||||
|
||||
impl HasViewportPercentage for SpecifiedFilter {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
match *self {
|
||||
SpecifiedFilter::Blur(length) => length.has_viewport_percentage(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(pcwalton): `drop-shadow`
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -576,6 +620,7 @@ ${helpers.predefined_type("opacity",
|
|||
<%helpers:longhand name="transform" animatable="True">
|
||||
use app_units::Au;
|
||||
use values::CSSFloat;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
|
@ -684,6 +729,20 @@ ${helpers.predefined_type("opacity",
|
|||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedOperation {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
match *self {
|
||||
SpecifiedOperation::Translate(_, l1, l2, l3) => {
|
||||
l1.has_viewport_percentage() ||
|
||||
l2.has_viewport_percentage() ||
|
||||
l3.has_viewport_percentage()
|
||||
},
|
||||
SpecifiedOperation::Perspective(length) => length.has_viewport_percentage(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for SpecifiedOperation {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
|
@ -743,6 +802,13 @@ ${helpers.predefined_type("opacity",
|
|||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
let &SpecifiedValue(ref specified_ops) = self;
|
||||
specified_ops.iter().any(|ref x| x.has_viewport_percentage())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue(Vec<SpecifiedOperation>);
|
||||
|
@ -1133,6 +1199,7 @@ ${helpers.single_keyword("transform-style",
|
|||
<%helpers:longhand name="transform-origin" animatable="True">
|
||||
use app_units::Au;
|
||||
use values::LocalToCss;
|
||||
use values::HasViewportPercentage;
|
||||
use values::specified::{Length, LengthOrPercentage, Percentage};
|
||||
|
||||
use cssparser::ToCss;
|
||||
|
@ -1150,6 +1217,14 @@ ${helpers.single_keyword("transform-style",
|
|||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -1217,6 +1292,7 @@ ${helpers.predefined_type("perspective",
|
|||
|
||||
// FIXME: This prop should be animatable
|
||||
<%helpers:longhand name="perspective-origin" animatable="False">
|
||||
use values::HasViewportPercentage;
|
||||
use values::specified::{LengthOrPercentage, Percentage};
|
||||
|
||||
use cssparser::ToCss;
|
||||
|
@ -1241,6 +1317,12 @@ ${helpers.predefined_type("perspective",
|
|||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -10,10 +10,13 @@
|
|||
additional_methods=[Method("compute_font_hash", is_mut=True)]) %>
|
||||
<%helpers:longhand name="font-family" animatable="False">
|
||||
use self::computed_value::FontFamily;
|
||||
use values::NoViewportPercentage;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
pub use self::computed_value::T as SpecifiedValue;
|
||||
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
pub mod computed_value {
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
|
@ -128,6 +131,9 @@ ${helpers.single_keyword("font-variant",
|
|||
<%helpers:longhand name="font-weight" need_clone="True" animatable="True">
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::NoViewportPercentage;
|
||||
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Copy)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -251,6 +257,7 @@ ${helpers.single_keyword("font-variant",
|
|||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::FONT_MEDIUM_PX;
|
||||
use values::HasViewportPercentage;
|
||||
use values::specified::{LengthOrPercentage, Length, Percentage};
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
|
@ -259,6 +266,13 @@ ${helpers.single_keyword("font-variant",
|
|||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
let &SpecifiedValue(length) = self;
|
||||
return length.has_viewport_percentage()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue(pub specified::LengthOrPercentage);
|
||||
|
|
|
@ -64,6 +64,9 @@ ${helpers.single_keyword("color-adjust",
|
|||
}
|
||||
}
|
||||
|
||||
use values::NoViewportPercentage;
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
pub type SpecifiedValue = computed_value::T;
|
||||
|
||||
#[inline]
|
||||
|
@ -104,6 +107,9 @@ ${helpers.single_keyword("color-adjust",
|
|||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
use values::NoViewportPercentage;
|
||||
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
|
||||
|
|
|
@ -19,6 +19,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
|||
<%helpers:longhand name="border-spacing" animatable="False">
|
||||
use app_units::Au;
|
||||
use values::LocalToCss;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
|
@ -34,6 +35,12 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
|||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
return self.horizontal.has_viewport_percentage() || self.vertical.has_viewport_percentage()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue {
|
||||
|
|
|
@ -11,6 +11,16 @@
|
|||
use std::fmt;
|
||||
use values::LocalToCss;
|
||||
use values::CSSFloat;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
match *self {
|
||||
SpecifiedValue::LengthOrPercentage(length) => length.has_viewport_percentage(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Copy)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -123,7 +133,9 @@
|
|||
<%helpers:longhand name="text-align" animatable="False">
|
||||
pub use self::computed_value::T as SpecifiedValue;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
use values::NoViewportPercentage;
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
pub mod computed_value {
|
||||
macro_rules! define_text_align {
|
||||
( $( $name: ident ( $string: expr ) => $discriminant: expr, )+ ) => {
|
||||
|
@ -184,6 +196,16 @@
|
|||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::LocalToCss;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
match *self {
|
||||
SpecifiedValue::Specified(length) => length.has_viewport_percentage(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -248,6 +270,16 @@
|
|||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::LocalToCss;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
match *self {
|
||||
SpecifiedValue::Specified(length) => length.has_viewport_percentage(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -340,10 +372,12 @@ ${helpers.single_keyword("text-justify",
|
|||
use cssparser::{RGBA, ToCss};
|
||||
use std::fmt;
|
||||
|
||||
use values:: NoViewportPercentage;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
use properties::style_struct_traits::{Box, Color, Text};
|
||||
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
#[derive(Clone, PartialEq, Copy, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -422,7 +456,9 @@ ${helpers.single_keyword("text-justify",
|
|||
gecko_constant_prefix="NS_STYLE_WHITESPACE"
|
||||
animatable="False">
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
use values::NoViewportPercentage;
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
impl SpecifiedValue {
|
||||
pub fn allow_wrap(&self) -> bool {
|
||||
|
@ -461,11 +497,27 @@ ${helpers.single_keyword("text-justify",
|
|||
use cssparser::{self, ToCss};
|
||||
use std::fmt;
|
||||
use values::LocalToCss;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
let &SpecifiedValue(ref vec) = self;
|
||||
vec.iter().any(|ref x| x .has_viewport_percentage())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue(Vec<SpecifiedTextShadow>);
|
||||
|
||||
impl HasViewportPercentage for SpecifiedTextShadow {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
self.offset_x.has_viewport_percentage() ||
|
||||
self.offset_y.has_viewport_percentage() ||
|
||||
self.blur_radius.has_viewport_percentage()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedTextShadow {
|
||||
|
|
|
@ -31,6 +31,9 @@ ${helpers.single_keyword("list-style-type", """
|
|||
use std::fmt;
|
||||
use url::Url;
|
||||
use values::LocalToCss;
|
||||
use values::NoViewportPercentage;
|
||||
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -96,6 +99,7 @@ ${helpers.single_keyword("list-style-type", """
|
|||
<%helpers:longhand name="quotes" animatable="False">
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
use values::NoViewportPercentage;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
|
||||
use cssparser::{ToCss, Token};
|
||||
|
@ -109,6 +113,7 @@ ${helpers.single_keyword("list-style-type", """
|
|||
}
|
||||
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
|
|
|
@ -32,6 +32,7 @@ ${helpers.predefined_type("outline-color", "CSSColor", "::cssparser::Color::Curr
|
|||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::LocalToCss;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
|
@ -42,6 +43,14 @@ ${helpers.predefined_type("outline-color", "CSSColor", "::cssparser::Color::Curr
|
|||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
specified::parse_border_width(input).map(SpecifiedValue)
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
let &SpecifiedValue(length) = self;
|
||||
length.has_viewport_percentage()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue(pub specified::Length);
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
|
||||
<%helpers:longhand name="cursor" animatable="False">
|
||||
pub use self::computed_value::T as SpecifiedValue;
|
||||
use values::NoViewportPercentage;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
pub mod computed_value {
|
||||
use cssparser::ToCss;
|
||||
|
|
|
@ -13,9 +13,11 @@
|
|||
% endfor
|
||||
|
||||
<%helpers:longhand name="z-index" animatable="True">
|
||||
use values::NoViewportPercentage;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
pub type SpecifiedValue = computed_value::T;
|
||||
pub mod computed_value {
|
||||
use cssparser::ToCss;
|
||||
|
|
|
@ -25,8 +25,10 @@ ${helpers.single_keyword("unicode-bidi",
|
|||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
use values::NoViewportPercentage;
|
||||
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue