Add ref test for dashed, dotted, groove, and ridge borders.

Don't line up :'s in render_context.rs (style)
This commit is contained in:
Bryan Bell 2014-05-20 19:36:11 -07:00
parent 792666ec87
commit afe0c0bfa6
5 changed files with 97 additions and 27 deletions

View file

@ -306,9 +306,9 @@ impl<'a> RenderContext<'a> {
}
fn get_scaled_bounds(&self,
bounds : &Rect<Au>,
border : SideOffsets2D<f32>,
shrink_factor : f32) -> (Point2D<f32>, Point2D<f32>, Point2D<f32>, Point2D<f32>) {
bounds: &Rect<Au>,
border: SideOffsets2D<f32>,
shrink_factor: f32) -> (Point2D<f32>, Point2D<f32>, Point2D<f32>, Point2D<f32>) {
let rect = bounds.to_azure_rect();
let scaled_border = SideOffsets2D::new(shrink_factor * border.top,
@ -334,10 +334,10 @@ impl<'a> RenderContext<'a> {
}
fn draw_groove_border_segment(&self,
direction : Direction,
bounds : &Rect<Au>,
border : SideOffsets2D<f32>,
color : Color) {
direction: Direction,
bounds: &Rect<Au>,
border: SideOffsets2D<f32>,
color: Color) {
let rect = bounds.to_azure_rect();
let left_top = Point2D(rect.origin.x, rect.origin.y);
let right_top = Point2D(rect.origin.x + rect.size.width, rect.origin.y);
@ -414,10 +414,10 @@ impl<'a> RenderContext<'a> {
}
fn draw_ridge_border_segment(&self,
direction : Direction,
bounds : &Rect<Au>,
border : SideOffsets2D<f32>,
color : Color) {
direction: Direction,
bounds: &Rect<Au>,
border: SideOffsets2D<f32>,
color: Color) {
let rect = bounds.to_azure_rect();
let left_top = Point2D(rect.origin.x, rect.origin.y);
let right_top = Point2D(rect.origin.x + rect.size.width, rect.origin.y);
@ -536,21 +536,21 @@ impl<'a> RenderContext<'a> {
}
fn draw_short_ended_path(&self,
left_top : Point2D<f32>,
right_top : Point2D<f32>,
left_bottom : Point2D<f32>,
right_bottom : Point2D<f32>,
direction : Direction,
border : SideOffsets2D<f32>,
color : Color,
short_end : ShortEnd) {
left_top: Point2D<f32>,
right_top: Point2D<f32>,
left_bottom: Point2D<f32>,
right_bottom: Point2D<f32>,
direction: Direction,
border: SideOffsets2D<f32>,
color: Color,
short_end: ShortEnd) {
match direction {
Top | Bottom => {
let left_border_short = match short_end { LeftShort | AllShort => { border.left }
_ => { 0.0 }};
let right_border_short = match short_end { RightShort | AllShort => { border.right }
_ => { 0.0 }};
let left_border_short = match short_end { LeftShort | AllShort => border.left,
_ => 0.0 };
let right_border_short = match short_end { RightShort | AllShort => border.right,
_ => 0.0 };
self.draw_square_border_path(left_top + Point2D(left_border_short, 0.0),
right_top + Point2D(-right_border_short, 0.0),
left_bottom + Point2D(left_border_short, 0.0),
@ -563,10 +563,10 @@ impl<'a> RenderContext<'a> {
color);
}
Left | Right => {
let top_border_short = match short_end { TopShort | AllShort => { border.top }
_ => { 0.0 }};
let bottom_border_short = match short_end { BottomShort | AllShort => { border.bottom }
_ => { 0.0 }};
let top_border_short = match short_end { TopShort | AllShort => border.top,
_ => 0.0 };
let bottom_border_short = match short_end { BottomShort | AllShort => border.bottom,
_ => 0.0 };
self.draw_square_border_path(left_top + Point2D(0.0, top_border_short),
right_top + Point2D(0.0, top_border_short),

View file

@ -16,6 +16,7 @@
== root_height_a.html root_height_b.html
== png_rgba_colorspace_a.html png_rgba_colorspace_b.html
== border_style_none_a.html border_style_none_b.html
== borders_a.html borders_b.html
== acid1_a.html acid1_b.html
# text_decoration_propagation_a.html text_decoration_propagation_b.html
# inline_text_align_a.html inline_text_align_b.html

BIN
src/test/ref/borders.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

View file

@ -0,0 +1,50 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<style>
#none{
border-style: none;
border-width: 10px;
border-color: green red yellow black;
}
#hidden{
border-style: hidden;
border-width: 10px;
border-color: green red yellow black;
}
#solid{
border-style: solid;
border-width: 10px;
border-color: yellow green red black;
}
#dashed{
border-style: dashed;
border-width: 10px;
border-color: green yellow black red;
}
#dotted{
border-style: dotted;
border-width: 10px;
border-color: green red yellow black;
}
#groove{
border-style: groove;
border-width: 10px;
border-color: green red yellow black;
}
#ridge{
border-style: ridge;
border-width: 10px;
border-color: green red yellow black;
}
</style>
</head>
<body>
<div id="none"></div>
<div id="hidden"></div>
<div id="dashed"></div>
<div id="dotted"></div>
<div id="groove"></div>
<div id="ridge"></div>
</body>
</HTML>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<style>
html {
margin: 0;
padding: 0;
background-color: white;
border: none;
}
body {
margin: 0;
padding: 0;
border: none;
}
</style>
</head>
<body><img src="borders.png"></body>
</html>