Commit 9ce77b8c authored by olivierrobin's avatar olivierrobin Committed by Commit bot

Create headerHeightForTab in TabHeadersDelegate.

When creating a tab in foreground, the TabModel loads it before
marking it active to avoid visual blinking.
But loading require getting the header height of the new tab and not
of the current tab.

BUG=676153

Review-Url: https://codereview.chromium.org/2599313002
Cr-Commit-Position: refs/heads/master@{#443276}
parent 48d29c26
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#import "base/mac/scoped_nsobject.h" #import "base/mac/scoped_nsobject.h"
#import "ios/chrome/browser/snapshots/snapshot_manager.h" #import "ios/chrome/browser/snapshots/snapshot_manager.h"
#import "ios/chrome/browser/tabs/tab.h" #import "ios/chrome/browser/tabs/tab.h"
#import "ios/chrome/browser/ui/fullscreen_controller.h" #import "ios/chrome/browser/tabs/tab_headers_delegate.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h" #import "ios/chrome/browser/ui/uikit_ui_util.h"
#import "ios/web/web_state/ui/crw_web_controller.h" #import "ios/web/web_state/ui/crw_web_controller.h"
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
} else { } else {
// Crops the bottom of the fullscreen snapshot. // Crops the bottom of the fullscreen snapshot.
CGRect cropRect = CGRect cropRect =
CGRectMake(0, [[_tab fullScreenControllerDelegate] headerHeight], CGRectMake(0, [[_tab tabHeadersDelegate] headerHeightForTab:_tab],
[snapshot size].width, [snapshot size].height); [snapshot size].width, [snapshot size].height);
snapshotToCache = CropImage(snapshot, cropRect); snapshotToCache = CropImage(snapshot, cropRect);
} }
......
...@@ -7,6 +7,7 @@ source_set("tabs") { ...@@ -7,6 +7,7 @@ source_set("tabs") {
"tab.h", "tab.h",
"tab_delegate.h", "tab_delegate.h",
"tab_dialog_delegate.h", "tab_dialog_delegate.h",
"tab_headers_delegate.h",
"tab_model.h", "tab_model.h",
"tab_model_list.h", "tab_model_list.h",
"tab_model_observer.h", "tab_model_observer.h",
......
...@@ -40,6 +40,7 @@ class GURL; ...@@ -40,6 +40,7 @@ class GURL;
@protocol TabDelegate; @protocol TabDelegate;
@protocol TabDialogDelegate; @protocol TabDialogDelegate;
@class Tab; @class Tab;
@protocol TabHeadersDelegate;
@class TabModel; @class TabModel;
@protocol TabSnapshottingDelegate; @protocol TabSnapshottingDelegate;
@class TranslateControllerImplIOS; @class TranslateControllerImplIOS;
...@@ -134,6 +135,7 @@ extern NSString* const kProxyPassthroughHeaderValue; ...@@ -134,6 +135,7 @@ extern NSString* const kProxyPassthroughHeaderValue;
@property(nonatomic, readonly) BOOL canGoBack; @property(nonatomic, readonly) BOOL canGoBack;
@property(nonatomic, readonly) BOOL canGoForward; @property(nonatomic, readonly) BOOL canGoForward;
@property(nonatomic, assign) id<TabDelegate> delegate; @property(nonatomic, assign) id<TabDelegate> delegate;
@property(nonatomic, assign) id<TabHeadersDelegate> tabHeadersDelegate;
@property(nonatomic, assign) id<TabSnapshottingDelegate> @property(nonatomic, assign) id<TabSnapshottingDelegate>
tabSnapshottingDelegate; tabSnapshottingDelegate;
@property(nonatomic, readonly) BOOL useDesktopUserAgent; @property(nonatomic, readonly) BOOL useDesktopUserAgent;
......
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
#include "ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h" #include "ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h"
#import "ios/chrome/browser/tabs/tab_delegate.h" #import "ios/chrome/browser/tabs/tab_delegate.h"
#import "ios/chrome/browser/tabs/tab_dialog_delegate.h" #import "ios/chrome/browser/tabs/tab_dialog_delegate.h"
#import "ios/chrome/browser/tabs/tab_headers_delegate.h"
#import "ios/chrome/browser/tabs/tab_model.h" #import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/chrome/browser/tabs/tab_private.h" #import "ios/chrome/browser/tabs/tab_private.h"
#import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h" #import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h"
...@@ -248,6 +249,9 @@ enum class RendererTerminationTabState { ...@@ -248,6 +249,9 @@ enum class RendererTerminationTabState {
// The Full Screen Controller responsible for hiding/showing the toolbar. // The Full Screen Controller responsible for hiding/showing the toolbar.
base::scoped_nsobject<FullScreenController> fullScreenController_; base::scoped_nsobject<FullScreenController> fullScreenController_;
// The delegate responsible for headers over the tab.
id<TabHeadersDelegate> tabHeadersDelegate_; // weak
base::WeakNSProtocol<id<FullScreenControllerDelegate>> base::WeakNSProtocol<id<FullScreenControllerDelegate>>
fullScreenControllerDelegate_; fullScreenControllerDelegate_;
...@@ -523,6 +527,7 @@ void AddNetworkClientFactoryOnIOThread( ...@@ -523,6 +527,7 @@ void AddNetworkClientFactoryOnIOThread(
@synthesize isVoiceSearchResultsTab = isVoiceSearchResultsTab_; @synthesize isVoiceSearchResultsTab = isVoiceSearchResultsTab_;
@synthesize delegate = delegate_; @synthesize delegate = delegate_;
@synthesize tabSnapshottingDelegate = tabSnapshottingDelegate_; @synthesize tabSnapshottingDelegate = tabSnapshottingDelegate_;
@synthesize tabHeadersDelegate = tabHeadersDelegate_;
- (instancetype)initWithWindowName:(NSString*)windowName - (instancetype)initWithWindowName:(NSString*)windowName
opener:(Tab*)opener opener:(Tab*)opener
...@@ -1725,7 +1730,7 @@ void AddNetworkClientFactoryOnIOThread( ...@@ -1725,7 +1730,7 @@ void AddNetworkClientFactoryOnIOThread(
CGPoint dialogLocation = CGPoint dialogLocation =
CGPointMake(CGRectGetMidX(webController.view.frame), CGPointMake(CGRectGetMidX(webController.view.frame),
CGRectGetMinY(webController.view.frame) + CGRectGetMinY(webController.view.frame) +
[[self fullScreenControllerDelegate] headerHeight]); [self.tabHeadersDelegate headerHeightForTab:self]);
formResubmissionCoordinator_.reset([[FormResubmissionCoordinator alloc] formResubmissionCoordinator_.reset([[FormResubmissionCoordinator alloc]
initWithBaseViewController:topController initWithBaseViewController:topController
...@@ -2137,7 +2142,7 @@ void AddNetworkClientFactoryOnIOThread( ...@@ -2137,7 +2142,7 @@ void AddNetworkClientFactoryOnIOThread(
} }
- (CGFloat)headerHeightForWebController:(CRWWebController*)webController { - (CGFloat)headerHeightForWebController:(CRWWebController*)webController {
return [fullScreenControllerDelegate_ headerHeight]; return [self.tabHeadersDelegate headerHeightForTab:self];
} }
- (void)webControllerDidUpdateSSLStatusForCurrentNavigationItem: - (void)webControllerDidUpdateSSLStatusForCurrentNavigationItem:
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_TABS_TAB_HEADERS_DELEGATE_H_
#define IOS_CHROME_BROWSER_TABS_TAB_HEADERS_DELEGATE_H_
#import <UIKit/UIKit.h>
// A protocol implemented by a delegate of Tab that handles the headers above a
// tab.
@protocol TabHeadersDelegate
// Called to retrieve the height of the header view above |tab|.
- (CGFloat)headerHeightForTab:(Tab*)tab;
@end
#endif // IOS_CHROME_BROWSER_TABS_TAB_HEADERS_DELEGATE_H_
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
#import "ios/chrome/browser/storekit_launcher.h" #import "ios/chrome/browser/storekit_launcher.h"
#import "ios/chrome/browser/tabs/tab.h" #import "ios/chrome/browser/tabs/tab.h"
#import "ios/chrome/browser/tabs/tab_dialog_delegate.h" #import "ios/chrome/browser/tabs/tab_dialog_delegate.h"
#import "ios/chrome/browser/tabs/tab_headers_delegate.h"
#import "ios/chrome/browser/tabs/tab_model.h" #import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/chrome/browser/tabs/tab_model_observer.h" #import "ios/chrome/browser/tabs/tab_model_observer.h"
#import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h" #import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h"
...@@ -310,6 +311,7 @@ NSString* const kReadingListSnackbarCategory = @"ReadingListSnackbarCategory"; ...@@ -310,6 +311,7 @@ NSString* const kReadingListSnackbarCategory = @"ReadingListSnackbarCategory";
SnapshotOverlayProvider, SnapshotOverlayProvider,
StoreKitLauncher, StoreKitLauncher,
TabDialogDelegate, TabDialogDelegate,
TabHeadersDelegate,
TabModelObserver, TabModelObserver,
TabSnapshottingDelegate, TabSnapshottingDelegate,
UIGestureRecognizerDelegate, UIGestureRecognizerDelegate,
...@@ -737,8 +739,6 @@ NSString* const kReadingListSnackbarCategory = @"ReadingListSnackbarCategory"; ...@@ -737,8 +739,6 @@ NSString* const kReadingListSnackbarCategory = @"ReadingListSnackbarCategory";
- (UIView*)footerView; - (UIView*)footerView;
// Returns the height of the header view for the tab model's current tab. // Returns the height of the header view for the tab model's current tab.
- (CGFloat)headerHeight; - (CGFloat)headerHeight;
// Returns the height of the header view for |tab|.
- (CGFloat)headerHeightForTab:(Tab*)tab;
// Sets the frame for the headers. // Sets the frame for the headers.
- (void)setFramesForHeaders:(const std::vector<HeaderDefinition>)headers - (void)setFramesForHeaders:(const std::vector<HeaderDefinition>)headers
atOffset:(CGFloat)headerOffset; atOffset:(CGFloat)headerOffset;
...@@ -2110,6 +2110,7 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { ...@@ -2110,6 +2110,7 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver {
if (!IsIPadIdiom()) { if (!IsIPadIdiom()) {
tab.overscrollActionsControllerDelegate = self; tab.overscrollActionsControllerDelegate = self;
} }
tab.tabHeadersDelegate = self;
tab.tabSnapshottingDelegate = self; tab.tabSnapshottingDelegate = self;
// Install the proper CRWWebController delegates. // Install the proper CRWWebController delegates.
tab.webController.nativeProvider = self; tab.webController.nativeProvider = self;
......
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