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

Unified Diff: ui/views/cocoa/bridged_content_view.mm

Issue 2019233003: MacViews: Fix crash caused due to nil TextInputClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/cocoa/bridged_content_view.mm
diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm
index a59d4f0788461572994df001532e34bd5fbccace..4cc203559d854fa7230e9697b6c0b72edb75305f 100644
--- a/ui/views/cocoa/bridged_content_view.mm
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -79,6 +79,7 @@ bool DispatchEventToMenu(views::Widget* widget, ui::KeyboardCode key_code) {
// Returns true if |client| has RTL text.
bool IsTextRTL(const ui::TextInputClient* client) {
+ DCHECK(client);
tapted 2016/05/30 10:31:54 I think it's nicer for this just to return false,
gfx::Range text_range;
base::string16 text;
return client->GetTextRange(&text_range) &&
@@ -650,6 +651,8 @@ base::string16 AttributedSubstringForRangeHelper(
// Selection movement and scrolling.
- (void)moveForward:(id)sender {
+ if (!textInputClient_)
+ return;
IsTextRTL(textInputClient_) ? [self moveLeft:sender]
: [self moveRight:sender];
}
@@ -662,6 +665,8 @@ base::string16 AttributedSubstringForRangeHelper(
}
- (void)moveBackward:(id)sender {
+ if (!textInputClient_)
+ return;
IsTextRTL(textInputClient_) ? [self moveRight:sender]
: [self moveLeft:sender];
}
@@ -688,11 +693,15 @@ base::string16 AttributedSubstringForRangeHelper(
}
- (void)moveWordForward:(id)sender {
+ if (!textInputClient_)
+ return;
IsTextRTL(textInputClient_) ? [self moveWordLeft:sender]
: [self moveWordRight:sender];
}
- (void)moveWordBackward:(id)sender {
+ if (!textInputClient_)
+ return;
IsTextRTL(textInputClient_) ? [self moveWordRight:sender]
: [self moveWordLeft:sender];
}
@@ -748,21 +757,29 @@ base::string16 AttributedSubstringForRangeHelper(
}
- (void)moveBackwardAndModifySelection:(id)sender {
+ if (!textInputClient_)
+ return;
IsTextRTL(textInputClient_) ? [self moveRightAndModifySelection:sender]
: [self moveLeftAndModifySelection:sender];
}
- (void)moveForwardAndModifySelection:(id)sender {
+ if (!textInputClient_)
+ return;
IsTextRTL(textInputClient_) ? [self moveLeftAndModifySelection:sender]
: [self moveRightAndModifySelection:sender];
}
- (void)moveWordForwardAndModifySelection:(id)sender {
+ if (!textInputClient_)
+ return;
IsTextRTL(textInputClient_) ? [self moveWordLeftAndModifySelection:sender]
: [self moveWordRightAndModifySelection:sender];
}
- (void)moveWordBackwardAndModifySelection:(id)sender {
+ if (!textInputClient_)
+ return;
IsTextRTL(textInputClient_) ? [self moveWordRightAndModifySelection:sender]
: [self moveWordLeftAndModifySelection:sender];
}
@@ -888,22 +905,30 @@ base::string16 AttributedSubstringForRangeHelper(
}
- (void)moveToLeftEndOfLine:(id)sender {
+ if (!textInputClient_)
+ return;
IsTextRTL(textInputClient_) ? [self moveToEndOfLine:sender]
: [self moveToBeginningOfLine:sender];
}
- (void)moveToRightEndOfLine:(id)sender {
+ if (!textInputClient_)
+ return;
IsTextRTL(textInputClient_) ? [self moveToBeginningOfLine:sender]
: [self moveToEndOfLine:sender];
}
- (void)moveToLeftEndOfLineAndModifySelection:(id)sender {
+ if (!textInputClient_)
+ return;
IsTextRTL(textInputClient_)
? [self moveToEndOfLineAndModifySelection:sender]
: [self moveToBeginningOfLineAndModifySelection:sender];
}
- (void)moveToRightEndOfLineAndModifySelection:(id)sender {
+ if (!textInputClient_)
+ return;
IsTextRTL(textInputClient_)
? [self moveToBeginningOfLineAndModifySelection:sender]
: [self moveToEndOfLineAndModifySelection:sender];
« 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