mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-29 02:17:45 -10:00
<!-- Please describe your changes on the following line: --> Use the new `ComputedUrl` type for computed types and `SpecifiedUrl` for specified types instead of using the `SpecifiedUrl` implementation for both. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #17625 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because this is an implementation change and tests already exist. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 8a48578a2601769d61ab6f8429e7b1ecb19cbb84
63 lines
2.3 KiB
Rust
63 lines
2.3 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
//! CSS handling for the computed value of
|
|
//! [`basic-shape`][basic-shape]s
|
|
//!
|
|
//! [basic-shape]: https://drafts.csswg.org/css-shapes/#typedef-basic-shape
|
|
|
|
use std::fmt;
|
|
use style_traits::ToCss;
|
|
use values::computed::{LengthOrPercentage, ComputedUrl};
|
|
use values::generics::basic_shape::{BasicShape as GenericBasicShape};
|
|
use values::generics::basic_shape::{Circle as GenericCircle, ClippingShape as GenericClippingShape};
|
|
use values::generics::basic_shape::{Ellipse as GenericEllipse, FloatAreaShape as GenericFloatAreaShape};
|
|
use values::generics::basic_shape::{InsetRect as GenericInsetRect, ShapeRadius as GenericShapeRadius};
|
|
|
|
/// A specified clipping shape.
|
|
pub type ClippingShape = GenericClippingShape<BasicShape, ComputedUrl>;
|
|
|
|
/// A specified float area shape.
|
|
pub type FloatAreaShape = GenericFloatAreaShape<BasicShape, ComputedUrl>;
|
|
|
|
/// A computed basic shape.
|
|
pub type BasicShape = GenericBasicShape<LengthOrPercentage, LengthOrPercentage, LengthOrPercentage>;
|
|
|
|
/// The computed value of `inset()`
|
|
pub type InsetRect = GenericInsetRect<LengthOrPercentage>;
|
|
|
|
/// A computed circle.
|
|
pub type Circle = GenericCircle<LengthOrPercentage, LengthOrPercentage, LengthOrPercentage>;
|
|
|
|
/// A computed ellipse.
|
|
pub type Ellipse = GenericEllipse<LengthOrPercentage, LengthOrPercentage, LengthOrPercentage>;
|
|
|
|
/// The computed value of `ShapeRadius`
|
|
pub type ShapeRadius = GenericShapeRadius<LengthOrPercentage>;
|
|
|
|
impl ToCss for Circle {
|
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
|
dest.write_str("circle(")?;
|
|
self.radius.to_css(dest)?;
|
|
dest.write_str(" at ")?;
|
|
self.position.to_css(dest)?;
|
|
dest.write_str(")")
|
|
}
|
|
}
|
|
|
|
impl ToCss for Ellipse {
|
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
|
dest.write_str("ellipse(")?;
|
|
if (self.semiaxis_x, self.semiaxis_y) != Default::default() {
|
|
self.semiaxis_x.to_css(dest)?;
|
|
dest.write_str(" ")?;
|
|
self.semiaxis_y.to_css(dest)?;
|
|
dest.write_str(" ")?;
|
|
}
|
|
dest.write_str("at ")?;
|
|
self.position.to_css(dest)?;
|
|
dest.write_str(")")
|
|
}
|
|
}
|