diff options
-rw-r--r-- | components/layout/block.rs | 31 | ||||
-rw-r--r-- | components/layout/incremental.rs | 6 | ||||
-rw-r--r-- | components/style/properties.mako.rs | 32 |
3 files changed, 40 insertions, 29 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs index 32413de6906..13971d2a626 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -55,7 +55,7 @@ use std::cmp::{max, min}; use std::fmt; use std::sync::Arc; use style::computed_values::{border_collapse, box_sizing, display, float, overflow_x, overflow_y}; -use style::computed_values::{position, text_align, transform, transform_style}; +use style::computed_values::{position, text_align, transform_style}; use style::properties::ComputedValues; use style::values::computed::{LengthOrNone, LengthOrPercentageOrNone}; use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto}; @@ -585,33 +585,6 @@ impl BlockFlow { } } - pub fn transform_requires_layer(&self) -> bool { - // Check if the transform matrix is 2D or 3D - if let Some(ref transform_list) = self.fragment.style().get_effects().transform.0 { - for transform in transform_list { - match *transform { - transform::ComputedOperation::Perspective(..) => { - return true; - } - transform::ComputedOperation::Matrix(m) => { - // See http://dev.w3.org/csswg/css-transforms/#2d-matrix - if m.m31 != 0.0 || m.m32 != 0.0 || - m.m13 != 0.0 || m.m23 != 0.0 || - m.m43 != 0.0 || m.m14 != 0.0 || - m.m24 != 0.0 || m.m34 != 0.0 || - m.m33 != 1.0 || m.m44 != 1.0 { - return true; - } - } - _ => {} - } - } - } - - // Neither perspective nor transform present - false - } - /// Compute the actual inline size and position for this block. pub fn compute_used_inline_size(&mut self, layout_context: &LayoutContext, @@ -1560,7 +1533,7 @@ impl BlockFlow { // This flow needs a layer if it has a 3d transform, or provides perspective // to child layers. See http://dev.w3.org/csswg/css-transforms/#3d-rendering-contexts. - let has_3d_transform = self.transform_requires_layer(); + let has_3d_transform = self.fragment.style().transform_requires_layer(); let has_perspective = self.fragment.style().get_effects().perspective != LengthOrNone::None; diff --git a/components/layout/incremental.rs b/components/layout/incremental.rs index 6f60e9a2ab8..de89c187120 100644 --- a/components/layout/incremental.rs +++ b/components/layout/incremental.rs @@ -191,6 +191,12 @@ pub fn compute_damage(old: &Option<Arc<ComputedValues>>, new: &ComputedValues) - get_font.font_size, get_font.font_stretch ]); + // If the layer requirements of this flow have changed due to the value + // of the transform, then reflow is required to rebuild the layers. + if old.transform_requires_layer() != new.transform_requires_layer() { + damage.insert(rebuild_and_reflow()); + } + // FIXME: test somehow that we checked every CSS property damage } diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index 847155c8de8..79199a82466 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -6227,6 +6227,38 @@ impl ComputedValues { effects.transform_style } + pub fn transform_requires_layer(&self) -> bool { + // Check if the transform matrix is 2D or 3D + if let Some(ref transform_list) = self.get_effects().transform.0 { + for transform in transform_list { + match *transform { + computed_values::transform::ComputedOperation::Perspective(..) => { + return true; + } + computed_values::transform::ComputedOperation::Matrix(m) => { + // See http://dev.w3.org/csswg/css-transforms/#2d-matrix + if m.m31 != 0.0 || m.m32 != 0.0 || + m.m13 != 0.0 || m.m23 != 0.0 || + m.m43 != 0.0 || m.m14 != 0.0 || + m.m24 != 0.0 || m.m34 != 0.0 || + m.m33 != 1.0 || m.m44 != 1.0 { + return true; + } + } + computed_values::transform::ComputedOperation::Translate(_, _, z) => { + if z != Au(0) { + return true; + } + } + _ => {} + } + } + } + + // Neither perspective nor transform present + false + } + % for style_struct in STYLE_STRUCTS: #[inline] pub fn get_${style_struct.name.lower()} |