From 7a063930b83d272afaa4c3c02f39762d46364a35 Mon Sep 17 00:00:00 2001 From: Youngmin Yoo Date: Mon, 12 Aug 2013 19:18:14 +0900 Subject: [PATCH 1/2] Update CSSUnit(Pt, Cm, Mm, In, Pc) --- computed.rs | 8 ++++++-- units.rs | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/computed.rs b/computed.rs index e4a1fb6..ce70a0a 100644 --- a/computed.rs +++ b/computed.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use color::{Color, rgba}; -use units::{Length, Px, Em, Pt}; +use units::{Length, Px, Em}; use netsurfcss::util::css_fixed_to_float; use std::either::{Either, Left, Right}; use n; @@ -406,7 +406,11 @@ fn convert_net_unit_to_length_or_percent(unit: n::t::CssUnit) -> Either Left(Px(css_fixed_to_float(l))), n::t::CssUnitEm(l) => Left(Em(css_fixed_to_float(l))), - n::t::CssUnitPt(l) => Left(Pt(css_fixed_to_float(l))), + n::t::CssUnitPt(l) => Left(Px(css_fixed_to_float(l) / 72f * 96f)), + n::t::CssUnitCm(l) => Left(Px(css_fixed_to_float(l) / 2.54f * 96f)), + n::t::CssUnitMm(l) => Left(Px(css_fixed_to_float(l) / 25.4f * 96f)), + n::t::CssUnitIn(l) => Left(Px(css_fixed_to_float(l) / 1f * 96f)), + n::t::CssUnitPc(l) => Left(Px(css_fixed_to_float(l) / 6f * 96f)), n::t::CssUnitPct(p) => Right(css_fixed_to_float(p)), _ => unimpl("unit") } diff --git a/units.rs b/units.rs index 3c21e6d..c743ae0 100644 --- a/units.rs +++ b/units.rs @@ -10,7 +10,6 @@ Units used by CSS pub enum Length { Em(float), // normalized to 'em' Px(float), // normalized to 'px' - Pt(float) } impl Length { From f3d537019c416d7ddd089cf52cf01108d989c8d3 Mon Sep 17 00:00:00 2001 From: Youngmin Yoo Date: Mon, 19 Aug 2013 18:34:52 +0900 Subject: [PATCH 2/2] Update testcase --- test.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.rs b/test.rs index 0363304..c8c3f8d 100644 --- a/test.rs +++ b/test.rs @@ -334,9 +334,9 @@ fn test_font_family_specific() { #[test] fn test_font_size() { - let style = "span { font-size: 10pt; }"; + let style = "span { font-size: 10px; }"; do child_test(style) |computed| { - assert!(computed.font_size() == Specified(CSSFontSizeLength(Pt(10.0)))); + assert!(computed.font_size() == Specified(CSSFontSizeLength(Px(10.0)))); } let style = "span { font-size: 10%; }"; do child_test(style) |computed| {