mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Update CSSUnit
This commit is contained in:
parent
75884b8259
commit
cf5b308962
3 changed files with 5 additions and 9 deletions
|
@ -22,11 +22,12 @@ use gfx::display_list::{DisplayList, ImageDisplayItem, ImageDisplayItemClass};
|
|||
use gfx::display_list::{SolidColorDisplayItem, SolidColorDisplayItemClass, TextDisplayItem};
|
||||
use gfx::display_list::{TextDisplayItemClass};
|
||||
use gfx::font::{FontStyle, FontWeight300};
|
||||
use gfx::geometry::{Au, pt_to_px};
|
||||
use gfx::geometry::Au;
|
||||
use gfx::text::text_run::TextRun;
|
||||
use newcss::color::rgb;
|
||||
use newcss::complete::CompleteStyle;
|
||||
use newcss::units::{Cursive, Em, Fantasy, Monospace, Pt, Px, SansSerif, Serif};
|
||||
use newcss::units::{Em, Px};
|
||||
use newcss::units::{Cursive, Fantasy, Monospace, SansSerif, Serif};
|
||||
use newcss::values::{CSSClearNone, CSSClearLeft, CSSClearRight, CSSClearBoth};
|
||||
use newcss::values::{CSSFontFamilyFamilyName, CSSFontFamilyGenericFamily};
|
||||
use newcss::values::{CSSFontSizeLength, CSSFontStyleItalic, CSSFontStyleNormal};
|
||||
|
@ -790,7 +791,6 @@ impl RenderBox {
|
|||
|
||||
let font_size = match my_style.font_size() {
|
||||
CSSFontSizeLength(Px(length)) => length,
|
||||
CSSFontSizeLength(Pt(length)) => pt_to_px(length),
|
||||
// todo: this is based on a hard coded font size, should be the parent element's font size
|
||||
CSSFontSizeLength(Em(length)) => length * 16f,
|
||||
_ => 16f // px units
|
||||
|
|
|
@ -18,7 +18,7 @@ use geom::{Point2D, Rect, Size2D};
|
|||
use gfx::display_list::DisplayList;
|
||||
use gfx::geometry::Au;
|
||||
use newcss::values::{CSSTextAlignLeft, CSSTextAlignCenter, CSSTextAlignRight, CSSTextAlignJustify};
|
||||
use newcss::units::{Em, Px, Pt};
|
||||
use newcss::units::{Em, Px};
|
||||
use newcss::values::{CSSLineHeightNormal, CSSLineHeightNumber, CSSLineHeightLength, CSSLineHeightPercentage};
|
||||
use servo_util::range::Range;
|
||||
use servo_util::tree::TreeNodeRef;
|
||||
|
@ -194,7 +194,6 @@ impl LineboxScanner {
|
|||
CSSLineHeightNumber(l) => em_size.scale_by(l),
|
||||
CSSLineHeightLength(Em(l)) => em_size.scale_by(l),
|
||||
CSSLineHeightLength(Px(l)) => Au::from_frac_px(l),
|
||||
CSSLineHeightLength(Pt(l)) => Au::from_pt(l),
|
||||
CSSLineHeightPercentage(p) => em_size.scale_by(p / 100.0f)
|
||||
};
|
||||
|
||||
|
@ -690,7 +689,6 @@ impl InlineFlowData {
|
|||
CSSLineHeightNumber(l) => em_size.scale_by(l),
|
||||
CSSLineHeightLength(Em(l)) => em_size.scale_by(l),
|
||||
CSSLineHeightLength(Px(l)) => Au::from_frac_px(l),
|
||||
CSSLineHeightLength(Pt(l)) => Au::from_pt(l),
|
||||
CSSLineHeightPercentage(p) => em_size.scale_by(p / 100.0f)
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::num::Zero;
|
|||
use geom::side_offsets::SideOffsets2D;
|
||||
use gfx::geometry::Au;
|
||||
use newcss::complete::CompleteStyle;
|
||||
use newcss::units::{Length, Em, Pt, Px};
|
||||
use newcss::units::{Length, Em, Px};
|
||||
use newcss::values::{CSSBorderWidth, CSSBorderWidthLength, CSSBorderWidthMedium};
|
||||
use newcss::values::{CSSBorderWidthThick, CSSBorderWidthThin, CSSFontSize, CSSFontSizeLength};
|
||||
use newcss::values::{CSSWidth, CSSWidthLength, CSSWidthPercentage, CSSWidthAuto};
|
||||
|
@ -27,11 +27,9 @@ pub struct BoxModel {
|
|||
fn from_length(length: Length, font_size: CSSFontSize) -> Au {
|
||||
match length {
|
||||
Px(v) => Au::from_frac_px(v),
|
||||
Pt(v) => Au::from_pt(v),
|
||||
Em(em) => {
|
||||
match font_size {
|
||||
CSSFontSizeLength(Px(v)) => Au::from_frac_px(em * v),
|
||||
CSSFontSizeLength(Pt(v)) => Au::from_pt(em * v),
|
||||
_ => fail!("expected non-relative font size")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue