Commit 28378c49 authored by edchin's avatar edchin Committed by Commit Bot

[ios] Unused Tab references in BVC

The private method |-(CGFloat)headerHeightForTab:(Tab*)tab| was not
using the |tab| argument in calculations. Therefore, the argument was
unnecessary. Furthermore, there already exists a property called
|headerHeight|, which called this private method.
This CL simplifies and removes unnecessary references to Tab.

Change-Id: Ib56aef51929d59e672197d2c9d58cf62061209f0
Reviewed-on: https://chromium-review.googlesource.com/c/1344834Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610137}
parent 602c0515
...@@ -659,7 +659,7 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -659,7 +659,7 @@ NSString* const kBrowserViewControllerSnackbarCategory =
@property(nonatomic, assign) CGFloat footerFullscreenProgress; @property(nonatomic, assign) CGFloat footerFullscreenProgress;
// Y-dimension offset for placement of the header. // Y-dimension offset for placement of the header.
@property(nonatomic, readonly) CGFloat headerOffset; @property(nonatomic, readonly) CGFloat headerOffset;
// Height of the header view for the tab model's current tab. // Height of the header view.
@property(nonatomic, readonly) CGFloat headerHeight; @property(nonatomic, readonly) CGFloat headerHeight;
// The webState of the active tab. // The webState of the active tab.
...@@ -736,8 +736,6 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -736,8 +736,6 @@ NSString* const kBrowserViewControllerSnackbarCategory =
- (CGRect)ntpFrameForWebState:(web::WebState*)webState; - (CGRect)ntpFrameForWebState:(web::WebState*)webState;
// Returns web contents frame without including primary toolbar. // Returns web contents frame without including primary toolbar.
- (CGRect)visibleFrameForTab:(Tab*)tab; - (CGRect)visibleFrameForTab:(Tab*)tab;
// Returns the header height needed for |tab|.
- (CGFloat)headerHeightForTab:(Tab*)tab;
// Sets the frame for the headers. // Sets the frame for the headers.
- (void)setFramesForHeaders:(NSArray<HeaderDefinition*>*)headers - (void)setFramesForHeaders:(NSArray<HeaderDefinition*>*)headers
atOffset:(CGFloat)headerOffset; atOffset:(CGFloat)headerOffset;
...@@ -1243,7 +1241,20 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint ...@@ -1243,7 +1241,20 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
} }
- (CGFloat)headerHeight { - (CGFloat)headerHeight {
return [self headerHeightForTab:self.tabModel.currentTab]; NSArray<HeaderDefinition*>* views = [self headerViews];
CGFloat height = self.headerOffset;
for (HeaderDefinition* header in views) {
if (header.view && header.behaviour == Hideable) {
height += CGRectGetHeight([header.view frame]);
}
}
CGFloat statusBarOffset = 0;
if (!self.usesFullscreenContainer) {
statusBarOffset = StatusBarHeight();
}
return height - statusBarOffset;
} }
- (web::WebState*)currentWebState { - (web::WebState*)currentWebState {
...@@ -2593,23 +2604,6 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint ...@@ -2593,23 +2604,6 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
return UIEdgeInsetsInsetRect([self viewForTab:tab].bounds, headerInset); return UIEdgeInsetsInsetRect([self viewForTab:tab].bounds, headerInset);
} }
- (CGFloat)headerHeightForTab:(Tab*)tab {
NSArray<HeaderDefinition*>* views = [self headerViews];
CGFloat height = self.headerOffset;
for (HeaderDefinition* header in views) {
if (header.view && header.behaviour == Hideable) {
height += CGRectGetHeight([header.view frame]);
}
}
CGFloat statusBarOffset = 0;
if (!self.usesFullscreenContainer) {
statusBarOffset = StatusBarHeight();
}
return height - statusBarOffset;
}
- (void)setFramesForHeaders:(NSArray<HeaderDefinition*>*)headers - (void)setFramesForHeaders:(NSArray<HeaderDefinition*>*)headers
atOffset:(CGFloat)headerOffset { atOffset:(CGFloat)headerOffset {
CGFloat height = self.headerOffset; CGFloat height = self.headerOffset;
...@@ -3027,8 +3021,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint ...@@ -3027,8 +3021,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
->IsInitialized() || ->IsInitialized() ||
webState->GetWebViewProxy().shouldUseViewContentInset; webState->GetWebViewProxy().shouldUseViewContentInset;
if (isNTPActive || (outOfWeb && !usesContentInset)) { if (isNTPActive || (outOfWeb && !usesContentInset)) {
CGFloat headerHeight = [self headerHeightForTab:tab]; return UIEdgeInsetsMake(self.headerHeight, 0.0, 0.0, 0.0);
return UIEdgeInsetsMake(headerHeight, 0.0, 0.0, 0.0);
} }
// For all other scenarios, the content area is inset from the snapshot base // For all other scenarios, the content area is inset from the snapshot base
...@@ -3071,9 +3064,9 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint ...@@ -3071,9 +3064,9 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
viewController]; viewController];
UIView* sadTabView = viewController.view; UIView* sadTabView = viewController.view;
if (sadTabView) { if (sadTabView) {
CGFloat offset = [self headerHeightForTab:tab];
SnapshotOverlay* sadTabOverlay = SnapshotOverlay* sadTabOverlay =
[[SnapshotOverlay alloc] initWithView:sadTabView yOffset:offset]; [[SnapshotOverlay alloc] initWithView:sadTabView
yOffset:self.headerHeight];
[overlays addObject:sadTabOverlay]; [overlays addObject:sadTabOverlay];
} }
} }
...@@ -3478,11 +3471,9 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint ...@@ -3478,11 +3471,9 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
runRepostFormDialogWithCompletionHandler:(void (^)(BOOL))handler { runRepostFormDialogWithCompletionHandler:(void (^)(BOOL))handler {
// Display the action sheet with the arrow pointing at the top center of the // Display the action sheet with the arrow pointing at the top center of the
// web contents. // web contents.
Tab* tab = LegacyTabHelper::GetTabForWebState(webState);
UIView* view = webState->GetView(); UIView* view = webState->GetView();
CGPoint dialogLocation = CGPoint dialogLocation = CGPointMake(
CGPointMake(CGRectGetMidX(view.frame), CGRectGetMidX(view.frame), CGRectGetMinY(view.frame) + self.headerHeight);
CGRectGetMinY(view.frame) + [self headerHeightForTab:tab]);
auto* helper = RepostFormTabHelper::FromWebState(webState); auto* helper = RepostFormTabHelper::FromWebState(webState);
helper->PresentDialog(dialogLocation, base::BindOnce(^(bool shouldContinue) { helper->PresentDialog(dialogLocation, base::BindOnce(^(bool shouldContinue) {
handler(shouldContinue); handler(shouldContinue);
...@@ -3753,15 +3744,14 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint ...@@ -3753,15 +3744,14 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
} }
- (CGFloat)nativeContentHeaderHeightForWebState:(web::WebState*)webState { - (CGFloat)nativeContentHeaderHeightForWebState:(web::WebState*)webState {
Tab* tab = LegacyTabHelper::GetTabForWebState(webState); if (IsVisibleUrlNewTabPage(webState) && ![self canShowTabStrip]) {
if (IsVisibleUrlNewTabPage(tab.webState) && ![self canShowTabStrip]) {
if (self.usesFullscreenContainer) if (self.usesFullscreenContainer)
return 0; return 0;
// Also subtract the top safe area so the view will appear as full screen. // Also subtract the top safe area so the view will appear as full screen.
// TODO(crbug.com/826369) Remove this once NTP is out of native content. // TODO(crbug.com/826369) Remove this once NTP is out of native content.
return -self.view.safeAreaInsets.top; return -self.view.safeAreaInsets.top;
} }
return [self headerHeightForTab:tab]; return self.headerHeight;
} }
#pragma mark - DialogPresenterDelegate methods #pragma mark - DialogPresenterDelegate methods
......
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