-
Notifications
You must be signed in to change notification settings - Fork 0
/
TR3.html
1393 lines (1253 loc) · 92 KB
/
TR3.html
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
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html dir="ltr" typeof="bibo:Document " about="" property="dcterms:language" content="en" lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- foo -->
<meta charset="UTF-8">
<title>Input Method Editor API</title>
<style>
body {
counter-reset: figcaption;
counter-reset: example;
}
figcaption {
font-weight: bold;
}
var {
font-weight: bold;
color: green;
padding-left: 2px;
padding-right: 4px;
}
.tocline {
padding-top: 2px;
}
.ed_mailto:before {
content: "<";
}
.ed_mailto:after {
content: ">";
}
</style>
<style>/*****************************************************************
* ReSpec 3 CSS
* Robin Berjon - http://berjon.com/
*****************************************************************/
/* --- INLINES --- */
em.rfc2119 {
text-transform: lowercase;
font-variant: small-caps;
font-style: normal;
color: #900;
}
h1 acronym, h2 acronym, h3 acronym, h4 acronym, h5 acronym, h6 acronym, a acronym,
h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr {
border: none;
}
dfn {
font-weight: bold;
}
a.internalDFN {
color: inherit;
border-bottom: 1px solid #99c;
text-decoration: none;
}
a.externalDFN {
color: inherit;
border-bottom: 1px dotted #ccc;
text-decoration: none;
}
a.bibref {
text-decoration: none;
}
cite .bibref {
font-style: normal;
}
code {
color: #ff4500;
}
/* --- TOC --- */
.toc a, .tof a {
text-decoration: none;
}
a .secno, a .figno {
color: #000;
}
ul.tof, ol.tof {
list-style: none outside none;
}
.caption {
margin-top: 0.5em;
font-style: italic;
}
/* --- TABLE --- */
table.simple {
border-spacing: 0;
border-collapse: collapse;
border-bottom: 3px solid #005a9c;
}
.simple th {
background: #005a9c;
color: #fff;
padding: 3px 5px;
text-align: left;
}
.simple th[scope="row"] {
background: inherit;
color: inherit;
border-top: 1px solid #ddd;
}
.simple td {
padding: 3px 10px;
border-top: 1px solid #ddd;
}
.simple tr:nth-child(even) {
background: #f0f6ff;
}
/* --- DL --- */
.section dd > p:first-child {
margin-top: 0;
}
.section dd > p:last-child {
margin-bottom: 0;
}
.section dd {
margin-bottom: 1em;
}
.section dl.attrs dd, .section dl.eldef dd {
margin-bottom: 0;
}
</style><style>/* --- EXAMPLES --- */
div.example-title {
min-width: 7.5em;
color: #b9ab2d;
}
div.example-title span {
text-transform: uppercase;
}
aside.example, div.example, div.illegal-example {
padding: 0.5em;
margin: 1em 0;
position: relative;
clear: both;
}
div.illegal-example { color: red }
div.illegal-example p { color: black }
aside.example, div.example {
padding: .5em;
border-left-width: .5em;
border-left-style: solid;
border-color: #e0cb52;
background: #fcfaee;
}
aside.example div.example {
border-left-width: .1em;
border-color: #999;
background: #fff;
}
aside.example div.example div.example-title {
color: #999;
}
</style><style>/* --- ISSUES/NOTES --- */
div.issue-title, div.note-title {
padding-right: 1em;
min-width: 7.5em;
color: #b9ab2d;
}
div.issue-title { color: #e05252; }
div.note-title { color: #2b2; }
div.issue-title span, div.note-title span {
text-transform: uppercase;
}
div.note, div.issue {
margin-top: 1em;
margin-bottom: 1em;
}
.note > p:first-child, .issue > p:first-child { margin-top: 0 }
.issue, .note {
padding: .5em;
border-left-width: .5em;
border-left-style: solid;
}
div.issue, div.note {
padding: 1em 1.2em 0.5em;
margin: 1em 0;
position: relative;
clear: both;
}
span.note, span.issue { padding: .1em .5em .15em; }
.issue {
border-color: #e05252;
background: #fbe9e9;
}
.note {
border-color: #52e052;
background: #e9fbe9;
}
</style><style>/* HIGHLIGHTS */
code.prettyprint {
color: inherit;
}
/* this from google-code-prettify */
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
</style><style>/* --- WEB IDL --- */
pre.idl {
border-top: 1px solid #90b8de;
border-bottom: 1px solid #90b8de;
padding: 1em;
line-height: 120%;
}
pre.idl::before {
content: "WebIDL";
display: block;
width: 150px;
background: #90b8de;
color: #fff;
font-family: initial;
padding: 3px;
font-weight: bold;
margin: -1em 0 1em -1em;
}
.idlType {
color: #ff4500;
font-weight: bold;
text-decoration: none;
}
/*.idlModule*/
/*.idlModuleID*/
/*.idlInterface*/
.idlInterfaceID, .idlDictionaryID, .idlCallbackID, .idlEnumID {
font-weight: bold;
color: #005a9c;
}
a.idlEnumItem {
color: #000;
border-bottom: 1px dotted #ccc;
text-decoration: none;
}
.idlSuperclass {
font-style: italic;
color: #005a9c;
}
/*.idlAttribute*/
.idlAttrType, .idlFieldType, .idlMemberType {
color: #005a9c;
}
.idlAttrName, .idlFieldName, .idlMemberName {
color: #ff4500;
}
.idlAttrName a, .idlFieldName a, .idlMemberName a {
color: #ff4500;
border-bottom: 1px dotted #ff4500;
text-decoration: none;
}
/*.idlMethod*/
.idlMethType, .idlCallbackType {
color: #005a9c;
}
.idlMethName {
color: #ff4500;
}
.idlMethName a {
color: #ff4500;
border-bottom: 1px dotted #ff4500;
text-decoration: none;
}
/*.idlCtor*/
.idlCtorName {
color: #ff4500;
}
.idlCtorName a {
color: #ff4500;
border-bottom: 1px dotted #ff4500;
text-decoration: none;
}
/*.idlParam*/
.idlParamType {
color: #005a9c;
}
.idlParamName, .idlDefaultValue {
font-style: italic;
}
.extAttr {
color: #666;
}
/*.idlSectionComment*/
.idlSectionComment {
color: gray;
}
/*.idlConst*/
.idlConstType {
color: #005a9c;
}
.idlConstName {
color: #ff4500;
}
.idlConstName a {
color: #ff4500;
border-bottom: 1px dotted #ff4500;
text-decoration: none;
}
/*.idlException*/
.idlExceptionID {
font-weight: bold;
color: #c00;
}
.idlTypedefID, .idlTypedefType {
color: #005a9c;
}
.idlRaises, .idlRaises a.idlType, .idlRaises a.idlType code, .excName a, .excName a code {
color: #c00;
font-weight: normal;
}
.excName a {
font-family: monospace;
}
.idlRaises a.idlType, .excName a.idlType {
border-bottom: 1px dotted #c00;
}
.excGetSetTrue, .excGetSetFalse, .prmNullTrue, .prmNullFalse, .prmOptTrue, .prmOptFalse {
width: 45px;
text-align: center;
}
.excGetSetTrue, .prmNullTrue, .prmOptTrue { color: #0c0; }
.excGetSetFalse, .prmNullFalse, .prmOptFalse { color: #c00; }
.idlImplements a {
font-weight: bold;
}
dl.attributes, dl.methods, dl.constants, dl.constructors, dl.fields, dl.dictionary-members {
margin-left: 2em;
}
.attributes dt, .methods dt, .constants dt, .constructors dt, .fields dt, .dictionary-members dt {
font-weight: normal;
}
.attributes dt code, .methods dt code, .constants dt code, .constructors dt code, .fields dt code, .dictionary-members dt code {
font-weight: bold;
color: #000;
font-family: monospace;
}
.attributes dt code, .fields dt code, .dictionary-members dt code {
background: #ffffd2;
}
.attributes dt .idlAttrType code, .fields dt .idlFieldType code, .dictionary-members dt .idlMemberType code {
color: #005a9c;
background: transparent;
font-family: inherit;
font-weight: normal;
font-style: italic;
}
.methods dt code {
background: #d9e6f8;
}
.constants dt code {
background: #ddffd2;
}
.constructors dt code {
background: #cfc;
}
.attributes dd, .methods dd, .constants dd, .constructors dd, .fields dd, .dictionary-members dd {
margin-bottom: 1em;
}
table.parameters, table.exceptions {
border-spacing: 0;
border-collapse: collapse;
margin: 0.5em 0;
width: 100%;
}
table.parameters { border-bottom: 1px solid #90b8de; }
table.exceptions { border-bottom: 1px solid #deb890; }
.parameters th, .exceptions th {
color: #fff;
padding: 3px 5px;
text-align: left;
font-family: initial;
font-weight: normal;
text-shadow: #666 1px 1px 0;
}
.parameters th { background: #90b8de; }
.exceptions th { background: #deb890; }
.parameters td, .exceptions td {
padding: 3px 10px;
border-top: 1px solid #ddd;
vertical-align: top;
}
.parameters tr:first-child td, .exceptions tr:first-child td {
border-top: none;
}
.parameters td.prmName, .exceptions td.excName, .exceptions td.excCodeName {
width: 100px;
}
.parameters td.prmType {
width: 120px;
}
table.exceptions table {
border-spacing: 0;
border-collapse: collapse;
width: 100%;
}
</style>
<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-WD"/>
<!--[if lt IE 9]><script src='https://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]--></head>
<body class="h-entry"><div class="head">
<p>
<a href="http://www.w3.org/"><img height="48" width="72" alt="W3C" src="http://www.w3.org/Icons/w3c_home"/></a>
</p>
<h1 class="title p-name" id="title" property="dcterms:title">Input Method Editor API</h1>
<h2 id="w3c-working-draft-15-august-2013" property="dcterms:issued" datatype="xsd:dateTime" content="2013-08-15T15:00:00.000Z"><abbr title="World Wide Web Consortium">W3C</abbr> Working Draft <time class="dt-published" datetime="2013-08-15">15 August 2013</time></h2>
<dl>
<dt>This version:</dt>
<dd><a href="http://www.w3.org/TR/2013/WD-ime-api-20130815/">http://www.w3.org/TR/2013/WD-ime-api-20130815/</a></dd>
<dt>Latest published version:</dt>
<dd><a href="http://www.w3.org/TR/ime-api/">http://www.w3.org/TR/ime-api/</a></dd>
<dt>Previous versions:</dt>
<dd><a href="http://www.w3.org/TR/2013/WD-ime-api-20130404/">http://www.w3.org/TR/2013/WD-ime-api-20130404/</a></dd>
<dd><a href="http://www.w3.org/TR/2012/WD-ime-api-20120524/">http://www.w3.org/TR/2012/WD-ime-api-20120524/</a></dd>
<dt>Latest editor's draft:</dt>
<dd><a href="http://dvcs.w3.org/hg/ime-api/raw-file/default/Overview.html">http://dvcs.w3.org/hg/ime-api/raw-file/default/Overview.html</a></dd>
<dt>Editors:</dt>
<dd class="p-author h-card vcard" rel="bibo:editor" inlist=""><span typeof="foaf:Person"><span property="foaf:name" class="p-name fn">Takayoshi Kochi</span>, Google, <span class="ed_mailto"><a class="u-email email" rel="foaf:mbox" href="mailto:kochi@google.com">kochi@google.com</a></span></span>
</dd>
<dd class="p-author h-card vcard" rel="bibo:editor" inlist=""><span typeof="foaf:Person"><span property="foaf:name" class="p-name fn">Kenji Baheux</span>, Google, <span class="ed_mailto"><a class="u-email email" rel="foaf:mbox" href="mailto:kenjibaheux@google.com">kenjibaheux@google.com</a></span></span>
</dd>
<dt>Previous editor:</dt>
<dd class="p-author h-card vcard" rel="bibo:editor" inlist=""><span typeof="foaf:Person"><span property="foaf:name" class="p-name fn">Hironori Bono (坊野 博典)</span>, (formerly) Google</span>
</dd>
</dl>
<p class="copyright">
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> ©
2013
<a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
(<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
<a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
<a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>), All Rights Reserved.
<abbr title="World Wide Web Consortium">W3C</abbr> <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and
<a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.
</p>
<hr>
</div>
<section rel="bibo:chapter" resource="#abstract" typeof="bibo:Chapter" datatype="" property="dcterms:abstract" class="introductory" id="abstract"><h2>Abstract</h2>
<p>This specification defines an “IME API” that provides
Web applications with scripted access to an IME
(<a href="#IME">input-method editor</a>) associated with
a hosting user agent. This IME API includes:</p>
<ul>
<li>An <a class="idlType" href="#idl-def-InputMethodContext"><code>InputMethodContext</code></a> interface, which provides methods to
retrieve detailed data from an in-progress IME
<a href="#ime-composition">composition</a>.</li>
<li>A <a class="idlType" href="#idl-def-Composition"><code>Composition</code></a> interface, which represents read-only
attributes about the current
<a href="#ime-composition">composition</a>, such as actual text
and its associated information.</li>
</ul>
<p>This API is designed to be used in conjunction with DOM events
[<cite><a href="#bib-DOM-LEVEL-3-EVENTS" class="bibref">DOM-LEVEL-3-EVENTS</a></cite>].</p>
</section><section rel="bibo:chapter" resource="#sotd" typeof="bibo:Chapter" id="sotd" class="introductory"><h2>Status of This Document</h2>
<p>
<em>This section describes the status of this document at the time of its publication. Other
documents may supersede this document. A list of current <abbr title="World Wide Web Consortium">W3C</abbr> publications and the latest revision
of this technical report can be found in the <a href="http://www.w3.org/TR/"><abbr title="World Wide Web Consortium">W3C</abbr> technical reports
index</a> at http://www.w3.org/TR/.</em>
</p>
<p>
This document is a proposal that is being made available for public
review in order to solicit feedback, particularly from
implementors, with a goal of potential cross-browser implementation
and standardization.
</p>
<p>
This document was published by the <a href="http://www.w3.org/2008/webapps/">Web Applications Working Group</a> as an Editor's Draft.
If you wish to make comments regarding this document, please send them to
<a href="mailto:public-webapps@w3.org">public-webapps@w3.org</a>
with <code>[ime-api]</code> at the start of the subject header
(<a href="mailto:public-webapps-request@w3.org?subject=subscribe">subscribe</a>,
<a href="http://lists.w3.org/Archives/Public/public-webapps/">archives</a>).
All comments are welcome.</p>
<p>
Publication as a Working Draft does not imply endorsement by the <abbr title="World Wide Web Consortium">W3C</abbr> Membership.
This is a draft document and may be updated, replaced or obsoleted by other documents at
any time. It is inappropriate to cite this document as other than work in progress.
</p>
<p>
This document was produced by a group operating under the
<a id="sotd_patent" about="" rel="w3p:patentRules" href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
<abbr title="World Wide Web Consortium">W3C</abbr> maintains a <a href="http://www.w3.org/2004/01/pp-impl/42538/status" rel="disclosure">public list of any patent disclosures</a>
made in connection with the deliverables of the group; that page also includes instructions for
disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the
information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
</p>
</section><section id="toc"><h2 class="introductory">Table of Contents</h2><ul class="toc"><li class="tocline"><a class="tocxref" href="#introduction"><span class="secno">1. </span>Introduction</a></li><li class="tocline"><a class="tocxref" href="#background"><span class="secno">2. </span>Background: What’s an Input Method Editor?</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#composer-section"><span class="secno">2.1 </span>Composer</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#phonetic-composer-section"><span class="secno">2.1.1 </span>Phonetic Composer</a></li><li class="tocline"><a class="tocxref" href="#radical-composer-section"><span class="secno">2.1.2 </span>Radical Composer</a></li><li class="tocline"><a class="tocxref" href="#on-screen-keyboard-section"><span class="secno">2.1.3 </span>On-Screen Keyboard</a></li></ul></li><li class="tocline"><a class="tocxref" href="#converter-section"><span class="secno">2.2 </span>Converter</a></li></ul></li><li class="tocline"><a class="tocxref" href="#conformance"><span class="secno">3. </span>Conformance</a></li><li class="tocline"><a class="tocxref" href="#terminology"><span class="secno">4. </span>Terminology and Algorithms</a></li><li class="tocline"><a class="tocxref" href="#the-inputmethodcontext-property"><span class="secno">5. </span>The inputMethodContext property</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#attributes"><span class="secno">5.1 </span>Attributes</a></li></ul></li><li class="tocline"><a class="tocxref" href="#composition-interface"><span class="secno">6. </span>The Composition Interface</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#attributes-1"><span class="secno">6.1 </span>Attributes</a></li><li class="tocline"><a class="tocxref" href="#methods"><span class="secno">6.2 </span>Methods</a></li></ul></li><li class="tocline"><a class="tocxref" href="#inputmethodcontext-interface"><span class="secno">7. </span>The InputMethodContext Interface</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#attributes-2"><span class="secno">7.1 </span>Attributes</a></li><li class="tocline"><a class="tocxref" href="#methods-1"><span class="secno">7.2 </span>Methods</a></li></ul></li><li class="tocline"><a class="tocxref" href="#best-practices"><span class="secno">8. </span>Best Practices</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#life-of-inputmethodcontext"><span class="secno">8.1 </span>Life of InputMethodContext</a></li><li class="tocline"><a class="tocxref" href="#drawing-composition-text"><span class="secno">8.2 </span>Drawing Composition Text</a></li></ul></li><li class="tocline"><a class="tocxref" href="#revision-history"><span class="secno">A. </span>Revision History</a></li><li class="tocline"><a class="tocxref" href="#references"><span class="secno">B. </span>References</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#normative-references"><span class="secno">B.1 </span>Normative references</a></li></ul></li></ul></section>
<section rel="bibo:chapter" resource="#introduction" typeof="bibo:Chapter" class="informative" id="introduction">
<!--OddPage--><h2><span class="secno">1. </span>Introduction</h2><p><em>This section is non-normative.</em></p>
<p>Even though existing Web-platform APIs allow developers to implement
very complicated Web applications, such as visual chat applications or
WYSIWYG presentation editors, developers have difficulties when
implementing Web applications that involve
<a href="#IME">input-method editors</a>.
To mitigate the difficulties,
<a href="http://www.w3.org/TR/DOM-Level-3-Events/">the DOM
Level 3 Events specification</a>[<cite><a href="#bib-DOM-LEVEL-3-EVENTS" class="bibref">DOM-LEVEL-3-EVENTS</a></cite>]
introduces <i>composition events</i>
to retrieve <a href="#ime-composition">composition text</a>
while it is being composed in an associated IME.</p>
<p>However, Web applications can still run into difficulties when
they want text input on non-editable elements such as the
<code><div></code> element without <code>contenteditable</code>
attribute being set to <code>true</code>, or interact with IMEs;
those difficulties include
the fact that a Web application cannot do the following:</p>
<ul>
<li>get input outside any editable element even with focus</li>
<li>indicate to the user whether the Web application renders
composition text by itself, or needs to ask user agents to
render it</li>
<li>determine the place where user agents render composition text</li>
<li>determine the place where user agents render
<a href="#candidate-window">candidate windows</a></li>
</ul>
<p>To solve these IME-related problems, this specification introduces
an IME API that allows Web applications to interact with the IME.
This specification introduces interfaces for
<a href="#ime-composition">compositions</a>,
so Web applications can read detailed composition data.
A <a class="idlType" href="#idl-def-Composition"><code>Composition</code></a> object provides a reference to an ongoing IME
<a href="#ime-composition">composition</a>,
so Web applications can retrieve the composition text and
its attributes. In addition,
this API also gives Web applications the ability to
give a hint as to where to position a
<a href="#composition-window">composition window</a>.
</p><p>There are also proposed standards related to IME:
</p><ul>
<li>Changing IME mode via CSS
(<a href="http://www.w3.org/TR/css3-ui/#ime-mode">ime-mode property
in CSS3 UI</a>)
</li><li>Controlling generic input modality
(<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#input-modalities:-the-inputmode-attribute">inputmode attribute in HTML spec</a>)
</li></ul>
They can work independently of this API.
<p></p>
<p>Please also refer to the separate
<a href="https://dvcs.w3.org/hg/ime-api/raw-file/default/use-cases/Overview.html">use cases for Input Method Editor
API </a>document for more information about possible use cases.</p>
<p>Consider the following examples.</p>
<p>This example shows the source which gives a hint for an IME
where the application wants it to avoid placing UI elements. A simple
web search page which gives a user suggestions while the user is
doing composition.</p>
<div class="example"><div class="example-title"><span>Example 1</span></div><pre class="example highlight prettyprint" id="ex-ime-suggest-position"><span class="dec"><!DOCTYPE html></span><span class="pln">
</span><span class="tag"><html></span><span class="pln">
</span><span class="tag"><head></span><span class="pln">
</span><span class="tag"><style</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/css"</span><span class="tag">></span><span class="pln">
</span><span class="com">#search0 {</span><span class="pln">
max</span><span class="pun">-</span><span class="pln">width</span><span class="pun">:</span><span class="pln"> </span><span class="lit">400px</span><span class="pun">;</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="com">#input0 {</span><span class="pln">
width</span><span class="pun">:</span><span class="pln"> </span><span class="lit">100</span><span class="pun">%;</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="com">#suggest0 {</span><span class="pln">
width</span><span class="pun">:</span><span class="pln"> </span><span class="lit">100</span><span class="pun">%;</span><span class="pln">
list</span><span class="pun">-</span><span class="pln">style</span><span class="pun">:</span><span class="pln"> none</span><span class="pun">;</span><span class="pln">
margin</span><span class="pun">:</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln">
padding</span><span class="pun">:</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln">
border</span><span class="pun">-</span><span class="pln">style</span><span class="pun">:</span><span class="pln"> solid</span><span class="pun">;</span><span class="pln">
border</span><span class="pun">-</span><span class="pln">width</span><span class="pun">:</span><span class="pln"> </span><span class="lit">1px</span><span class="pun">;</span><span class="pln">
border</span><span class="pun">-</span><span class="pln">color</span><span class="pun">:</span><span class="pln"> </span><span class="com">#000;</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="tag"></style></span><span class="pln">
</span><span class="tag"><script</span><span class="pln"> </span><span class="atn">language</span><span class="pun">=</span><span class="atv">"javascript"</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="tag">></span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> init</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> node </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">'input0'</span><span class="pun">);</span><span class="pln">
</span><span class="com">// This code only handles the compositionupdate event for brevity of the</span><span class="pln">
</span><span class="com">// example, but of course other input field changes should also be handled.</span><span class="pln">
node</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'compositionupdate'</span><span class="pun">,</span><span class="pln"> onCompositionUpdate</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="com">// Sends an XHR request to get search suggestions.</span><span class="pln">
</span><span class="com">// Upon receiving the result, expandSuggest() is called back.</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> getSuggests</span><span class="pun">(</span><span class="pln">query</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="com">// For brevity, implementation of this function is omitted.</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> expandSuggest</span><span class="pun">(</span><span class="pln">candidates</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="com">// Callback after getting search suggestions.</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> suggest </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">'suggest0'</span><span class="pun">);</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> i</span><span class="pun">;</span><span class="pln">
</span><span class="com">// Clear old suggestions.</span><span class="pln">
</span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="pln">i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i </span><span class="pun"><</span><span class="pln"> suggest</span><span class="pun">.</span><span class="pln">childNodes</span><span class="pun">.</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
suggest</span><span class="pun">.</span><span class="pln">removeChild</span><span class="pun">(</span><span class="pln">suggest</span><span class="pun">.</span><span class="pln">childNodes</span><span class="pun">[</span><span class="lit">0</span><span class="pun">]);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="com">// Render new suggeston list.</span><span class="pln">
</span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="pln">i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i </span><span class="pun"><</span><span class="pln"> candidates</span><span class="pun">.</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
suggest</span><span class="pun">.</span><span class="pln">appendChild</span><span class="pun">(</span><span class="pln">document</span><span class="pun">.</span><span class="pln">createElement</span><span class="pun">(</span><span class="str">'li'</span><span class="pun">));</span><span class="pln">
suggest</span><span class="pun">.</span><span class="pln">childNodes</span><span class="pun">[</span><span class="pln">i</span><span class="pun">].</span><span class="pln">textContent </span><span class="pun">=</span><span class="pln"> candidates</span><span class="pun">[</span><span class="pln">i</span><span class="pun">];</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="com">// Set exclusion area hint for the IME.</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> input </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">'input0'</span><span class="pun">);</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> context </span><span class="pun">=</span><span class="pln"> input</span><span class="pun">.</span><span class="pln">inputMethodContext</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> relative_x </span><span class="pun">=</span><span class="pln"> suggest</span><span class="pun">.</span><span class="pln">offsetLeft </span><span class="pun">-</span><span class="pln"> input</span><span class="pun">.</span><span class="pln">offsetLeft</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> relative_y </span><span class="pun">=</span><span class="pln"> suggest</span><span class="pun">.</span><span class="pln">offsetTop </span><span class="pun">-</span><span class="pln"> input</span><span class="pun">.</span><span class="pln">offsetTop</span><span class="pun">;</span><span class="pln">
context</span><span class="pun">.</span><span class="pln">setExclusionRectangle</span><span class="pun">(</span><span class="pln">input</span><span class="pun">,</span><span class="pln"> relative_x</span><span class="pun">,</span><span class="pln"> relative_y</span><span class="pun">,</span><span class="pln">
suggest</span><span class="pun">.</span><span class="pln">offsetWidth</span><span class="pun">,</span><span class="pln">
suggest</span><span class="pun">.</span><span class="pln">offsetHeight</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> onCompositionUpdate</span><span class="pun">(</span><span class="pln">event</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> query </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">'input0'</span><span class="pun">).</span><span class="pln">value</span><span class="pun">;</span><span class="pln">
getSuggests</span><span class="pun">(</span><span class="pln">query</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="tag"></script></span><span class="pln">
</span><span class="tag"></head></span><span class="pln">
</span><span class="tag"><body></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"search0"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><input</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"input0"</span><span class="pln"> </span><span class="atn">placeholder</span><span class="pun">=</span><span class="atv">"search here"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><ul</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"suggest0"</span><span class="tag">></ul></span><span class="pln">
</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"></body></span><span class="pln">
</span><span class="tag"></html></span></pre></div>
<p>This example shows the source which draws composition text in
its own style.</p>
<div class="note"><div aria-level="3" class="note-title" role="heading"><span>Note</span></div><p class="">For the usage of compositionupdate event, see also
the note in
<a href="#drawing-composition-text">Drawing Composition Text</a>
section.
</p></div>
<div class="example"><div class="example-title"><span>Example 2</span></div><pre class="example highlight prettyprint" id="ex-drawing-composition"><span class="dec"><!DOCTYPE html></span><span class="pln">
</span><span class="tag"><html></span><span class="pln">
</span><span class="tag"><head></span><span class="pln">
</span><span class="tag"><style></span><span class="pln">
</span><span class="pun">.</span><span class="pln">clause </span><span class="pun">{</span><span class="pln">
margin</span><span class="pun">-</span><span class="pln">right</span><span class="pun">:</span><span class="pln"> </span><span class="lit">2px</span><span class="pun">;</span><span class="pln">
border</span><span class="pun">-</span><span class="pln">style</span><span class="pun">:</span><span class="pln"> solid</span><span class="pun">;</span><span class="pln">
border</span><span class="pun">-</span><span class="pln">width</span><span class="pun">:</span><span class="pln"> </span><span class="lit">0px</span><span class="pln"> </span><span class="lit">0px</span><span class="pln"> </span><span class="lit">1px</span><span class="pln"> </span><span class="lit">0px</span><span class="pun">;</span><span class="pln">
border</span><span class="pun">-</span><span class="pln">color</span><span class="pun">:</span><span class="pln"> </span><span class="com">#333333;</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="pun">.</span><span class="pln">selected </span><span class="pun">{</span><span class="pln">
border</span><span class="pun">-</span><span class="pln">width</span><span class="pun">:</span><span class="pln"> </span><span class="lit">0px</span><span class="pln"> </span><span class="lit">0px</span><span class="pln"> </span><span class="lit">2px</span><span class="pln"> </span><span class="lit">0px</span><span class="pun">;</span><span class="pln">
border</span><span class="pun">-</span><span class="pln">color</span><span class="pun">:</span><span class="pln"> </span><span class="com">#000000;</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="tag"></style></span><span class="pln">
</span><span class="tag"><script</span><span class="pln"> </span><span class="atn">language</span><span class="pun">=</span><span class="atv">"javascript"</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="tag">></span><span class="pln">
</span><span class="com">// compositionupdate event handler</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> onCompositionUpdate</span><span class="pun">(</span><span class="pln">event</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> target </span><span class="pun">=</span><span class="pln"> event</span><span class="pun">.</span><span class="pln">target</span><span class="pun">;</span><span class="pln">
</span><span class="com">// Remove all children.</span><span class="pln">
</span><span class="kwd">while</span><span class="pln"> </span><span class="pun">(</span><span class="pln">target</span><span class="pun">.</span><span class="pln">childNodes</span><span class="pun">.</span><span class="pln">length </span><span class="pun"><</span><span class="pln"> </span><span class="lit">0</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
edit</span><span class="pun">.</span><span class="pln">removeChild</span><span class="pun">(</span><span class="pln">edit</span><span class="pun">.</span><span class="pln">childNodes</span><span class="pun">[</span><span class="lit">0</span><span class="pun">]);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="com">// Get the IME context.</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> ctx </span><span class="pun">=</span><span class="pln"> target</span><span class="pun">.</span><span class="pln">inputMethodContext</span><span class="pun">;</span><span class="pln">
</span><span class="com">// Create clause spans.</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> text </span><span class="pun">=</span><span class="pln"> ctx</span><span class="pun">.</span><span class="pln">text</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> segments </span><span class="pun">=</span><span class="pln"> ctx</span><span class="pun">.</span><span class="pln">segments</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="pln">i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i </span><span class="pun"><</span><span class="pln"> segments</span><span class="pun">.</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> span </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">createElement</span><span class="pun">(</span><span class="str">'span'</span><span class="pun">);</span><span class="pln">
span</span><span class="pun">.</span><span class="pln">classList</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="str">'clause'</span><span class="pun">);</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> selected </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">segments</span><span class="pun">[</span><span class="pln">i</span><span class="pun">]</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> ctx</span><span class="pun">.</span><span class="pln">selectionStart</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
selected </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">;</span><span class="pln">
span</span><span class="pun">.</span><span class="pln">classList</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="str">'selected'</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> end </span><span class="pun">=</span><span class="pln"> text</span><span class="pun">.</span><span class="pln">length</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">i </span><span class="pun"><</span><span class="pln"> segments</span><span class="pun">.</span><span class="pln">length </span><span class="pun">-</span><span class="pln"> </span><span class="lit">1</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
end </span><span class="pun">=</span><span class="pln"> segments</span><span class="pun">[</span><span class="pln">i </span><span class="pun">+</span><span class="pln"> </span><span class="lit">1</span><span class="pun">];</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
span</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">=</span><span class="pln"> text</span><span class="pun">.</span><span class="pln">substring</span><span class="pun">(</span><span class="pln">ctx</span><span class="pun">.</span><span class="pln">segments</span><span class="pun">[</span><span class="pln">i</span><span class="pun">],</span><span class="pln"> end</span><span class="pun">);</span><span class="pln">
target</span><span class="pun">.</span><span class="pln">appendChild</span><span class="pun">(</span><span class="pln">span</span><span class="pun">);</span><span class="pln">
</span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">selected</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
ctx</span><span class="pun">.</span><span class="pln">setCaretRectangle</span><span class="pun">(</span><span class="pln">document</span><span class="pun">.</span><span class="pln">body</span><span class="pun">,</span><span class="pln"> rect</span><span class="pun">.</span><span class="pln">left</span><span class="pun">,</span><span class="pln"> rect</span><span class="pun">.</span><span class="pln">top</span><span class="pun">,</span><span class="pln">
rect</span><span class="pun">.</span><span class="pln">width</span><span class="pun">,</span><span class="pln"> rect</span><span class="pun">.</span><span class="pln">height</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="com">// Prevent the browser from drawing composition text.</span><span class="pln">
event</span><span class="pun">.</span><span class="pln">preventDefault</span><span class="pun">();</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="kwd">function</span><span class="pln"> init</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> composition </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">'composition'</span><span class="pun">);</span><span class="pln">
composition</span><span class="pun">.</span><span class="pln">focus</span><span class="pun">();</span><span class="pln">
composition</span><span class="pun">.</span><span class="pln">addEventHandler</span><span class="pun">(</span><span class="str">'compositionupdate'</span><span class="pun">,</span><span class="pln"> onCompositionUpdate</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="tag"></script></span><span class="pln">
</span><span class="tag"></head></span><span class="pln">
</span><span class="tag"><body</span><span class="pln"> </span><span class="atn">onload</span><span class="pun">=</span><span class="atv">"</span><span class="pln">init</span><span class="pun">();</span><span class="atv">"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"composition"</span><span class="tag">></div></span><span class="pln">
</span><span class="tag"></body></span><span class="pln">
</span><span class="tag"></html></span></pre></div>
</section>
<section rel="bibo:chapter" resource="#background" typeof="bibo:Chapter" class="informative" id="background">
<!--OddPage--><h2><span class="secno">2. </span>Background: What’s an Input Method Editor?</h2><p><em>This section is non-normative.</em></p>
<p>An <dfn id="IME">IME</dfn> (input-method editor) is an application
that allows a standard keyboard (such as a US-101 keyboard) to be used
to type characters and symbols that are not directly represented on the
keyboard itself. In China, Japan, and Korea, IMEs are used ubiquitously
to enable standard keyboards to be employed to type the very large
number of characters required for writing in Chinese, Japanese, and
Korean.</p>
<p>On platforms with touch-based input device such as mobile phones,
an IME also plays a role to type text that a simple on-screen keyboard
cannot type directly.</p>
<p>A <dfn id="system-ime">system IME</dfn> is an IME already installed
on a user's system.
</p><p>An IME consists of two modules; a <a href="#composer">composer</a>
and a <a href="#converter">converter</a>.</p>
<p>A <dfn id="composer">composer</dfn> is a context-free parser that
composes non-ASCII characters (including phonetic characters) from
keystrokes, e.g. Hiragana or Pinyin.</p>
<p>A <dfn id="converter">converter</dfn> is a context-sensitive parser
that looks up a dictionary to convert phonetic characters to
a set of ideographic characters, e.g. Kanji.</p>
<p>An <dfn id="ime-clause">IME clause</dfn> is a grammatical word
produced in an IME.</p>
<p>An <dfn id="ime-selected-clause">IME selected clause</dfn> is an
<a href="#ime-clause">IME clause</a> currently being converted by
an IME.</p>
<p>An <dfn id="ime-composition">IME composition</dfn>
is an instance of text produced in an IME. For IMEs that can produce
multiple words, an IME composition consists of multiple IME clauses.
For IMEs that produce only one word, an IME composition is equal to an
IME clause.</p>
<p>When an IME receives keystrokes, it sends the keystrokes to a
composer and receives phonetic characters matching to the keystrokes.
When an IME receives phonetic characters from a composer, it sends the
phonetic characters to a converter and receives the list of ideographic
characters matching to the phonetic characters. The following figure
shows the basic structure of an IME.</p>
<figure id="fig-ime-structure">
<p><img src="TR3_files/image10.png" height="199" width="615"></p>
<figcaption>Fig. <span class="figno">1</span> <span class="fig-title">Basic structure of an IME</span></figcaption>
</figure>
<section rel="bibo:chapter" resource="#composer-section" typeof="bibo:Chapter" id="composer-section">
<h3><span class="secno">2.1 </span>Composer</h3><p><em>This section is non-normative.</em></p>
<p>A composer consists of two types of composers: a
<a href="#phonetic-composer">phonetic composer</a>
and a
<a href="#radical-composer">radical composer</a>.</p>
<p>A <dfn id="phonetic-composer">phonetic composer</dfn> composes a phonetic
character from its ASCII representation.</p>
<p>A <dfn id="radical-composer">radical composer</dfn> composes a
phonetic character from <a href="#phonetic-radical">phonetic radicals</a>.</p>
<p>A <dfn id="phonetic-radical">phonetic radical</dfn> is a character
component of a Latin character, a Chinese character, or a Korean
character. A Latin character can consist of an ASCII character and
accent marks, e.g. the character ‘á’ consists of
the ASCII character ‘a’ and the accent mark
‘´’. A Chinese character can consist of Chinese
character components that refer to its semantic origins, e.g. the
Chinese character ‘略’ consists of two components
‘田’ and ‘各’. A Korean
character consists of Korean character components that represent
consonants or vowels, e.g. the Korean character
‘가’ consists of the consonant
‘ㄱ’ and the vowel ‘ㅏ’.</p>
<p>A <dfn id="composition-window">composition window</dfn> is a window
that shows ASCII characters being composed by
<a href="#phonetic-composer">phonetic composers</a> or
<a href="#phonetic-radical">phonetic radicals</a> being composed by
<a href="#radical-composer">radical composers</a>.</p>
<p>An IME usually shows the text being composed by a composer with its
own style to distinguish it from the existing text. Even though most
of composers output phonetic characters, some composers (such as
Bopomofo composers) output a placeholder character
instead of phonetic characters while composing text.</p>
<section rel="bibo:chapter" resource="#phonetic-composer-section" typeof="bibo:Chapter" id="phonetic-composer-section">
<h4><span class="secno">2.1.1 </span>Phonetic Composer</h4><p><em>This section is non-normative.</em></p>
<p>Phonetic composers are not only used for typing Simplified
Chinese and Japanese, but also used for typing non-ASCII
characters (such as mathematical symbols, Yi, Amharic, etc.) with
a US-101 keyboard. Each of these languages has a mapping table
from its character to a sequence of ASCII characters representing
its pronunciation: e.g.,
‘か’ to ‘ka’ in Japanese, and;
‘卡’ to ‘ka’ in Simplified Chinese.
This mapping table is called as Romaji for Japanese and Pinyin for
Simplified Chinese, respectively. A phonetic composer uses these
mapping tables to compose a phonetic character from a sequence of
ASCII characters produced by a US keyboard.</p>
<p>An example of a phonetic composer for Simplified Chinese outputs
the ASCII characters that were input by the user, as its
composition text.</p>
<figure id="fig-ascii-composition-text">
<p><img src="TR3_files/image11.png" height="180" width="352"></p>
<figcaption>Fig. <span class="figno">2</span> <span class="fig-title">Composition text (Simplified Chinese)</span></figcaption>
</figure>
<p>On the other hand, a typical phonetic composer for Japanese
outputs phonetic characters when the typed ASCII characters have
corresponding phonetic characters.</p>
<figure id="fig-kana-composition-text">
<p><img src="TR3_files/image13.png" height="180" width="352"></p>
<figcaption>Fig. <span class="figno">3</span> <span class="fig-title">Composition text (Japanese)</span></figcaption>
</figure>
<p>An example of a phonetic composer for mathematical symbols
outputs composed mathematical symbol and shows the source
keystrokes in its own window, which is an example of a composition
window.</p>
<figure id="fig-composition-window">
<p><img src="TR3_files/image14.png" height="214" width="435"></p>
<figcaption>Fig. <span class="figno">4</span> <span class="fig-title">Composition text (Latex input)</span></figcaption>
</figure>
</section>
<section rel="bibo:chapter" resource="#radical-composer-section" typeof="bibo:Chapter" id="radical-composer-section">
<h4><span class="secno">2.1.2 </span>Radical Composer</h4>
<p>Radical composers are mainly used for typing Traditional
Chinese and Korean with phonetic keyboards. Each phonetic
keyboard of these languages can produce phonetic radicals:
e.g., typing ‘r’ produces ‘ㄱ’
on a Korean keyboard; typing ‘o’ produces
‘人’ on a Traditional-Chinese (or Bopomofo)
keyboard, etc. A radical composer composes a phonetic
character from phonetic radicals given by these keyboards:
e.g., typing ‘ㄱ’ (r) and ‘ㅏ’
(k) produces ‘가’ on a Korean keyboard;
typing ‘人’ (o), ‘弓’ (n), and
‘火’ (f) produces ‘你’ on a
Traditional-Chinese keyboard, etc.</p>
<p>A radical composer for Korean outputs the phonetic radicals as
its composition text.</p>
<figure id="fig-radical-composer-korean">
<p><img src="TR3_files/image15.png" height="180" width="352"></p>
<figcaption>Fig. <span class="figno">5</span> <span class="fig-title">Radical composer (Korean)</span></figcaption>
</figure>
<p>A radical composer for Traditional Chinese outputs a
placeholder character (U+3000) and shows the phonetic radicals
being composed to its own window. This window is an example
of a composition window.</p>
<figure id="fig-radical-composer-chinese">
<p><img src="TR3_files/image02.png" height="180" width="352"></p>
<figcaption>Fig. <span class="figno">6</span> <span class="fig-title">Radical composer (Traditional Chinese)</span></figcaption>
</figure>
<p>Some platforms (such as Mac and Linux) use radical composers
for typing accented characters used in European countries.
For example,
typing ‘ ̈ ’ (option+u) and ‘a’ (a)
produces ‘ä’ on US keyboards of Mac.</p>
<figure id="fig-radical-composer-mac">
<p><img src="TR3_files/image01.png" height="177" width="479"></p>
<figcaption>Fig. <span class="figno">7</span> <span class="fig-title">Radical composer (Mac)</span></figcaption>
</figure>
</section>
<section rel="bibo:chapter" resource="#on-screen-keyboard-section" typeof="bibo:Chapter" id="on-screen-keyboard-section">
<h4><span class="secno">2.1.3 </span>On-Screen Keyboard</h4>
<p>On touch-based platforms without hardware keyboard like
mobile phone or tablet platforms, some kind of on-screen keyboard
is displayed to help a user typing text, which occupies some
part of the screen. A user uses this keyboard to type composition
text.</p>
<figure id="fig-on-screen-keyboard-english">
<p><img src="TR3_files/mobile_ime_keyboard_en.png" height="557" width="416"></p>
<figcaption>Fig. <span class="figno">8</span> <span class="fig-title">An example of an on-screen keyboard (English)</span></figcaption>
</figure>
<p>The layout of an on-screen keyboard may vary depending on
language or its input modality (e.g. a telephone number
input field requires number buttons only).</p>
<figure id="fig-on-screen-keyboard-japanese">
<p><img src="TR3_files/mobile_ime_keyboard_jp.png" height="467" width="416"></p>
<figcaption>Fig. <span class="figno">9</span> <span class="fig-title">An example of an on-screen keyboard (Japanese)</span></figcaption>
</figure>
</section>
</section>
<section rel="bibo:chapter" resource="#converter-section" typeof="bibo:Chapter" id="converter-section">
<h3><span class="secno">2.2 </span>Converter</h3>
<p>A converter is a context-sensitive parser used for replacing
the outputs of a composer to ideographic characters on Chinese,
Japanese, and Korean.</p>
<div class="note"><div aria-level="4" class="note-title" role="heading"><span>Note</span></div><p class="">Korean seldom uses ideographic characters.</p></div>
<p>Because Chinese, Japanese, and Korean have many homonyms, each
sequence of phonetic characters usually matches many ideographic
characters: e.g., a Japanese
phonetic character ‘か’ matches Japanese
ideographic characters
‘化’, ‘科’,
‘課’,
etc.; Pinyin characters ‘ka’ matches Simplified-Chinese
ideographic characters ‘卡’,
‘喀’,
‘咯’, etc.; Bopomofo characters
‘人弓’ matches Traditional-Chinese
ideographic characters ‘乞’,
‘亿’, ‘亇’, etc.</p>
<p>A converter looks up a dictionary and shows a list of
candidates of possible ideographic characters so a user can choose
one. This list is known as a <dfn id="candidate-list">candidate