diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs index 499cdf1397e..23d54fdf1cb 100644 --- a/components/gfx/paint_context.rs +++ b/components/gfx/paint_context.rs @@ -598,10 +598,22 @@ impl<'a> PaintContext<'a> { border_style::ridge => false, _ => panic!("invalid border style") }; - let darker_color = self.scale_color(color, if is_groove { 1.0/3.0 } else { 2.0/3.0 }); + + let mut lighter_color; + let mut darker_color; + + if color.r != 0.0 || color.g != 0.0 || color.b != 0.0 { + darker_color = self.scale_color(color, if is_groove { 1.0/3.0 } else { 2.0/3.0 }); + lighter_color = color; + } else { + // You can't scale black color (i.e. 'scaled = 0 * scale', equals black). + darker_color = Color::new(0.3, 0.3, 0.3, color.a); + lighter_color = Color::new(0.7, 0.7, 0.7, color.a); + } + let (outer_color, inner_color) = match (direction, is_groove) { - (Top, true) | (Left, true) | (Right, false) | (Bottom, false) => (darker_color, color), - (Top, false) | (Left, false) | (Right, true) | (Bottom, true) => (color, darker_color) + (Top, true) | (Left, true) | (Right, false) | (Bottom, false) => (darker_color, lighter_color), + (Top, false) | (Left, false) | (Right, true) | (Bottom, true) => (lighter_color, darker_color) }; // outer portion of the border self.draw_border_path(&original_bounds, direction, scaled_border, radius, outer_color); diff --git a/tests/ref/basic.list b/tests/ref/basic.list index f1de5d65c41..a6496e794a0 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -194,3 +194,6 @@ fragment=top != ../html/acid2.html acid2_ref.html == outlines_simple_a.html outlines_simple_ref.html == outlines_wrap_a.html outlines_wrap_ref.html == letter_spacing_a.html letter_spacing_ref.html +!= border_black_groove.html border_black_solid.html +!= border_black_ridge.html border_black_solid.html +!= border_black_ridge.html border_black_groove.html diff --git a/tests/ref/border_black_groove.html b/tests/ref/border_black_groove.html new file mode 100644 index 00000000000..c572f1d4df0 --- /dev/null +++ b/tests/ref/border_black_groove.html @@ -0,0 +1,21 @@ + + + + + + + +
+ + diff --git a/tests/ref/border_black_ridge.html b/tests/ref/border_black_ridge.html new file mode 100644 index 00000000000..b1434ef3671 --- /dev/null +++ b/tests/ref/border_black_ridge.html @@ -0,0 +1,21 @@ + + + + + + + +
+ + diff --git a/tests/ref/border_black_solid.html b/tests/ref/border_black_solid.html new file mode 100644 index 00000000000..63ef95bef81 --- /dev/null +++ b/tests/ref/border_black_solid.html @@ -0,0 +1,20 @@ + + + + + + + +
+ +