| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_block.h" | 10 #include "base/mac/scoped_block.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // responsible for bouncing to the main thread if necessary. | 74 // responsible for bouncing to the main thread if necessary. |
| 75 // The callback parameters provide the attributed word under the point and | 75 // The callback parameters provide the attributed word under the point and |
| 76 // the lower left baseline point of the text. | 76 // the lower left baseline point of the text. |
| 77 void GetStringAtPoint(RenderWidgetHost* rwh, | 77 void GetStringAtPoint(RenderWidgetHost* rwh, |
| 78 gfx::Point point, | 78 gfx::Point point, |
| 79 void (^replyHandler)(NSAttributedString*, NSPoint)); | 79 void (^replyHandler)(NSAttributedString*, NSPoint)); |
| 80 // This is called on the IO thread when we get the renderer's reply for | 80 // This is called on the IO thread when we get the renderer's reply for |
| 81 // GetStringAtPoint. | 81 // GetStringAtPoint. |
| 82 void GetStringAtPointReply(NSAttributedString*, NSPoint); | 82 void GetStringAtPointReply(NSAttributedString*, NSPoint); |
| 83 | 83 |
| 84 // This async method is invoked from RenderWidgetHostViewMacDictionaryHelper's |
| 85 // ShowDefinitionForSelection(). |
| 86 // The reply callback will be invoked from the IO thread, the caller is |
| 87 // responsible for bouncing to the main thread if necessary. |
| 88 // The callback parameters provide the attributed word under the point and |
| 89 // the lower left baseline point of the text. |
| 90 void GetStringFromRange(RenderWidgetHost* rwh, |
| 91 NSRange range, |
| 92 void (^replyHandler)(NSAttributedString*, NSPoint)); |
| 93 // This is called on the IO thread when we get the renderer's reply for |
| 94 // GetStringFromRange. |
| 95 void GetStringFromRangeReply(NSAttributedString*, NSPoint); |
| 96 |
| 84 private: | 97 private: |
| 85 friend struct DefaultSingletonTraits<TextInputClientMac>; | 98 friend struct DefaultSingletonTraits<TextInputClientMac>; |
| 86 TextInputClientMac(); | 99 TextInputClientMac(); |
| 87 ~TextInputClientMac(); | 100 ~TextInputClientMac(); |
| 88 | 101 |
| 89 // The critical sections that the Condition guards are in Get*() methods. | 102 // The critical sections that the Condition guards are in Get*() methods. |
| 90 // These methods lock the internal condition for use before the asynchronous | 103 // These methods lock the internal condition for use before the asynchronous |
| 91 // message is sent to the renderer to lookup the required information. These | 104 // message is sent to the renderer to lookup the required information. These |
| 92 // are only used on the UI thread. | 105 // are only used on the UI thread. |
| 93 void BeforeRequest(); | 106 void BeforeRequest(); |
| 94 // Called at the end of a critical section. This will release the lock and | 107 // Called at the end of a critical section. This will release the lock and |
| 95 // condition. | 108 // condition. |
| 96 void AfterRequest(); | 109 void AfterRequest(); |
| 97 | 110 |
| 98 NSUInteger character_index_; | 111 NSUInteger character_index_; |
| 99 NSRect first_rect_; | 112 NSRect first_rect_; |
| 100 base::scoped_nsobject<NSAttributedString> substring_; | 113 base::scoped_nsobject<NSAttributedString> substring_; |
| 101 | 114 |
| 102 base::Lock lock_; | 115 base::Lock lock_; |
| 103 base::ConditionVariable condition_; | 116 base::ConditionVariable condition_; |
| 104 | 117 |
| 105 base::mac::ScopedBlock<void(^)(NSAttributedString*, NSPoint)> replyHandler_; | 118 base::mac::ScopedBlock<void(^)(NSAttributedString*, NSPoint)> |
| 119 replyForPointHandler_; |
| 120 base::mac::ScopedBlock<void(^)(NSAttributedString*, NSPoint)> |
| 121 replyForRangeHandler_; |
| 106 | 122 |
| 107 DISALLOW_COPY_AND_ASSIGN(TextInputClientMac); | 123 DISALLOW_COPY_AND_ASSIGN(TextInputClientMac); |
| 108 }; | 124 }; |
| 109 | 125 |
| 110 } // namespace content | 126 } // namespace content |
| 111 | 127 |
| 112 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ | 128 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ |
| OLD | NEW |