style: Use rust lengths for border corners.

The test in https://github.com/web-platform-tests/wpt/pull/15423 hasn't been
synced over yet, but it passes with this patch of course.

Differential Revision: https://phabricator.services.mozilla.com/D20960
This commit is contained in:
Emilio Cobos Álvarez 2019-02-24 10:47:53 -08:00
parent aad4dac5b4
commit 197065f6bc
7 changed files with 51 additions and 174 deletions

View file

@ -87,6 +87,16 @@ impl BorderCornerRadius {
}
impl BorderRadius {
/// Returns a `0` border radius.
pub fn zero() -> Self {
Self {
top_left: BorderCornerRadius::zero(),
top_right: BorderCornerRadius::zero(),
bottom_right: BorderCornerRadius::zero(),
bottom_left: BorderCornerRadius::zero(),
}
}
/// Returns whether all the values are `0px`.
pub fn all_zero(&self) -> bool {
fn all(corner: &BorderCornerRadius) -> bool {

View file

@ -53,7 +53,10 @@ pub use self::GenericBorderImageSlice as BorderImageSlice;
ToComputedValue,
ToCss,
)]
pub struct BorderCornerRadius<L>(#[css(field_bound)] pub Size2D<L>);
#[repr(C)]
pub struct GenericBorderCornerRadius<L>(#[css(field_bound)] pub Size2D<L>);
pub use self::GenericBorderCornerRadius as BorderCornerRadius;
impl<L> BorderCornerRadius<L> {
/// Trivially create a `BorderCornerRadius`.
@ -77,6 +80,7 @@ impl<L> BorderCornerRadius<L> {
ToComputedValue,
ToCss,
)]
#[repr(transparent)]
pub struct BorderSpacing<L>(#[css(field_bound)] pub Size2D<L>);
impl<L> BorderSpacing<L> {
@ -101,17 +105,20 @@ impl<L> BorderSpacing<L> {
ToAnimatedValue,
ToComputedValue,
)]
pub struct BorderRadius<LengthPercentage> {
#[repr(C)]
pub struct GenericBorderRadius<LengthPercentage> {
/// The top left radius.
pub top_left: BorderCornerRadius<LengthPercentage>,
pub top_left: GenericBorderCornerRadius<LengthPercentage>,
/// The top right radius.
pub top_right: BorderCornerRadius<LengthPercentage>,
pub top_right: GenericBorderCornerRadius<LengthPercentage>,
/// The bottom right radius.
pub bottom_right: BorderCornerRadius<LengthPercentage>,
pub bottom_right: GenericBorderCornerRadius<LengthPercentage>,
/// The bottom left radius.
pub bottom_left: BorderCornerRadius<LengthPercentage>,
pub bottom_left: GenericBorderCornerRadius<LengthPercentage>,
}
pub use self::GenericBorderRadius as BorderRadius;
impl<L> BorderRadius<L> {
/// Returns a new `BorderRadius<L>`.
#[inline]

View file

@ -25,6 +25,7 @@ use style_traits::{CssWriter, ParseError, ToCss};
ToComputedValue,
)]
#[allow(missing_docs)]
#[repr(C)]
pub struct Size2D<L> {
pub width: L,
pub height: L,