mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Correctly paint the CSS canvas’ background
https://drafts.csswg.org/css-backgrounds/#special-backgrounds Fixes https://github.com/servo/servo/issues/25559 Closes https://github.com/servo/servo/pull/26121, as it is an alternative.
This commit is contained in:
parent
c7acfc37ed
commit
1f6efbf9e9
9 changed files with 312 additions and 37 deletions
|
@ -10,6 +10,7 @@ use style::computed_values::position::T as ComputedPosition;
|
|||
use style::computed_values::transform_style::T as ComputedTransformStyle;
|
||||
use style::properties::longhands::box_sizing::computed_value::T as BoxSizing;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::image::Image as ComputedImageLayer;
|
||||
use style::values::computed::{Length, LengthPercentage};
|
||||
use style::values::computed::{NonNegativeLengthPercentage, Size};
|
||||
use style::values::generics::box_::Perspective;
|
||||
|
@ -88,6 +89,7 @@ pub(crate) trait ComputedValuesExt {
|
|||
fn establishes_stacking_context(&self) -> bool;
|
||||
fn establishes_containing_block(&self) -> bool;
|
||||
fn establishes_containing_block_for_all_descendants(&self) -> bool;
|
||||
fn background_is_transparent(&self) -> bool;
|
||||
}
|
||||
|
||||
impl ComputedValuesExt for ComputedValues {
|
||||
|
@ -361,6 +363,18 @@ impl ComputedValuesExt for ComputedValues {
|
|||
// TODO: We need to handle CSS Contain here.
|
||||
false
|
||||
}
|
||||
|
||||
/// Whether or not this style specifies a non-transparent background.
|
||||
fn background_is_transparent(&self) -> bool {
|
||||
let background = self.get_background();
|
||||
let color = self.resolve_color(background.background_color);
|
||||
color.alpha == 0 &&
|
||||
background
|
||||
.background_image
|
||||
.0
|
||||
.iter()
|
||||
.all(|layer| matches!(layer, ComputedImageLayer::None))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<stylo::Display> for Display {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue