From 4bfe134c84f8ef6f304191658e58869d0e089130 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Thu, 18 Dec 2014 12:01:05 -0800 Subject: [PATCH 1/3] Similar to groove/ridge case, inset/outset would scale the color to decorate the border. Scale fails when the color is black (i.e. zero), thus this patch will fix this issue by using a fixed color. --- components/gfx/paint_context.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) 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); } From 06bbecc049e2c824d6309395374881d50df2a179 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Thu, 18 Dec 2014 12:05:22 -0800 Subject: [PATCH 2/3] Adding inset ref test. --- tests/ref/basic.list | 2 ++ tests/ref/blackborder_ref.html | 20 ++++++++++++++++++++ tests/ref/inset_blackborder.html | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 tests/ref/blackborder_ref.html create mode 100644 tests/ref/inset_blackborder.html diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 3e8abb9e30f..5c271708a02 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -219,3 +219,5 @@ 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 + 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 @@ + + + + +
+ + From b6f315cb35e13ba38b8337d2ae02501d67888c14 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Thu, 18 Dec 2014 12:06:29 -0800 Subject: [PATCH 3/3] Adding outset ref test. --- tests/ref/basic.list | 1 + tests/ref/outset_blackborder.html | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/ref/outset_blackborder.html diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 5c271708a02..9864cb0bfa0 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -220,4 +220,5 @@ fragment=top != ../html/acid2.html acid2_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/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 @@ + + + + +
+ +