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 #include "content/public/test/content_browser_test_utils.h" | 5 #include "content/public/test/content_browser_test_utils.h" |
6 | 6 |
7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
| 10 #include "content/browser/renderer_host/text_input_client_mac.h" |
| 11 #include "content/public/browser/render_widget_host.h" |
| 12 #include "ui/gfx/geometry/point.h" |
10 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
| 14 #include "ui/gfx/range/range.h" |
11 | 15 |
12 namespace content { | 16 namespace content { |
13 | 17 |
14 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds) { | 18 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds) { |
15 NSRect new_bounds = NSRectFromCGRect(bounds.ToCGRect()); | 19 NSRect new_bounds = NSRectFromCGRect(bounds.ToCGRect()); |
16 if ([[NSScreen screens] count] > 0) { | 20 if ([[NSScreen screens] count] > 0) { |
17 new_bounds.origin.y = | 21 new_bounds.origin.y = |
18 [[[NSScreen screens] firstObject] frame].size.height - | 22 [[[NSScreen screens] firstObject] frame].size.height - |
19 new_bounds.origin.y - new_bounds.size.height; | 23 new_bounds.origin.y - new_bounds.size.height; |
20 } | 24 } |
21 | 25 |
22 [window setFrame:new_bounds display:NO]; | 26 [window setFrame:new_bounds display:NO]; |
23 } | 27 } |
24 | 28 |
| 29 void GetStringAtPointForRenderWidget( |
| 30 RenderWidgetHost* rwh, |
| 31 const gfx::Point& point, |
| 32 base::Callback<void(const std::string&, const gfx::Point&)> |
| 33 result_callback) { |
| 34 TextInputClientMac::GetInstance()->GetStringAtPoint( |
| 35 rwh, point, ^(NSAttributedString* string, NSPoint baselinePoint) { |
| 36 result_callback.Run([[string string] UTF8String], |
| 37 gfx::Point(baselinePoint.x, baselinePoint.y)); |
| 38 }); |
| 39 } |
| 40 |
| 41 void GetStringFromRangeForRenderWidget( |
| 42 RenderWidgetHost* rwh, |
| 43 const gfx::Range& range, |
| 44 base::Callback<void(const std::string&, const gfx::Point&)> |
| 45 result_callback) { |
| 46 TextInputClientMac::GetInstance()->GetStringFromRange( |
| 47 rwh, range.ToNSRange(), |
| 48 ^(NSAttributedString* string, NSPoint baselinePoint) { |
| 49 result_callback.Run([[string string] UTF8String], |
| 50 gfx::Point(baselinePoint.x, baselinePoint.y)); |
| 51 }); |
| 52 } |
| 53 |
25 } // namespace content | 54 } // namespace content |
OLD | NEW |