Skip to content

Commit

Permalink
Add style field to render them in RenderContext
Browse files Browse the repository at this point in the history
  • Loading branch information
sammykim committed Sep 10, 2013
1 parent 0b0755b commit 03fb29e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
9 changes: 7 additions & 2 deletions src/components/gfx/display_list.rs
Expand Up @@ -16,6 +16,7 @@

use color::Color;
use geometry::Au;
use newcss::values::CSSBorderStyle;
use render_context::RenderContext;
use text::SendableTextRun;

Expand Down Expand Up @@ -103,8 +104,11 @@ pub struct BorderDisplayItem<E> {
/// The border widths
border: SideOffsets2D<Au>,

/// The color of the border.
/// The border colors.
color: SideOffsets2D<Color>,

/// The border styles.
style: SideOffsets2D<CSSBorderStyle>
}

impl<E> DisplayItem<E> {
Expand Down Expand Up @@ -151,7 +155,8 @@ impl<E> DisplayItem<E> {
BorderDisplayItemClass(ref border) => {
render_context.draw_border(&border.base.bounds,
border.border,
border.color)
border.color,
border.style)
}
}
}
Expand Down
27 changes: 16 additions & 11 deletions src/components/main/layout/box.rs
Expand Up @@ -27,6 +27,7 @@ use newcss::color::rgb;
use newcss::complete::CompleteStyle;
use newcss::units::{Em, Px};
use newcss::units::{Cursive, Fantasy, Monospace, SansSerif, Serif};
use newcss::values::{CSSBorderStyleDashed, CSSBorderStyleSolid};
use newcss::values::{CSSClearNone, CSSClearLeft, CSSClearRight, CSSClearBoth};
use newcss::values::{CSSFontFamilyFamilyName, CSSFontFamilyGenericFamily};
use newcss::values::{CSSFontSizeLength, CSSFontStyleItalic, CSSFontStyleNormal};
Expand Down Expand Up @@ -637,7 +638,8 @@ impl RenderBox {
extra: ExtraDisplayListData::new(*self),
},
border: debug_border,
color: SideOffsets2D::new_all_same(rgb(0, 0, 200).to_gfx_color())
color: SideOffsets2D::new_all_same(rgb(0, 0, 200).to_gfx_color()),
style: SideOffsets2D::new_all_same(CSSBorderStyleSolid)

};
list.append_item(BorderDisplayItemClass(border_display_item))
Expand All @@ -658,7 +660,8 @@ impl RenderBox {
extra: ExtraDisplayListData::new(*self),
},
border: debug_border,
color: SideOffsets2D::new_all_same(rgb(0, 200, 0).to_gfx_color())
color: SideOffsets2D::new_all_same(rgb(0, 200, 0).to_gfx_color()),
style: SideOffsets2D::new_all_same(CSSBorderStyleDashed)

};
list.append_item(BorderDisplayItemClass(border_display_item))
Expand All @@ -684,7 +687,8 @@ impl RenderBox {
extra: ExtraDisplayListData::new(*self),
},
border: debug_border,
color: SideOffsets2D::new_all_same(rgb(0, 0, 200).to_gfx_color())
color: SideOffsets2D::new_all_same(rgb(0, 0, 200).to_gfx_color()),
style: SideOffsets2D::new_all_same(CSSBorderStyleSolid)

};
list.append_item(BorderDisplayItemClass(border_display_item))
Expand Down Expand Up @@ -915,11 +919,8 @@ impl RenderBox {
return
}

let top_color = self.style().border_top_color();
let right_color = self.style().border_right_color();
let bottom_color = self.style().border_bottom_color();
let left_color = self.style().border_left_color();

let (top_color, right_color, bottom_color, left_color) = (self.style().border_top_color(), self.style().border_right_color(), self.style().border_bottom_color(), self.style().border_left_color());
let (top_style, right_style, bottom_style, left_style) = (self.style().border_top_style(), self.style().border_right_style(), self.style().border_bottom_style(), self.style().border_left_style());
// Append the border to the display list.
do list.with_mut_ref |list| {
let border_display_item = ~BorderDisplayItem {
Expand All @@ -932,9 +933,13 @@ impl RenderBox {
border.bottom,
border.left),
color: SideOffsets2D::new(top_color.to_gfx_color(),
right_color.to_gfx_color(),
bottom_color.to_gfx_color(),
left_color.to_gfx_color())
right_color.to_gfx_color(),
bottom_color.to_gfx_color(),
left_color.to_gfx_color()),
style: SideOffsets2D::new(top_style,
right_style,
bottom_style,
left_style)
};

list.append_item(BorderDisplayItemClass(border_display_item))
Expand Down

0 comments on commit 03fb29e

Please sign in to comment.