From fcc0229d5e321af0a7d0e70619d9e2354c6dc02e Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Wed, 10 Dec 2014 17:23:25 -0800 Subject: [PATCH 1/3] Groove and Ridge rendering shows a solid border when color is black, that is broken and the current patch will implement a similar behavior as Firefox. --- components/gfx/paint_context.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs index 499cdf1397e..6e08dce0445 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 = self.scale_color(color, if is_groove { 1.5/3.0 } else { 2.5/3.0 }); + } 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); From 4d5cca2c69dd30b480104797eef90648ddda4e12 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Fri, 12 Dec 2014 10:01:34 -0800 Subject: [PATCH 2/3] Adding tests to check behavior. There are 3 files that will test: a) If the groove border is different from a black border (the bug that this patch set fixes); b) If a ridge border is different from a black border (samething); c) If groove is different from ridge (they should be inverse of each other). All 3 new tests passes on OSX Yosemite (10.10). --- tests/ref/basic.list | 3 +++ tests/ref/border_black_groove.html | 21 +++++++++++++++++++++ tests/ref/border_black_ridge.html | 21 +++++++++++++++++++++ tests/ref/border_black_solid.html | 20 ++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 tests/ref/border_black_groove.html create mode 100644 tests/ref/border_black_ridge.html create mode 100644 tests/ref/border_black_solid.html 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 @@ + + + + + + + +
+ + From 00f1ae0a1d1118445ad4fe6b5dd45479bc3aebf6 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Fri, 12 Dec 2014 12:41:05 -0800 Subject: [PATCH 3/3] Restored older behavior for lighter color, should fix the regression. --- components/gfx/paint_context.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs index 6e08dce0445..23d54fdf1cb 100644 --- a/components/gfx/paint_context.rs +++ b/components/gfx/paint_context.rs @@ -604,7 +604,7 @@ impl<'a> PaintContext<'a> { 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 = self.scale_color(color, if is_groove { 1.5/3.0 } else { 2.5/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);