diff options
-rw-r--r-- | components/compositing/compositor.rs | 2 | ||||
-rw-r--r-- | components/gfx/color.rs | 5 | ||||
-rw-r--r-- | components/gfx/paint_context.rs | 10 | ||||
-rw-r--r-- | components/layout/layout_task.rs | 6 |
4 files changed, 12 insertions, 11 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index f09eb6b51a8..e9e0f6bf8d2 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -508,7 +508,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { epoch: Epoch(0), id: LayerId::null(), rect: Rect::zero(), - background_color: color::black(), + background_color: color::transparent_black(), scroll_policy: ScrollPolicy::Scrollable, }; diff --git a/components/gfx/color.rs b/components/gfx/color.rs index f1f589ef4b7..0bf03bff6dc 100644 --- a/components/gfx/color.rs +++ b/components/gfx/color.rs @@ -24,6 +24,11 @@ pub fn rgba(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloat) -> AzColor { #[inline] pub fn black() -> AzColor { + AzColor { r: 0.0, g: 0.0, b: 0.0, a: 1.0 } +} + +#[inline] +pub fn transparent_black() -> AzColor { AzColor { r: 0.0, g: 0.0, b: 0.0, a: 0.0 } } diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs index 7a304bfb4cb..64495418ffe 100644 --- a/components/gfx/paint_context.rs +++ b/components/gfx/paint_context.rs @@ -154,7 +154,7 @@ impl<'a> PaintContext<'a> { } pub fn clear(&self) { - let pattern = ColorPattern::new(color::black()); + let pattern = ColorPattern::new(color::transparent_black()); let rect = Rect(Point2D(self.page_rect.origin.x as AzFloat, self.page_rect.origin.y as AzFloat), Size2D(self.screen_rect.size.width as AzFloat, @@ -729,9 +729,8 @@ impl<'a> PaintContext<'a> { }; let mut lighter_color; - let mut darker_color = color::black();; - // TODO(Savago): Use equality operators when we sync with rust-azure. - if color.r != darker_color.r || color.g != darker_color.g || color.b != darker_color.b { + let mut darker_color = color::black(); + if color != darker_color { darker_color = self.scale_color(color, if is_groove { 1.0/3.0 } else { 2.0/3.0 }); lighter_color = color; } else { @@ -775,8 +774,7 @@ impl<'a> PaintContext<'a> { // You can't scale black color (i.e. 'scaled = 0 * scale', equals black). let mut scaled_color = color::black(); - // TODO(Savago): Use equality operators when we sync with rust-azure. - if color.r != scaled_color.r || color.g != scaled_color.g || color.b != scaled_color.b { + if color != scaled_color { scaled_color = match direction { Direction::Top | Direction::Left => { self.scale_color(color, if is_inset { 2.0/3.0 } else { 1.0 }) diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index e2eea711de7..cd2328df866 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -677,10 +677,8 @@ impl LayoutTask { .to_gfx_color() }; - let black = color::black(); - // TODO: Use equality operators when we sync with rust-azure. - if element_bg_color.r != black.r || element_bg_color.g != black.g || - element_bg_color.b != black.b || element_bg_color.a != black.a { + let black = color::transparent_black(); + if element_bg_color != black { color = element_bg_color; break; |