mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
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:
parent
792666ec87
commit
afe0c0bfa6
5 changed files with 97 additions and 27 deletions
|
@ -306,9 +306,9 @@ impl<'a> RenderContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_scaled_bounds(&self,
|
fn get_scaled_bounds(&self,
|
||||||
bounds : &Rect<Au>,
|
bounds: &Rect<Au>,
|
||||||
border : SideOffsets2D<f32>,
|
border: SideOffsets2D<f32>,
|
||||||
shrink_factor : f32) -> (Point2D<f32>, Point2D<f32>, Point2D<f32>, Point2D<f32>) {
|
shrink_factor: f32) -> (Point2D<f32>, Point2D<f32>, Point2D<f32>, Point2D<f32>) {
|
||||||
|
|
||||||
let rect = bounds.to_azure_rect();
|
let rect = bounds.to_azure_rect();
|
||||||
let scaled_border = SideOffsets2D::new(shrink_factor * border.top,
|
let scaled_border = SideOffsets2D::new(shrink_factor * border.top,
|
||||||
|
@ -334,10 +334,10 @@ impl<'a> RenderContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_groove_border_segment(&self,
|
fn draw_groove_border_segment(&self,
|
||||||
direction : Direction,
|
direction: Direction,
|
||||||
bounds : &Rect<Au>,
|
bounds: &Rect<Au>,
|
||||||
border : SideOffsets2D<f32>,
|
border: SideOffsets2D<f32>,
|
||||||
color : Color) {
|
color: Color) {
|
||||||
let rect = bounds.to_azure_rect();
|
let rect = bounds.to_azure_rect();
|
||||||
let left_top = Point2D(rect.origin.x, rect.origin.y);
|
let left_top = Point2D(rect.origin.x, rect.origin.y);
|
||||||
let right_top = Point2D(rect.origin.x + rect.size.width, 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,
|
fn draw_ridge_border_segment(&self,
|
||||||
direction : Direction,
|
direction: Direction,
|
||||||
bounds : &Rect<Au>,
|
bounds: &Rect<Au>,
|
||||||
border : SideOffsets2D<f32>,
|
border: SideOffsets2D<f32>,
|
||||||
color : Color) {
|
color: Color) {
|
||||||
let rect = bounds.to_azure_rect();
|
let rect = bounds.to_azure_rect();
|
||||||
let left_top = Point2D(rect.origin.x, rect.origin.y);
|
let left_top = Point2D(rect.origin.x, rect.origin.y);
|
||||||
let right_top = Point2D(rect.origin.x + rect.size.width, 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,
|
fn draw_short_ended_path(&self,
|
||||||
left_top : Point2D<f32>,
|
left_top: Point2D<f32>,
|
||||||
right_top : Point2D<f32>,
|
right_top: Point2D<f32>,
|
||||||
left_bottom : Point2D<f32>,
|
left_bottom: Point2D<f32>,
|
||||||
right_bottom : Point2D<f32>,
|
right_bottom: Point2D<f32>,
|
||||||
direction : Direction,
|
direction: Direction,
|
||||||
border : SideOffsets2D<f32>,
|
border: SideOffsets2D<f32>,
|
||||||
color : Color,
|
color: Color,
|
||||||
short_end : ShortEnd) {
|
short_end: ShortEnd) {
|
||||||
|
|
||||||
match direction {
|
match direction {
|
||||||
Top | Bottom => {
|
Top | Bottom => {
|
||||||
let left_border_short = match short_end { LeftShort | AllShort => { border.left }
|
let left_border_short = match short_end { LeftShort | AllShort => border.left,
|
||||||
_ => { 0.0 }};
|
_ => 0.0 };
|
||||||
let right_border_short = match short_end { RightShort | AllShort => { border.right }
|
let right_border_short = match short_end { RightShort | AllShort => border.right,
|
||||||
_ => { 0.0 }};
|
_ => 0.0 };
|
||||||
self.draw_square_border_path(left_top + Point2D(left_border_short, 0.0),
|
self.draw_square_border_path(left_top + Point2D(left_border_short, 0.0),
|
||||||
right_top + Point2D(-right_border_short, 0.0),
|
right_top + Point2D(-right_border_short, 0.0),
|
||||||
left_bottom + Point2D(left_border_short, 0.0),
|
left_bottom + Point2D(left_border_short, 0.0),
|
||||||
|
@ -563,10 +563,10 @@ impl<'a> RenderContext<'a> {
|
||||||
color);
|
color);
|
||||||
}
|
}
|
||||||
Left | Right => {
|
Left | Right => {
|
||||||
let top_border_short = match short_end { TopShort | AllShort => { border.top }
|
let top_border_short = match short_end { TopShort | AllShort => border.top,
|
||||||
_ => { 0.0 }};
|
_ => 0.0 };
|
||||||
let bottom_border_short = match short_end { BottomShort | AllShort => { border.bottom }
|
let bottom_border_short = match short_end { BottomShort | AllShort => border.bottom,
|
||||||
_ => { 0.0 }};
|
_ => 0.0 };
|
||||||
|
|
||||||
self.draw_square_border_path(left_top + Point2D(0.0, top_border_short),
|
self.draw_square_border_path(left_top + Point2D(0.0, top_border_short),
|
||||||
right_top + Point2D(0.0, top_border_short),
|
right_top + Point2D(0.0, top_border_short),
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
== root_height_a.html root_height_b.html
|
== root_height_a.html root_height_b.html
|
||||||
== png_rgba_colorspace_a.html png_rgba_colorspace_b.html
|
== png_rgba_colorspace_a.html png_rgba_colorspace_b.html
|
||||||
== border_style_none_a.html border_style_none_b.html
|
== border_style_none_a.html border_style_none_b.html
|
||||||
|
== borders_a.html borders_b.html
|
||||||
== acid1_a.html acid1_b.html
|
== acid1_a.html acid1_b.html
|
||||||
# text_decoration_propagation_a.html text_decoration_propagation_b.html
|
# text_decoration_propagation_a.html text_decoration_propagation_b.html
|
||||||
# inline_text_align_a.html inline_text_align_b.html
|
# inline_text_align_a.html inline_text_align_b.html
|
||||||
|
|
BIN
src/test/ref/borders.png
Normal file
BIN
src/test/ref/borders.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3 KiB |
50
src/test/ref/borders_a.html
Normal file
50
src/test/ref/borders_a.html
Normal 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>
|
19
src/test/ref/borders_b.html
Normal file
19
src/test/ref/borders_b.html
Normal 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>
|
Loading…
Add table
Add a link
Reference in a new issue