Chromium Code Reviews| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 void SetSubstringAndSignal(NSAttributedString* string); | 72 void SetSubstringAndSignal(NSAttributedString* string); |
| 73 | 73 |
| 74 // This async method is invoked from RenderWidgetHostViewCocoa's | 74 // This async method is invoked from RenderWidgetHostViewCocoa's |
| 75 // -quickLookWithEvent:, when the user taps a word using 3 fingers. | 75 // -quickLookWithEvent:, when the user taps a word using 3 fingers. |
| 76 // The reply callback will be invoked from the IO thread, the caller is | 76 // The reply callback will be invoked from the IO thread, the caller is |
| 77 // responsible for bouncing to the main thread if necessary. | 77 // responsible for bouncing to the main thread if necessary. |
| 78 // The callback parameters provide the attributed word under the point and | 78 // The callback parameters provide the attributed word under the point and |
| 79 // the lower left baseline point of the text. | 79 // the lower left baseline point of the text. |
| 80 void GetStringAtPoint(RenderWidgetHost* rwh, | 80 void GetStringAtPoint(RenderWidgetHost* rwh, |
| 81 gfx::Point point, | 81 gfx::Point point, |
| 82 void (^replyHandler)(NSAttributedString*, NSPoint)); | 82 void (^reply_handler)(NSAttributedString*, NSPoint)); |
| 83 // This is called on the IO thread when we get the renderer's reply for | 83 // This is called on the IO thread when we get the renderer's reply for |
|
Alexei Svitkine (slow)
2015/09/21 15:47:55
Nit: Add an empty line before this for consistency
Shu Chen
2015/09/22 05:46:08
Done.
| |
| 84 // GetStringAtPoint. | 84 // GetStringAtPoint. |
| 85 void GetStringAtPointReply(NSAttributedString*, NSPoint); | 85 void GetStringAtPointReply(NSAttributedString*, NSPoint); |
|
Alexei Svitkine (slow)
2015/09/21 15:47:55
Nit: Can you name these params too?
Shu Chen
2015/09/22 05:46:08
Done.
| |
| 86 | 86 |
| 87 // This async method is invoked from RenderWidgetHostViewMacDictionaryHelper's | |
| 88 // ShowDefinitionForSelection(). | |
|
Alexei Svitkine (slow)
2015/09/21 15:47:55
This comment is referencing code outside content/
Shu Chen
2015/09/22 05:46:08
I don't understand. RenderWidgetHostViewMacDiction
| |
| 89 // The reply callback will be invoked from the IO thread, the caller is | |
|
Alexei Svitkine (slow)
2015/09/21 15:47:56
Nit: , -> ;
Also make the same change for the com
Shu Chen
2015/09/22 05:46:08
Done.
| |
| 90 // responsible for bouncing to the main thread if necessary. | |
| 91 // The callback parameters provide the attributed word under the point and | |
| 92 // the lower left baseline point of the text. | |
| 93 void GetStringFromRange(RenderWidgetHost* rwh, | |
| 94 NSRange range, | |
| 95 void (^reply_handler)(NSAttributedString*, NSPoint)); | |
| 96 | |
| 97 // This is called on the IO thread when we get the renderer's reply for | |
| 98 // GetStringFromRange. | |
| 99 void GetStringFromRangeReply(NSAttributedString* string, NSPoint point); | |
| 100 | |
| 87 private: | 101 private: |
| 88 friend struct base::DefaultSingletonTraits<TextInputClientMac>; | 102 friend struct base::DefaultSingletonTraits<TextInputClientMac>; |
| 89 TextInputClientMac(); | 103 TextInputClientMac(); |
| 90 ~TextInputClientMac(); | 104 ~TextInputClientMac(); |
| 91 | 105 |
| 92 // The critical sections that the Condition guards are in Get*() methods. | 106 // The critical sections that the Condition guards are in Get*() methods. |
| 93 // These methods lock the internal condition for use before the asynchronous | 107 // These methods lock the internal condition for use before the asynchronous |
| 94 // message is sent to the renderer to lookup the required information. These | 108 // message is sent to the renderer to lookup the required information. These |
| 95 // are only used on the UI thread. | 109 // are only used on the UI thread. |
| 96 void BeforeRequest(); | 110 void BeforeRequest(); |
| 97 // Called at the end of a critical section. This will release the lock and | 111 // Called at the end of a critical section. This will release the lock and |
| 98 // condition. | 112 // condition. |
| 99 void AfterRequest(); | 113 void AfterRequest(); |
| 100 | 114 |
| 101 NSUInteger character_index_; | 115 NSUInteger character_index_; |
| 102 NSRect first_rect_; | 116 NSRect first_rect_; |
| 103 base::scoped_nsobject<NSAttributedString> substring_; | 117 base::scoped_nsobject<NSAttributedString> substring_; |
| 104 | 118 |
| 105 base::Lock lock_; | 119 base::Lock lock_; |
| 106 base::ConditionVariable condition_; | 120 base::ConditionVariable condition_; |
| 107 | 121 |
| 108 base::mac::ScopedBlock<void(^)(NSAttributedString*, NSPoint)> replyHandler_; | 122 // The callback when received IPC TextInputClientReplyMsg_GotStringAtPoint. |
| 123 base::mac::ScopedBlock<void(^)(NSAttributedString*, NSPoint)> | |
| 124 replyForPointHandler_; | |
| 125 | |
| 126 // The callback when received IPC TextInputClientReplyMsg_GotStringForRange. | |
| 127 base::mac::ScopedBlock<void(^)(NSAttributedString*, NSPoint)> | |
| 128 replyForRangeHandler_; | |
| 109 | 129 |
| 110 DISALLOW_COPY_AND_ASSIGN(TextInputClientMac); | 130 DISALLOW_COPY_AND_ASSIGN(TextInputClientMac); |
| 111 }; | 131 }; |
| 112 | 132 |
| 113 } // namespace content | 133 } // namespace content |
| 114 | 134 |
| 115 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ | 135 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ |
| OLD | NEW |