mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Auto merge of #19529 - DonatJR:counter-reset-out-of-mako, r=emilio
style: moved css longhand counter-reset out of mako <!-- Please describe your changes on the following line: --> This is a sub-PR of #19015 Code does not yet compile with `build-geckolib`. r? emilio --- <!-- 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 #19387 <!-- Either: --> - [x] These changes do not require tests <!-- 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19529) <!-- Reviewable:end -->
This commit is contained in:
commit
38ef515463
11 changed files with 240 additions and 151 deletions
80
components/style/values/computed/counters.rs
Normal file
80
components/style/values/computed/counters.rs
Normal file
|
@ -0,0 +1,80 @@
|
|||
/* 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/. */
|
||||
|
||||
//! Computed values for counter properties
|
||||
|
||||
use values::CustomIdent;
|
||||
use values::computed::{Context, ToComputedValue};
|
||||
use values::generics::counters::CounterIntegerList;
|
||||
use values::specified::{CounterIncrement as SpecifiedCounterIncrement, CounterReset as SpecifiedCounterReset};
|
||||
|
||||
type ComputedIntegerList = CounterIntegerList<i32>;
|
||||
|
||||
/// A computed value for the `counter-increment` property.
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
|
||||
pub struct CounterIncrement(pub ComputedIntegerList);
|
||||
|
||||
impl CounterIncrement {
|
||||
/// Returns the `none` value.
|
||||
#[inline]
|
||||
pub fn none() -> CounterIncrement {
|
||||
CounterIncrement(ComputedIntegerList::new(Vec::new()))
|
||||
}
|
||||
|
||||
/// Returns a new computed `counter-increment` object with the given values.
|
||||
pub fn new(vec: Vec<(CustomIdent, i32)>) -> CounterIncrement {
|
||||
CounterIncrement(ComputedIntegerList::new(vec))
|
||||
}
|
||||
|
||||
/// Returns the values of the computed `counter-increment` object.
|
||||
pub fn get_values(&self) -> &[(CustomIdent, i32)] {
|
||||
self.0.get_values()
|
||||
}
|
||||
}
|
||||
|
||||
impl ToComputedValue for SpecifiedCounterIncrement {
|
||||
type ComputedValue = CounterIncrement;
|
||||
|
||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||
CounterIncrement(self.0.to_computed_value(context))
|
||||
}
|
||||
|
||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||
SpecifiedCounterIncrement(ToComputedValue::from_computed_value(&computed.0))
|
||||
}
|
||||
}
|
||||
|
||||
/// A computed value for the `counter-reset` property.
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
|
||||
pub struct CounterReset(pub ComputedIntegerList);
|
||||
|
||||
impl CounterReset {
|
||||
/// Returns the `none` value.
|
||||
#[inline]
|
||||
pub fn none() -> CounterReset {
|
||||
CounterReset(ComputedIntegerList::new(Vec::new()))
|
||||
}
|
||||
|
||||
/// Returns a new computed `counter-reset` object with the given values.
|
||||
pub fn new(vec: Vec<(CustomIdent, i32)>) -> CounterReset {
|
||||
CounterReset(ComputedIntegerList::new(vec))
|
||||
}
|
||||
|
||||
/// Returns the values of the computed `counter-reset` object.
|
||||
pub fn get_values(&self) -> &[(CustomIdent, i32)] {
|
||||
self.0.get_values()
|
||||
}
|
||||
}
|
||||
|
||||
impl ToComputedValue for SpecifiedCounterReset {
|
||||
type ComputedValue = CounterReset;
|
||||
|
||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||
CounterReset(self.0.to_computed_value(context))
|
||||
}
|
||||
|
||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||
SpecifiedCounterReset(ToComputedValue::from_computed_value(&computed.0))
|
||||
}
|
||||
}
|
|
@ -46,6 +46,7 @@ pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier,
|
|||
pub use self::box_::{AnimationIterationCount, AnimationName, Display, OverscrollBehavior, Contain};
|
||||
pub use self::box_::{OverflowClipBox, ScrollSnapType, TouchAction, VerticalAlign, WillChange};
|
||||
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
|
||||
pub use self::counters::{CounterIncrement, CounterReset};
|
||||
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
|
||||
pub use self::flex::FlexBasis;
|
||||
pub use self::image::{Gradient, GradientItem, Image, ImageLayer, LineDirection, MozImageRect};
|
||||
|
@ -86,6 +87,7 @@ pub mod border;
|
|||
#[path = "box.rs"]
|
||||
pub mod box_;
|
||||
pub mod color;
|
||||
pub mod counters;
|
||||
pub mod effects;
|
||||
pub mod flex;
|
||||
pub mod font;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue