Companion single Color patch.

This will also update the rust-azure dependency
to point to the hash where we have a single Color type.

Just executed ref-tests and no regressions found.
This commit is contained in:
Adenilson Cavalcanti 2015-02-12 10:22:40 -08:00
parent 52fc01ad37
commit ffa62c9688
9 changed files with 31 additions and 16 deletions

View file

@ -3,9 +3,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use azure::AzFloat; use azure::AzFloat;
use azure::azure_hl::Color as AzColor; use azure::azure::AzColor;
pub type Color = AzColor; #[inline]
pub fn new(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloat) -> AzColor {
AzColor { r: r, g: g, b: b, a: a }
}
#[inline] #[inline]
pub fn rgb(r: u8, g: u8, b: u8) -> AzColor { pub fn rgb(r: u8, g: u8, b: u8) -> AzColor {

View file

@ -16,7 +16,6 @@
#![deny(unsafe_blocks)] #![deny(unsafe_blocks)]
use color::Color;
use display_list::optimizer::DisplayListOptimizer; use display_list::optimizer::DisplayListOptimizer;
use paint_context::{PaintContext, ToAzureRect}; use paint_context::{PaintContext, ToAzureRect};
use self::DisplayItem::*; use self::DisplayItem::*;
@ -25,6 +24,8 @@ use text::glyph::CharIndex;
use text::TextRun; use text::TextRun;
use azure::azure::AzFloat; use azure::azure::AzFloat;
use azure::azure_hl::{Color};
use collections::dlist::{self, DList}; use collections::dlist::{self, DList};
use geom::{Point2D, Rect, SideOffsets2D, Size2D, Matrix2D}; use geom::{Point2D, Rect, SideOffsets2D, Size2D, Matrix2D};
use geom::num::Zero; use geom::num::Zero;

View file

@ -687,7 +687,10 @@ impl<'a> PaintContext<'a> {
} }
fn scale_color(&self, color: Color, scale_factor: f32) -> Color { fn scale_color(&self, color: Color, scale_factor: f32) -> Color {
return Color::new(color.r * scale_factor, color.g * scale_factor, color.b * scale_factor, color.a); return color::new(color.r * scale_factor,
color.g * scale_factor,
color.b * scale_factor,
color.a);
} }
fn draw_double_border_segment(&self, fn draw_double_border_segment(&self,
@ -735,8 +738,8 @@ impl<'a> PaintContext<'a> {
lighter_color = color; lighter_color = color;
} else { } else {
// You can't scale black color (i.e. 'scaled = 0 * scale', equals black). // 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); darker_color = color::new(0.3, 0.3, 0.3, color.a);
lighter_color = Color::new(0.7, 0.7, 0.7, color.a); lighter_color = color::new(0.7, 0.7, 0.7, color.a);
} }
let (outer_color, inner_color) = match (direction, is_groove) { let (outer_color, inner_color) = match (direction, is_groove) {
@ -787,16 +790,16 @@ impl<'a> PaintContext<'a> {
scaled_color = match direction { scaled_color = match direction {
Direction::Top | Direction::Left => { Direction::Top | Direction::Left => {
if is_inset { if is_inset {
Color::new(0.3, 0.3, 0.3, color.a) color::new(0.3, 0.3, 0.3, color.a)
} else { } else {
Color::new(0.7, 0.7, 0.7, color.a) color::new(0.7, 0.7, 0.7, color.a)
} }
} }
Direction::Right | Direction::Bottom => { Direction::Right | Direction::Bottom => {
if is_inset { if is_inset {
Color::new(0.7, 0.7, 0.7, color.a) color::new(0.7, 0.7, 0.7, color.a)
} else { } else {
Color::new(0.3, 0.3, 0.3, color.a) color::new(0.3, 0.3, 0.3, color.a)
} }
} }
}; };

View file

@ -7,6 +7,9 @@ authors = ["The Servo Project Developers"]
name = "layout" name = "layout"
path = "lib.rs" path = "lib.rs"
[dependencies.azure]
git = "https://github.com/servo/rust-azure"
[dependencies.canvas] [dependencies.canvas]
path = "../canvas" path = "../canvas"

View file

@ -25,7 +25,8 @@
#[macro_use] #[macro_use]
extern crate log; extern crate log;
#[macro_use] extern crate bitflags; #[macro_use]extern crate bitflags;
extern crate azure;
extern crate cssparser; extern crate cssparser;
extern crate canvas; extern crate canvas;
extern crate geom; extern crate geom;

View file

@ -9,6 +9,7 @@ use incremental::RestyleDamage;
use parallel::DomParallelInfo; use parallel::DomParallelInfo;
use wrapper::{LayoutNode, TLayoutNode, ThreadSafeLayoutNode}; use wrapper::{LayoutNode, TLayoutNode, ThreadSafeLayoutNode};
use azure::azure_hl::{Color};
use gfx::display_list::OpaqueNode; use gfx::display_list::OpaqueNode;
use gfx; use gfx;
use libc::{c_void, uintptr_t}; use libc::{c_void, uintptr_t};
@ -169,11 +170,11 @@ impl OpaqueNodeMethods for OpaqueNode {
/// Allows a CSS color to be converted into a graphics color. /// Allows a CSS color to be converted into a graphics color.
pub trait ToGfxColor { pub trait ToGfxColor {
/// Converts a CSS color to a graphics color. /// Converts a CSS color to a graphics color.
fn to_gfx_color(&self) -> gfx::color::Color; fn to_gfx_color(&self) -> Color;
} }
impl ToGfxColor for style::values::RGBA { impl ToGfxColor for style::values::RGBA {
fn to_gfx_color(&self) -> gfx::color::Color { fn to_gfx_color(&self) -> Color {
gfx::color::rgba(self.red, self.green, self.blue, self.alpha) gfx::color::rgba(self.red, self.green, self.blue, self.alpha)
} }
} }

View file

@ -36,7 +36,7 @@ dependencies = [
[[package]] [[package]]
name = "azure" name = "azure"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-azure#9ae7938c56e8c59d09a3ce682dd4cf5fcbb2ac57" source = "git+https://github.com/servo/rust-azure#08d2513e8ebbfe9ce6620aa514c2f2b91059b304"
dependencies = [ dependencies = [
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)", "core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
@ -476,6 +476,7 @@ dependencies = [
name = "layout" name = "layout"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"bitflags 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"canvas 0.0.1", "canvas 0.0.1",
"cssparser 0.2.0 (git+https://github.com/servo/rust-cssparser)", "cssparser 0.2.0 (git+https://github.com/servo/rust-cssparser)",

3
ports/cef/Cargo.lock generated
View file

@ -38,7 +38,7 @@ dependencies = [
[[package]] [[package]]
name = "azure" name = "azure"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-azure#9ae7938c56e8c59d09a3ce682dd4cf5fcbb2ac57" source = "git+https://github.com/servo/rust-azure#08d2513e8ebbfe9ce6620aa514c2f2b91059b304"
dependencies = [ dependencies = [
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)", "core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
@ -478,6 +478,7 @@ dependencies = [
name = "layout" name = "layout"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"bitflags 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"canvas 0.0.1", "canvas 0.0.1",
"cssparser 0.2.0 (git+https://github.com/servo/rust-cssparser)", "cssparser 0.2.0 (git+https://github.com/servo/rust-cssparser)",

3
ports/gonk/Cargo.lock generated
View file

@ -17,7 +17,7 @@ dependencies = [
[[package]] [[package]]
name = "azure" name = "azure"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-azure#9ae7938c56e8c59d09a3ce682dd4cf5fcbb2ac57" source = "git+https://github.com/servo/rust-azure#08d2513e8ebbfe9ce6620aa514c2f2b91059b304"
dependencies = [ dependencies = [
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)", "core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
@ -396,6 +396,7 @@ dependencies = [
name = "layout" name = "layout"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"bitflags 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"canvas 0.0.1", "canvas 0.0.1",
"cssparser 0.2.0 (git+https://github.com/servo/rust-cssparser)", "cssparser 0.2.0 (git+https://github.com/servo/rust-cssparser)",