Commit 6460a841 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Cleanup BVC's HeaderDefinition

This CL clean the HeaderDefinition class, removing unused properties.

Bug: 836730
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Iddc78f1a52ca587617d1def9c03455c2a1052f5b
Reviewed-on: https://chromium-review.googlesource.com/1026679
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553514}
parent 9b1f79de
...@@ -337,8 +337,6 @@ const CGFloat kSearchByImageMaxImageHeight = 400.0; ...@@ -337,8 +337,6 @@ const CGFloat kSearchByImageMaxImageHeight = 400.0;
enum HeaderBehaviour { enum HeaderBehaviour {
// The header moves completely out of the screen. // The header moves completely out of the screen.
Hideable = 0, Hideable = 0,
// This header stays on screen and doesn't overlap with the content.
Visible,
// This header stay on screen and covers part of the content. // This header stay on screen and covers part of the content.
Overlap Overlap
}; };
...@@ -358,25 +356,22 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -358,25 +356,22 @@ NSString* const kBrowserViewControllerSnackbarCategory =
#pragma mark - HeaderDefinition helper #pragma mark - HeaderDefinition helper
// Class used to define a header, an object displayed at the top of the browser.
@interface HeaderDefinition : NSObject @interface HeaderDefinition : NSObject
// The header view. // The header view.
@property(nonatomic, strong) UIView* view; @property(nonatomic, strong) UIView* view;
// How to place the view, and its behaviour when the headers move. // How to place the view, and its behaviour when the headers move.
@property(nonatomic, assign) HeaderBehaviour behaviour; @property(nonatomic, assign) HeaderBehaviour behaviour;
// Reduces the height of a header to adjust for shadows.
@property(nonatomic, assign) CGFloat heightAdjustement;
// Nudges that particular header up by this number of points. // Nudges that particular header up by this number of points.
@property(nonatomic, assign) CGFloat inset; @property(nonatomic, assign) CGFloat inset;
- (instancetype)initWithView:(UIView*)view - (instancetype)initWithView:(UIView*)view
headerBehaviour:(HeaderBehaviour)behaviour headerBehaviour:(HeaderBehaviour)behaviour
heightAdjustment:(CGFloat)heightAdjustment
inset:(CGFloat)inset; inset:(CGFloat)inset;
+ (instancetype)definitionWithView:(UIView*)view + (instancetype)definitionWithView:(UIView*)view
headerBehaviour:(HeaderBehaviour)behaviour headerBehaviour:(HeaderBehaviour)behaviour
heightAdjustment:(CGFloat)heightAdjustment
inset:(CGFloat)inset; inset:(CGFloat)inset;
@end @end
...@@ -384,28 +379,23 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -384,28 +379,23 @@ NSString* const kBrowserViewControllerSnackbarCategory =
@implementation HeaderDefinition @implementation HeaderDefinition
@synthesize view = _view; @synthesize view = _view;
@synthesize behaviour = _behaviour; @synthesize behaviour = _behaviour;
@synthesize heightAdjustement = _heightAdjustement;
@synthesize inset = _inset; @synthesize inset = _inset;
+ (instancetype)definitionWithView:(UIView*)view + (instancetype)definitionWithView:(UIView*)view
headerBehaviour:(HeaderBehaviour)behaviour headerBehaviour:(HeaderBehaviour)behaviour
heightAdjustment:(CGFloat)heightAdjustment
inset:(CGFloat)inset { inset:(CGFloat)inset {
return [[self alloc] initWithView:view return [[self alloc] initWithView:view
headerBehaviour:behaviour headerBehaviour:behaviour
heightAdjustment:heightAdjustment
inset:inset]; inset:inset];
} }
- (instancetype)initWithView:(UIView*)view - (instancetype)initWithView:(UIView*)view
headerBehaviour:(HeaderBehaviour)behaviour headerBehaviour:(HeaderBehaviour)behaviour
heightAdjustment:(CGFloat)heightAdjustment
inset:(CGFloat)inset { inset:(CGFloat)inset {
self = [super init]; self = [super init];
if (self) { if (self) {
_view = view; _view = view;
_behaviour = behaviour; _behaviour = behaviour;
_heightAdjustement = heightAdjustment;
_inset = inset; _inset = inset;
} }
return self; return self;
...@@ -1325,14 +1315,12 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -1325,14 +1315,12 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
definitionWithView:self.primaryToolbarCoordinator definitionWithView:self.primaryToolbarCoordinator
.viewController.view .viewController.view
headerBehaviour:Hideable headerBehaviour:Hideable
heightAdjustment:0.0
inset:0.0]]; inset:0.0]];
} }
} else { } else {
if (self.tabStripView) { if (self.tabStripView) {
[results addObject:[HeaderDefinition definitionWithView:self.tabStripView [results addObject:[HeaderDefinition definitionWithView:self.tabStripView
headerBehaviour:Hideable headerBehaviour:Hideable
heightAdjustment:0.0
inset:0.0]]; inset:0.0]];
} }
if (self.primaryToolbarCoordinator.viewController.view) { if (self.primaryToolbarCoordinator.viewController.view) {
...@@ -1340,14 +1328,12 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -1340,14 +1328,12 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
definitionWithView:self.primaryToolbarCoordinator definitionWithView:self.primaryToolbarCoordinator
.viewController.view .viewController.view
headerBehaviour:Hideable headerBehaviour:Hideable
heightAdjustment:0.0
inset:0.0]]; inset:0.0]];
} }
if ([_findBarController view]) { if ([_findBarController view]) {
[results addObject:[HeaderDefinition [results addObject:[HeaderDefinition
definitionWithView:[_findBarController view] definitionWithView:[_findBarController view]
headerBehaviour:Overlap headerBehaviour:Overlap
heightAdjustment:0.0
inset:kIPadFindBarOverlap]]; inset:kIPadFindBarOverlap]];
} }
} }
...@@ -2550,8 +2536,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -2550,8 +2536,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
CGFloat height = self.headerOffset; CGFloat height = self.headerOffset;
for (HeaderDefinition* header in views) { for (HeaderDefinition* header in views) {
if (header.view && header.behaviour == Hideable) { if (header.view && header.behaviour == Hideable) {
height += CGRectGetHeight([header.view frame]) - height += CGRectGetHeight([header.view frame]) - header.inset;
header.heightAdjustement - header.inset;
} }
} }
......
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