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
//
// DO NOT EDIT.  THIS FILE IS GENERATED FROM ../../../dist/idl/nsITextInputProcessor.idl
//


/// `interface nsITextInputProcessor : nsISupports`
///

/// ```text
/// /**
///  * An nsITextInputProcessor instance is associated with a top level widget which
///  * handles native IME.  It's associated by calling beginInputTransaction() or
///  * beginInputTransactionForTests().  While an instance has composition, nobody
///  * can steal the rights to make composition on the top level widget.  In other
///  * words, if another instance is composing on a top level widget, either
///  * beginInputTransaction() or beginInputTransactionForTests() returns false
///  * (i.e., not throws an exception).
///  *
///  * NOTE: See nsITextInputProcessorCallback.idl for examples of |callback| in
///  *       following examples,
///  *
///  * Example #1 JS-IME can start composition like this:
///  *
///  *   var TIP = Components.classes["@mozilla.org/text-input-processor;1"].
///  *               createInstance(Components.interfaces.nsITextInputProcessor);
///  *   if (!TIP.beginInputTransaction(window, callback)) {
    ///  *     return; // You failed to get the rights to make composition
    ///  *   }
///  *   // Create a keyboard event if the following compositionc change is caused
///  *   // by a key event.
///  *   var keyEvent =
///  *     new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz });
///  *   // Set new composition string first
///  *   TIP.setPendingCompositionString("some-words-are-inputted");
///  *   // Set clause information.
///  *   TIP.appendClauseToPendingComposition(23, TIP.ATTR_RAW_CLAUSE);
///  *   // Set caret position, this is optional.
///  *   TIP.setCaretInPendingComposition(23);
///  *   // Flush the pending composition
///  *   if (!TIP.flushPendingComposition(keyEvent)) {
    ///  *     // If it returns false, it fails to start composition.
    ///  *     return;
    ///  *   }
///  *
///  * Example #2 JS-IME can separate composition string to two or more clauses:
///  *
///  *   // Create a keyboard event if the following compositionc change is caused
///  *   // by a key event.
///  *   var keyEvent =
///  *     new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz });
///  *   // First, set composition string again
///  *   TIP.setPendingCompositionString("some-words-are-inputted");
///  *   // Then, if "are" is selected to convert, there are 3 clauses:
///  *   TIP.appendClauseToPendingComposition(11, TIP.ATTR_CONVERTED_CLAUSE);
///  *   TIP.appendClauseToPendingComposition(3,  TIP.ATTR_SELECTED_CLAUSE);
///  *   TIP.appendClauseToPendingComposition(9,  TIP.ATTR_CONVERTED_CLAUSE);
///  *   // Show caret at the beginning of the selected clause
///  *   TIP.setCaretInPendingComposition(11);
///  *   // Flush the pending composition.  Note that if there is a composition,
///  *   // flushPendingComposition() won't return false.
///  *   TIP.flushPendingComposition(keyEvent);
///  *
///  * Example #3 JS-IME can commit composition with specific string with this:
///  *
///  *   // Create a keyboard event if the following compositionc change is caused
///  *   // by a key event.
///  *   var keyEvent1 =
///  *     new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz });
///  *   // First, there is a composition.
///  *   TIP.setPendingCompositionString("some-words-directly-inputted");
///  *   TIP.appendClauseToPendingComposition(28, TIP.ATTR_RAW_CLAUSE);
///  *   TIP.flushPendingComposition(keyEvent1);
///  *   // Create a keyboard event if the following commit composition is caused
///  *   // by a key event.
///  *   var keyEvent2 =
///  *     new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz });
///  *   // This is useful when user selects a commit string from candidate list UI
///  *   // which is provided by JS-IME.
///  *   TIP.commitCompositionWith("selected-words-from-candidate-list", keyEvent2);
///  *
///  * Example #4 JS-IME can commit composition with the last composition string
///  *            without specifying commit string:
///  *
///  *   // Create a keyboard event if the following compositionc change is caused
///  *   // by a key event.
///  *   var keyEvent1 =
///  *     new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz });
///  *   // First, there is a composition.
///  *   TIP.setPendingCompositionString("some-words-will-be-commited");
///  *   TIP.appendClauseToPendingComposition(27, TIP.ATTR_RAW_CLAUSE);
///  *   TIP.flushPendingComposition(keyEvent1);
///  *   // Create a keyboard event if the following commit is caused by a key
///  *   // event.
///  *   var keyEvent2 =
///  *     new KeyboardEvent("", { key: "Enter", code: "Enter",
        ///                                keyCode: KeyboardEvent.DOM_VK_RETURN });
///  *   // This is useful when user just type Enter key.
///  *   TIP.commitComposition(keyEvent2);
///  *
///  * Example #5 JS-IME can cancel composition with this:
///  *
///  *   // Create a keyboard event if the following composition change is caused
///  *   // by a key event.
///  *   var keyEvent1 =
///  *     new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz });
///  *   // First, there is a composition.
///  *   TIP.setPendingCompositionString("some-words-will-be-canceled");
///  *   TIP.appendClauseToPendingComposition(27, TIP.ATTR_RAW_CLAUSE);
///  *   TIP.flushPendingComposition(keyEvent1);
///  *   // Create a keyboard event if the following canceling composition is
///  *   // caused by a key event.
///  *   var keyEvent2 =
///  *     new KeyboardEvent("", { key: "Escape", code: "Escape",
        ///                                keyCode: KeyboardEvent.DOM_VK_ESCAPE });
///  *   // This is useful when user doesn't want to commit the composition.
///  *   // FYI: This is same as TIP.commitCompositionWith("") for now.
///  *   TIP.cancelComposition(keyEvent2);
///  *
///  * Example #6 JS-IME can insert text only with commitCompositionWith():
///  *
///  *   // Create a keyboard event if the following inserting text is caused by a
///  *   // key event.
///  *   var keyEvent1 =
///  *     new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz });
///  *   if (!TIP.beginInputTransaction(window, callback)) {
    ///  *     return; // You failed to get the rights to make composition
    ///  *   }
///  *   TIP.commitCompositionWith("Some words", keyEvent1);
///  *
///  * Example #7 JS-IME can start composition explicitly:
///  *
///  *   if (!TIP.beginInputTransaction(window, callback)) {
    ///  *     return; // You failed to get the rights to make composition
    ///  *   }
///  *   // Create a keyboard event if the following starting composition is caused
///  *   // by a key event.
///  *   var keyEvent1 =
///  *     new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz });
///  *   // If JS-IME don't want to show composing string in the focused editor,
///  *   // JS-IME can dispatch only compositionstart event with this.
///  *   if (!TIP.startComposition(keyEvent1)) {
    ///  *     // Failed to start composition.
    ///  *     return;
    ///  *   }
///  *   // And when user selects a result from UI of JS-IME, commit with it.
///  *   // Then, the key event should be null.
///  *   TIP.commitCompositionWith("selected-words");
///  *
///  * Example #8 JS-IME or JS-Keyboard should dispatch key events even during
///  *            composition (non-printable key case):
///  *
///  *   if (!TIP.beginInputTransaction(window, callback)) {
    ///  *     return; // You failed to get the rights to dispatch key events
    ///  *   }
///  *
///  *   // You don't need to specify .keyCode value if it's non-printable key
///  *   // because it can be computed from .key value.
///  *   // If you specify non-zero value to .keyCode, it'll be used.
///  *   var keyEvent = new KeyboardEvent("", { code: "Enter", key: "Enter" });
///  *   if (TIP.keydown(keyEvent)) {
    ///  *     // Handle its default action
    ///  *   }
///  *
///  *   // Even if keydown event was consumed, keyup event should be dispatched.
///  *   if (TIP.keyup(keyEvent)) {
    ///  *     // Handle its default action
    ///  *   }
///  *
///  * Example #9 JS-IME or JS-Keyboard should dispatch key events even during
///  *            composition (printable key case):
///  *
///  *   if (!TIP.beginInputTransaction(window, callback)) {
    ///  *     return; // You failed to get the rights to dispatch key events
    ///  *   }
///  *
///  *   // You need to specify .keyCode value if it's printable key.
///  *   // The rules of .keyCode value is documented in MDN:
///  *   //   https://developer.mozilla.org/docs/Web/API/KeyboardEvent.keyCode
///  *   //
///  *   //   #1 If the key location is DOM_KEY_LOCATION_NUMPAD and NumLock is
///  *   //      active, you should specify DOM_VK_NUMPAD[0-9], DOM_VK_MULTIPLY,
///  *   //      DOM_VK_ADD, DOM_VK_SEPARATOR, DOM_VK_SUBTRACT, DOM_VK_DECIMAL or
///  *   //      DOM_VK_DIVIDE.
///  *   //   #2 If the key is Spacebar, use DOM_VK_SPACE.
///  *   //
///  *   //   Following rules are printable keys in DOM_KEY_LOCATION_STANDARD.
///  *   //   .keyCode value for a key shouldn't be changed by modifier states:
///  *   //     #1 If the key can input [0-9] with any modifier state (except
    ///  *   //        NumLock state), the value should be DOM_VK_[0-9].
///  *   //     #2 Otherwise, and if the key inputs an ASCII alphabet with no
///  *   //        active modifiers, use DOM_VK_[A-Z].
///  *   //     #3 Otherwise, and if the key inputs an ASCII alphabet with no
///  *   //        active modifiers except Shift key state, use DOM_VK_[A-Z] for
///  *   //        the shifted character.  E.g., if a key causes non-alphabet
///  *   //        character such as "@" or a Unicode character without Shift key
///  *   //        but "a" is inputted when Shift key is pressed, the proper
///  *   //        keyCode is DOM_VK_A.
///  *   //     #4 Otherwise, and if the key inputs another ASCII character with
///  *   //        no modifier states, use a proper value for the character.  E.g.,
///  *   //        if the key inputs "*" without Shift key state, it should be
///  *   //        DOM_VK_ASTERISK.
///  *   //     #5 Otherwise, and if the key inputs another ASCII character with
///  *   //        Shift key state, use a proper value for the character.  E.g.,
///  *   //        if a key causes a Unicode character without Shift key but "&"
///  *   //        is inputted when Shift key is pressed, the proper keyCode is
///  *   //        DOM_VK_AMPERSAND.
///  *   //     See above document for the other cases.
///  *   //
///  *   // NOTE: If the software keyboard is 10-key like simple phone,
///  *   //       We don't have common rules to decide its .keyCode value.
///  *   //       Above rules should be used when the JS-Keyboard emulates PC
///  *   //       keyboard.
///  *   // .key value should be inputting character by the key with current
///  *   // modifier state.
///  *   // .code value should be empty string if the JS-Keyboard isn't emulating
///  *   // physical keyboard.  Otherwise, use same value with physical keyboard's
///  *   // same key.
///  *   var keyEvent = new KeyboardEvent("", { code: "KeyA", key: "a",
        ///  *                                          keyCode: KeyboardEvent.DOM_VK_A });
///  *   if (TIP.keydown(keyEvent)) {
    ///  *     // Handle its default action
    ///  *   }
///  *
///  *   // Even if keydown event was consumed, keyup event should be dispatched.
///  *   if (TIP.keyup(keyEvent)) {
    ///  *     // Handle its default action
    ///  *   }
///  *
///  * Example #10 JS-Keyboard doesn't need to initialize modifier states at
///  *             calling either keydown() or keyup().
///  *
///  *   // Neither beginInputTransaction() nor beginInputTransactionForTests()
///  *   // resets modifier state.
///  *   if (!TIP.beginInputTransaction(window, callback)) {
    ///  *     return; // You failed to get the rights to dispatch key events
    ///  *   }
///  *
///  *   var leftShift = new KeyboardEvent("", { code: "ShiftLeft", key: "Shift" });
///  *
///  *   // This causes following key events will be shifted automatically.
///  *   TIP.keydown(leftShift);
///  *
///  *   var rightShift =
///  *     new KeyboardEvent("", { code: "ShiftRight", key: "Shift" });
///  *
///  *   TIP.keydown(rightShift);
///  *
///  *   // keyup of one of shift key doesn't cause inactivating "Shift" state.
///  *   TIP.keyup(rightShift);
///  *
///  *   // This causes inactivating "Shift" state completely.
///  *   TIP.keyup(leftShift);
///  */
/// ```
///

// The actual type definition for the interface. This struct has methods
// declared on it which will call through its vtable. You never want to pass
// this type around by value, always pass it behind a reference.

#[repr(C)]
pub struct nsITextInputProcessor {
    vtable: *const nsITextInputProcessorVTable,

    /// This field is a phantomdata to ensure that the VTable type and any
    /// struct containing it is not safe to send across threads, as XPCOM is
    /// generally not threadsafe.
    ///
    /// XPCOM interfaces in general are not safe to send across threads.
    __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>,
}

// Implementing XpCom for an interface exposes its IID, which allows for easy
// use of the `.query_interface<T>` helper method. This also defines that
// method for nsITextInputProcessor.
unsafe impl XpCom for nsITextInputProcessor {
    const IID: nsIID = nsID(0x47ae2181, 0x2e98, 0x4d58,
        [0x84, 0xa2, 0xb8, 0xdb, 0x67, 0x64, 0xce, 0x9a]);
}

// We need to implement the RefCounted trait so we can be used with `RefPtr`.
// This trait teaches `RefPtr` how to manage our memory.
unsafe impl RefCounted for nsITextInputProcessor {
    #[inline]
    unsafe fn addref(&self) {
        self.AddRef();
    }
    #[inline]
    unsafe fn release(&self) {
        self.Release();
    }
}

// This trait is implemented on all types which can be coerced to from nsITextInputProcessor.
// It is used in the implementation of `fn coerce<T>`. We hide it from the
// documentation, because it clutters it up a lot.
#[doc(hidden)]
pub trait nsITextInputProcessorCoerce {
    /// Cheaply cast a value of this type from a `nsITextInputProcessor`.
    fn coerce_from(v: &nsITextInputProcessor) -> &Self;
}

// The trivial implementation: We can obviously coerce ourselves to ourselves.
impl nsITextInputProcessorCoerce for nsITextInputProcessor {
    #[inline]
    fn coerce_from(v: &nsITextInputProcessor) -> &Self {
        v
    }
}

impl nsITextInputProcessor {
    /// Cast this `nsITextInputProcessor` to one of its base interfaces.
    #[inline]
    pub fn coerce<T: nsITextInputProcessorCoerce>(&self) -> &T {
        T::coerce_from(self)
    }
}

// Every interface struct type implements `Deref` to its base interface. This
// causes methods on the base interfaces to be directly avaliable on the
// object. For example, you can call `.AddRef` or `.QueryInterface` directly
// on any interface which inherits from `nsISupports`.
impl ::std::ops::Deref for nsITextInputProcessor {
    type Target = nsISupports;
    #[inline]
    fn deref(&self) -> &nsISupports {
        unsafe {
            ::std::mem::transmute(self)
        }
    }
}

// Ensure we can use .coerce() to cast to our base types as well. Any type which
// our base interface can coerce from should be coercable from us as well.
impl<T: nsISupportsCoerce> nsITextInputProcessorCoerce for T {
    #[inline]
    fn coerce_from(v: &nsITextInputProcessor) -> &Self {
        T::coerce_from(v)
    }
}

// This struct represents the interface's VTable. A pointer to a statically
// allocated version of this struct is at the beginning of every nsITextInputProcessor
// object. It contains one pointer field for each method in the interface. In
// the case where we can't generate a binding for a method, we include a void
// pointer.
#[doc(hidden)]
#[repr(C)]
pub struct nsITextInputProcessorVTable {
    /// We need to include the members from the base interface's vtable at the start
    /// of the VTable definition.
    pub __base: nsISupportsVTable,

    /* readonly attribute boolean hasComposition; */
    pub GetHasComposition: unsafe extern "system" fn (this: *const nsITextInputProcessor, aHasComposition: *mut bool) -> nsresult,

    /* boolean beginInputTransaction (in mozIDOMWindow aWindow, in nsITextInputProcessorCallback aCallback); */
    pub BeginInputTransaction: unsafe extern "system" fn (this: *const nsITextInputProcessor, aWindow: *const mozIDOMWindow, aCallback: *const nsITextInputProcessorCallback, _retval: *mut bool) -> nsresult,

    /* [optional_argc] boolean beginInputTransactionForTests (in mozIDOMWindow aWindow, [optional] in nsITextInputProcessorCallback aCallback); */
    /// Unable to generate binding because `optional_argc is unsupported`
    pub BeginInputTransactionForTests: *const ::libc::c_void,

    /* [optional_argc] boolean startComposition ([optional] in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags); */
    /// Unable to generate binding because `optional_argc is unsupported`
    pub StartComposition: *const ::libc::c_void,

    /* void setPendingCompositionString (in DOMString aString); */
    pub SetPendingCompositionString: unsafe extern "system" fn (this: *const nsITextInputProcessor, aString: &::nsstring::nsAString) -> nsresult,

    /* void appendClauseToPendingComposition (in unsigned long aLength, in unsigned long aAttribute); */
    pub AppendClauseToPendingComposition: unsafe extern "system" fn (this: *const nsITextInputProcessor, aLength: libc::uint32_t, aAttribute: libc::uint32_t) -> nsresult,

    /* void setCaretInPendingComposition (in unsigned long aOffset); */
    pub SetCaretInPendingComposition: unsafe extern "system" fn (this: *const nsITextInputProcessor, aOffset: libc::uint32_t) -> nsresult,

    /* [optional_argc] boolean flushPendingComposition ([optional] in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags); */
    /// Unable to generate binding because `optional_argc is unsupported`
    pub FlushPendingComposition: *const ::libc::c_void,

    /* [optional_argc] void commitComposition ([optional] in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags); */
    /// Unable to generate binding because `optional_argc is unsupported`
    pub CommitComposition: *const ::libc::c_void,

    /* [optional_argc] boolean commitCompositionWith (in DOMString aCommitString, [optional] in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags); */
    /// Unable to generate binding because `optional_argc is unsupported`
    pub CommitCompositionWith: *const ::libc::c_void,

    /* [optional_argc] void cancelComposition ([optional] in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags); */
    /// Unable to generate binding because `optional_argc is unsupported`
    pub CancelComposition: *const ::libc::c_void,

    /* [optional_argc] unsigned long keydown (in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags); */
    /// Unable to generate binding because `optional_argc is unsupported`
    pub Keydown: *const ::libc::c_void,

    /* [optional_argc] boolean keyup (in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags); */
    /// Unable to generate binding because `optional_argc is unsupported`
    pub Keyup: *const ::libc::c_void,

    /* boolean getModifierState (in DOMString aModifierKey); */
    pub GetModifierState: unsafe extern "system" fn (this: *const nsITextInputProcessor, aModifierKey: &::nsstring::nsAString, _retval: *mut bool) -> nsresult,

    /* void shareModifierStateOf (in nsITextInputProcessor aOther); */
    pub ShareModifierStateOf: unsafe extern "system" fn (this: *const nsITextInputProcessor, aOther: *const nsITextInputProcessor) -> nsresult,
}


// The implementations of the function wrappers which are exposed to rust code.
// Call these methods rather than manually calling through the VTable struct.
impl nsITextInputProcessor {

    pub const ATTR_RAW_CLAUSE: i64 = 2;


    pub const ATTR_SELECTED_RAW_CLAUSE: i64 = 3;


    pub const ATTR_CONVERTED_CLAUSE: i64 = 4;


    pub const ATTR_SELECTED_CLAUSE: i64 = 5;


    pub const KEY_DEFAULT_PREVENTED: i64 = 1;


    pub const KEY_NON_PRINTABLE_KEY: i64 = 2;


    pub const KEY_FORCE_PRINTABLE_KEY: i64 = 4;


    pub const KEY_KEEP_KEY_LOCATION_STANDARD: i64 = 8;


    pub const KEY_KEEP_KEYCODE_ZERO: i64 = 16;


    pub const KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT: i64 = 32;


    pub const KEYEVENT_NOT_CONSUMED: i64 = 0;


    pub const KEYDOWN_IS_CONSUMED: i64 = 1;


    pub const KEYPRESS_IS_CONSUMED: i64 = 2;

    /// ```text
    /// /**
    ///    * Returns true if this instance was dispatched compositionstart but hasn't
    ///    * dispatched compositionend yet.
    ///    */
    /// ```
    ///

    /// `readonly attribute boolean hasComposition;`
    #[inline]
    pub unsafe fn GetHasComposition(&self, aHasComposition: *mut bool) -> nsresult {
        ((*self.vtable).GetHasComposition)(self, aHasComposition)
    }


    /// ```text
    /// /**
    ///    * When you create an instance, you must call beginInputTransaction() first
    ///    * except when you created the instance for automated tests.
    ///    *
    ///    * @param aWindow         A DOM window.  The instance will look for a top
    ///    *                        level widget from this.
    ///    * @param aCallback       Callback interface which handles requests to
    ///    *                        IME and notifications to IME.  This must not be
    ///    *                        null.
    ///    * @return                If somebody uses internal text input service for a
    ///    *                        composition, this returns false.  Otherwise, returns
    ///    *                        true.  I.e., only your TIP can create composition
    ///    *                        when this returns true.  If this returns false,
    ///    *                        your TIP should wait next chance.
    ///    */
    /// ```
    ///

    /// `boolean beginInputTransaction (in mozIDOMWindow aWindow, in nsITextInputProcessorCallback aCallback);`
    #[inline]
    pub unsafe fn BeginInputTransaction(&self, aWindow: *const mozIDOMWindow, aCallback: *const nsITextInputProcessorCallback, _retval: *mut bool) -> nsresult {
        ((*self.vtable).BeginInputTransaction)(self, aWindow, aCallback, _retval)
    }


    /// ```text
    /// /**
    ///    * When you create an instance for automated test, you must call
    ///    * beginInputTransaction(), first.  See beginInputTransaction() for more
    ///    * detail of this.
    ///    * Note that aCallback can be null.  If it's null, nsITextInputProcessor
    ///    * implementation will handle them automatically.
    ///    */
    /// ```
    ///

    /// `[optional_argc] boolean beginInputTransactionForTests (in mozIDOMWindow aWindow, [optional] in nsITextInputProcessorCallback aCallback);`
    const _BeginInputTransactionForTests: () = ();

    /// ```text
    /// /**
    ///    * startComposition() dispatches compositionstart event explicitly.
    ///    * IME does NOT need to call this typically since compositionstart event
    ///    * is automatically dispatched by sendPendingComposition() if
    ///    * compositionstart event hasn't been dispatched yet.  If this is called
    ///    * when compositionstart has already been dispatched, this throws an
    ///    * exception.
    ///    *
    ///    * @param aKeyboardEvent  Key event which causes starting composition.
    ///    *                        If its type value is "keydown", this method
    ///    *                        dispatches only keydown event first.  Otherwise,
    ///    *                        dispatches keydown first and keyup at last.
    ///    * @param aKeyFlags       See KEY_* constants.
    ///    * @return                Returns true if composition starts normally.
    ///    *                        Otherwise, returns false because it might be
    ///    *                        canceled by the web application.
    ///    */
    /// ```
    ///

    /// `[optional_argc] boolean startComposition ([optional] in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags);`
    const _StartComposition: () = ();

    /// ```text
    /// /**
    ///    * Set new composition string.  Pending composition will be flushed by
    ///    * a call of flushPendingComposition().  However, if the new composition
    ///    * string isn't empty, you need to call appendClauseToPendingComposition() to
    ///    * fill all characters of aString with one or more clauses before flushing.
    ///    * Note that if you need to commit or cancel composition, use
    ///    * commitComposition(), commitCompositionWith() or cancelComposition().
    ///    */
    /// ```
    ///

    /// `void setPendingCompositionString (in DOMString aString);`
    #[inline]
    pub unsafe fn SetPendingCompositionString(&self, aString: &::nsstring::nsAString) -> nsresult {
        ((*self.vtable).SetPendingCompositionString)(self, aString)
    }


    /// ```text
    /// /**
    ///    * Append a clause to the pending composition.
    ///    *
    ///    * If you need to fill the pending composition string with a clause, you
    ///    * should call this once.  For example:
    ///    *   appendClauseToPendingComposition(compositionString.length,
        ///    *                                    ATTR_RAW_CLAUSE);
    ///    * is enough.  If you need to separate the pending composition string to
    ///    * multiple clauses, you need to call this multiple times. For example,
    ///    * if your pending composition string has three clauses and the second clause
    ///    * is being converted:
    ///    *  appendClauseToPendingComposition(firstClauseLength,
        ///    *                                   ATTR_CONVERTED_CLAUSE);
    ///    *  appendClauseToPendingComposition(secondClauseLength,
        ///    *                                   ATTR_SELECTED_CLAUSE);
    ///    *  appendClauseToPendingComposition(thirdClauseLength,
        ///    *                                   ATTR_CONVERTED_CLAUSE);
    ///    * Note that if sum of aLength mismatches length of the pending composition
    ///    * string, flushPendingComposition() will throw an exception.  I.e.,
    ///    * |firstClauseLength + secondClauseLength + thirdClauseLength| must be
    ///    * same as the length of pending composition string.
    ///    *
    ///    * TODO: Should be able to specify custom clause style.
    ///    *
    ///    * @param aLength         Length of the clause.
    ///    * @param aAttribute      One of ATTR_* constants.
    ///    */
    /// ```
    ///

    /// `void appendClauseToPendingComposition (in unsigned long aLength, in unsigned long aAttribute);`
    #[inline]
    pub unsafe fn AppendClauseToPendingComposition(&self, aLength: libc::uint32_t, aAttribute: libc::uint32_t) -> nsresult {
        ((*self.vtable).AppendClauseToPendingComposition)(self, aLength, aAttribute)
    }


    /// ```text
    /// /**
    ///    * Set caret offset in the pending composition string.  If you don't need to
    ///    * show a caret, you don't need to call this.
    ///    *
    ///    * @param aOffset         Caret offset in the pending composition string.
    ///    *                        This must be between 0 and length of the pending
    ///    *                        composition string.
    ///    */
    /// ```
    ///

    /// `void setCaretInPendingComposition (in unsigned long aOffset);`
    #[inline]
    pub unsafe fn SetCaretInPendingComposition(&self, aOffset: libc::uint32_t) -> nsresult {
        ((*self.vtable).SetCaretInPendingComposition)(self, aOffset)
    }


    /// ```text
    /// /**
    ///    * flushPendingComposition() must be called after
    ///    * setPendingCompositionString() and appendClauseToPendingComposition()
    ///    * (setCaretInPendingComposition() is optional) are called.
    ///    *
    ///    * Note that compositionstart will be automatically dispatched if this is
    ///    * called when there is no composition.
    ///    *
    ///    * Note that if sum of lengths of appended clauses are not same as composition
    ///    * string or caret offset is larger than the composition string length, this
    ///    * throws an exception.
    ///    *
    ///    * @param aKeyboardEvent  Key event which causes the composition string.
    ///    *                        If its type value is "keydown", this method
    ///    *                        dispatches only keydown event first.  Otherwise,
    ///    *                        dispatches keydown first and keyup at last.
    ///    * @param aKeyFlags       See KEY_* constants.
    ///    * @return                Returns true if there is a composition already or
    ///    *                        starting composition automatically.
    ///    *                        Otherwise, i.e., if it cannot start composition
    ///    *                        automatically, e.g., canceled by web apps, returns
    ///    *                        false.
    ///    */
    /// ```
    ///

    /// `[optional_argc] boolean flushPendingComposition ([optional] in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags);`
    const _FlushPendingComposition: () = ();

    /// ```text
    /// /**
    ///    * commitComposition() will commit composition with the last composition
    ///    * string.  If there is no composition, this will throw an exception.
    ///    *
    ///    * @param aKeyboardEvent  Key event which causes the commit composition.
    ///    *                        If its type value is "keydown", this method
    ///    *                        dispatches only keydown event first.  Otherwise,
    ///    *                        dispatches keydown first and keyup at last.
    ///    * @param aKeyFlags       See KEY_* constants.
    ///    */
    /// ```
    ///

    /// `[optional_argc] void commitComposition ([optional] in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags);`
    const _CommitComposition: () = ();

    /// ```text
    /// /**
    ///    * commitCompositionWith() will commit composition with the specific string.
    ///    * If there is no composition, this will start composition and commit it
    ///    * with the specified string.
    ///    *
    ///    * @param aCommitString   The string to be committed.
    ///    * @param aKeyboardEvent  Key event which causes the commit composition.
    ///    *                        If its type value is "keydown", this method
    ///    *                        dispatches only keydown event first.  Otherwise,
    ///    *                        dispatches keydown first and keyup at last.
    ///    * @param aKeyFlags       See KEY_* constants.
    ///    * @return                Returns true if there is a composition already or
    ///    *                        starting composition automatically.
    ///    *                        Otherwise, i.e., if it cannot start composition
    ///    *                        automatically, e.g., canceled by web apps, returns
    ///    *                        false.
    ///    */
    /// ```
    ///

    /// `[optional_argc] boolean commitCompositionWith (in DOMString aCommitString, [optional] in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags);`
    const _CommitCompositionWith: () = ();

    /// ```text
    /// /**
    ///    * cancelComposition() will cancel composition.  This is for now the same as
    ///    * calling commitComposition("").  However, in the future, this might work
    ///    * better.  If your IME needs to cancel composition, use this instead of
    ///    * commitComposition().
    ///    *
    ///    * Note that if you tries to cancel composition when there is no composition,
    ///    * this throws an exception.
    ///    *
    ///    * @param aKeyboardEvent  Key event which causes the canceling composition.
    ///    *                        If its type value is "keydown", this method
    ///    *                        dispatches only keydown event first.  Otherwise,
    ///    *                        dispatches keydown first and keyup at last.
    ///    * @param aKeyFlags       See KEY_* constants.
    ///    */
    /// ```
    ///

    /// `[optional_argc] void cancelComposition ([optional] in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags);`
    const _CancelComposition: () = ();

    /// ```text
    /// /**
    ///    * keydown() may dispatch a keydown event and some keypress events if
    ///    * preceding keydown event isn't consumed and they are necessary.
    ///    * Note that even if this is called during composition, key events may not
    ///    * be dispatched.  In this case, this returns false.
    ///    *
    ///    * You should initialize at least .key value and .code value of the event.
    ///    * Additionally, if you try to emulate a printable key, .keyCode value should
    ///    * be specified if there is proper key value.  See the comment of above
    ///    * example how to decide .keyCode value of a printable key.  On the other
    ///    * hand, .keyCode value is automatically computed when you try to emulate
    ///    * non-printable key.  However, if you try to emulate physical keyboard of
    ///    * desktop platform, you need to specify proper value explicitly because
    ///    * the mapping table of this API isn't enough to emulate the behavior of
    ///    * Gecko for desktop platforms.
    ///    *
    ///    * NOTE: Even if this has composition, JS-Keyboard should call keydown() and
    ///    *       keyup().  Although, with the default preferences and normal
    ///    *       conditions, DOM key events won't be fired during composition.
    ///    *       However, they MAY be dispatched for some reasons, e.g., the web
    ///    *       content listens only key events, or if the standard DOM event spec
    ///    *       will be changed in the future.
    ///    *
    ///    * @param aKeyboardEvent  Must be a keyboard event which should be dispatched
    ///    *                        as a keydown event and keypress events.
    ///    *                        #1 Note that you don't need to set charCode value
    ///    *                        because it's computed from its key value.
    ///    *                        #2 If code value is set properly and location value
    ///    *                        isn't specified (i.e., 0), the location value will
    ///    *                        be guessed from the code value.
    ///    *                        #3 Non-defined code names are not allowed. If your
    ///    *                        key isn't registered, file a bug. If your key isn't
    ///    *                        defined by any standards, use "" (empty string).
    ///    *                        #4 .keyCode is guessed from .key value if the key
    ///    *                        name is registered and .keyCode isn't initialized.
    ///    *                        #5 modifier key states, e.g., .shiftKey, are
    ///    *                        ignored.  Instead, modifier states are managed by
    ///    *                        each instance and set automatically.
    ///    * @param aKeyFlags       Special flags.  The values can be some of KEY_*
    ///    *                        constants.
    ///    * @return                KEYEVENT_NOT_CONSUMED, if the keydown event nor
    ///    *                        the following keypress event(s) are consumed.
    ///    *                        KEYDOWN_IS_CONSUMED, if the keydown event is
    ///    *                        consumed. No keypress event will be dispatched in
    ///    *                        this case.
    ///    *                        KEYPRESS_IS_CONSUMED, if the keypress event(s) is
    ///    *                        consumed when dispatched.
    ///    *                        Note that keypress event is always consumed by
    ///    *                        native code for the printable keys (indicating the
        ///    *                        default action has been taken).
    ///    */
    /// ```
    ///

    /// `[optional_argc] unsigned long keydown (in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags);`
    const _Keydown: () = ();

    /// ```text
    /// /**
    ///    * Similar to keydown(), but this dispatches only a keyup event.
    ///    */
    /// ```
    ///

    /// `[optional_argc] boolean keyup (in nsIDOMKeyEvent aKeyboardEvent, [optional] in unsigned long aKeyFlags);`
    const _Keyup: () = ();

    /// ```text
    /// /**
    ///    * getModifierState() returns modifier state managed by this instance.
    ///    *
    ///    * @param aModifier       One of modifier key names.  This doesn't support
    ///    *                        virtual modifiers like "Accel".
    ///    * @return                true if the modifier key is active.  Otherwise,
    ///    *                        false.
    ///    */
    /// ```
    ///

    /// `boolean getModifierState (in DOMString aModifierKey);`
    #[inline]
    pub unsafe fn GetModifierState(&self, aModifierKey: &::nsstring::nsAString, _retval: *mut bool) -> nsresult {
        ((*self.vtable).GetModifierState)(self, aModifierKey, _retval)
    }


    /// ```text
    /// /**
    ///    * shareModifierStateOf() makes the instance shares modifier state of
    ///    * another instance.  When this is called, the instance refers the modifier
    ///    * state of another instance.  After that, changes to either this and the
    ///    * other instance's modifier state is synchronized.
    ///    *
    ///    * @param aOther          Another instance which will be referred by the
    ///    *                        instance.  If this is null, the instance restarts
    ///    *                        to manage modifier state independently.
    ///    */
    /// ```
    ///

    /// `void shareModifierStateOf (in nsITextInputProcessor aOther);`
    #[inline]
    pub unsafe fn ShareModifierStateOf(&self, aOther: *const nsITextInputProcessor) -> nsresult {
        ((*self.vtable).ShareModifierStateOf)(self, aOther)
    }


}