Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4244)

Unified Diff: chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm

Issue 89023003: [rAC, OSX] Fix dialog jankiness. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm b/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm
index b8db59a2e5b157b3a0b51c3cc1bd57a8810fa2a0..c36ddecfbfebf945b41bce58a2a54dc3b8706bf3 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm
@@ -32,6 +32,54 @@ const CGFloat kMinimumContentsHeight = 101;
} // namespace
+#pragma mark AutofillDialogWindow
+
+// Window class for the AutofillDialog. Its main purpose is the proper handling
+// of layout requests - i.e. ensuring that layout is fully done before any
+// updates of the display happen.
+@interface AutofillDialogWindow : ConstrainedWindowCustomWindow {
+ @private
+ BOOL needsLayout; // Indicates that the subviews need to be laid out.
Nico 2013/11/27 01:03:06 don't we name instance variables with a trailing _
groby-ooo-7-16 2013/11/27 01:34:04 Yes, we do. My brain is already eating turkey, it
+}
+
+// Request a new layout for all subviews. Layout occurs right before -display
+// or -displayIfNeeded are invoked.
+- (void)requestRelayout;
+
+// Layout the window's subviews. Delegates to the controller.
+- (void)performLayout;
+
+@end
+
+
+@implementation AutofillDialogWindow
+
+- (void)requestRelayout {
+ needsLayout = YES;
+}
+
+- (void)performLayout {
+ if (needsLayout) {
+ needsLayout = NO;
+ AutofillDialogWindowController* controller =
+ base::mac::ObjCCastStrict<AutofillDialogWindowController>(
+ [self windowController]);
+ [controller performLayout];
+ }
+}
+
+- (void)display {
+ [self performLayout];
+ [super display];
+}
+
+- (void)displayIfNeeded {
+ [self performLayout];
+ [super displayIfNeeded];
+}
+
+@end
+
#pragma mark Field Editor
@interface AutofillDialogFieldEditor : NSTextView
@@ -81,6 +129,8 @@ const CGFloat kMinimumContentsHeight = 101;
// Update whether or not the main container is hidden.
- (void)updateMainContainerVisibility;
+- (AutofillDialogWindow*)autofillWindow;
+
@end
@@ -108,7 +158,7 @@ const CGFloat kMinimumContentsHeight = 101;
DCHECK(webContents);
base::scoped_nsobject<ConstrainedWindowCustomWindow> window(
- [[ConstrainedWindowCustomWindow alloc]
+ [[AutofillDialogWindow alloc]
initWithContentRect:ui::kWindowSizeDeterminedLater]);
if ((self = [super initWithWindow:window])) {
@@ -196,15 +246,12 @@ const CGFloat kMinimumContentsHeight = 101;
[[mainContainer_ view] setHidden:!visible];
}
-- (void)cancelRelayout {
- [NSObject cancelPreviousPerformRequestsWithTarget:self
- selector:@selector(performLayout)
- object:nil];
+- (AutofillDialogWindow*)autofillWindow {
+ return base::mac::ObjCCastStrict<AutofillDialogWindow>([self window]);
}
- (void)requestRelayout {
- [self cancelRelayout];
- [self performSelector:@selector(performLayout) withObject:nil afterDelay:0.0];
+ [[self autofillWindow] requestRelayout];
}
- (NSSize)preferredSize {
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698