mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #14227 - chenpighead:font-size-adjust-gecko, r=Manishearth
Stylo - gecko glue code for font-size-adjust. <!-- Please describe your changes on the following line: --> Implement the gecko-side glue code for font-size-adjust. This is a followup for #14125, which is originally filed in #13875. --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/14227) <!-- Reviewable:end -->
This commit is contained in:
commit
a4e26d503a
2 changed files with 37 additions and 4 deletions
|
@ -887,7 +887,7 @@ fn static_assert() {
|
|||
</%self:impl_trait>
|
||||
|
||||
<%self:impl_trait style_struct_name="Font"
|
||||
skip_longhands="font-family font-size font-weight font-synthesis"
|
||||
skip_longhands="font-family font-size font-size-adjust font-weight font-synthesis"
|
||||
skip_additionals="*">
|
||||
|
||||
pub fn set_font_family(&mut self, v: longhands::font_family::computed_value::T) {
|
||||
|
@ -974,6 +974,28 @@ fn static_assert() {
|
|||
self.gecko.mFont.synthesis = other.gecko.mFont.synthesis;
|
||||
}
|
||||
|
||||
pub fn set_font_size_adjust(&mut self, v: longhands::font_size_adjust::computed_value::T) {
|
||||
use properties::longhands::font_size_adjust::computed_value::T;
|
||||
match v {
|
||||
T::None => self.gecko.mFont.sizeAdjust = -1.0 as f32,
|
||||
T::Number(n) => self.gecko.mFont.sizeAdjust = n.0 as f32,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn copy_font_size_adjust_from(&mut self, other: &Self) {
|
||||
self.gecko.mFont.sizeAdjust = other.gecko.mFont.sizeAdjust;
|
||||
}
|
||||
|
||||
pub fn clone_font_size_adjust(&self) -> longhands::font_size_adjust::computed_value::T {
|
||||
use properties::longhands::font_size_adjust::computed_value::T;
|
||||
use values::specified::Number;
|
||||
|
||||
match self.gecko.mFont.sizeAdjust {
|
||||
-1.0 => T::None,
|
||||
_ => T::Number(Number(self.gecko.mFont.sizeAdjust)),
|
||||
}
|
||||
}
|
||||
|
||||
</%self:impl_trait>
|
||||
|
||||
<% skip_box_longhands= """display overflow-y vertical-align
|
||||
|
|
|
@ -353,8 +353,7 @@ ${helpers.single_keyword("font-variant",
|
|||
</%helpers:longhand>
|
||||
|
||||
// https://www.w3.org/TR/css-fonts-3/#font-size-adjust-prop
|
||||
// FIXME: This prop should be animatable
|
||||
<%helpers:longhand products="none" name="font-size-adjust" animatable="False">
|
||||
<%helpers:longhand products="gecko" name="font-size-adjust" animatable="True">
|
||||
use values::NoViewportPercentage;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
use values::specified::Number;
|
||||
|
@ -362,7 +361,7 @@ ${helpers.single_keyword("font-variant",
|
|||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub enum SpecifiedValue {
|
||||
None,
|
||||
|
@ -372,6 +371,8 @@ ${helpers.single_keyword("font-variant",
|
|||
pub mod computed_value {
|
||||
use style_traits::ToCss;
|
||||
use std::fmt;
|
||||
use properties::animated_properties::Interpolate;
|
||||
use values::specified::Number;
|
||||
|
||||
pub use super::SpecifiedValue as T;
|
||||
|
||||
|
@ -383,6 +384,16 @@ ${helpers.single_keyword("font-variant",
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Interpolate for T {
|
||||
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
|
||||
match (*self, *other) {
|
||||
(T::Number(ref number), T::Number(ref other)) =>
|
||||
Ok(T::Number(Number(try!(number.0.interpolate(&other.0, time))))),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline] pub fn get_initial_value() -> computed_value::T {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue