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

Side by Side 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: 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Canvas Hit Regions: fillRule test</title>
5 <script src="../../resources/js-test.js"></script>
6 </head>
7 <body>
8 <canvas id="canvas" width="400" height="400">
9 </canvas>
10 <script>
11
12 var canvas = document.getElementById("canvas");
13 var context = canvas.getContext("2d");
14
15 function clickCanvas(x, y)
16 {
17 if (!window.eventSender)
18 return "This test requires eventSender";
19
20 var result = null;
21 function listener(event)
22 {
23 result = event.region;
24 }
25
26 var rect = canvas.getBoundingClientRect();
27 canvas.addEventListener("click", listener, false);
28 eventSender.mouseMoveTo(rect.left + x, rect.top + y);
29 eventSender.mouseDown();
30 eventSender.mouseUp();
31 canvas.removeEventListener("click", listener, false);
32
33 return result;
34 }
35
36 context.rect(20, 20, 60, 60);
37 context.rect(0, 0, 100, 100);
38 context.addHitRegion({
39 id : "nonzero"
40 // no fill rule option
Justin Novosad 2014/06/23 14:44:49 I would call thais "default fill rule", rather tha
zino 2014/06/23 17:21:41 Done.
41 });
42
43 debug("No fillRule:");
Justin Novosad 2014/06/23 14:44:50 "Default fill rule (nonzero)"
zino 2014/06/23 17:21:41 Done.
44 shouldBe("clickCanvas(1, 1)", "'nonzero'");
45 shouldBe("clickCanvas(99, 98)", "'nonzero'");
46 shouldBe("clickCanvas(21, 21)", "'nonzero'");
47 shouldBe("clickCanvas(50, 50)", "'nonzero'");
48 debug("");
49
50 context.removeHitRegion("nonzero");
51
52 context.addHitRegion({
53 id : "evenodd",
54 fillRule : "evenodd"
55 });
56
57 debug("fillRule = evenodd:");
58 shouldBe("clickCanvas(1, 1)", "'evenodd'");
59 shouldBe("clickCanvas(99, 98)", "'evenodd'");
60 shouldBe("clickCanvas(21, 21)", "null");
61 shouldBe("clickCanvas(50, 50)", "null");
62 debug("");
63
64 context.removeHitRegion("evenodd");
65
66 context.addHitRegion({
67 id : "nonzero",
68 fillRule : "nonzero"
69 });
70
71 debug("fillRule = nonzero:");
72 shouldBe("clickCanvas(1, 1)", "'nonzero'");
73 shouldBe("clickCanvas(99, 98)", "'nonzero'");
74 shouldBe("clickCanvas(21, 21)", "'nonzero'");
75 shouldBe("clickCanvas(50, 50)", "'nonzero'");
76 debug("");
77
78 context.removeHitRegion("nonzero");
79
80 context.addHitRegion({
81 id : "nonzero",
82 fillRule : null
83 });
84
85 debug("fillRule = null:");
Justin Novosad 2014/06/23 14:44:49 "fillRule = null, falls back to default (nonzero):
zino 2014/06/23 17:21:41 Done.
86 shouldBe("clickCanvas(1, 1)", "'nonzero'");
87 shouldBe("clickCanvas(99, 98)", "'nonzero'");
88 shouldBe("clickCanvas(21, 21)", "'nonzero'");
89 shouldBe("clickCanvas(50, 50)", "'nonzero'");
90 debug("");
91
92 context.removeHitRegion("nonzero");
93
94 context.addHitRegion({
95 id : "nonzero",
96 fillRule : undefined
97 });
98
99 debug("fillRule = undefined:");
Justin Novosad 2014/06/23 14:44:50 same here
zino 2014/06/23 17:21:41 Done.
100 shouldBe("clickCanvas(1, 1)", "'nonzero'");
101 shouldBe("clickCanvas(99, 98)", "'nonzero'");
102 shouldBe("clickCanvas(21, 21)", "'nonzero'");
103 shouldBe("clickCanvas(50, 50)", "'nonzero'");
104 debug("");
105
106 </script>
107 </body>
108 </html>
OLDNEW
« 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