Rename BorderRadiusSize to BorderCornerSize

This commit is contained in:
Anthony Ramine 2017-05-29 00:57:46 +02:00
parent af3ede418b
commit 862fc4f88d
12 changed files with 45 additions and 45 deletions

View file

@ -14,7 +14,7 @@ use std::fmt;
use style::computed_values::transform::ComputedMatrix; use style::computed_values::transform::ComputedMatrix;
use style::logical_geometry::{LogicalMargin, WritingMode}; use style::logical_geometry::{LogicalMargin, WritingMode};
use style::properties::ServoComputedValues; use style::properties::ServoComputedValues;
use style::values::computed::{BorderRadiusSize, LengthOrPercentageOrAuto}; use style::values::computed::{BorderCornerRadius, LengthOrPercentageOrAuto};
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrNone}; use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrNone};
/// A collapsible margin. See CSS 2.1 § 8.3.1. /// A collapsible margin. See CSS 2.1 § 8.3.1.
@ -471,7 +471,7 @@ pub fn style_length(style_length: LengthOrPercentageOrAuto,
/// ///
/// [1]: https://drafts.csswg.org/css-backgrounds-3/#border-radius /// [1]: https://drafts.csswg.org/css-backgrounds-3/#border-radius
pub fn specified_border_radius( pub fn specified_border_radius(
radius: BorderRadiusSize, radius: BorderCornerRadius,
containing_size: Size2D<Au>) containing_size: Size2D<Au>)
-> Size2D<Au> -> Size2D<Au>
{ {

View file

@ -363,7 +363,7 @@ pub mod basic_shape {
use gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue}; use gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue};
use std::borrow::Borrow; use std::borrow::Borrow;
use values::computed::basic_shape::{BasicShape, ShapeRadius}; use values::computed::basic_shape::{BasicShape, ShapeRadius};
use values::computed::border::{BorderRadius, BorderRadiusSize}; use values::computed::border::{BorderCornerRadius, BorderRadius};
use values::computed::length::LengthOrPercentage; use values::computed::length::LengthOrPercentage;
use values::computed::position; use values::computed::position;
use values::generics::basic_shape::{BasicShape as GenericBasicShape, InsetRect, Polygon}; use values::generics::basic_shape::{BasicShape as GenericBasicShape, InsetRect, Polygon};
@ -436,7 +436,7 @@ pub mod basic_shape {
fn from(other: T) -> Self { fn from(other: T) -> Self {
let other = other.borrow(); let other = other.borrow();
let get_corner = |index| { let get_corner = |index| {
BorderRadiusSize::new( BorderCornerRadius::new(
LengthOrPercentage::from_gecko_style_coord(&other.data_at(index)) LengthOrPercentage::from_gecko_style_coord(&other.data_at(index))
.expect("<border-radius> should be a length, percentage, or calc value"), .expect("<border-radius> should be a length, percentage, or calc value"),
LengthOrPercentage::from_gecko_style_coord(&other.data_at(index + 1)) LengthOrPercentage::from_gecko_style_coord(&other.data_at(index + 1))
@ -457,7 +457,7 @@ pub mod basic_shape {
impl BorderRadius { impl BorderRadius {
/// Set this `BorderRadius` into a given `nsStyleCoord`. /// Set this `BorderRadius` into a given `nsStyleCoord`.
pub fn set_corners(&self, other: &mut nsStyleCorners) { pub fn set_corners(&self, other: &mut nsStyleCorners) {
let mut set_corner = |field: &BorderRadiusSize, index| { let mut set_corner = |field: &BorderCornerRadius, index| {
field.0.width.to_gecko_style_coord(&mut other.data_at_mut(index)); field.0.width.to_gecko_style_coord(&mut other.data_at_mut(index));
field.0.height.to_gecko_style_coord(&mut other.data_at_mut(index + 1)); field.0.height.to_gecko_style_coord(&mut other.data_at_mut(index + 1));
}; };

View file

@ -558,14 +558,14 @@ fn color_to_nscolor_zero_currentcolor(color: Color) -> structs::nscolor {
% if need_clone: % if need_clone:
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
use values::computed::border::BorderRadiusSize; use values::computed::border::BorderCornerRadius;
let width = GeckoStyleCoordConvertible::from_gecko_style_coord( let width = GeckoStyleCoordConvertible::from_gecko_style_coord(
&self.gecko.${gecko_ffi_name}.data_at(${x_index})) &self.gecko.${gecko_ffi_name}.data_at(${x_index}))
.expect("Failed to clone ${ident}"); .expect("Failed to clone ${ident}");
let height = GeckoStyleCoordConvertible::from_gecko_style_coord( let height = GeckoStyleCoordConvertible::from_gecko_style_coord(
&self.gecko.${gecko_ffi_name}.data_at(${y_index})) &self.gecko.${gecko_ffi_name}.data_at(${y_index}))
.expect("Failed to clone ${ident}"); .expect("Failed to clone ${ident}");
BorderRadiusSize::new(width, height) BorderCornerRadius::new(width, height)
} }
% endif % endif
</%def> </%def>

View file

@ -39,11 +39,11 @@ use super::ComputedValues;
use values::CSSFloat; use values::CSSFloat;
use values::{Auto, Either}; use values::{Auto, Either};
use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
use values::computed::{BorderRadiusSize, ClipRect}; use values::computed::{BorderCornerRadius, ClipRect};
use values::computed::{CalcLengthOrPercentage, Context, LengthOrPercentage}; use values::computed::{CalcLengthOrPercentage, Context, LengthOrPercentage};
use values::computed::{MaxLength, MozLength}; use values::computed::{MaxLength, MozLength};
use values::computed::ToComputedValue; use values::computed::ToComputedValue;
use values::generics::border::BorderRadiusSize as GenericBorderRadiusSize; use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
use values::generics::position as generic_position; use values::generics::position as generic_position;
@ -875,10 +875,10 @@ impl<T: Animatable + Copy> Animatable for Point2D<T> {
} }
} }
impl Animatable for BorderRadiusSize { impl Animatable for BorderCornerRadius {
#[inline] #[inline]
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64) -> Result<Self, ()> { fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64) -> Result<Self, ()> {
self.0.add_weighted(&other.0, self_portion, other_portion).map(GenericBorderRadiusSize) self.0.add_weighted(&other.0, self_portion, other_portion).map(GenericBorderCornerRadius)
} }
#[inline] #[inline]

View file

@ -46,7 +46,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
// FIXME(#4126): when gfx supports painting it, make this Size2D<LengthOrPercentage> // FIXME(#4126): when gfx supports painting it, make this Size2D<LengthOrPercentage>
% for corner in ["top-left", "top-right", "bottom-right", "bottom-left"]: % for corner in ["top-left", "top-right", "bottom-right", "bottom-left"]:
${helpers.predefined_type("border-" + corner + "-radius", "BorderRadiusSize", ${helpers.predefined_type("border-" + corner + "-radius", "BorderCornerRadius",
"computed::LengthOrPercentage::zero().into()", "computed::LengthOrPercentage::zero().into()",
"parse", extra_prefixes="webkit", "parse", extra_prefixes="webkit",
spec="https://drafts.csswg.org/css-backgrounds/#border-%s-radius" % corner, spec="https://drafts.csswg.org/css-backgrounds/#border-%s-radius" % corner,

View file

@ -108,7 +108,7 @@ ${helpers.predefined_type("outline-color", "CSSColor", "computed::CSSColor::Curr
// The -moz-outline-radius-* properties are non-standard and not on a standards track. // The -moz-outline-radius-* properties are non-standard and not on a standards track.
// TODO: Should they animate? // TODO: Should they animate?
% for corner in ["topleft", "topright", "bottomright", "bottomleft"]: % for corner in ["topleft", "topright", "bottomright", "bottomleft"]:
${helpers.predefined_type("-moz-outline-radius-" + corner, "BorderRadiusSize", ${helpers.predefined_type("-moz-outline-radius-" + corner, "BorderCornerRadius",
"computed::LengthOrPercentage::zero().into()", "computed::LengthOrPercentage::zero().into()",
products="gecko", products="gecko",
boxed=True, boxed=True,

View file

@ -6,10 +6,10 @@
use values::computed::{Number, NumberOrPercentage}; use values::computed::{Number, NumberOrPercentage};
use values::computed::length::LengthOrPercentage; use values::computed::length::LengthOrPercentage;
use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
use values::generics::border::BorderImageSlice as GenericBorderImageSlice; use values::generics::border::BorderImageSlice as GenericBorderImageSlice;
use values::generics::border::BorderImageWidthSide as GenericBorderImageWidthSide; use values::generics::border::BorderImageWidthSide as GenericBorderImageWidthSide;
use values::generics::border::BorderRadius as GenericBorderRadius; use values::generics::border::BorderRadius as GenericBorderRadius;
use values::generics::border::BorderRadiusSize as GenericBorderRadiusSize;
use values::generics::rect::Rect; use values::generics::rect::Rect;
/// A computed value for the `border-image-width` property. /// A computed value for the `border-image-width` property.
@ -25,7 +25,7 @@ pub type BorderImageSlice = GenericBorderImageSlice<NumberOrPercentage>;
pub type BorderRadius = GenericBorderRadius<LengthOrPercentage>; pub type BorderRadius = GenericBorderRadius<LengthOrPercentage>;
/// A computed value for the `border-*-radius` longhand properties. /// A computed value for the `border-*-radius` longhand properties.
pub type BorderRadiusSize = GenericBorderRadiusSize<LengthOrPercentage>; pub type BorderCornerRadius = GenericBorderCornerRadius<LengthOrPercentage>;
impl BorderImageWidthSide { impl BorderImageWidthSide {
/// Returns `1`. /// Returns `1`.

View file

@ -25,7 +25,7 @@ pub use app_units::Au;
pub use cssparser::Color as CSSColor; pub use cssparser::Color as CSSColor;
pub use self::background::BackgroundSize; pub use self::background::BackgroundSize;
pub use self::border::{BorderImageSlice, BorderImageWidth, BorderImageWidthSide}; pub use self::border::{BorderImageSlice, BorderImageWidth, BorderImageWidthSide};
pub use self::border::{BorderRadius, BorderRadiusSize}; pub use self::border::{BorderRadius, BorderCornerRadius};
pub use self::image::{Gradient, GradientItem, ImageLayer, LineDirection, Image, ImageRect}; pub use self::image::{Gradient, GradientItem, ImageLayer, LineDirection, Image, ImageRect};
pub use self::rect::LengthOrNumberRect; pub use self::rect::LengthOrNumberRect;
pub use super::{Auto, Either, None_}; pub use super::{Auto, Either, None_};

View file

@ -38,19 +38,19 @@ pub struct BorderImageSlice<NumberOrPercentage> {
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue)] #[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue)]
pub struct BorderRadius<LengthOrPercentage> { pub struct BorderRadius<LengthOrPercentage> {
/// The top left radius. /// The top left radius.
pub top_left: BorderRadiusSize<LengthOrPercentage>, pub top_left: BorderCornerRadius<LengthOrPercentage>,
/// The top right radius. /// The top right radius.
pub top_right: BorderRadiusSize<LengthOrPercentage>, pub top_right: BorderCornerRadius<LengthOrPercentage>,
/// The bottom right radius. /// The bottom right radius.
pub bottom_right: BorderRadiusSize<LengthOrPercentage>, pub bottom_right: BorderCornerRadius<LengthOrPercentage>,
/// The bottom left radius. /// The bottom left radius.
pub bottom_left: BorderRadiusSize<LengthOrPercentage>, pub bottom_left: BorderCornerRadius<LengthOrPercentage>,
} }
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue)] #[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue)]
/// A generic value for `border-*-radius` longhand properties. /// A generic value for `border-*-radius` longhand properties.
pub struct BorderRadiusSize<L>(pub Size2D<L>); pub struct BorderCornerRadius<L>(pub Size2D<L>);
impl<L, N> ToCss for BorderImageWidthSide<L, N> impl<L, N> ToCss for BorderImageWidthSide<L, N>
where L: ToCss, N: ToCss, where L: ToCss, N: ToCss,
@ -95,10 +95,10 @@ impl<N> ToCss for BorderImageSlice<N>
impl<L> BorderRadius<L> { impl<L> BorderRadius<L> {
/// Returns a new `BorderRadius<L>`. /// Returns a new `BorderRadius<L>`.
#[inline] #[inline]
pub fn new(tl: BorderRadiusSize<L>, pub fn new(tl: BorderCornerRadius<L>,
tr: BorderRadiusSize<L>, tr: BorderCornerRadius<L>,
br: BorderRadiusSize<L>, br: BorderCornerRadius<L>,
bl: BorderRadiusSize<L>) bl: BorderCornerRadius<L>)
-> Self { -> Self {
BorderRadius { BorderRadius {
top_left: tl, top_left: tl,
@ -144,21 +144,21 @@ impl<L> ToCss for BorderRadius<L>
} }
} }
impl<L> BorderRadiusSize<L> { impl<L> BorderCornerRadius<L> {
#[inline] #[inline]
/// Create a new `BorderRadiusSize` for an area of given width and height. /// Create a new `BorderCornerRadius` for an area of given width and height.
pub fn new(width: L, height: L) -> BorderRadiusSize<L> { pub fn new(width: L, height: L) -> BorderCornerRadius<L> {
BorderRadiusSize(Size2D::new(width, height)) BorderCornerRadius(Size2D::new(width, height))
} }
} }
impl<L: Clone> From<L> for BorderRadiusSize<L> { impl<L: Clone> From<L> for BorderCornerRadius<L> {
fn from(radius: L) -> Self { fn from(radius: L) -> Self {
Self::new(radius.clone(), radius) Self::new(radius.clone(), radius)
} }
} }
impl<L> ToCss for BorderRadiusSize<L> impl<L> ToCss for BorderCornerRadius<L>
where L: ToCss, where L: ToCss,
{ {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result fn to_css<W>(&self, dest: &mut W) -> fmt::Result

View file

@ -6,10 +6,10 @@
use cssparser::Parser; use cssparser::Parser;
use parser::{Parse, ParserContext}; use parser::{Parse, ParserContext};
use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
use values::generics::border::BorderImageSlice as GenericBorderImageSlice; use values::generics::border::BorderImageSlice as GenericBorderImageSlice;
use values::generics::border::BorderImageWidthSide as GenericBorderImageWidthSide; use values::generics::border::BorderImageWidthSide as GenericBorderImageWidthSide;
use values::generics::border::BorderRadius as GenericBorderRadius; use values::generics::border::BorderRadius as GenericBorderRadius;
use values::generics::border::BorderRadiusSize as GenericBorderRadiusSize;
use values::generics::rect::Rect; use values::generics::rect::Rect;
use values::specified::{Number, NumberOrPercentage}; use values::specified::{Number, NumberOrPercentage};
use values::specified::length::LengthOrPercentage; use values::specified::length::LengthOrPercentage;
@ -27,7 +27,7 @@ pub type BorderImageSlice = GenericBorderImageSlice<NumberOrPercentage>;
pub type BorderRadius = GenericBorderRadius<LengthOrPercentage>; pub type BorderRadius = GenericBorderRadius<LengthOrPercentage>;
/// A specified value for the `border-*-radius` longhand properties. /// A specified value for the `border-*-radius` longhand properties.
pub type BorderRadiusSize = GenericBorderRadiusSize<LengthOrPercentage>; pub type BorderCornerRadius = GenericBorderCornerRadius<LengthOrPercentage>;
impl BorderImageWidthSide { impl BorderImageWidthSide {
/// Returns `1`. /// Returns `1`.
@ -76,15 +76,15 @@ impl Parse for BorderRadius {
}; };
Ok(GenericBorderRadius { Ok(GenericBorderRadius {
top_left: BorderRadiusSize::new(widths.0, heights.0), top_left: BorderCornerRadius::new(widths.0, heights.0),
top_right: BorderRadiusSize::new(widths.1, heights.1), top_right: BorderCornerRadius::new(widths.1, heights.1),
bottom_right: BorderRadiusSize::new(widths.2, heights.2), bottom_right: BorderCornerRadius::new(widths.2, heights.2),
bottom_left: BorderRadiusSize::new(widths.3, heights.3), bottom_left: BorderCornerRadius::new(widths.3, heights.3),
}) })
} }
} }
impl Parse for BorderRadiusSize { impl Parse for BorderCornerRadius {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> { fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
let first = LengthOrPercentage::parse_non_negative(context, input)?; let first = LengthOrPercentage::parse_non_negative(context, input)?;
let second = input let second = input

View file

@ -29,8 +29,8 @@ use values::specified::calc::CalcNode;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems}; pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems};
pub use self::background::BackgroundSize; pub use self::background::BackgroundSize;
pub use self::border::{BorderImageSlice, BorderImageWidth, BorderImageWidthSide}; pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
pub use self::border::{BorderRadius, BorderRadiusSize}; pub use self::border::{BorderImageWidthSide, BorderRadius};
pub use self::color::Color; pub use self::color::Color;
pub use self::rect::LengthOrNumberRect; pub use self::rect::LengthOrNumberRect;
pub use super::generics::grid::GridLine; pub use super::generics::grid::GridLine;

View file

@ -368,22 +368,22 @@ mod shorthand_serialization {
assert_eq!(serialization, "border-style: solid dotted;"); assert_eq!(serialization, "border-style: solid dotted;");
} }
use style::values::specified::BorderRadiusSize; use style::values::specified::BorderCornerRadius;
use style::values::specified::length::Percentage; use style::values::specified::length::Percentage;
#[test] #[test]
fn border_radius_should_serialize_correctly() { fn border_radius_should_serialize_correctly() {
let mut properties = Vec::new(); let mut properties = Vec::new();
properties.push(PropertyDeclaration::BorderTopLeftRadius(Box::new(BorderRadiusSize::new( properties.push(PropertyDeclaration::BorderTopLeftRadius(Box::new(BorderCornerRadius::new(
Percentage(0.01).into(), Percentage(0.05).into() Percentage(0.01).into(), Percentage(0.05).into()
)))); ))));
properties.push(PropertyDeclaration::BorderTopRightRadius(Box::new(BorderRadiusSize::new( properties.push(PropertyDeclaration::BorderTopRightRadius(Box::new(BorderCornerRadius::new(
Percentage(0.02).into(), Percentage(0.06).into() Percentage(0.02).into(), Percentage(0.06).into()
)))); ))));
properties.push(PropertyDeclaration::BorderBottomRightRadius(Box::new(BorderRadiusSize::new( properties.push(PropertyDeclaration::BorderBottomRightRadius(Box::new(BorderCornerRadius::new(
Percentage(0.03).into(), Percentage(0.07).into() Percentage(0.03).into(), Percentage(0.07).into()
)))); ))));
properties.push(PropertyDeclaration::BorderBottomLeftRadius(Box::new(BorderRadiusSize::new( properties.push(PropertyDeclaration::BorderBottomLeftRadius(Box::new(BorderCornerRadius::new(
Percentage(0.04).into(), Percentage(0.08).into() Percentage(0.04).into(), Percentage(0.08).into()
)))); ))));