diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs index 96de5a82aed..7dea4896d6b 100644 --- a/components/gfx/paint_context.rs +++ b/components/gfx/paint_context.rs @@ -642,11 +642,22 @@ impl<'a> PaintContext<'a> { }; // original bounds as a Rect let original_bounds = self.get_scaled_bounds(bounds, border, 0.0); - // select and scale the color appropriately. - let scaled_color = match direction { - Direction::Top | Direction::Left => self.scale_color(color, if is_inset { 2.0/3.0 } else { 1.0 }), - Direction::Right | Direction::Bottom => self.scale_color(color, if is_inset { 1.0 } else { 2.0/3.0 }) - }; + + let mut scaled_color; + + // You can't scale black color (i.e. 'scaled = 0 * scale', equals black). + if color.r != 0.0 || color.g != 0.0 || color.b != 0.0 { + scaled_color = match direction { + Direction::Top | Direction::Left => self.scale_color(color, if is_inset { 2.0/3.0 } else { 1.0 }), + Direction::Right | Direction::Bottom => self.scale_color(color, if is_inset { 1.0 } else { 2.0/3.0 }) + }; + } else { + scaled_color = match direction { + Direction::Top | Direction::Left => if is_inset { Color::new(0.3, 0.3, 0.3, color.a) } else { Color::new(0.7, 0.7, 0.7, color.a) }, + Direction::Right | Direction::Bottom => if is_inset { Color::new(0.7, 0.7, 0.7, color.a) } else { Color::new(0.3, 0.3, 0.3, color.a) } + }; + } + self.draw_border_path(&original_bounds, direction, border, radius, scaled_color); } diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 3e8abb9e30f..9864cb0bfa0 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -219,3 +219,6 @@ fragment=top != ../html/acid2.html acid2_ref.html == table_caption_top_a.html table_caption_top_ref.html == table_caption_bottom_a.html table_caption_bottom_ref.html == clip_a.html clip_ref.html +!= inset_blackborder.html blackborder_ref.html +!= outset_blackborder.html blackborder_ref.html + diff --git a/tests/ref/blackborder_ref.html b/tests/ref/blackborder_ref.html new file mode 100644 index 00000000000..266c7f058c5 --- /dev/null +++ b/tests/ref/blackborder_ref.html @@ -0,0 +1,20 @@ + + + + +
+ + diff --git a/tests/ref/inset_blackborder.html b/tests/ref/inset_blackborder.html new file mode 100644 index 00000000000..ffacd8a7855 --- /dev/null +++ b/tests/ref/inset_blackborder.html @@ -0,0 +1,20 @@ + + + + +
+ + diff --git a/tests/ref/outset_blackborder.html b/tests/ref/outset_blackborder.html new file mode 100644 index 00000000000..35cda879793 --- /dev/null +++ b/tests/ref/outset_blackborder.html @@ -0,0 +1,20 @@ + + + + +
+ +