Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit f02576d

Browse files
committed
Merge pull request #28 from recrack/length_postfix
Impl cm postfix
2 parents 9ed02f7 + f3d5370 commit f02576d

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

computed.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
use color::{Color, rgba};
6-
use units::{Length, Px, Em, Pt};
6+
use units::{Length, Px, Em};
77
use netsurfcss::util::css_fixed_to_float;
88
use std::either::{Either, Left, Right};
99
use n;
@@ -406,7 +406,11 @@ fn convert_net_unit_to_length_or_percent(unit: n::t::CssUnit) -> Either<Length,
406406
match unit {
407407
n::t::CssUnitPx(l) => Left(Px(css_fixed_to_float(l))),
408408
n::t::CssUnitEm(l) => Left(Em(css_fixed_to_float(l))),
409-
n::t::CssUnitPt(l) => Left(Pt(css_fixed_to_float(l))),
409+
n::t::CssUnitPt(l) => Left(Px(css_fixed_to_float(l) / 72f * 96f)),
410+
n::t::CssUnitCm(l) => Left(Px(css_fixed_to_float(l) / 2.54f * 96f)),
411+
n::t::CssUnitMm(l) => Left(Px(css_fixed_to_float(l) / 25.4f * 96f)),
412+
n::t::CssUnitIn(l) => Left(Px(css_fixed_to_float(l) / 1f * 96f)),
413+
n::t::CssUnitPc(l) => Left(Px(css_fixed_to_float(l) / 6f * 96f)),
410414
n::t::CssUnitPct(p) => Right(css_fixed_to_float(p)),
411415
_ => unimpl("unit")
412416
}

test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,9 @@ fn test_font_family_specific() {
334334
335335
#[test]
336336
fn test_font_size() {
337-
let style = "span { font-size: 10pt; }";
337+
let style = "span { font-size: 10px; }";
338338
do child_test(style) |computed| {
339-
assert!(computed.font_size() == Specified(CSSFontSizeLength(Pt(10.0))));
339+
assert!(computed.font_size() == Specified(CSSFontSizeLength(Px(10.0))));
340340
}
341341
let style = "span { font-size: 10%; }";
342342
do child_test(style) |computed| {

units.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Units used by CSS
1010
pub enum Length {
1111
Em(float), // normalized to 'em'
1212
Px(float), // normalized to 'px'
13-
Pt(float)
1413
}
1514

1615
impl Length {

0 commit comments

Comments
 (0)