Commit add28426 authored by Elodie Banel's avatar Elodie Banel Committed by Commit Bot

Remove dead left/right frame code in FormInputAccessoryView.

Follow up to https://chromium-review.googlesource.com/c/chromium/src/+/721325

Bug: none
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I9caba1853bb8df851ceea954da9a222b82d6f3f3
Reviewed-on: https://chromium-review.googlesource.com/758653Reviewed-by: default avatarMoe Ahmadi <mahmadi@chromium.org>
Commit-Queue: Elodie Banel <lod@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515915}
parent fd687b32
...@@ -14,20 +14,14 @@ ...@@ -14,20 +14,14 @@
// way of the playInputClick method. // way of the playInputClick method.
@interface FormInputAccessoryView : UIView<UIInputViewAudioFeedback> @interface FormInputAccessoryView : UIView<UIInputViewAudioFeedback>
// Initializes with |delegate|. // Sets up the view with the given |customView|. Navigation controls are shown
- (instancetype)initWithDelegate:(id<FormInputAccessoryViewDelegate>)delegate; // and use |delegate| for actions.
- (void)setUpWithNavigationDelegate:(id<FormInputAccessoryViewDelegate>)delegate
customView:(UIView*)customView;
// Initializes with |frame| to show |customView|. Navigation controls are not // Sets up the view with the given |customView|. Navigation controls are not
// shown. // shown.
- (instancetype)initWithFrame:(CGRect)frame customView:(UIView*)customView; - (void)setUpWithCustomView:(UIView*)customView;
// Initializes the view with the given |customView|.
// If the size of |rightFrame| is non-zero, the view will be split into two
// parts with |leftFrame| and |rightFrame|. Otherwise the Autofill view will
// be shown in |leftFrame|.
- (void)initializeViewWithCustomView:(UIView*)customView
leftFrame:(CGRect)leftFrame
rightFrame:(CGRect)rightFrame;
@end @end
......
...@@ -121,43 +121,6 @@ NSArray* FindDescendantToolbarItemsForActionName( ...@@ -121,43 +121,6 @@ NSArray* FindDescendantToolbarItemsForActionName(
return toolbarItems; return toolbarItems;
} }
// Computes the frame of each part of the accessory view of the keyboard. It is
// assumed that the keyboard has either two parts (when it is split) or one part
// (when it is merged).
//
// If there are two parts, the frame of the left part is returned in
// |leftFrame| and the frame of the right part is returned in |rightFrame|.
// If there is only one part, the frame is returned in |leftFrame| and
// |rightFrame| has size zero.
//
// Heuristics are used to compute this information. It returns false if the
// number of |inputAccessoryView.subviews| is not 2.
bool ComputeFramesOfKeyboardParts(UIView* inputAccessoryView,
CGRect* leftFrame,
CGRect* rightFrame) {
// It is observed (on iOS 6) there are always two subviews in the original
// input accessory view. When the keyboard is split, each subview represents
// one part of the accesssary view of the keyboard. When the keyboard is
// merged, one subview has the same frame as that of the whole accessory view
// and the other has zero size with the screen width as origin.x.
// The computation here is based on this observation.
NSArray* subviews = inputAccessoryView.subviews;
if (subviews.count != 2)
return false;
CGRect first_frame = static_cast<UIView*>(subviews[0]).frame;
CGRect second_frame = static_cast<UIView*>(subviews[1]).frame;
if (CGRectGetMinX(first_frame) < CGRectGetMinX(second_frame) ||
CGRectGetWidth(second_frame) == 0) {
*leftFrame = first_frame;
*rightFrame = second_frame;
} else {
*rightFrame = first_frame;
*leftFrame = second_frame;
}
return true;
}
} // namespace } // namespace
@interface FormInputAccessoryViewController () @interface FormInputAccessoryViewController ()
...@@ -321,8 +284,8 @@ bool ComputeFramesOfKeyboardParts(UIView* inputAccessoryView, ...@@ -321,8 +284,8 @@ bool ComputeFramesOfKeyboardParts(UIView* inputAccessoryView,
- (void)showCustomInputAccessoryView:(UIView*)view { - (void)showCustomInputAccessoryView:(UIView*)view {
DCHECK(view); DCHECK(view);
if (IsIPadIdiom()) { if (IsIPadIdiom()) {
// On iPads running iOS 9 or later, there's no inputAccessoryView available // On iPad, there's no inputAccessoryView available, so we attach the custom
// so we attach the custom view directly to the keyboard view instead. // view directly to the keyboard view instead.
[_customAccessoryView removeFromSuperview]; [_customAccessoryView removeFromSuperview];
// If the keyboard isn't visible don't show the custom view. // If the keyboard isn't visible don't show the custom view.
...@@ -346,30 +309,26 @@ bool ComputeFramesOfKeyboardParts(UIView* inputAccessoryView, ...@@ -346,30 +309,26 @@ bool ComputeFramesOfKeyboardParts(UIView* inputAccessoryView,
} }
_suggestionsHaveBeenShown = YES; _suggestionsHaveBeenShown = YES;
_customAccessoryView = [[FormInputAccessoryView alloc] init];
[_customAccessoryView setUpWithCustomView:view];
CGFloat height = autofill::kInputAccessoryHeight; CGFloat height = autofill::kInputAccessoryHeight;
CGRect contentFrame = self.webViewProxy.frame; CGRect contentFrame = self.webViewProxy.frame;
CGRect frame = CGRectMake(contentFrame.origin.x, -height, _customAccessoryView.frame = CGRectMake(contentFrame.origin.x, -height,
contentFrame.size.width, height); contentFrame.size.width, height);
_customAccessoryView =
[[FormInputAccessoryView alloc] initWithFrame:frame customView:view];
UIView* keyboardView = [self getKeyboardView]; UIView* keyboardView = [self getKeyboardView];
DCHECK(keyboardView); DCHECK(keyboardView);
[keyboardView addSubview:_customAccessoryView]; [keyboardView addSubview:_customAccessoryView];
} else { } else {
// On all other versions, the custom view replaces the default UI of the // On iPhone, the custom view replaces the default UI of the
// inputAccessoryView. // inputAccessoryView.
[self restoreDefaultInputAccessoryView]; [self restoreDefaultInputAccessoryView];
CGRect leftFrame;
CGRect rightFrame;
UIView* inputAccessoryView = [self.webViewProxy keyboardAccessory]; UIView* inputAccessoryView = [self.webViewProxy keyboardAccessory];
if (ComputeFramesOfKeyboardParts(inputAccessoryView, &leftFrame, if (inputAccessoryView) {
&rightFrame)) {
[self hideSubviewsInOriginalAccessoryView:inputAccessoryView]; [self hideSubviewsInOriginalAccessoryView:inputAccessoryView];
_customAccessoryView = _customAccessoryView = [[FormInputAccessoryView alloc] init];
[[FormInputAccessoryView alloc] initWithDelegate:self]; [_customAccessoryView setUpWithNavigationDelegate:self customView:view];
[_customAccessoryView initializeViewWithCustomView:view
leftFrame:leftFrame
rightFrame:rightFrame];
[inputAccessoryView addSubview:_customAccessoryView]; [inputAccessoryView addSubview:_customAccessoryView];
AddSameConstraints(_customAccessoryView, inputAccessoryView); AddSameConstraints(_customAccessoryView, inputAccessoryView);
} }
......
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