Only restyle viewport-relative nodes on viewport size change

This commit is contained in:
Shing Lyu 2016-06-22 16:44:04 +08:00
parent e7a55ae55e
commit f754cacbd5
28 changed files with 515 additions and 11 deletions

View file

@ -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 {