mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Rename BorderRadiusSize to BorderCornerSize
This commit is contained in:
parent
af3ede418b
commit
862fc4f88d
12 changed files with 45 additions and 45 deletions
|
@ -14,7 +14,7 @@ use std::fmt;
|
|||
use style::computed_values::transform::ComputedMatrix;
|
||||
use style::logical_geometry::{LogicalMargin, WritingMode};
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::values::computed::{BorderRadiusSize, LengthOrPercentageOrAuto};
|
||||
use style::values::computed::{BorderCornerRadius, LengthOrPercentageOrAuto};
|
||||
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrNone};
|
||||
|
||||
/// 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
|
||||
pub fn specified_border_radius(
|
||||
radius: BorderRadiusSize,
|
||||
radius: BorderCornerRadius,
|
||||
containing_size: Size2D<Au>)
|
||||
-> Size2D<Au>
|
||||
{
|
||||
|
|
|
@ -363,7 +363,7 @@ pub mod basic_shape {
|
|||
use gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue};
|
||||
use std::borrow::Borrow;
|
||||
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::position;
|
||||
use values::generics::basic_shape::{BasicShape as GenericBasicShape, InsetRect, Polygon};
|
||||
|
@ -436,7 +436,7 @@ pub mod basic_shape {
|
|||
fn from(other: T) -> Self {
|
||||
let other = other.borrow();
|
||||
let get_corner = |index| {
|
||||
BorderRadiusSize::new(
|
||||
BorderCornerRadius::new(
|
||||
LengthOrPercentage::from_gecko_style_coord(&other.data_at(index))
|
||||
.expect("<border-radius> should be a length, percentage, or calc value"),
|
||||
LengthOrPercentage::from_gecko_style_coord(&other.data_at(index + 1))
|
||||
|
@ -457,7 +457,7 @@ pub mod basic_shape {
|
|||
impl BorderRadius {
|
||||
/// Set this `BorderRadius` into a given `nsStyleCoord`.
|
||||
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.height.to_gecko_style_coord(&mut other.data_at_mut(index + 1));
|
||||
};
|
||||
|
|
|
@ -558,14 +558,14 @@ fn color_to_nscolor_zero_currentcolor(color: Color) -> structs::nscolor {
|
|||
% if need_clone:
|
||||
#[allow(non_snake_case)]
|
||||
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(
|
||||
&self.gecko.${gecko_ffi_name}.data_at(${x_index}))
|
||||
.expect("Failed to clone ${ident}");
|
||||
let height = GeckoStyleCoordConvertible::from_gecko_style_coord(
|
||||
&self.gecko.${gecko_ffi_name}.data_at(${y_index}))
|
||||
.expect("Failed to clone ${ident}");
|
||||
BorderRadiusSize::new(width, height)
|
||||
BorderCornerRadius::new(width, height)
|
||||
}
|
||||
% endif
|
||||
</%def>
|
||||
|
|
|
@ -39,11 +39,11 @@ use super::ComputedValues;
|
|||
use values::CSSFloat;
|
||||
use values::{Auto, Either};
|
||||
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::{MaxLength, MozLength};
|
||||
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;
|
||||
|
||||
|
||||
|
@ -875,10 +875,10 @@ impl<T: Animatable + Copy> Animatable for Point2D<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Animatable for BorderRadiusSize {
|
||||
impl Animatable for BorderCornerRadius {
|
||||
#[inline]
|
||||
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]
|
||||
|
|
|
@ -46,7 +46,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
|
|||
|
||||
// FIXME(#4126): when gfx supports painting it, make this Size2D<LengthOrPercentage>
|
||||
% 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()",
|
||||
"parse", extra_prefixes="webkit",
|
||||
spec="https://drafts.csswg.org/css-backgrounds/#border-%s-radius" % corner,
|
||||
|
|
|
@ -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.
|
||||
// TODO: Should they animate?
|
||||
% 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()",
|
||||
products="gecko",
|
||||
boxed=True,
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
use values::computed::{Number, NumberOrPercentage};
|
||||
use values::computed::length::LengthOrPercentage;
|
||||
use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
|
||||
use values::generics::border::BorderImageSlice as GenericBorderImageSlice;
|
||||
use values::generics::border::BorderImageWidthSide as GenericBorderImageWidthSide;
|
||||
use values::generics::border::BorderRadius as GenericBorderRadius;
|
||||
use values::generics::border::BorderRadiusSize as GenericBorderRadiusSize;
|
||||
use values::generics::rect::Rect;
|
||||
|
||||
/// A computed value for the `border-image-width` property.
|
||||
|
@ -25,7 +25,7 @@ pub type BorderImageSlice = GenericBorderImageSlice<NumberOrPercentage>;
|
|||
pub type BorderRadius = GenericBorderRadius<LengthOrPercentage>;
|
||||
|
||||
/// A computed value for the `border-*-radius` longhand properties.
|
||||
pub type BorderRadiusSize = GenericBorderRadiusSize<LengthOrPercentage>;
|
||||
pub type BorderCornerRadius = GenericBorderCornerRadius<LengthOrPercentage>;
|
||||
|
||||
impl BorderImageWidthSide {
|
||||
/// Returns `1`.
|
||||
|
|
|
@ -25,7 +25,7 @@ pub use app_units::Au;
|
|||
pub use cssparser::Color as CSSColor;
|
||||
pub use self::background::BackgroundSize;
|
||||
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::rect::LengthOrNumberRect;
|
||||
pub use super::{Auto, Either, None_};
|
||||
|
|
|
@ -38,19 +38,19 @@ pub struct BorderImageSlice<NumberOrPercentage> {
|
|||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue)]
|
||||
pub struct BorderRadius<LengthOrPercentage> {
|
||||
/// The top left radius.
|
||||
pub top_left: BorderRadiusSize<LengthOrPercentage>,
|
||||
pub top_left: BorderCornerRadius<LengthOrPercentage>,
|
||||
/// The top right radius.
|
||||
pub top_right: BorderRadiusSize<LengthOrPercentage>,
|
||||
pub top_right: BorderCornerRadius<LengthOrPercentage>,
|
||||
/// The bottom right radius.
|
||||
pub bottom_right: BorderRadiusSize<LengthOrPercentage>,
|
||||
pub bottom_right: BorderCornerRadius<LengthOrPercentage>,
|
||||
/// The bottom left radius.
|
||||
pub bottom_left: BorderRadiusSize<LengthOrPercentage>,
|
||||
pub bottom_left: BorderCornerRadius<LengthOrPercentage>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue)]
|
||||
/// 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>
|
||||
where L: ToCss, N: ToCss,
|
||||
|
@ -95,10 +95,10 @@ impl<N> ToCss for BorderImageSlice<N>
|
|||
impl<L> BorderRadius<L> {
|
||||
/// Returns a new `BorderRadius<L>`.
|
||||
#[inline]
|
||||
pub fn new(tl: BorderRadiusSize<L>,
|
||||
tr: BorderRadiusSize<L>,
|
||||
br: BorderRadiusSize<L>,
|
||||
bl: BorderRadiusSize<L>)
|
||||
pub fn new(tl: BorderCornerRadius<L>,
|
||||
tr: BorderCornerRadius<L>,
|
||||
br: BorderCornerRadius<L>,
|
||||
bl: BorderCornerRadius<L>)
|
||||
-> Self {
|
||||
BorderRadius {
|
||||
top_left: tl,
|
||||
|
@ -144,21 +144,21 @@ impl<L> ToCss for BorderRadius<L>
|
|||
}
|
||||
}
|
||||
|
||||
impl<L> BorderRadiusSize<L> {
|
||||
impl<L> BorderCornerRadius<L> {
|
||||
#[inline]
|
||||
/// Create a new `BorderRadiusSize` for an area of given width and height.
|
||||
pub fn new(width: L, height: L) -> BorderRadiusSize<L> {
|
||||
BorderRadiusSize(Size2D::new(width, height))
|
||||
/// Create a new `BorderCornerRadius` for an area of given width and height.
|
||||
pub fn new(width: L, height: L) -> BorderCornerRadius<L> {
|
||||
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 {
|
||||
Self::new(radius.clone(), radius)
|
||||
}
|
||||
}
|
||||
|
||||
impl<L> ToCss for BorderRadiusSize<L>
|
||||
impl<L> ToCss for BorderCornerRadius<L>
|
||||
where L: ToCss,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
|
||||
use values::generics::border::BorderImageSlice as GenericBorderImageSlice;
|
||||
use values::generics::border::BorderImageWidthSide as GenericBorderImageWidthSide;
|
||||
use values::generics::border::BorderRadius as GenericBorderRadius;
|
||||
use values::generics::border::BorderRadiusSize as GenericBorderRadiusSize;
|
||||
use values::generics::rect::Rect;
|
||||
use values::specified::{Number, NumberOrPercentage};
|
||||
use values::specified::length::LengthOrPercentage;
|
||||
|
@ -27,7 +27,7 @@ pub type BorderImageSlice = GenericBorderImageSlice<NumberOrPercentage>;
|
|||
pub type BorderRadius = GenericBorderRadius<LengthOrPercentage>;
|
||||
|
||||
/// A specified value for the `border-*-radius` longhand properties.
|
||||
pub type BorderRadiusSize = GenericBorderRadiusSize<LengthOrPercentage>;
|
||||
pub type BorderCornerRadius = GenericBorderCornerRadius<LengthOrPercentage>;
|
||||
|
||||
impl BorderImageWidthSide {
|
||||
/// Returns `1`.
|
||||
|
@ -76,15 +76,15 @@ impl Parse for BorderRadius {
|
|||
};
|
||||
|
||||
Ok(GenericBorderRadius {
|
||||
top_left: BorderRadiusSize::new(widths.0, heights.0),
|
||||
top_right: BorderRadiusSize::new(widths.1, heights.1),
|
||||
bottom_right: BorderRadiusSize::new(widths.2, heights.2),
|
||||
bottom_left: BorderRadiusSize::new(widths.3, heights.3),
|
||||
top_left: BorderCornerRadius::new(widths.0, heights.0),
|
||||
top_right: BorderCornerRadius::new(widths.1, heights.1),
|
||||
bottom_right: BorderCornerRadius::new(widths.2, heights.2),
|
||||
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, ()> {
|
||||
let first = LengthOrPercentage::parse_non_negative(context, input)?;
|
||||
let second = input
|
||||
|
|
|
@ -29,8 +29,8 @@ use values::specified::calc::CalcNode;
|
|||
#[cfg(feature = "gecko")]
|
||||
pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems};
|
||||
pub use self::background::BackgroundSize;
|
||||
pub use self::border::{BorderImageSlice, BorderImageWidth, BorderImageWidthSide};
|
||||
pub use self::border::{BorderRadius, BorderRadiusSize};
|
||||
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
|
||||
pub use self::border::{BorderImageWidthSide, BorderRadius};
|
||||
pub use self::color::Color;
|
||||
pub use self::rect::LengthOrNumberRect;
|
||||
pub use super::generics::grid::GridLine;
|
||||
|
|
|
@ -368,22 +368,22 @@ mod shorthand_serialization {
|
|||
assert_eq!(serialization, "border-style: solid dotted;");
|
||||
}
|
||||
|
||||
use style::values::specified::BorderRadiusSize;
|
||||
use style::values::specified::BorderCornerRadius;
|
||||
use style::values::specified::length::Percentage;
|
||||
|
||||
#[test]
|
||||
fn border_radius_should_serialize_correctly() {
|
||||
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()
|
||||
))));
|
||||
properties.push(PropertyDeclaration::BorderTopRightRadius(Box::new(BorderRadiusSize::new(
|
||||
properties.push(PropertyDeclaration::BorderTopRightRadius(Box::new(BorderCornerRadius::new(
|
||||
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()
|
||||
))));
|
||||
properties.push(PropertyDeclaration::BorderBottomLeftRadius(Box::new(BorderRadiusSize::new(
|
||||
properties.push(PropertyDeclaration::BorderBottomLeftRadius(Box::new(BorderCornerRadius::new(
|
||||
Percentage(0.04).into(), Percentage(0.08).into()
|
||||
))));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue