layout: Implement filter per CSS-FILTERS § 5.

`blur` and `drop-shadow` are not yet supported, because the
`text-shadow` PR makes some fundamental changes to blur rendering that
are needed first.
This commit is contained in:
Patrick Walton 2015-01-05 19:22:02 -08:00
parent 6b3c05cdd2
commit 15d60d7ea4
20 changed files with 499 additions and 62 deletions

View file

@ -41,7 +41,7 @@ use std::fmt;
use std::slice::Items;
use std::sync::Arc;
use style::ComputedValues;
use style::computed_values::{border_style, cursor, pointer_events};
use style::computed_values::{border_style, cursor, filter, pointer_events};
// It seems cleaner to have layout code not mention Azure directly, so let's just reexport this for
// layout to use.
@ -163,8 +163,8 @@ pub struct StackingContext {
pub overflow: Rect<Au>,
/// The `z-index` for this stacking context.
pub z_index: i32,
/// The opacity of this stacking context.
pub opacity: AzFloat,
/// CSS filters to be applied to this stacking context (including opacity).
pub filters: filter::T,
}
impl StackingContext {
@ -174,7 +174,7 @@ impl StackingContext {
bounds: &Rect<Au>,
overflow: &Rect<Au>,
z_index: i32,
opacity: AzFloat,
filters: filter::T,
layer: Option<Arc<PaintLayer>>)
-> StackingContext {
StackingContext {
@ -183,7 +183,7 @@ impl StackingContext {
bounds: *bounds,
overflow: *overflow,
z_index: z_index,
opacity: opacity,
filters: filters,
}
}
@ -194,7 +194,7 @@ impl StackingContext {
transform: &Matrix2D<AzFloat>,
clip_rect: Option<&Rect<Au>>) {
let temporary_draw_target =
paint_context.get_or_create_temporary_draw_target(self.opacity);
paint_context.get_or_create_temporary_draw_target(&self.filters);
{
let mut paint_subcontext = PaintContext {
draw_target: temporary_draw_target.clone(),
@ -306,7 +306,8 @@ impl StackingContext {
paint_subcontext.draw_target.set_transform(&old_transform)
}
paint_context.draw_temporary_draw_target_if_necessary(&temporary_draw_target, self.opacity)
paint_context.draw_temporary_draw_target_if_necessary(&temporary_draw_target,
&self.filters)
}
/// Translate the given tile rect into the coordinate system of a child stacking context.