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

Side by Side Diff: third_party/WebKit/LayoutTests/images/color-profile-image-canvas-pattern.html

Issue 2938543003: Remove almost all Javascript calls to setColorProfile (Closed)
Patch Set: Created 3 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <script src="../resources/run-after-layout-and-paint.js"></script> 3 <script src="../resources/run-after-layout-and-paint.js"></script>
4 4
5 <style> 5 <style>
6 canvas { transform: translateZ(0); } 6 canvas { transform: translateZ(0); }
7 img, canvas { margin: 5px; width: 48% } 7 img, canvas { margin: 5px; width: 48% }
8 </style> 8 </style>
9 9
10 <body style="overflow: hidden"> 10 <body style="overflow: hidden">
11 <!-- The _blue_ sector of the <img> image should be at 12 o'clock. --> 11 <!-- The _blue_ sector of the <img> image should be at 12 o'clock. -->
12 <img> 12 <img>
13 <!-- The red sector of the <canvas> image should be at 12 o'clock. --> 13 <!-- The red sector of the <canvas> image should be at 12 o'clock. -->
14 <canvas></canvas> 14 <canvas></canvas>
15 </body> 15 </body>
16 16
17 <script> 17 <script>
18 window.onload = function() { 18 window.onload = function() {
19 var image = document.querySelector('img'); 19 var image = document.querySelector('img');
20 20
21 image.onload = function() { 21 image.onload = function() {
22 runAfterLayoutAndPaint(window.testRunner ? changeColorProfile : profileChang ed); 22 runAfterLayoutAndPaint(drawImagePatternToCanvas);
23 }; 23 };
24 24
25 image.src = 'resources/red-at-12-oclock-with-color-profile.jpg'; 25 image.src = 'resources/red-at-12-oclock-with-color-profile.jpg';
26 }; 26 };
27 27
28 function changeColorProfile() {
29 window.testRunner.setColorProfile('colorSpin', profileChanged);
30 }
31
32 function profileChanged() {
33 setTimeout(drawImagePatternToCanvas, 0);
34 }
35
36 function drawImagePatternToCanvas() { 28 function drawImagePatternToCanvas() {
37 var canvas = document.querySelector('canvas'); 29 var canvas = document.querySelector('canvas');
38 var ctx = canvas.getContext('2d'); 30 var ctx = canvas.getContext('2d');
39 var pattern = ctx.createPattern(document.querySelector('img'), null); 31 var pattern = ctx.createPattern(document.querySelector('img'), null);
40 var scale = 0.1870; 32 var scale = 0.1870;
41 33
42 ctx.clearRect(0, 0, canvas.width = 300, canvas.height = 300); 34 ctx.clearRect(0, 0, canvas.width = 300, canvas.height = 300);
43 ctx.save(); 35 ctx.save();
44 ctx.scale(scale, scale); 36 ctx.scale(scale, scale);
45 ctx.fillStyle = pattern; 37 ctx.fillStyle = pattern;
46 ctx.fillRect(0, 0, canvas.width / scale, canvas.height / scale); 38 ctx.fillRect(0, 0, canvas.width / scale, canvas.height / scale);
47 ctx.restore(); 39 ctx.restore();
48 40
49 if (window.testRunner) 41 if (window.testRunner)
50 window.testRunner.notifyDone(); 42 window.testRunner.notifyDone();
51 } 43 }
52 44
53 if (window.testRunner) { 45 if (window.testRunner) {
54 testRunner.dumpAsTextWithPixelResults(); 46 testRunner.dumpAsTextWithPixelResults();
55 testRunner.waitUntilDone(); 47 testRunner.waitUntilDone();
56 } 48 }
57 </script> 49 </script>
58 </html> 50 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698