mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
Implement support for the drop-shadow
filter (#30439)
* Implement support for `drop-shadow` * Clean up remnant from early attempts * Fix misleading comments on GenericSimpleShadow If Servo-specific `style` changes will need to be upstreamed anyway, I might as well fix a thing that had thrown me off! * Revert "Fix misleading comments on GenericSimpleShadow" This reverts commit cdc810b826ac082041adc212c24649ee3b86ca0a. * Clean up an import * Update test expectations * Fix missing expectation on Layout 2013
This commit is contained in:
parent
8436002383
commit
f7c340f881
23 changed files with 51 additions and 355 deletions
|
@ -17,6 +17,11 @@ pub trait ToLayout {
|
|||
fn to_layout(&self) -> Self::Type;
|
||||
}
|
||||
|
||||
pub trait FilterToLayout {
|
||||
type Type;
|
||||
fn to_layout(&self, current_color: &RGBA) -> Self::Type;
|
||||
}
|
||||
|
||||
impl ToLayout for BorderStyle {
|
||||
type Type = wr::BorderStyle;
|
||||
fn to_layout(&self) -> Self::Type {
|
||||
|
@ -35,9 +40,9 @@ impl ToLayout for BorderStyle {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToLayout for Filter {
|
||||
impl FilterToLayout for Filter {
|
||||
type Type = wr::FilterOp;
|
||||
fn to_layout(&self) -> Self::Type {
|
||||
fn to_layout(&self, current_color: &RGBA) -> Self::Type {
|
||||
match *self {
|
||||
Filter::Blur(radius) => wr::FilterOp::Blur(radius.px(), radius.px()),
|
||||
Filter::Brightness(amount) => wr::FilterOp::Brightness(amount.0),
|
||||
|
@ -48,8 +53,14 @@ impl ToLayout for Filter {
|
|||
Filter::Opacity(amount) => wr::FilterOp::Opacity(amount.0.into(), amount.0),
|
||||
Filter::Saturate(amount) => wr::FilterOp::Saturate(amount.0),
|
||||
Filter::Sepia(amount) => wr::FilterOp::Sepia(amount.0),
|
||||
// Statically check that DropShadow is impossible.
|
||||
Filter::DropShadow(ref shadow) => match *shadow {},
|
||||
Filter::DropShadow(ref shadow) => wr::FilterOp::DropShadow(wr::Shadow {
|
||||
blur_radius: shadow.blur.px(),
|
||||
offset: wr::units::LayoutVector2D::new(
|
||||
shadow.horizontal.px(),
|
||||
shadow.vertical.px(),
|
||||
),
|
||||
color: shadow.color.clone().into_rgba(*current_color).to_layout(),
|
||||
}),
|
||||
// Statically check that Url is impossible.
|
||||
Filter::Url(ref url) => match *url {},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue