Skip to content

Commit

Permalink
Auto merge of #14227 - chenpighead:font-size-adjust-gecko, r=Manishearth
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
bors-servo committed Nov 18, 2016
2 parents cc06363 + 32bf5ab commit 11d9c2c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
24 changes: 23 additions & 1 deletion components/style/properties/gecko.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions components/style/properties/longhand/font.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,15 @@ ${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;

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,
Expand All @@ -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;

Expand All @@ -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 {
Expand Down

0 comments on commit 11d9c2c

Please sign in to comment.