mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Setting current color to black if canvas is not rendered in document
This commit is contained in:
parent
69acd8e1cc
commit
b5159dc7ff
2 changed files with 19 additions and 7 deletions
|
@ -486,11 +486,29 @@ impl CanvasRenderingContext2D {
|
||||||
match color {
|
match color {
|
||||||
Ok(CSSColor::RGBA(rgba)) => Ok(rgba),
|
Ok(CSSColor::RGBA(rgba)) => Ok(rgba),
|
||||||
Ok(CSSColor::CurrentColor) => {
|
Ok(CSSColor::CurrentColor) => {
|
||||||
|
// TODO: https://github.com/whatwg/html/issues/1099
|
||||||
|
// Reconsider how to calculate currentColor in a display:none canvas
|
||||||
|
|
||||||
// TODO: will need to check that the context bitmap mode is fixed
|
// TODO: will need to check that the context bitmap mode is fixed
|
||||||
// once we implement CanvasProxy
|
// once we implement CanvasProxy
|
||||||
let window = window_from_node(&*self.canvas);
|
let window = window_from_node(&*self.canvas);
|
||||||
|
|
||||||
let style = window.GetComputedStyle(&*self.canvas.upcast(), None);
|
let style = window.GetComputedStyle(&*self.canvas.upcast(), None);
|
||||||
self.parse_color(&style.GetPropertyValue(DOMString::from("color")))
|
|
||||||
|
let element_not_rendered =
|
||||||
|
!self.canvas.upcast::<Node>().is_in_doc() ||
|
||||||
|
style.GetPropertyValue(DOMString::from("display")) == "none";
|
||||||
|
|
||||||
|
if element_not_rendered {
|
||||||
|
Ok(RGBA {
|
||||||
|
red: 0.0,
|
||||||
|
green: 0.0,
|
||||||
|
blue: 0.0,
|
||||||
|
alpha: 1.0,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
self.parse_color(&style.GetPropertyValue(DOMString::from("color")))
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_ => Err(())
|
_ => Err(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[2d.fillStyle.parse.current.removed.html]
|
|
||||||
type: testharness
|
|
||||||
bug: https://github.com/servo/servo/issues/10601
|
|
||||||
[currentColor is solid black when the canvas element is not in a document]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue