Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Side by Side Diff: content/browser/renderer_host/text_input_client_mac.mm

Issue 166903005: mac: Add support for asynchronous dictionary lookup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use ScopedBlock. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #import "content/browser/renderer_host/text_input_client_mac.h" 5 #import "content/browser/renderer_host/text_input_client_mac.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/threading/thread_restrictions.h" 9 #include "base/threading/thread_restrictions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 27
28 TextInputClientMac::~TextInputClientMac() { 28 TextInputClientMac::~TextInputClientMac() {
29 } 29 }
30 30
31 // static 31 // static
32 TextInputClientMac* TextInputClientMac::GetInstance() { 32 TextInputClientMac* TextInputClientMac::GetInstance() {
33 return Singleton<TextInputClientMac>::get(); 33 return Singleton<TextInputClientMac>::get();
34 } 34 }
35 35
36 void TextInputClientMac::GetStringAtPoint(
37 RenderWidgetHost* rwh,
38 gfx::Point point,
39 void (^replyHandler)(NSAttributedString*, NSPoint)) {
40 replyHandler_.reset(replyHandler, base::scoped_policy::RETAIN);
Avi (use Gerrit) 2014/03/12 04:55:40 Out of paranoia, DCHECK if the replyHandler_ isn't
Andre 2014/03/12 16:59:26 Done.
41 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh);
42 rwhi->Send(new TextInputClientMsg_StringAtPoint(rwhi->GetRoutingID(), point));
43 }
44
45 void TextInputClientMac::GetStringAtPointReply(NSAttributedString* string,
46 NSPoint point) {
Avi (use Gerrit) 2014/03/12 04:55:40 Isn't this guaranteed to be on the main thread?
Andre 2014/03/12 16:59:26 No, this happens on the IO thread.
47 if (replyHandler_.get()) {
48 replyHandler_.get()(string, point);
49 replyHandler_.reset();
50 }
51 }
52
36 NSUInteger TextInputClientMac::GetCharacterIndexAtPoint(RenderWidgetHost* rwh, 53 NSUInteger TextInputClientMac::GetCharacterIndexAtPoint(RenderWidgetHost* rwh,
37 gfx::Point point) { 54 gfx::Point point) {
38 base::TimeTicks start = base::TimeTicks::Now(); 55 base::TimeTicks start = base::TimeTicks::Now();
39 56
40 BeforeRequest(); 57 BeforeRequest();
41 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); 58 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh);
42 rwhi->Send(new TextInputClientMsg_CharacterIndexForPoint(rwhi->GetRoutingID(), 59 rwhi->Send(new TextInputClientMsg_CharacterIndexForPoint(rwhi->GetRoutingID(),
43 point)); 60 point));
44 // http://crbug.com/121917 61 // http://crbug.com/121917
45 base::ThreadRestrictions::ScopedAllowWait allow_wait; 62 base::ThreadRestrictions::ScopedAllowWait allow_wait;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 character_index_ = NSNotFound; 148 character_index_ = NSNotFound;
132 first_rect_ = NSZeroRect; 149 first_rect_ = NSZeroRect;
133 substring_.reset(); 150 substring_.reset();
134 } 151 }
135 152
136 void TextInputClientMac::AfterRequest() { 153 void TextInputClientMac::AfterRequest() {
137 lock_.Release(); 154 lock_.Release();
138 } 155 }
139 156
140 } // namespace content 157 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698