Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: LayoutTests/fast/canvas/canvas-hit-regions-fill-rule-test.html

Issue 346003007: Add fillRule option for hit regions on canvas2d. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/canvas-hit-regions-fill-rule-test-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/canvas/canvas-hit-regions-fill-rule-test.html
diff --git a/LayoutTests/fast/canvas/canvas-hit-regions-fill-rule-test.html b/LayoutTests/fast/canvas/canvas-hit-regions-fill-rule-test.html
new file mode 100644
index 0000000000000000000000000000000000000000..5bdbe3cefd829c92a2ee17d099eabca1a6da0be4
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-hit-regions-fill-rule-test.html
@@ -0,0 +1,108 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Canvas Hit Regions: fillRule test</title>
+ <script src="../../resources/js-test.js"></script>
+</head>
+<body>
+<canvas id="canvas" width="400" height="400">
+</canvas>
+<script>
+
+ var canvas = document.getElementById("canvas");
+ var context = canvas.getContext("2d");
+
+ function clickCanvas(x, y)
+ {
+ if (!window.eventSender)
+ return "This test requires eventSender";
+
+ var result = null;
+ function listener(event)
+ {
+ result = event.region;
+ }
+
+ var rect = canvas.getBoundingClientRect();
+ canvas.addEventListener("click", listener, false);
+ eventSender.mouseMoveTo(rect.left + x, rect.top + y);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ canvas.removeEventListener("click", listener, false);
+
+ return result;
+ }
+
+ context.rect(20, 20, 60, 60);
+ context.rect(0, 0, 100, 100);
+ context.addHitRegion({
+ id : "nonzero"
+ // default fillRule
+ });
+
+ debug("default fillRule(nonzero):");
+ shouldBe("clickCanvas(1, 1)", "'nonzero'");
+ shouldBe("clickCanvas(99, 98)", "'nonzero'");
+ shouldBe("clickCanvas(21, 21)", "'nonzero'");
+ shouldBe("clickCanvas(50, 50)", "'nonzero'");
+ debug("");
+
+ context.removeHitRegion("nonzero");
+
+ context.addHitRegion({
+ id : "evenodd",
+ fillRule : "evenodd"
+ });
+
+ debug("fillRule = evenodd:");
+ shouldBe("clickCanvas(1, 1)", "'evenodd'");
+ shouldBe("clickCanvas(99, 98)", "'evenodd'");
+ shouldBe("clickCanvas(21, 21)", "null");
+ shouldBe("clickCanvas(50, 50)", "null");
+ debug("");
+
+ context.removeHitRegion("evenodd");
+
+ context.addHitRegion({
+ id : "nonzero",
+ fillRule : "nonzero"
+ });
+
+ debug("fillRule = nonzero:");
+ shouldBe("clickCanvas(1, 1)", "'nonzero'");
+ shouldBe("clickCanvas(99, 98)", "'nonzero'");
+ shouldBe("clickCanvas(21, 21)", "'nonzero'");
+ shouldBe("clickCanvas(50, 50)", "'nonzero'");
+ debug("");
+
+ context.removeHitRegion("nonzero");
+
+ context.addHitRegion({
+ id : "nonzero",
+ fillRule : null
+ });
+
+ debug("fillRule = null, falls back to default (nonzero):");
+ shouldBe("clickCanvas(1, 1)", "'nonzero'");
+ shouldBe("clickCanvas(99, 98)", "'nonzero'");
+ shouldBe("clickCanvas(21, 21)", "'nonzero'");
+ shouldBe("clickCanvas(50, 50)", "'nonzero'");
+ debug("");
+
+ context.removeHitRegion("nonzero");
+
+ context.addHitRegion({
+ id : "nonzero",
+ fillRule : undefined
+ });
+
+ debug("fillRule = undefined, falls back to default (nonzero):");
+ shouldBe("clickCanvas(1, 1)", "'nonzero'");
+ shouldBe("clickCanvas(99, 98)", "'nonzero'");
+ shouldBe("clickCanvas(21, 21)", "'nonzero'");
+ shouldBe("clickCanvas(50, 50)", "'nonzero'");
+ debug("");
+
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/canvas-hit-regions-fill-rule-test-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698