Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAre Border Gradients Sufficiently Expressive? #1875
Comments
|
In particular I don't think the current API (or at least the part of the API that is exposed through wrench YAML) allows us to specify the intrinsic size of the gradient image. For correct rendering of border-image gradients, the following pieces of information are necessary:
|
|
Here's the relevant part of the API: #[repr(C)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct NinePatchDescriptor {
pub width: u32,
pub height: u32,
pub slice: SideOffsets2D<u32>,
}
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct ImageBorder {
pub image_key: ImageKey,
pub patch: NinePatchDescriptor,
/// Controls whether the center of the 9 patch image is
/// rendered or ignored.
pub fill: bool,
pub outset: SideOffsets2D<f32>,
pub repeat_horizontal: RepeatMode,
pub repeat_vertical: RepeatMode,
}
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct GradientBorder {
pub gradient: Gradient,
pub outset: SideOffsets2D<f32>,
}
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct RadialGradientBorder {
pub gradient: RadialGradient,
pub outset: SideOffsets2D<f32>,
}
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum BorderDetails {
Normal(NormalBorder),
Image(ImageBorder),
Gradient(GradientBorder),
RadialGradient(RadialGradientBorder),
}
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct BorderDisplayItem {
pub widths: BorderWidths,
pub details: BorderDetails,
}So pub fill: bool,
pub repeat_horizontal: RepeatMode,
pub repeat_vertical: RepeatMode,And I don't believe the #[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum NinePartBorderSource {
Image(ImageKey),
Gradient(Gradient),
RadialGradient(RadialGradient),
}
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct NinePartBorder {
/// Describes what to use as the 9-part source image. If this is an image,
/// it will be stretched to fill the size given by width x height. If this
/// is a type of gradient, the 9-part source image is obtained by rendering
/// the gradient into a conceptual surface of dimensions width x height.
pub source: NinePartBorderSource,
/// The width of the 9-part image.
pub width: u32,
/// The height of the 9-part image.
pub height: u32,
/// Distances from each edge where the image should be sliced up. These
/// values are in 9-part-image space (the same space as width and height),
/// and the resulting image parts will be used to fill the corresponding
/// parts of the border as given by the border widths. This can lead to
/// stretching.
/// Slices can be overlapping. In that case, the same pixels from the
/// 9-part image will show up in multiple parts of the resulting border.
pub slice: SideOffsets2D<u32>,
/// Controls whether the center of the 9 patch image is rendered or
/// ignored. The center is never rendered if the slices are overlapping.
pub fill: bool,
/// Determines what happens if the horizontal side parts of the 9-part
/// image have a different size than the horizontal parts of the border.
pub repeat_horizontal: RepeatMode,
/// Determines what happens if the vertical side parts of the 9-part
/// image have a different size than the vertical parts of the border.
pub repeat_vertical: RepeatMode,
}
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum BorderDetails {
Normal(NormalBorder),
NinePart(NinePartBorder),
}
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct BorderDisplayItem {
pub widths: BorderWidths,
pub details: BorderDetails,
} |
|
Thanks for doing that detailed write up, sounds good! |
This is a preparatory patch to add support for nine-patch like functionality to border gradients. The new API is based on mstage's proposed API from servo#1875.
This is a preparatory patch to add support for nine-patch like functionality to border gradients. The new API is based on mstage's proposed API from servo#1875.
…e-patch-technology, r=Ganko Make border image API more general This is a preparatory patch to add support for nine-patch like functionality to border gradients. The new API is based on mstage's proposed API from #1875. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2724) <!-- Reviewable:end -->
This will allow border-gradients to support the full richness of the CSS API. There are some areas where the implementation doesn't match what CSS expects, but this should move us a good deal closer. We can gradually fix those issues and turn this on in Gecko. Fixes servo#1875.
This will allow border-gradients to support the full richness of the CSS API. There are some areas where the implementation doesn't match what CSS expects, but this should move us a good deal closer. We can gradually fix those issues and turn this on in Gecko. Fixes servo#1875.
Implement nine patch support for border gradients This will allow border-gradients to support the full richness of the CSS API. There are some areas where the implementation doesn't match what CSS expects, but this should move us a good deal closer. We can gradually fix those issues and turn this on in Gecko. Fixes #1875. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2848) <!-- Reviewable:end -->
This will allow border-gradients to support the full richness of the CSS API. There are some areas where the implementation doesn't match what CSS expects, but this should move us a good deal closer. We can gradually fix those issues and turn this on in Gecko. Fixes servo#1875.
I'm still taking this all in, but here's a weird case that @mstange believes can't be captured with the arguments we pass to wr: