-
Notifications
You must be signed in to change notification settings - Fork 0
/
11.diff
188 lines (173 loc) · 7.13 KB
/
11.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
diff --git a/ios/chrome/browser/ui/toolbar/BUILD.gn b/ios/chrome/browser/ui/toolbar/BUILD.gn
index 9ac010b..c2986eb 100644
--- a/ios/chrome/browser/ui/toolbar/BUILD.gn
+++ b/ios/chrome/browser/ui/toolbar/BUILD.gn
@@ -17,7 +17,6 @@
"toolbar_controller_constants.mm",
"toolbar_coordinator.h",
"toolbar_coordinator.mm",
- "toolbar_frame_delegate.h",
"toolbar_model_delegate_ios.h",
"toolbar_model_delegate_ios.mm",
"toolbar_model_impl_ios.h",
@@ -28,6 +27,7 @@
"toolbar_tools_menu_button.mm",
"toolbar_view.h",
"toolbar_view.mm",
+ "toolbar_view_delegate.h",
"tools_menu_button_observer_bridge.h",
"tools_menu_button_observer_bridge.mm",
"web_toolbar_controller.h",
diff --git a/ios/chrome/browser/ui/toolbar/toolbar_frame_delegate.h b/ios/chrome/browser/ui/toolbar/toolbar_frame_delegate.h
deleted file mode 100644
index 4def7ba..0000000
--- a/ios/chrome/browser/ui/toolbar/toolbar_frame_delegate.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// 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_UI_TOOLBAR_TOOLBAR_FRAME_DELEGATE_H_
-#define IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_FRAME_DELEGATE_H_
-
-#import <Foundation/Foundation.h>
-
-// Create a thin wrapper around UIImageView to catch frame change and window
-// events.
-@protocol ToolbarFrameDelegate<NSObject>
-- (void)frameDidChangeFrame:(CGRect)newFrame fromFrame:(CGRect)oldFrame;
-- (void)windowDidChange;
-- (void)traitCollectionDidChange;
-@end
-
-#endif // IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_FRAME_DELEGATE_H_
diff --git a/ios/chrome/browser/ui/toolbar/toolbar_view.h b/ios/chrome/browser/ui/toolbar/toolbar_view.h
index 8712d73..d37320b 100644
--- a/ios/chrome/browser/ui/toolbar/toolbar_view.h
+++ b/ios/chrome/browser/ui/toolbar/toolbar_view.h
@@ -9,7 +9,7 @@
#import "ios/chrome/browser/ui/util/relaxed_bounds_constraints_hittest.h"
-@protocol ToolbarFrameDelegate;
+@protocol ToolbarViewDelegate;
@interface ToolbarView : UIView<RelaxedBoundsConstraintsHitTestSupport>
- (instancetype)initWithNibName:(NSString*)name
@@ -17,7 +17,7 @@
- (instancetype)initWithCoder:(NSCoder*)coder NS_UNAVAILABLE;
// The delegate used to handle frame changes and windows events.
-@property(nonatomic, weak) id<ToolbarFrameDelegate> delegate;
+@property(nonatomic, weak) id<ToolbarViewDelegate> delegate;
// Records whether or not the toolbar is currently involved in a transition
// animation.
@property(nonatomic, assign, getter=isAnimatingTransition)
diff --git a/ios/chrome/browser/ui/toolbar/toolbar_view.mm b/ios/chrome/browser/ui/toolbar/toolbar_view.mm
index ef4a858..0c2797a 100644
--- a/ios/chrome/browser/ui/toolbar/toolbar_view.mm
+++ b/ios/chrome/browser/ui/toolbar/toolbar_view.mm
@@ -5,7 +5,7 @@
#import "ios/chrome/browser/ui/toolbar/toolbar_view.h"
#import "ios/chrome/browser/ui/toolbar/toolbar_controller_base_feature.h"
-#import "ios/chrome/browser/ui/toolbar/toolbar_frame_delegate.h"
+#import "ios/chrome/browser/ui/toolbar/toolbar_view_delegate.h"
@implementation ToolbarView
@@ -57,10 +57,9 @@
return hitView;
}
-- (void)setFrame:(CGRect)frame {
- CGRect oldFrame = self.frame;
- [super setFrame:frame];
- [delegate_ frameDidChangeFrame:frame fromFrame:oldFrame];
+- (void)layoutSubviews {
+ [super layoutSubviews];
+ [delegate_ toolbarDidLayout];
}
- (void)didMoveToWindow {
diff --git a/ios/chrome/browser/ui/toolbar/toolbar_view_delegate.h b/ios/chrome/browser/ui/toolbar/toolbar_view_delegate.h
new file mode 100644
index 0000000..e7e85d2
--- /dev/null
+++ b/ios/chrome/browser/ui/toolbar/toolbar_view_delegate.h
@@ -0,0 +1,26 @@
+// 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_UI_TOOLBAR_TOOLBAR_VIEW_DELEGATE_H_
+#define IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_VIEW_DELEGATE_H_
+
+#import <Foundation/Foundation.h>
+
+// A delegate protocol to pass UIView information about the toolbar.
+// TODO(crbug.com/683793): Remove this protocol when toolbars are presented via
+// UIViewControllers, as this can already be accomplished through that API.
+@protocol ToolbarViewDelegate<NSObject>
+
+// Called when the toolbar view performs a layout pass.
+- (void)toolbarDidLayout;
+
+// Called when the toolbar view is transferred to a new parent window.
+- (void)windowDidChange;
+
+// Called when the toolbar view's trait collection changes.
+- (void)traitCollectionDidChange;
+
+@end
+
+#endif // IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_VIEW_DELEGATE_H_
diff --git a/ios/chrome/browser/ui/toolbar/web_toolbar_controller.h b/ios/chrome/browser/ui/toolbar/web_toolbar_controller.h
index bc518aa..ecaacf6 100644
--- a/ios/chrome/browser/ui/toolbar/web_toolbar_controller.h
+++ b/ios/chrome/browser/ui/toolbar/web_toolbar_controller.h
@@ -19,7 +19,6 @@
@protocol ApplicationCommands;
@protocol BrowserCommands;
@class Tab;
-@protocol ToolbarFrameDelegate;
@protocol UrlLoader;
@protocol WebToolbarDelegate;
diff --git a/ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm b/ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm
index 6573de5..15bf92a 100644
--- a/ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm
+++ b/ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm
@@ -56,7 +56,7 @@
#import "ios/chrome/browser/ui/toolbar/keyboard_assist/toolbar_assistive_keyboard_views.h"
#import "ios/chrome/browser/ui/toolbar/toolbar_controller+protected.h"
#import "ios/chrome/browser/ui/toolbar/toolbar_controller_base_feature.h"
-#import "ios/chrome/browser/ui/toolbar/toolbar_frame_delegate.h"
+#import "ios/chrome/browser/ui/toolbar/toolbar_view_delegate.h"
#import "ios/chrome/browser/ui/toolbar/toolbar_model_ios.h"
#include "ios/chrome/browser/ui/toolbar/toolbar_resource_macros.h"
#import "ios/chrome/browser/ui/toolbar/web_toolbar_controller_constants.h"
@@ -100,7 +100,7 @@
LocationBarDelegate,
OmniboxPopupPositioner,
ToolbarAssistiveKeyboardDelegate,
- ToolbarFrameDelegate> {
+ ToolbarViewDelegate> {
// Top-level view for web content.
UIView* _webToolbar;
UIButton* _backButton;
@@ -138,6 +138,9 @@
// reversed.
ToolbarButtonMode _forwardButtonMode;
+ // Keeps track of the last known toolbar frame.
+ CGRect _lastKnownToolbarFrame;
+
// Keeps track of last known trait collection used by the subviews.
UITraitCollection* _lastKnownTraitCollection;
@@ -1199,12 +1202,14 @@
}
#pragma mark -
-#pragma mark ToolbarFrameDelegate methods.
+#pragma mark ToolbarViewDelegate methods.
-- (void)frameDidChangeFrame:(CGRect)newFrame fromFrame:(CGRect)oldFrame {
- if (oldFrame.origin.y == newFrame.origin.y)
+- (void)toolbarDidLayout {
+ CGRect frame = self.view.frame;
+ if (CGRectEqualToRect(_lastKnownToolbarFrame, frame))
return;
- [self updateToolbarAlphaForFrame:newFrame];
+ [self updateToolbarAlphaForFrame:frame];
+ _lastKnownToolbarFrame = frame;
}
- (void)windowDidChange {