• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
2 // 2013 The Chromium Authors. All rights reserved. Use of this source code is
3 // governed by a BSD-style license that can be found in the LICENSE file.
4 
5 #ifndef CEF_TESTS_CEFCLIENT_BROWSER_OSR_TEXT_INPUT_CLIENT_OSR_MAC_H_
6 #define CEF_TESTS_CEFCLIENT_BROWSER_OSR_TEXT_INPUT_CLIENT_OSR_MAC_H_
7 #pragma once
8 
9 #import <Cocoa/Cocoa.h>
10 #include <string>
11 #include <vector>
12 
13 #include "include/cef_browser.h"
14 #include "include/cef_render_handler.h"
15 
16 // Implementation for the NSTextInputClient protocol used for enabling IME on
17 // mac when window rendering is disabled.
18 
19 @interface CefTextInputClientOSRMac : NSObject<NSTextInputClient> {
20  @private
21 
22   // The range of current marked text inside the whole content of the DOM node
23   // being edited.
24   NSRange markedRange_;
25 
26   // The current composition character range and its bounds.
27   CefRange composition_range_;
28   std::vector<CefRect> composition_bounds_;
29 
30   // Represents the input-method attributes supported by this object.
31   NSArray* validAttributesForMarkedText_;
32 
33   // Indicates if we are currently handling a key down event.
34   BOOL handlingKeyDown_;
35 
36   // Indicates if there is any marked text.
37   BOOL hasMarkedText_;
38 
39   // Indicates whether there was any marked text prior to handling
40   // the current key event.
41   BOOL oldHasMarkedText_;
42 
43   // Indicates if unmarkText is called or not when handling a keyboard
44   // event.
45   BOOL unmarkTextCalled_;
46 
47   // The selected range, cached from a message sent by the renderer.
48   NSRange selectedRange_;
49 
50   // Text to be inserted which was generated by handling a key down event.
51   std::string textToBeInserted_;
52 
53   // Marked text which was generated by handling a key down event.
54   CefString markedText_;
55 
56   // Underline information of the |markedText_|.
57   std::vector<CefCompositionUnderline> underlines_;
58 
59   // Replacement range information received from |setMarkedText:|.
60   CefRange setMarkedTextReplacementRange_;
61 
62   CefRefPtr<CefBrowser> browser_;
63 }
64 
65 @property(nonatomic, readonly) NSRange selectedRange;
66 @property(nonatomic) BOOL handlingKeyDown;
67 
68 - (id)initWithBrowser:(CefRefPtr<CefBrowser>)browser;
69 - (void)detach;
70 - (void)HandleKeyEventBeforeTextInputClient:(NSEvent*)keyEvent;
71 - (void)HandleKeyEventAfterTextInputClient:(CefKeyEvent)keyEvent;
72 - (void)ChangeCompositionRange:(CefRange)range
73               character_bounds:(const CefRenderHandler::RectList&)bounds;
74 - (void)cancelComposition;
75 
76 @end
77 
78 #endif  // CEF_TESTS_CEFCLIENT_BROWSER_OSR_TEXT_INPUT_CLIENT_OSR_MAC_H_
79