mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 12:45:27 +00:00
servo: Merge #4790 - Implements 2 helper functions for Color type (white() and black()) (from Adenilson:colorOperatorsHelpers01); r=jdm
Implements 2 helper functions for Color type (white() and black()) plus uses the new equality operators implemented in rust-azure. Source-Repo: https://github.com/servo/servo Source-Revision: 685412ec488ab4336c71ea303b4a9a30f214a1a3
This commit is contained in:
parent
0bdad32b66
commit
b201ec4863
@ -21,3 +21,13 @@ pub fn rgb(r: u8, g: u8, b: u8) -> AzColor {
|
|||||||
pub fn rgba(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloat) -> AzColor {
|
pub fn rgba(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloat) -> AzColor {
|
||||||
AzColor { r: r, g: g, b: b, a: a }
|
AzColor { r: r, g: g, b: b, a: a }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn black() -> AzColor {
|
||||||
|
AzColor { r: 0.0, g: 0.0, b: 0.0, a: 0.0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn white() -> AzColor {
|
||||||
|
AzColor { r: 1.0, g: 1.0, b: 1.0, a: 1.0 }
|
||||||
|
}
|
||||||
|
@ -664,7 +664,7 @@ impl LayoutTask {
|
|||||||
|
|
||||||
// FIXME(pcwalton): This is really ugly and can't handle overflow: scroll. Refactor
|
// FIXME(pcwalton): This is really ugly and can't handle overflow: scroll. Refactor
|
||||||
// it with extreme prejudice.
|
// it with extreme prejudice.
|
||||||
let mut color = color::rgba(1.0, 1.0, 1.0, 1.0);
|
let mut color = color::white();
|
||||||
for child in node.traverse_preorder() {
|
for child in node.traverse_preorder() {
|
||||||
if child.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLHtmlElement))) ||
|
if child.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLHtmlElement))) ||
|
||||||
child.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement))) {
|
child.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement))) {
|
||||||
@ -676,9 +676,12 @@ impl LayoutTask {
|
|||||||
.background_color)
|
.background_color)
|
||||||
.to_gfx_color()
|
.to_gfx_color()
|
||||||
};
|
};
|
||||||
// FIXME: Add equality operators for azure color type.
|
|
||||||
if element_bg_color.r != 0.0 || element_bg_color.g != 0.0 ||
|
let black = color::black();
|
||||||
element_bg_color.b != 0.0 || element_bg_color.a != 0.0 {
|
// 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 {
|
||||||
|
|
||||||
color = element_bg_color;
|
color = element_bg_color;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user