aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-08-31 02:19:55 -0600
committerbors-servo <metajack+bors@gmail.com>2015-08-31 02:19:55 -0600
commit1093f6bdcf501bec37dc3d422b24c05eea8e1c23 (patch)
treea834f05f5b10755b5ca00ce5acda2efb19ebe97c
parentd46e4a6c4a68ebc87be4b1a7a5fcc5ffbee3c2ab (diff)
parent8ab6bea0f3315ad3964bca8a6c3c7a38f5d64cba (diff)
downloadservo-1093f6bdcf501bec37dc3d422b24c05eea8e1c23.tar.gz
servo-1093f6bdcf501bec37dc3d422b24c05eea8e1c23.zip
Auto merge of #7463 - nox:css-ch, r=SimonSapin
Implement the ch unit as 0.5em <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7463) <!-- Reviewable:end -->
-rw-r--r--components/style/values.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/components/style/values.rs b/components/style/values.rs
index 7e5774d9262..2a5de980ed9 100644
--- a/components/style/values.rs
+++ b/components/style/values.rs
@@ -151,6 +151,7 @@ pub mod specified {
pub enum FontRelativeLength {
Em(CSSFloat),
Ex(CSSFloat),
+ Ch(CSSFloat),
Rem(CSSFloat)
}
@@ -159,6 +160,7 @@ pub mod specified {
match self {
&FontRelativeLength::Em(length) => write!(dest, "{}em", length),
&FontRelativeLength::Ex(length) => write!(dest, "{}ex", length),
+ &FontRelativeLength::Ch(length) => write!(dest, "{}ch", length),
&FontRelativeLength::Rem(length) => write!(dest, "{}rem", length)
}
}
@@ -172,9 +174,10 @@ pub mod specified {
{
match self {
&FontRelativeLength::Em(length) => reference_font_size.scale_by(length),
- &FontRelativeLength::Ex(length) => {
- let x_height = 0.5; // TODO: find that from the font
- reference_font_size.scale_by(length * x_height)
+ &FontRelativeLength::Ex(length) | &FontRelativeLength::Ch(length) => {
+ // https://github.com/servo/servo/issues/7462
+ let em_factor = 0.5;
+ reference_font_size.scale_by(length * em_factor)
},
&FontRelativeLength::Rem(length) => root_font_size.scale_by(length)
}
@@ -284,6 +287,7 @@ pub mod specified {
match self {
FontRelativeLength::Em(v) => FontRelativeLength::Em(v * scalar),
FontRelativeLength::Ex(v) => FontRelativeLength::Ex(v * scalar),
+ FontRelativeLength::Ch(v) => FontRelativeLength::Ch(v * scalar),
FontRelativeLength::Rem(v) => FontRelativeLength::Rem(v * scalar),
}
}
@@ -338,6 +342,7 @@ pub mod specified {
// font-relative
"em" => Ok(Length::FontRelative(FontRelativeLength::Em(value))),
"ex" => Ok(Length::FontRelative(FontRelativeLength::Ex(value))),
+ "ch" => Ok(Length::FontRelative(FontRelativeLength::Ch(value))),
"rem" => Ok(Length::FontRelative(FontRelativeLength::Rem(value))),
// viewport percentages
"vw" => Ok(Length::ViewportPercentage(ViewportPercentageLength::Vw(value))),