aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/canvasrenderingcontext2d.rs20
-rw-r--r--tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.fillStyle.parse.current.removed.html.ini6
2 files changed, 19 insertions, 7 deletions
diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs
index a0c4ee9d021..36c042b4d75 100644
--- a/components/script/dom/canvasrenderingcontext2d.rs
+++ b/components/script/dom/canvasrenderingcontext2d.rs
@@ -486,11 +486,29 @@ impl CanvasRenderingContext2D {
match color {
Ok(CSSColor::RGBA(rgba)) => Ok(rgba),
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
// once we implement CanvasProxy
let window = window_from_node(&*self.canvas);
+
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(())
}
diff --git a/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.fillStyle.parse.current.removed.html.ini b/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.fillStyle.parse.current.removed.html.ini
deleted file mode 100644
index f0b7aa4e440..00000000000
--- a/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.fillStyle.parse.current.removed.html.ini
+++ /dev/null
@@ -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
-