Chromium Code Reviews| 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]; |