Commit e26f5245 authored by vabr's avatar vabr Committed by Commit bot

Non-strict cast in showCustomInputAccessoryView:

FormInputAccessoryViewController's -showCustomInputAccessoryView: intends to
handle the case when the view is a suggestion view and there are no
suggestions by not showing the view.

The code seems to have this pattern:
  try to cast the view into a suggestion view
  if (succeeded in the cast) {
    handle the 0-suggestion case
  }
Also, https://codereview.chromium.org/1310813002 which introduced this code has a
description indicating that the non-suggestion-view case should be handled
gracefully.

Yet, the code uses ObjCCastStrict instead of ObjCCast. The strict cast DCHECKs
that the casted object is indeed of the target type, whereas the non-strict
cast just returns nil if it is not.

Given the above, it seems more appropriate to use the non-strict cast, which
is done in this CL.

BUG=634245
R=jdonnelly@chromium.org

Review-Url: https://codereview.chromium.org/2213383003
Cr-Commit-Position: refs/heads/master@{#410394}
parent 52d3a47c
......@@ -336,7 +336,7 @@ bool ComputeFramesOfKeyboardParts(UIView* inputAccessoryView,
// If this is a form suggestion view and no suggestions have been triggered
// yet, don't show the custom view.
FormSuggestionView* formSuggestionView =
base::mac::ObjCCastStrict<FormSuggestionView>(view);
base::mac::ObjCCast<FormSuggestionView>(view);
if (formSuggestionView) {
int numSuggestions = [[formSuggestionView suggestions] count];
if (!_suggestionsHaveBeenShown && numSuggestions == 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment