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

Impl cm postfix #28

Merged
merged 2 commits into from
Aug 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions computed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -406,7 +406,11 @@ fn convert_net_unit_to_length_or_percent(unit: n::t::CssUnit) -> Either<Length,
match unit {
n::t::CssUnitPx(l) => 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")
}
Expand Down
4 changes: 2 additions & 2 deletions test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
1 change: 0 additions & 1 deletion units.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down