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

Side by Side Diff: ui/views/cocoa/bridged_content_view.mm

Issue 2063413002: BridgedContentView: Modify IsTextRTL to use TextInputClient::GetTextDirection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/views/cocoa/bridged_content_view.h" 5 #import "ui/views/cocoa/bridged_content_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/mac/mac_util.h" 8 #import "base/mac/mac_util.h"
9 #import "base/mac/scoped_nsobject.h" 9 #import "base/mac/scoped_nsobject.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 if (menuController && menuController->owner() == widget) { 77 if (menuController && menuController->owner() == widget) {
78 if (menuController->OnWillDispatchKeyEvent(0, key_code) == 78 if (menuController->OnWillDispatchKeyEvent(0, key_code) ==
79 ui::POST_DISPATCH_NONE) 79 ui::POST_DISPATCH_NONE)
80 return true; 80 return true;
81 } 81 }
82 return false; 82 return false;
83 } 83 }
84 84
85 // Returns true if |client| has RTL text. 85 // Returns true if |client| has RTL text.
86 bool IsTextRTL(const ui::TextInputClient* client) { 86 bool IsTextRTL(const ui::TextInputClient* client) {
87 gfx::Range text_range; 87 return client && client->GetTextDirection() == base::i18n::RIGHT_TO_LEFT;
88 base::string16 text;
89 return client && client->GetTextRange(&text_range) &&
90 client->GetTextFromRange(text_range, &text) &&
91 base::i18n::GetFirstStrongCharacterDirection(text) ==
92 base::i18n::RIGHT_TO_LEFT;
93 } 88 }
94 89
95 // Returns the boundary rectangle for composition characters in the 90 // Returns the boundary rectangle for composition characters in the
96 // |requested_range|. Sets |actual_range| corresponding to the returned 91 // |requested_range|. Sets |actual_range| corresponding to the returned
97 // rectangle. For cases, where there is no composition text or the 92 // rectangle. For cases, where there is no composition text or the
98 // |requested_range| lies outside the composition range, a zero width rectangle 93 // |requested_range| lies outside the composition range, a zero width rectangle
99 // corresponding to the caret bounds is returned. Logic used is similar to 94 // corresponding to the caret bounds is returned. Logic used is similar to
100 // RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange(...). 95 // RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange(...).
101 gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, 96 gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client,
102 const gfx::Range& requested_range, 97 const gfx::Range& requested_range,
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 } 1228 }
1234 1229
1235 return [super accessibilityAttributeValue:attribute]; 1230 return [super accessibilityAttributeValue:attribute];
1236 } 1231 }
1237 1232
1238 - (id)accessibilityHitTest:(NSPoint)point { 1233 - (id)accessibilityHitTest:(NSPoint)point {
1239 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; 1234 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point];
1240 } 1235 }
1241 1236
1242 @end 1237 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698