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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-clip-test.html

Issue 1630683002: Canvas2d: addHitRegion() should take clipping region into account. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 10 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 | third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp » ('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 <title>HitRegion Clip Test</title>
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <script src="./resources/test-helpers.js"></script>
6 <canvas width="400" height="400"></canvas>
7 <style>
8
9 body {
10 margin : 0px;
11 padding : 0px;
12 }
13
14 </style>
15 <script>
16
17 var canvas = document.querySelector('canvas');
18 var context = canvas.getContext('2d');
19
20 function create_simple_rect_region_with_clip() {
21 context.clearRect(0, 0, 400, 400);
22 context.save();
23 context.beginPath();
24 context.rect(0, 0, 100, 100);
25 context.clip();
26 context.beginPath();
27 context.rect(50, 50, 100, 100);
28 context.fill();
29 context.addHitRegion({ id : 'clip' });
30 context.restore();
31 }
32
33 function create_non_rect_region_with_clip() {
34 context.clearRect(0, 0, 400, 400);
35 context.save();
36 context.beginPath();
37 context.arc(50, 50, 50, 0, Math.PI * 2);
38 context.clip();
39 context.beginPath();
40 context.rect(0, 0, 100, 100);
41 context.fill();
42 context.addHitRegion({ id : 'clip' });
43 context.restore();
44 }
45
46 function create_non_rect_region_with_multiple_clips() {
47 context.clearRect(0, 0, 400, 400);
48 context.save();
49 context.beginPath();
50 context.rect(0, 0, 100, 100);
51 context.clip();
52 context.beginPath();
53 context.arc(100, 50, 50, 0, Math.PI * 2);
54 context.clip();
55 context.beginPath();
56 context.rect(0, 0, 150, 50);
57 context.fill();
58 context.addHitRegion({ id : "clip" });
59 context.restore();
60 }
61
62 function no_pixel_test1() {
63 context.clearRect(0, 0, 400, 400);
64 context.save();
65 context.beginPath();
66 context.rect(0, 0, 100, 100);
67 context.clip();
68 context.beginPath();
69 context.rect(100, 100, 100, 100);
70 context.addHitRegion({ id : 'clip' });
71 context.restore();
72 }
73
74 function no_pixel_test2() {
75 context.save();
76 context.beginPath();
77 context.rect(0, 0, 50, 50);
78 context.rect(100, 0, 50, 50);
79 context.clip();
80 context.beginPath();
81 context.arc(75, 75, 30, 0, Math.PI * 2);
82 context.addHitRegion({ id : 'clip' });
83 context.restore();
84 }
85
86 coroutine(function*() {
87 setup({ explicit_done : true, explicit_timeout : true });
88
89 create_simple_rect_region_with_clip();
90 generate_tests(assert_equals, [
91 [ 'null', yield clickOrTouch(10, 10), null ],
92 [ 'clip', yield clickOrTouch(60, 60), 'clip' ]
93 ]);
94
95 create_non_rect_region_with_clip();
96 generate_tests(assert_equals, [
97 [ 'null', yield clickOrTouch(0, 0), null ],
98 [ 'null', yield clickOrTouch(100, 0), null ],
99 [ 'null', yield clickOrTouch(100, 100), null ],
100 [ 'null', yield clickOrTouch(0, 100), null ],
101 [ 'clip', yield clickOrTouch(50, 50), 'clip' ]
102 ]);
103
104 create_non_rect_region_with_multiple_clips();
105 generate_tests(assert_equals, [
106 [ 'null', yield clickOrTouch(00, 0), null ],
107 [ 'clip', yield clickOrTouch(100, 0), 'clip' ],
108 [ 'null', yield clickOrTouch(100, 100), null ],
109 [ 'null', yield clickOrTouch(0, 100), null ],
110 [ 'null', yield clickOrTouch(50, 0), null ],
111 [ 'null', yield clickOrTouch(150, 0), null ],
112 [ 'null', yield clickOrTouch(150, 100), null ],
113 [ 'null', yield clickOrTouch(50, 100), null ],
114 [ 'clip', yield clickOrTouch(50, 50), 'clip' ],
115 [ 'clip', yield clickOrTouch(100, 50), 'clip' ],
116 ]);
117
118 generate_tests(assert_throws, [
119 [ 'no pixel test1', { name : 'NotSupportedError' }, no_pixel_test1 ],
120 [ 'no pixel test2', { name : 'NotSupportedError' }, no_pixel_test2 ],
121 ]);
122
123 done();
124 });
125
126 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698