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

Commit 7a06393

Browse files
committed
Update CSSUnit(Pt, Cm, Mm, In, Pc)
1 parent 9ed02f7 commit 7a06393

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
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
}

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)