Commit 0e4939bc authored by Mike Dougherty's avatar Mike Dougherty Committed by Commit Bot

Modernize layout of toolbar items for ios web shell

The manual layout of the toolbar items for ios_web_shell is
outdated and no longer works with iOS 11. Update the UIButtons to
UIBarButtonItems and automatically lay them out with setItems: instead
of adding items as subviews to the UIToolbar.

Bug: None
Change-Id: Id04d7bd7b630c28b0f76f3dc0f78510bca650ffd
Reviewed-on: https://chromium-review.googlesource.com/580148Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488411}
parent aad31d56
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window makeKeyAndVisible]; [self.window makeKeyAndVisible];
self.window.backgroundColor = [UIColor whiteColor]; self.window.backgroundColor = [UIColor whiteColor];
self.window.tintColor = [UIColor darkGrayColor];
_delegate.reset(new web::ShellMainDelegate()); _delegate.reset(new web::ShellMainDelegate());
......
...@@ -84,26 +84,18 @@ using web::NavigationManager; ...@@ -84,26 +84,18 @@ using web::NavigationManager;
[self.view addSubview:_containerView]; [self.view addSubview:_containerView];
// Set up the toolbar buttons. // Set up the toolbar buttons.
UIButton* back = [UIButton buttonWithType:UIButtonTypeCustom]; UIBarButtonItem* back = [[UIBarButtonItem alloc]
[back setImage:[UIImage imageNamed:@"toolbar_back"] initWithImage:[UIImage imageNamed:@"toolbar_back"]
forState:UIControlStateNormal]; style:UIBarButtonItemStylePlain
[back setFrame:CGRectMake(0, 0, 44, 44)]; target:self
[back setImageEdgeInsets:UIEdgeInsetsMake(5, 5, 4, 4)]; action:@selector(back)];
[back setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin];
[back addTarget:self
action:@selector(back)
forControlEvents:UIControlEventTouchUpInside];
[back setAccessibilityLabel:kWebShellBackButtonAccessibilityLabel]; [back setAccessibilityLabel:kWebShellBackButtonAccessibilityLabel];
UIButton* forward = [UIButton buttonWithType:UIButtonTypeCustom]; UIBarButtonItem* forward = [[UIBarButtonItem alloc]
[forward setImage:[UIImage imageNamed:@"toolbar_forward"] initWithImage:[UIImage imageNamed:@"toolbar_forward"]
forState:UIControlStateNormal]; style:UIBarButtonItemStylePlain
[forward setFrame:CGRectMake(44, 0, 44, 44)]; target:self
[forward setImageEdgeInsets:UIEdgeInsetsMake(5, 5, 4, 4)]; action:@selector(forward)];
[forward setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin];
[forward addTarget:self
action:@selector(forward)
forControlEvents:UIControlEventTouchUpInside];
[forward setAccessibilityLabel:kWebShellForwardButtonAccessibilityLabel]; [forward setAccessibilityLabel:kWebShellForwardButtonAccessibilityLabel];
base::scoped_nsobject<UITextField> field([[UITextField alloc] base::scoped_nsobject<UITextField> field([[UITextField alloc]
...@@ -120,9 +112,9 @@ using web::NavigationManager; ...@@ -120,9 +112,9 @@ using web::NavigationManager;
[field setClearButtonMode:UITextFieldViewModeWhileEditing]; [field setClearButtonMode:UITextFieldViewModeWhileEditing];
self.field = field; self.field = field;
[_toolbarView addSubview:back]; [_toolbarView setItems:@[
[_toolbarView addSubview:forward]; back, forward, [[UIBarButtonItem alloc] initWithCustomView:field]
[_toolbarView addSubview:field]; ]];
web::WebState::CreateParams webStateCreateParams(_browserState); web::WebState::CreateParams webStateCreateParams(_browserState);
_webState = web::WebState::Create(webStateCreateParams); _webState = web::WebState::Create(webStateCreateParams);
......
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