the-canvas-element.html
49.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-US-x-Hixie" ><head><title>4.8.11 The canvas element — HTML5 </title><style type="text/css">
pre { margin-left: 2em; white-space: pre-wrap; }
h2 { margin: 3em 0 1em 0; }
h3 { margin: 2.5em 0 1em 0; }
h4 { margin: 2.5em 0 0.75em 0; }
h5, h6 { margin: 2.5em 0 1em; }
h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
p { margin: 1em 0; }
hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
dl, dd { margin-top: 0; margin-bottom: 0; }
dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
dt + dt { margin-top: 0; }
dd dt { margin-top: 0.25em; margin-bottom: 0; }
dd p { margin-top: 0; }
dd dl + p { margin-top: 1em; }
dd table + p { margin-top: 1em; }
p + * > li, dd li { margin: 1em 0; }
dt, dfn { font-weight: bold; font-style: normal; }
dt dfn { font-style: italic; }
pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
pre em { font-weight: bolder; font-style: normal; }
@media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
table { border-collapse: collapse; border-style: hidden hidden none hidden; }
table thead, table tbody { border-bottom: solid; }
table tbody th:first-child { border-left: solid; }
table tbody th { text-align: left; }
table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
.bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
.matrix, .matrix td { border: none; text-align: right; }
.matrix { margin-left: 2em; }
.dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
.dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
.dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
.toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
img.extra { float: right; }
pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
pre.css:first-line { color: #AAAA50; }
dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
dl.domintro dd p { margin: 0.5em 0; }
dl.switch { padding-left: 2em; }
dl.switch > dt { text-indent: -1.5em; }
dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
dl.triple { padding: 0 0 0 1em; }
dl.triple dt, dl.triple dd { margin: 0; display: inline }
dl.triple dt:after { content: ':'; }
dl.triple dd:after { content: '\A'; white-space: pre; }
.diff-old { text-decoration: line-through; color: silver; background: transparent; }
.diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
a .diff-new { border-bottom: 1px blue solid; }
h2 { page-break-before: always; }
h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
h1 + h2, hr + h2.no-toc { page-break-before: auto; }
p > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]),
li > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]), { border-bottom: solid #9999CC; }
div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
div.head p { margin: 0; }
div.head h1 { margin: 0; }
div.head .logo { float: right; margin: 0 1em; }
div.head .logo img { border: none } /* remove border from top image */
div.head dl { margin: 1em 0; }
div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
body > .toc > li > * { margin-bottom: 0.5em; }
body > .toc > li > * > li > * { margin-bottom: 0.25em; }
.toc, .toc li { list-style: none; }
.brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
.brief li { margin: 0; padding: 0; }
.brief li p { margin: 0; padding: 0; }
.category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
.category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
.category-list li { display: inline; }
.category-list li:not(:last-child)::after { content: ', '; }
.category-list li > span, .category-list li > a { text-transform: lowercase; }
.category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
.XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
.XXX > :first-child { margin-top: 0; }
p .XXX { line-height: 3em; }
.annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
.annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
.annotation :link, .annotation :visited { color: inherit; }
.annotation :link:hover, .annotation :visited:hover { background: transparent; }
.annotation span { border: none ! important; }
.note { color: green; background: transparent; font-family: sans-serif; }
.warning { color: red; background: transparent; }
.note, .warning { font-weight: bolder; font-style: italic; }
p.note, div.note { padding: 0.5em 2em; }
span.note { padding: 0 2em; }
.note p:first-child, .warning p:first-child { margin-top: 0; }
.note p:last-child, .warning p:last-child { margin-bottom: 0; }
.warning:before { font-style: normal; }
p.note:before { content: 'Note: '; }
p.warning:before { content: '\26A0 Warning! '; }
.bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
.bookkeeping { font-size: 0.8em; margin: 2em 0; }
.bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
.bookkeeping dt { margin: 0.5em 2em 0; }
.bookkeeping dd { margin: 0 3em 0.5em; }
h4 { position: relative; z-index: 3; }
h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
.element {
background: #EEEEFF;
color: black;
margin: 0 0 1em 0.15em;
padding: 0 1em 0.25em 0.75em;
border-left: solid #9999FF 0.25em;
position: relative;
z-index: 1;
}
.element:before {
position: absolute;
z-index: 2;
top: 0;
left: -1.15em;
height: 2em;
width: 0.9em;
background: #EEEEFF;
content: ' ';
border-style: none none solid solid;
border-color: #9999FF;
border-width: 0.25em;
}
.example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
td > .example:only-child { margin: 0 0 0 0.1em; }
ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
ul.domTree li li { list-style: none; }
ul.domTree li:first-child::before { position: absolute; top: 0; height: 0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
ul.domTree li:not(:last-child)::after { position: absolute; top: 0; bottom: -0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
ul.domTree span { font-style: italic; font-family: serif; }
ul.domTree .t1 code { color: purple; font-weight: bold; }
ul.domTree .t2 { font-style: normal; font-family: monospace; }
ul.domTree .t2 .name { color: black; font-weight: bold; }
ul.domTree .t2 .value { color: blue; font-weight: normal; }
ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
ul.domTree .t7 code, .domTree .t8 code { color: green; }
ul.domTree .t10 code { color: teal; }
body.dfnEnabled dfn { cursor: pointer; }
.dfnPanel {
display: inline;
position: absolute;
z-index: 10;
height: auto;
width: auto;
padding: 0.5em 0.75em;
font: small sans-serif, Droid Sans Fallback;
background: #DDDDDD;
color: black;
border: outset 0.2em;
}
.dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
.dfnPanel :link, .dfnPanel :visited { color: black; }
.dfnPanel p { font-weight: bolder; }
.dfnPanel * + p { margin-top: 0.25em; }
.dfnPanel li { list-style-position: inside; }
#configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
#configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
#configUI p label { display: block; }
#configUI #updateUI, #configUI .loginUI { text-align: center; }
#configUI input[type=button] { display: block; margin: auto; }
fieldset { margin: 1em; padding: 0.5em 1em; }
fieldset > legend + * { margin-top: 0; }
fieldset > :last-child { margin-bottom: 0; }
fieldset p { margin: 0.5em 0; }
.stability {
position: fixed;
bottom: 0;
left: 0; right: 0;
margin: 0 auto 0 auto !important;
z-index: 1000;
width: 50%;
background: maroon; color: yellow;
-webkit-border-radius: 1em 1em 0 0;
-moz-border-radius: 1em 1em 0 0;
border-radius: 1em 1em 0 0;
-moz-box-shadow: 0 0 1em #500;
-webkit-box-shadow: 0 0 1em #500;
box-shadow: 0 0 1em red;
padding: 0.5em 1em;
text-align: center;
}
.stability strong {
display: block;
}
.stability input {
appearance: none; margin: 0; border: 0; padding: 0.25em 0.5em; background: transparent; color: black;
position: absolute; top: -0.5em; right: 0; font: 1.25em sans-serif; text-align: center;
}
.stability input:hover {
color: white;
text-shadow: 0 0 2px black;
}
.stability input:active {
padding: 0.3em 0.45em 0.2em 0.55em;
}
.stability :link, .stability :visited,
.stability :link:hover, .stability :visited:hover {
background: transparent;
color: white;
}
</style><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D%0Ahtml%20%7B%20border:%20solid%20yellow;%20%7D%20.domintro:before%20%7B%20display:%20none;%20%7D" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D%20.domintro:before%20%7B%20background:%20%23FFEEEE;%20%7D" id="highlight" rel="alternate stylesheet" title="Highlight implementation
requirements"><link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css"><style type="text/css">
.applies thead th > * { display: block; }
.applies thead code { display: block; }
.applies tbody th { whitespace: nowrap; }
.applies td { text-align: center; }
.applies .yes { background: yellow; }
.matrix, .matrix td { border: hidden; text-align: right; }
.matrix { margin-left: 2em; }
.dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
.dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
.dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
td.eg { border-width: thin; text-align: center; }
#table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
#table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
#table-example-1 caption { padding-bottom: 0.5em; }
#table-example-1 thead, #table-example-1 tbody { border: none; }
#table-example-1 th, #table-example-1 td { border: solid thin; }
#table-example-1 th { font-weight: normal; }
#table-example-1 td { border-style: none solid; vertical-align: top; }
#table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
#table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
#table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
#table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
#table-example-1 tbody td:first-child::after { content: leader(". "); }
#table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
#table-example-1 tbody td:first-child + td { width: 10em; }
#table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
#table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
.apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
.apple-table-examples * { font-family: "Times", serif; }
.apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
.apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
.apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
.apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
.apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
.apple-table-examples td { text-align: right; vertical-align: top; }
.apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
.apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
.apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
.apple-table-examples sup { line-height: 0; }
.details-example img { vertical-align: top; }
#base64-table {
white-space: nowrap;
font-size: 0.6em;
column-width: 6em;
column-count: 5;
column-gap: 1em;
-moz-column-width: 6em;
-moz-column-count: 5;
-moz-column-gap: 1em;
-webkit-column-width: 6em;
-webkit-column-count: 5;
-webkit-column-gap: 1em;
}
#base64-table thead { display: none; }
#base64-table * { border: none; }
#base64-table tbody td:first-child:after { content: ':'; }
#base64-table tbody td:last-child { text-align: right; }
#named-character-references-table {
white-space: nowrap;
font-size: 0.6em;
column-width: 30em;
column-gap: 1em;
-moz-column-width: 30em;
-moz-column-gap: 1em;
-webkit-column-width: 30em;
-webkit-column-gap: 1em;
}
#named-character-references-table > table > tbody > tr > td:first-child + td,
#named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
#named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
#named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }
.glyph.control { color: red; }
@font-face {
font-family: 'Essays1743';
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743.ttf');
}
@font-face {
font-family: 'Essays1743';
font-weight: bold;
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Bold.ttf');
}
@font-face {
font-family: 'Essays1743';
font-style: italic;
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Italic.ttf');
}
@font-face {
font-family: 'Essays1743';
font-style: italic;
font-weight: bold;
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf');
}
</style><style type="text/css">
.domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
</style><script type="text/javascript">
function getCookie(name) {
var params = location.search.substr(1).split("&");
for (var index = 0; index < params.length; index++) {
if (params[index] == name)
return "1";
var data = params[index].split("=");
if (data[0] == name)
return unescape(data[1]);
}
var cookies = document.cookie.split("; ");
for (var index = 0; index < cookies.length; index++) {
var data = cookies[index].split("=");
if (data[0] == name)
return unescape(data[1]);
}
return null;
}
</script>
<script src="link-fixup.js" type="text/javascript"></script>
<link href="style.css" rel="stylesheet"><link href="the-iframe-element.html" title="4.8.2 The iframe element" rel="prev">
<link href="spec.html#contents" title="Table of contents" rel="index">
<link href="the-map-element.html" title="4.8.12 The map element" rel="next">
</head><body><div class="head" id="head">
<div id="multipage-common">
<p class="stability" id="wip"><strong>This is a work in
progress!</strong> For the latest updates from the HTML WG, possibly
including important bug fixes, please look at the <a href="http://dev.w3.org/html5/spec/Overview.html">editor's draft</a> instead.
There may also be a more
<a href="http://www.w3.org/TR/html5">up-to-date Working Draft</a>
with changes based on resolution of Last Call issues.
<input onclick="closeWarning(this.parentNode)" type="button" value="╳⃝"></p>
<script type="text/javascript">
function closeWarning(element) {
element.parentNode.removeChild(element);
var date = new Date();
date.setDate(date.getDate()+4);
document.cookie = 'hide-obsolescence-warning=1; expires=' + date.toGMTString();
}
if (getCookie('hide-obsolescence-warning') == '1')
setTimeout(function () { document.getElementById('wip').parentNode.removeChild(document.getElementById('wip')); }, 2000);
</script></div>
<p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
<h1>HTML5</h1>
</div><div>
<a href="the-iframe-element.html" class="prev">4.8.2 The iframe element</a> –
<a href="spec.html#contents">Table of contents</a> –
<a href="the-map-element.html" class="next">4.8.12 The map element</a>
<ol class="toc"><li><ol><li><ol><li><a href="the-canvas-element.html#the-canvas-element"><span class="secno">4.8.11 </span>The <code>canvas</code> element</a>
<ol><li><a href="the-canvas-element.html#color-spaces-and-color-correction"><span class="secno">4.8.11.1 </span>Color spaces and color correction</a></li><li><a href="the-canvas-element.html#security-with-canvas-elements"><span class="secno">4.8.11.2 </span>Security with <code>canvas</code> elements</a></li></ol></li></ol></li></ol></li></ol></div>
<h4 id="the-canvas-element"><span class="secno">4.8.11 </span>The <dfn id="canvas"><code>canvas</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
<dd><a href="content-models.html#flow-content">Flow content</a>.</dd>
<dd><a href="content-models.html#phrasing-content">Phrasing content</a>.</dd>
<dd><a href="content-models.html#embedded-content">Embedded content</a>.</dd>
<dt>Contexts in which this element can be used:</dt>
<dd>Where <a href="content-models.html#embedded-content">embedded content</a> is expected.</dd>
<dt>Content model:</dt>
<dd><a href="content-models.html#transparent">Transparent</a>.</dd>
<dt>Content attributes:</dt>
<dd><a href="elements.html#global-attributes">Global attributes</a></dd>
<dd><code title="attr-canvas-width"><a href="#attr-canvas-width">width</a></code></dd>
<dd><code title="attr-canvas-height"><a href="#attr-canvas-height">height</a></code></dd>
<dt>DOM interface:</dt>
<dd>
<pre class="idl">interface <dfn id="htmlcanvaselement">HTMLCanvasElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
attribute unsigned long <a href="#dom-canvas-width" title="dom-canvas-width">width</a>;
attribute unsigned long <a href="#dom-canvas-height" title="dom-canvas-height">height</a>;
DOMString <a href="#dom-canvas-todataurl" title="dom-canvas-toDataURL">toDataURL</a>(in optional DOMString type, in any... args);
void <a href="#dom-canvas-toblob" title="dom-canvas-toBlob">toBlob</a>(in <span>FileCallback</span>, in optional DOMString type, in any... args);
object <a href="#dom-canvas-getcontext" title="dom-canvas-getContext">getContext</a>(in DOMString contextId, in any... args);
};</pre>
</dd>
</dl><p>The <code><a href="#the-canvas-element">canvas</a></code> element provides scripts with a
resolution-dependent bitmap canvas, which can be used for rendering
graphs, game graphics, or other visual images on the fly.</p><p>Authors should not use the <code><a href="#the-canvas-element">canvas</a></code> element in a
document when a more suitable element is available. For example, it
is inappropriate to use a <code><a href="#the-canvas-element">canvas</a></code> element to render a
page heading: if the desired presentation of the heading is
graphically intense, it should be marked up using appropriate
elements (typically <code><a href="sections.html#the-h1-h2-h3-h4-h5-and-h6-elements">h1</a></code>) and then styled using CSS and
supporting technologies such as XBL.</p><p>When authors use the <code><a href="#the-canvas-element">canvas</a></code> element, they must also
provide content that, when presented to the user, conveys
essentially the same function or purpose as the bitmap canvas. This
content may be placed as content of the <code><a href="#the-canvas-element">canvas</a></code>
element. The contents of the <code><a href="#the-canvas-element">canvas</a></code> element, if any,
are the element's <a href="content-models.html#fallback-content">fallback content</a>.</p><p>In interactive visual media, if <a href="webappapis.html#concept-n-script" title="concept-n-script">scripting is enabled</a> for the
<code><a href="#the-canvas-element">canvas</a></code> element, and if support for <code><a href="#the-canvas-element">canvas</a></code>
elements has been enabled, the <code><a href="#the-canvas-element">canvas</a></code> element
<a href="rendering.html#represents">represents</a> <a href="content-models.html#embedded-content">embedded content</a> consisting of
a dynamically created image.</p><p>In non-interactive, static, visual media, if the
<code><a href="#the-canvas-element">canvas</a></code> element has been previously painted on (e.g. if
the page was viewed in an interactive visual medium and is now being
printed, or if some script that ran during the page layout process
painted on the element), then the <code><a href="#the-canvas-element">canvas</a></code> element
<a href="rendering.html#represents">represents</a> <a href="content-models.html#embedded-content">embedded content</a> with the
current image and size. Otherwise, the element represents its
<a href="content-models.html#fallback-content">fallback content</a> instead.</p><p>In non-visual media, and in visual media if <a href="webappapis.html#concept-n-noscript" title="concept-n-noscript">scripting is disabled</a> for the
<code><a href="#the-canvas-element">canvas</a></code> element or if support for <code><a href="#the-canvas-element">canvas</a></code>
elements has been disabled, the <code><a href="#the-canvas-element">canvas</a></code> element
<a href="rendering.html#represents">represents</a> its <a href="content-models.html#fallback-content">fallback content</a>
instead.</p><!-- CANVAS-FOCUS-FALLBACK --><p>When a <code><a href="#the-canvas-element">canvas</a></code> element <a href="rendering.html#represents">represents</a>
<a href="content-models.html#embedded-content">embedded content</a>, the user can still focus descendants
of the <code><a href="#the-canvas-element">canvas</a></code> element (in the <a href="content-models.html#fallback-content">fallback
content</a>). When an element is focused, it is the target of
keyboard interaction events (even though the element itself is not
visible). This allows authors to make an interactive canvas
keyboard-accessible: authors should have a one-to-one mapping of
interactive regions to focusable elements in the <a href="content-models.html#fallback-content">fallback
content</a>. (Focus has no effect on mouse interaction
events.) <a href="references.html#refsDOMEVENTS">[DOMEVENTS]</a></p><p>The <code><a href="#the-canvas-element">canvas</a></code> element has two attributes to control the
size of the coordinate space: <dfn id="attr-canvas-width" title="attr-canvas-width"><code>width</code></dfn> and <dfn id="attr-canvas-height" title="attr-canvas-height"><code>height</code></dfn>. These
attributes, when specified, must have values that are <a href="common-microsyntaxes.html#valid-non-negative-integer" title="valid non-negative integer">valid non-negative
integers</a>. <span class="impl">The <a href="common-microsyntaxes.html#rules-for-parsing-non-negative-integers">rules for parsing
non-negative integers</a> must be used to obtain their numeric
values. If an attribute is missing, or if parsing its value returns
an error, then the default value must be used instead.</span> The
<code title="attr-canvas-width"><a href="#attr-canvas-width">width</a></code> attribute defaults to
300, and the <code title="attr-canvas-height"><a href="#attr-canvas-height">height</a></code>
attribute defaults to 150.</p><p>The intrinsic dimensions of the <code><a href="#the-canvas-element">canvas</a></code> element equal
the size of the coordinate space, with the numbers interpreted in
CSS pixels. However, the element can be sized arbitrarily by a
style sheet. During rendering, the image is scaled to fit this layout
size.</p><div class="impl">
<p>The size of the coordinate space does not necessarily represent
the size of the actual bitmap that the user agent will use
internally or during rendering. On high-definition displays, for
instance, the user agent may internally use a bitmap with two device
pixels per unit in the coordinate space, so that the rendering
remains at high quality throughout.</p>
<p>When the <code><a href="#the-canvas-element">canvas</a></code> element is created, and subsequently
whenever the <code title="attr-canvas-width"><a href="#attr-canvas-width">width</a></code> and <code title="attr-canvas-height"><a href="#attr-canvas-height">height</a></code> attributes are set (whether
to a new value or to the previous value), the bitmap and any
associated contexts must be cleared back to their initial state and
reinitialized with the newly specified coordinate space
dimensions.</p>
<p>When the canvas is initialized, its bitmap must be cleared to
transparent black.</p>
<p>The <dfn id="dom-canvas-width" title="dom-canvas-width"><code>width</code></dfn> and
<dfn id="dom-canvas-height" title="dom-canvas-height"><code>height</code></dfn> IDL
attributes must <a href="common-dom-interfaces.html#reflect">reflect</a> the respective content
attributes of the same name, with the same defaults.</p>
</div><div class="example">
<p>Only one square appears to be drawn in the following example:</p>
<pre> // canvas is a reference to a <canvas> element
var context = canvas.getContext('2d');
context.fillRect(0,0,50,50);
canvas.setAttribute('width', '300'); // clears the canvas
context.fillRect(0,100,50,50);
canvas.width = canvas.width; // clears the canvas
context.fillRect(100,0,50,50); // only this square remains</pre>
</div><hr><dl class="domintro"><dt><var title="">context</var> = <var title="">canvas</var> . <code title="dom-canvas-getContext"><a href="#dom-canvas-getcontext">getContext</a></code>(<var title="">contextId</var> [, ... ])</dt>
<dd>
<p>Returns an object that exposes an API for drawing on the
canvas. The first argument specifies the desired API. Subsequent
arguments are handled by that API.</p>
<p>The list of defined contexts is given on the <a href="http://wiki.whatwg.org/wiki/CanvasContexts">WHATWG Wiki
CanvasContexts page</a>. <a href="references.html#refsWHATWGWIKI">[WHATWGWIKI]</a>
</p><p>Returns null if the given context ID is not supported or if the
canvas has already been initialised with some other (incompatible)
context type (e.g. trying to get a "<code title="canvas-context-2d">2d</code>" context after getting a
"<code title="canvas-context-webgl">webgl</code>" context).</p>
</dd>
</dl><div class="impl">
<p>A <code><a href="#the-canvas-element">canvas</a></code> element can have a <dfn id="primary-context">primary
context</dfn>, which is the first context to have been obtained for
that element. When created, a <code><a href="#the-canvas-element">canvas</a></code> element must not
have a <a href="#primary-context">primary context</a>.</p>
<p>The most commonly used primary context is the <a href="http://dev.w3.org/html5/2dcontext/">HTML Canvas 2D Context</a>.
</p><p>The <dfn id="dom-canvas-getcontext" title="dom-canvas-getContext"><code>getContext(<var title="">contextId</var>, <var title="">args...</var>)</code></dfn>
method of the <code><a href="#the-canvas-element">canvas</a></code> element, when invoked, must run
the following steps:</p>
<ol><li><p>Let <var title="">contextId</var> be the first argument to
the method.</p></li>
<li>
<p>If <var title="">contextId</var> is not the name of a context
supported by the user agent, return null and abort these
steps.</p>
<p class="note">An example of this would be a user agent that
theoretically supports the "<code title="canvas-context-webgl">webgl</code>" 3D context, in the case
where the platform does not have hardware support for OpenGL and
the user agent does not have a software OpenGL implementation.
Despite the user agent recognising the "<code title="canvas-context-webgl">webgl</code>" name, it would return
null at this step because that context is not, in practice,
supported at the time of the call.</p>
</li>
<li><p>If the element has a <a href="#primary-context">primary context</a> and that
context's entry in the <a href="http://wiki.whatwg.org/wiki/CanvasContexts">WHATWG Wiki
CanvasContexts page</a> does not list <var title="">contextId</var>
as a context with which it is compatible, return null and abort
these steps. <a href="references.html#refsWHATWGWIKI">[WHATWGWIKI]</a></p></li>
<li><p>If the element does not have a <a href="#primary-context">primary context</a>,
let the element's <a href="#primary-context">primary context</a> be <var title="">contextId</var>.</p></li>
<li><p>If the <code title="dom-canvas-getContext"><a href="#dom-canvas-getcontext">getContext()</a></code> method has
already been invoked on this element for the same <var title="">contextId</var>, return the same object as was returned
that time, and abort these steps. The additional arguments are
ignored.</p></li>
<li><p><dfn id="getcontext-return" title="getContext-return">Return a new object for <var title="">contextId</var></dfn>, as defined by the specification
given for <var title="">contextId</var>'s entry in the <a href="http://wiki.whatwg.org/wiki/CanvasContexts">WHATWG Wiki
CanvasContexts page</a>. <a href="references.html#refsWHATWGWIKI">[WHATWGWIKI]</a></p></li>
</ol><p>New context types may be registered in the <a href="http://wiki.whatwg.org/wiki/CanvasContexts">WHATWG Wiki
CanvasContexts page</a>. <a href="references.html#refsWHATWGWIKI">[WHATWGWIKI]</a></p>
<p>Anyone is free to edit the WHATWG Wiki CanvasContexts page at any
time to add a new context type. These new context types must be
specified with the following information:</p>
<dl><dt>Keyword</dt>
<dd><p>The value of <var title="">contextID</var> that will return
the object for the new API.</p></dd>
<dt>Specification</dt>
<dd><p>A link to a formal specification of the context type's
API. It could be another page on the Wiki, or a link to an external
page. If the type does not have a formal specification, an informal
description can be substituted until such time as a formal
specification is available.</p></dd>
<dt>Compatible with</dt>
<dd><p>The list of context types that are compatible with this one
(i.e. that operate on the same underlying bitmap). This list must
be transitive and symmetric; if one context type is defined as
compatible with another, then all types it is compatible with must
be compatible with all types the other is compatible with.</p></dd>
</dl><p>Vendors may also define experimental contexts using the syntax
<code><var title="">vendorname</var>-<var title="">context</var></code>, for example,
<code>moz-3d</code>. Such contexts should be registered in the
WHATWG Wiki CanvasContexts page.</p>
</div><hr><dl class="domintro"><dt><var title="">url</var> = <var title="">canvas</var> . <code title="dom-canvas-toDataURL"><a href="#dom-canvas-todataurl">toDataURL</a></code>( [ <var title="">type</var>, ... ])</dt>
<dd>
<p>Returns a <a href="infrastructure.html#data-protocol" title="data protocol"><code title="">data:</code> URL</a> for the image in the canvas.</p>
<p>The first argument, if provided, controls the type of the image
to be returned (e.g. PNG or JPEG). The default is <code title="">image/png</code>; that type is also used if the given
type isn't supported. The other arguments are specific to the
type, and control the way that the image is generated, as given in
the table below.</p>
<p>When trying to use types other than "<code>image/png</code>",
authors can check if the image was really returned in the
requested format by checking to see if the returned string starts
with one of the exact strings "<code title="">data:image/png,</code>" or "<code title="">data:image/png;</code>". If it does, the image is PNG,
and thus the requested type was not supported. (The one exception
to this is if the canvas has either no height or no width, in
which case the result might simply be "<code title="">data:,</code>".)</p>
</dd>
<dt><var title="">canvas</var> . <code title="dom-canvas-toBlob"><a href="#dom-canvas-toblob">toBlob</a></code>(<var title="">callback</var> [, <var title="">type</var>, ... ])</dt>
<dd>
<p>Creates a <code><a href="infrastructure.html#blob">Blob</a></code> object representing a file
containing the image in the canvas, and invokes a callback with a
handle to that object.</p>
<p>The second argument, if provided, controls the type of the
image to be returned (e.g. PNG or JPEG). The default is <code title="">image/png</code>; that type is also used if the given
type isn't supported. The other arguments are specific to the
type, and control the way that the image is generated, as given in
the table below.</p>
</dd>
</dl><div class="impl">
<p>The <dfn id="dom-canvas-todataurl" title="dom-canvas-toDataURL"><code>toDataURL()</code></dfn> method
must run the following steps:</p>
<ol><li><p>If the canvas has no pixels (i.e. either its horizontal
dimension or its vertical dimension is zero) then return the string
"<code title="">data:,</code>" and abort these steps. (This is the
shortest <a href="infrastructure.html#data-protocol" title="data protocol"><code title="">data:</code>
URL</a>; it represents the empty string in a <code title="">text/plain</code> resource.)</p></li>
<li><p>Let <var title="">file</var> be <a href="#a-serialization-of-the-image-as-a-file">a serialization of the
image as a file</a>, using the method's arguments (if any) as
the <var title="">arguments</var>.</p></li>
<li><p>Return a <a href="infrastructure.html#data-protocol" title="data protocol"><code title="">data:</code> URL</a> representing <var title="">file</var>. <a href="references.html#refsRFC2397">[RFC2397]</a></p>
</li></ol><p>The <dfn id="dom-canvas-toblob" title="dom-canvas-toBlob"><code>toBlob()</code></dfn> method
must run the following steps:</p>
<ol><li><p>Let <var title="">callback</var> be the first
argument.</p></li>
<li><p>Let <var title="">arguments</var> be the second and
subsequent arguments to the method, if any.</p></li>
<li><p>Let <var title="">file</var> be <a href="#a-serialization-of-the-image-as-a-file">a serialization of the
image as a file</a>, using <var title="">arguments</var>.</p></li>
<li><p>Return, but continue running these steps
asynchronously.</p></li>
<li><p>If <var title="">callback</var> is null, abort these
steps.</p></li>
<li><p><a href="webappapis.html#queue-a-task">Queue a task</a> to invoke the
<code>FileCallback</code> <var title="">callback</var> with a
<code><a href="infrastructure.html#blob">Blob</a></code> object representing <var title="">file</var> as
its argument. The <a href="webappapis.html#task-source">task source</a> for this task is the
<dfn id="canvas-blob-serialization-task-source">canvas blob serialization task source</dfn>. <a href="references.html#refsFILESYSTEMAPI">[FILESYSTEMAPI]</a> <a href="references.html#refsFILEAPI">[FILEAPI]</a> </p></li>
</ol><p>When a user agent is to create <dfn id="a-serialization-of-the-image-as-a-file">a serialization of the image
as a file</dfn>, optionally with some given <var title="">arguments</var>, it must create an image file in the format
given by the first value of <var title="">arguments</var>, or, if
there are no <var title="">arguments</var>, in the PNG format. <a href="references.html#refsPNG">[PNG]</a></p>
<p>If <var title="">arguments</var> is not empty, the first value
must be interpreted as a <a href="infrastructure.html#mime-type" title="MIME type">MIME type</a>
giving the format to use. If the type has any parameters, it must be
treated as not supported.</p>
<p class="example">For example, the value "<code>image/png</code>" would
mean to generate a PNG image, the value "<code>image/jpeg</code>"
would mean to generate a JPEG image, and the value
"<code>image/svg+xml</code>" would mean to generate an SVG image
(which would probably require that the implementation actually keep
enough information to reliably render an SVG image from the canvas).</p>
<p>User agents must support PNG ("<code>image/png</code>"). User
agents may support other types. If the user agent does not support
the requested type, it must create the file using the PNG format. <a href="references.html#refsPNG">[PNG]</a></p>
<p>User agents must <a href="infrastructure.html#converted-to-ascii-lowercase" title="converted to ASCII
lowercase">convert the provided type to ASCII lowercase</a>
before establishing if they support that type.</p>
<p>For image types that do not support an alpha channel, the
serialized image must be the canvas image composited onto a solid
black background using the source-over operator.</p>
<p>If the first argument in <var title="">arguments</var> gives a
type corresponding to one of the types given in the first column of
the following table, and the user agent supports that type, then the
subsequent arguments, if any, must be treated as described in the
second cell of that row.</p>
</div><table><thead><tr><th> Type </th><th> Other arguments </th><th> Reference
</th></tr></thead><tbody><tr><td> <code>image/jpeg</code>
</td><td> The second argument<span class="impl">, if it</span> is a
number in the range 0.0 to 1.0 inclusive<span class="impl">, must
be</span> treated as the desired quality level. <span class="impl">If it is not a number or is outside that range, the
user agent must use its default value, as if the argument had
been omitted.</span>
</td><td> <a href="references.html#refsJPEG">[JPEG]</a>
</td></tr></tbody></table><div class="impl">
<p>For the purposes of these rules, an argument is considered to be
a number if it is converted to an IDL double value by the rules for
handling arguments of type <code title="">any</code> in the Web IDL
specification. <a href="references.html#refsWEBIDL">[WEBIDL]</a></p>
<p>Other arguments must be ignored and must not cause the user agent
to raise an exception. A future version of this specification will
probably define other parameters to be passed to these methods to
allow authors to more carefully control compression settings, image
metadata, etc.</p>
</div><div class="impl">
<h5 id="color-spaces-and-color-correction"><span class="secno">4.8.11.1 </span>Color spaces and color correction</h5>
<p>The <code><a href="#the-canvas-element">canvas</a></code> APIs must perform color correction at
only two points: when rendering images with their own gamma
correction and color space information onto the canvas, to convert
the image to the color space used by the canvas (e.g. using the 2D
Context's <code title="dom-context-2d-drawImage">drawImage()</code>
method with an <code><a href="embedded-content-1.html#htmlimageelement">HTMLImageElement</a></code> object), and when
rendering the actual canvas bitmap to the output device.</p>
<p class="note">Thus, in the 2D context, colors used to draw shapes
onto the canvas will exactly match colors obtained through the <code title="dom-context-2d-getImageData">getImageData()</code>
method.</p>
<p>The <code title="dom-canvas-toDataURL"><a href="#dom-canvas-todataurl">toDataURL()</a></code> method
must not include color space information in the resource
returned. Where the output format allows it, the color of pixels in
resources created by <code title="dom-canvas-toDataURL"><a href="#dom-canvas-todataurl">toDataURL()</a></code> must match those
returned by the <code title="dom-context-2d-getImageData">getImageData()</code>
method.</p>
<p>In user agents that support CSS, the color space used by a
<code><a href="#the-canvas-element">canvas</a></code> element must match the color space used for
processing any colors for that element in CSS.</p>
<p>The gamma correction and color space information of images must
be handled in such a way that an image rendered directly using an
<code><a href="embedded-content-1.html#the-img-element">img</a></code> element would use the same colors as one painted on
a <code><a href="#the-canvas-element">canvas</a></code> element that is then itself
rendered. Furthermore, the rendering of images that have no color
correction information (such as those returned by the <code title="dom-canvas-toDataURL"><a href="#dom-canvas-todataurl">toDataURL()</a></code> method) must be
rendered with no color correction.</p>
<p class="note">Thus, in the 2D context, calling the <code title="dom-context-2d-drawImage">drawImage()</code> method to render
the output of the <code title="dom-canvas-toDataURL"><a href="#dom-canvas-todataurl">toDataURL()</a></code> method to the
canvas, given the appropriate dimensions, has no visible effect.</p>
</div><div class="impl">
<h5 id="security-with-canvas-elements"><span class="secno">4.8.11.2 </span>Security with <code><a href="#the-canvas-element">canvas</a></code> elements</h5>
<p><strong>Information leakage</strong> can occur if scripts from
one <a href="origin-0.html#origin">origin</a> can access information (e.g. read pixels)
from images from another origin (one that isn't the <a href="origin-0.html#same-origin" title="same origin">same</a>).</p>
<p>To mitigate this, <code><a href="#the-canvas-element">canvas</a></code> elements are defined to
have a flag indicating whether they are <i>origin-clean</i>. All
<code><a href="#the-canvas-element">canvas</a></code> elements must start with their
<i>origin-clean</i> set to true. The flag must be set to false if
any of the following actions occur:</p>
<ul><li><p>The element's 2D context's <code title="dom-context-2d-drawImage">drawImage()</code> method is
called with an <code><a href="embedded-content-1.html#htmlimageelement">HTMLImageElement</a></code> or an
<code><a href="the-iframe-element.html#htmlvideoelement">HTMLVideoElement</a></code> whose <a href="origin-0.html#origin">origin</a> is not the
<a href="origin-0.html#same-origin" title="same origin">same</a> as that of the
<code><a href="infrastructure.html#document">Document</a></code> object that owns the <code><a href="#the-canvas-element">canvas</a></code>
element.</p></li>
<li><p>The element's 2D context's <code title="dom-context-2d-drawImage">drawImage()</code> method is
called with an <code><a href="#htmlcanvaselement">HTMLCanvasElement</a></code> whose
<i>origin-clean</i> flag is false.</p></li>
<li><p>The element's 2D context's <code title="dom-context-2d-fillStyle">fillStyle</code> attribute is set
to a <code>CanvasPattern</code> object that was created from an
<code><a href="embedded-content-1.html#htmlimageelement">HTMLImageElement</a></code> or an <code><a href="the-iframe-element.html#htmlvideoelement">HTMLVideoElement</a></code>
whose <a href="origin-0.html#origin">origin</a> was not the <a href="origin-0.html#same-origin" title="same
origin">same</a> as that of the <code><a href="infrastructure.html#document">Document</a></code> object
that owns the <code><a href="#the-canvas-element">canvas</a></code> element when the pattern was
created.</p></li>
<li><p>The element's 2D context's <code title="dom-context-2d-fillStyle">fillStyle</code> attribute is set
to a <code>CanvasPattern</code> object that was created from an
<code><a href="#htmlcanvaselement">HTMLCanvasElement</a></code> whose <i>origin-clean</i> flag was
false when the pattern was created.</p></li>
<li><p>The element's 2D context's <code title="dom-context-2d-strokeStyle">strokeStyle</code> attribute is
set to a <code>CanvasPattern</code> object that was created from an
<code><a href="embedded-content-1.html#htmlimageelement">HTMLImageElement</a></code> or an <code><a href="the-iframe-element.html#htmlvideoelement">HTMLVideoElement</a></code>
whose <a href="origin-0.html#origin">origin</a> was not the <a href="origin-0.html#same-origin" title="same
origin">same</a> as that of the <code><a href="infrastructure.html#document">Document</a></code> object
that owns the <code><a href="#the-canvas-element">canvas</a></code> element when the pattern was
created.</p></li>
<li><p>The element's 2D context's <code title="dom-context-2d-strokeStyle">strokeStyle</code> attribute is
set to a <code>CanvasPattern</code> object that was created from an
<code><a href="#htmlcanvaselement">HTMLCanvasElement</a></code> whose <i>origin-clean</i> flag was
false when the pattern was created.</p></li>
<li><p>The element's 2D context's <code title="dom-context-2d-fillText">fillText()</code> or <code title="dom-context-2d-fillText">strokeText()</code> methods are
invoked and consider using a font that has an <a href="origin-0.html#origin">origin</a>
that is not the <a href="origin-0.html#same-origin" title="same origin">same</a> as that of
the <code><a href="infrastructure.html#document">Document</a></code> object that owns the <code><a href="#the-canvas-element">canvas</a></code>
element. (The font doesn't even have to be used; all that matters
is whether the font was considered for any of the glyphs
drawn.)</p></li>
</ul><p>Whenever the <code title="dom-canvas-toDataURL"><a href="#dom-canvas-todataurl">toDataURL()</a></code> method of a
<code><a href="#the-canvas-element">canvas</a></code> element whose <i>origin-clean</i> flag is set to
false is called, the method must raise a <code><a href="common-dom-interfaces.html#security_err">SECURITY_ERR</a></code>
exception.</p>
<p>Whenever the <code title="dom-context-2d-getImageData">getImageData()</code> method of
the 2D context of a <code><a href="#the-canvas-element">canvas</a></code> element whose
<i>origin-clean</i> flag is set to false is called with otherwise
correct arguments, the method must raise a <code><a href="common-dom-interfaces.html#security_err">SECURITY_ERR</a></code>
exception.</p>
<p>Whenever the <code title="dom-context-2d-measureText">measureText()</code> method of
the 2D context of a <code><a href="#the-canvas-element">canvas</a></code> element ends up using a font
that has an <a href="origin-0.html#origin">origin</a> that is not the <a href="origin-0.html#same-origin" title="same
origin">same</a> as that of the <code><a href="infrastructure.html#document">Document</a></code> object that
owns the <code><a href="#the-canvas-element">canvas</a></code> element, the method must raise a
<code><a href="common-dom-interfaces.html#security_err">SECURITY_ERR</a></code> exception.</p>
<p class="note">Even resetting the canvas state by changing its
<code title="attr-canvas-width"><a href="#attr-canvas-width">width</a></code> or <code title="attr-canvas-height"><a href="#attr-canvas-height">height</a></code> attributes doesn't reset
the <i>origin-clean</i> flag.</p>
</div></body></html>