summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgroby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-28 20:29:18 +0000
committergroby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-28 20:29:18 +0000
commit1a0569b9f3898af9c3432bef817d1affd395d05b (patch)
treeff507f5dd58aab4b52e92c0cd235d10cf47a2a27
parent1d889a84c85f96f3533f4b9a338cd58d9eb6877f (diff)
downloadchromium_src-1a0569b9f3898af9c3432bef817d1affd395d05b.zip
chromium_src-1a0569b9f3898af9c3432bef817d1affd395d05b.tar.gz
chromium_src-1a0569b9f3898af9c3432bef817d1affd395d05b.tar.bz2
[rAC] Allow sub-views to trigger layout reflow.
BUG=157274 Review URL: https://chromiumcodereview.appspot.com/15645004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202642 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--build/common.gypi2
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_details_container.h3
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_details_container.mm24
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h8
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm66
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_layout.h33
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_main_container.h3
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_main_container.mm19
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_section_container.h6
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_section_container.mm106
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_section_container_unittest.mm14
-rw-r--r--chrome/chrome_browser_ui.gypi5
12 files changed, 213 insertions, 76 deletions
diff --git a/build/common.gypi b/build/common.gypi
index 4a43c27..5e36f7f 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -504,7 +504,7 @@
}],
# Enable autofill dialog for Android and Views-enabled platforms for now.
- ['toolkit_views==1 or (OS=="android" and android_webview_build==0)', {
+ ['toolkit_views==1 or (OS=="android" and android_webview_build==0) or OS=="mac"', {
'enable_autofill_dialog%': 1
}],
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_details_container.h b/chrome/browser/ui/cocoa/autofill/autofill_details_container.h
index 0ef8181..79c5804 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_details_container.h
+++ b/chrome/browser/ui/cocoa/autofill/autofill_details_container.h
@@ -9,6 +9,7 @@
#include "base/memory/scoped_nsobject.h"
#include "chrome/browser/ui/autofill/autofill_dialog_types.h"
+#import "chrome/browser/ui/cocoa/autofill/autofill_layout.h"
namespace autofill {
class AutofillDialogController;
@@ -17,7 +18,7 @@ class AutofillDialogController;
@class AutofillSectionContainer;
// UI controller for details for current payment instrument.
-@interface AutofillDetailsContainer : NSViewController {
+@interface AutofillDetailsContainer : NSViewController<AutofillLayout> {
@private
scoped_nsobject<NSMutableArray> details_; // The individual detail sections.
autofill::AutofillDialogController* controller_; // Not owned.
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_details_container.mm b/chrome/browser/ui/cocoa/autofill/autofill_details_container.mm
index 56c20b8..5a88597 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_details_container.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_details_container.mm
@@ -4,6 +4,8 @@
#import "chrome/browser/ui/cocoa/autofill/autofill_details_container.h"
+#include <algorithm>
+
#include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
#import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h"
@@ -33,15 +35,33 @@
[self addSection:autofill::SECTION_SHIPPING];
[self setView:[[NSView alloc] init]];
+ for (AutofillSectionContainer* container in details_.get())
+ [[self view] addSubview:[container view]];
+
+ [self performLayout];
+}
+
+- (NSSize)preferredSize {
+ NSSize size = NSMakeSize(0, 0);
+ for (AutofillSectionContainer* container in details_.get()) {
+ NSSize containerSize = [container preferredSize];
+ size.height += containerSize.height;
+ size.width = std::max(containerSize.width, size.width);
+ }
+ return size;
+}
+
+- (void)performLayout {
NSRect rect = NSZeroRect;
for (AutofillSectionContainer* container in
[details_ reverseObjectEnumerator]) {
+ [container performLayout];
[[container view] setFrameOrigin:NSMakePoint(0, NSMaxY(rect))];
rect = NSUnionRect(rect, [[container view] frame]);
- [[self view] addSubview:[container view]];
}
- [[self view] setFrame:rect];
+
+ [[self view] setFrameSize:[self preferredSize]];
}
- (AutofillSectionContainer*)sectionForId:(autofill::DialogSection)section {
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h
index c39f13d..0641300 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h
+++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h
@@ -9,6 +9,7 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/autofill/autofill_dialog_types.h"
#include "chrome/browser/ui/autofill/autofill_dialog_view.h"
+#import "chrome/browser/ui/cocoa/autofill/autofill_layout.h"
#include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
namespace content {
@@ -71,8 +72,8 @@ class AutofillDialogCocoa : public AutofillDialogView,
} // autofill
-@interface AutofillDialogWindowController : NSWindowController
- <NSWindowDelegate> {
+@interface AutofillDialogWindowController :
+ NSWindowController<NSWindowDelegate, AutofillLayout> {
@private
content::WebContents* webContents_; // weak.
autofill::AutofillDialogCocoa* autofillDialog_; // weak.
@@ -86,6 +87,9 @@ class AutofillDialogCocoa : public AutofillDialogView,
- (id)initWithWebContents:(content::WebContents*)webContents
autofillDialog:(autofill::AutofillDialogCocoa*)autofillDialog;
+// A child view request re-layouting.
+- (void)requestRelayout;
+
// Validate data. If it is valid, notify the controller that the user would
// like to use the data.
- (IBAction)accept:(id)sender;
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm
index 6c19689..956cb24 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm
@@ -19,6 +19,13 @@
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_window.h"
#include "ui/base/cocoa/window_size_constants.h"
+namespace {
+
+const CGFloat kAccountChooserHeight = 20.0;
+const CGFloat kRelatedControlVerticalSpacing = 8.0;
+
+} // namespace;
+
namespace autofill {
// static
@@ -143,7 +150,6 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed(
[[mainContainer_ view] setFrame:clientRect];
[[signInContainer_ view] setFrame:clientRect];
- const CGFloat kAccountChooserHeight = 20.0;
NSRect headerRect = clientRect;
headerRect.size.height = kAccountChooserHeight;
headerRect.origin.y = NSMaxY(clientRect);
@@ -159,16 +165,60 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed(
contentRect.size.height += NSHeight(headerRect) +
chrome_style::kClientBottomPadding +
chrome_style::kTitleTopPadding;
- [[[self window] contentView] setFrame:contentRect];
- NSRect frame = [[self window] frameRectForContentRect:contentRect];
- [[self window] setFrame:frame display:YES];
-
- [accountChooser_
- setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)];
+ [self performLayout];
}
return self;
}
+- (void)requestRelayout {
+ [self performLayout];
+}
+
+- (NSSize)preferredSize {
+ NSSize contentSize;
+ // TODO(groby): Currently, keep size identical to main container.
+ // Change to allow autoresize of web contents.
+ contentSize = [mainContainer_ preferredSize];
+
+ NSSize headerSize = NSMakeSize(contentSize.width, kAccountChooserHeight);
+ NSSize size = NSMakeSize(
+ std::max(contentSize.width, headerSize.width),
+ contentSize.height + headerSize.height + kRelatedControlVerticalSpacing);
+ size.width += 2 * chrome_style::kHorizontalPadding;
+ size.height += chrome_style::kClientBottomPadding +
+ chrome_style::kTitleTopPadding;
+ return size;
+}
+
+- (void)performLayout {
+ // Don't animate when we first show the window.
+ BOOL shouldAnimate =
+ !NSEqualRects(ui::kWindowSizeDeterminedLater, [[self window] frame]);
+
+ NSRect contentRect = NSZeroRect;
+ contentRect.size = [self preferredSize];
+ NSRect clientRect = NSInsetRect(
+ contentRect, chrome_style::kHorizontalPadding, 0);
+ clientRect.origin.y += chrome_style::kClientBottomPadding;
+ clientRect.size.height -= chrome_style::kTitleTopPadding +
+ chrome_style::kClientBottomPadding;
+
+ NSRect headerRect, mainRect;
+ NSDivideRect(clientRect, &headerRect, &mainRect,
+ kAccountChooserHeight, NSMaxYEdge);
+
+ [accountChooser_ setFrame:headerRect];
+ if ([[signInContainer_ view] isHidden]) {
+ [[mainContainer_ view] setFrame:mainRect];
+ [mainContainer_ performLayout];
+ } else {
+ [[signInContainer_ view] setFrame:mainRect];
+ }
+
+ NSRect frameRect = [[self window] frameRectForContentRect:contentRect];
+ [[self window] setFrame:frameRect display:YES animate:shouldAnimate];
+}
+
- (IBAction)accept:(id)sender {
// TODO(groby): Validation goes here.
autofillDialog_->controller()->OnAccept();
@@ -188,6 +238,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed(
[signInContainer_ loadSignInPage];
[[mainContainer_ view] setHidden:YES];
[[signInContainer_ view] setHidden:NO];
+ [self performLayout];
return [signInContainer_ navigationController];
}
@@ -200,6 +251,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed(
- (void)hideSignIn {
[[signInContainer_ view] setHidden:YES];
[[mainContainer_ view] setHidden:NO];
+ [self performLayout];
}
- (void)modelChanged {
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_layout.h b/chrome/browser/ui/cocoa/autofill/autofill_layout.h
new file mode 100644
index 0000000..9a6f823
--- /dev/null
+++ b/chrome/browser/ui/cocoa/autofill/autofill_layout.h
@@ -0,0 +1,33 @@
+// Copyright 2013 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 CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_LAYOUT_H_
+#define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_LAYOUT_H_
+
+#import <Cocoa/Cocoa.h>
+
+// Defines a protocol that allows resizing a view hierarchy based on the size
+// requirements of the subviews. Is implemented by either views or view
+// controllers.
+// The way this works together is:
+// * Subview indicates by calling -requestRelayout on the window controller.
+// * Window controller queries subviews for preferredSize to determine the
+// total size of the contentView, adjusts subview origins appropriately,
+// and calls performLayout on each subview.
+// * Subviews then recursively do the same thing.
+@protocol AutofillLayout
+
+// Query the preferred size, without actually layouting.
+// Akin to -intrinsicContentSize on 10.7
+- (NSSize)preferredSize;
+
+// Layout the content according to the preferred size. Will not touch
+// frameOrigin. If all objects in the hierarchy were custom views (and not
+// view controllers), this could be replaced by overriding
+// -resizeSubviewsWithOldSize:.
+- (void)performLayout;
+
+@end
+
+#endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_LAYOUT_H_
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_main_container.h b/chrome/browser/ui/cocoa/autofill/autofill_main_container.h
index 1a6b96c..b05a713 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_main_container.h
+++ b/chrome/browser/ui/cocoa/autofill/autofill_main_container.h
@@ -9,6 +9,7 @@
#include "base/memory/scoped_nsobject.h"
#include "chrome/browser/ui/autofill/autofill_dialog_types.h"
+#import "chrome/browser/ui/cocoa/autofill/autofill_layout.h"
@class AutofillDetailsContainer;
@class AutofillDialogWindowController;
@@ -22,7 +23,7 @@ namespace autofill {
// NSViewController for the main portion of the autofill dialog. Contains
// account chooser, details for current payment instruments, OK/Cancel.
// Might dynamically add and remove other elements.
-@interface AutofillMainContainer : NSViewController {
+@interface AutofillMainContainer : NSViewController<AutofillLayout> {
@private
scoped_nsobject<GTMWidthBasedTweaker> buttonContainer_;
scoped_nsobject<AutofillDetailsContainer> detailsContainer_;
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_main_container.mm b/chrome/browser/ui/cocoa/autofill/autofill_main_container.mm
index 7579555..80b050cc 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_main_container.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_main_container.mm
@@ -4,6 +4,9 @@
#import "chrome/browser/ui/cocoa/autofill/autofill_main_container.h"
+#include <algorithm>
+#include <cmath>
+
#include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h"
#import "chrome/browser/ui/cocoa/autofill/autofill_details_container.h"
@@ -49,6 +52,22 @@
[[self view] addSubview:[detailsContainer_ view]];
}
+- (NSSize)preferredSize {
+ // The buttons never change size, so rely on container.
+ NSSize buttonSize = [buttonContainer_ frame].size;
+ NSSize detailsSize = [detailsContainer_ preferredSize];
+
+ NSSize size = NSMakeSize(std::max(buttonSize.width, detailsSize.width),
+ buttonSize.height + detailsSize.height);
+
+ return size;
+}
+
+- (void)performLayout {
+ // Assume that the frame for the container is set already.
+ [detailsContainer_ performLayout];
+}
+
- (void)buildWindowButtonsForFrame:(NSRect)frame {
if (buttonContainer_.get())
return;
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_section_container.h b/chrome/browser/ui/cocoa/autofill/autofill_section_container.h
index 9b0b3fe..c242dce 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_section_container.h
+++ b/chrome/browser/ui/cocoa/autofill/autofill_section_container.h
@@ -9,6 +9,7 @@
#include "base/memory/scoped_nsobject.h"
#include "chrome/browser/ui/autofill/autofill_dialog_types.h"
+#import "chrome/browser/ui/cocoa/autofill/autofill_layout.h"
namespace autofill {
class AutofillDialogController;
@@ -21,10 +22,13 @@ namespace autofill {
// View controller for a section of the payment details. Contains a label
// describing the section as well as associated inputs and controls. Built
// dynamically based on data retrieved from AutofillDialogController.
-@interface AutofillSectionContainer : NSViewController {
+@interface AutofillSectionContainer : NSViewController<AutofillLayout> {
@private
scoped_nsobject<LayoutView> inputs_;
scoped_nsobject<MenuButton> suggestButton_;
+ scoped_nsobject<NSTextField> label_;
+ scoped_nsobject<NSView> view_; // The view for the container.
+
scoped_nsobject<MenuController> menuController_;
autofill::DialogSection section_;
autofill::AutofillDialogController* controller_; // Not owned.
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm b/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm
index a3edb9c..ef5c960 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm
@@ -50,10 +50,6 @@ const size_t kDetailSectionInset = 10;
// Create properly styled label for section. Autoreleased.
- (NSTextField*)makeDetailSectionLabel:(NSString*)labelText;
-// Create NSView containing inputs & labelling. Autoreleased.
-- (NSView*)makeSectionView:(NSString*)labelText
- withControls:(LayoutView*)controls;
-
// Create a button offering input suggestions.
- (MenuButton*)makeSuggestionButton;
@@ -103,22 +99,67 @@ const size_t kDetailSectionInset = 10;
inputs_.reset([[self makeInputControls] retain]);
string16 labelText = controller_->LabelForSection(section_);
- scoped_nsobject<NSView> sectionView(
- [[self makeSectionView:base::SysUTF16ToNSString(labelText)
- withControls:inputs_] retain]);
+ label_.reset([[self makeDetailSectionLabel:
+ base::SysUTF16ToNSString(labelText)] retain]);
+
suggestButton_.reset([[self makeSuggestionButton] retain]);
- NSRect buttonFrame = [suggestButton_ frame];
- buttonFrame.origin.x = NSMaxX([sectionView frame]);
- NSRect frame = NSUnionRect(buttonFrame, [sectionView frame]);
- DCHECK(NSHeight(frame) >= NSHeight(buttonFrame) + 2 * kDetailSectionInset);
- buttonFrame.origin.y =
- NSMaxY(frame) - NSHeight(buttonFrame) - kDetailSectionInset;
- [suggestButton_ setFrame:buttonFrame];
[self modelChanged];
- [self setView:[[[NSView alloc] initWithFrame:frame] autorelease]];
- [[self view] setSubviews:@[sectionView, suggestButton_]];
+ view_.reset([[NSView alloc] initWithFrame:NSZeroRect]);
+ [self performLayout];
+ [self setView:view_];
+ [[self view] setSubviews:@[label_, inputs_, suggestButton_]];
+}
+
+- (NSSize)preferredSize {
+ NSSize labelSize = [label_ frame].size; // Assumes sizeToFit was called.
+ CGFloat contentHeight = [inputs_ preferredHeightForWidth:kDetailsWidth];
+ contentHeight = std::max(contentHeight, labelSize.height);
+ contentHeight = std::max(contentHeight, NSHeight([suggestButton_ frame]));
+
+ return NSMakeSize(kLabelWidth + kPadding + kDetailsWidth,
+ contentHeight + 2 * kDetailSectionInset);
+}
+
+- (void)performLayout {
+ NSSize buttonSize = [suggestButton_ frame].size; // Assume sizeToFit.
+ NSSize labelSize = [label_ frame].size; // Assumes sizeToFit was called.
+ CGFloat controlHeight = [inputs_ preferredHeightForWidth:kDetailsWidth];
+
+ NSRect viewFrame = NSZeroRect;
+ viewFrame.size = [self preferredSize];
+
+ NSRect contentFrame = NSInsetRect(viewFrame, 0, kDetailSectionInset);
+ NSRect dummy;
+
+ // Set up three content columns. kLabelWidth is first column width,
+ // then padding, then have suggestButton and inputs share kDetailsWidth.
+ NSRect column[3];
+ NSDivideRect(contentFrame, &column[0], &dummy, kLabelWidth, NSMinXEdge);
+ NSDivideRect(contentFrame, &column[1], &dummy, kDetailsWidth, NSMaxXEdge);
+ NSDivideRect(column[1],
+ &column[2], &column[1], buttonSize.width, NSMaxXEdge);
+
+ // Center inputs by height in column 1.
+ NSRect controlFrame = column[1];
+ int centerOffset = (NSHeight(controlFrame) - controlHeight) / 2;
+ controlFrame.origin.x += centerOffset;
+ controlFrame.size.height = controlHeight;
+
+ // Align label to right top in column 0.
+ NSRect labelFrame;
+ NSDivideRect(column[0], &labelFrame, &dummy, labelSize.height, NSMaxYEdge);
+ NSDivideRect(labelFrame, &labelFrame, &dummy, labelSize.width, NSMaxXEdge);
+
+ // suggest button is top left of column 2.
+ NSRect buttonFrame = column[2];
+ NSDivideRect(column[2], &buttonFrame, &dummy, buttonSize.height, NSMaxYEdge);
+
+ [inputs_ setFrame:controlFrame];
+ [label_ setFrame:labelFrame];
+ [suggestButton_ setFrame:buttonFrame];
+ [view_ setFrame:viewFrame];
}
- (NSTextField*)makeDetailSectionLabel:(NSString*)labelText {
@@ -134,37 +175,6 @@ const size_t kDetailSectionInset = 10;
return label.autorelease();
}
-- (NSView*)makeSectionView:(NSString*)labelText
- withControls:(LayoutView*)controls {
- scoped_nsobject<NSTextField> label(
- [[self makeDetailSectionLabel:labelText] retain]);
-
- CGFloat controlHeight = [controls preferredHeightForWidth:kDetailsWidth];
- NSRect frame = NSZeroRect;
- frame.size.width = kLabelWidth + kPadding + kDetailsWidth;
- frame.size.height = std::max(NSHeight([label frame]), controlHeight) +
- 2 * kDetailSectionInset;
- scoped_nsobject<NSView> section_container(
- [[NSView alloc] initWithFrame:frame]);
-
- NSPoint labelOrigin = NSMakePoint(
- kLabelWidth - NSWidth([label frame]),
- NSHeight(frame) - NSHeight([label frame]) - kDetailSectionInset);
- [label setFrameOrigin:labelOrigin];
- [label setAutoresizingMask:(NSViewMinYMargin | NSViewMinYMargin)];
-
- NSRect dummyFrame;
- NSRect controlFrame = [controls frame];
- NSDivideRect(NSInsetRect(frame, 0, kDetailSectionInset),
- &controlFrame, &dummyFrame, kDetailsWidth, NSMaxXEdge);
- controlFrame.size.height = controlHeight;
- [controls setFrame:controlFrame];
- [controls setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)];
-
- [section_container setSubviews:@[label, controls]];
- return section_container.autorelease();
-}
-
- (MenuButton*)makeSuggestionButton {
scoped_nsobject<MenuButton> button([[MenuButton alloc] init]);
@@ -272,4 +282,4 @@ const size_t kDetailSectionInset = 10;
return nil;
}
- @end \ No newline at end of file
+@end \ No newline at end of file
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_section_container_unittest.mm b/chrome/browser/ui/cocoa/autofill/autofill_section_container_unittest.mm
index 191f81a..c1043bd 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_section_container_unittest.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_section_container_unittest.mm
@@ -50,26 +50,18 @@ class AutofillSectionContainerTest : public ui::CocoaTest {
TEST_VIEW(AutofillSectionContainerTest, [container_ view])
TEST_F(AutofillSectionContainerTest, HasSubviews) {
- ASSERT_EQ(2U, [[[container_ view] subviews] count]);
-
bool hasLayoutView = false;
bool hasTextField = false;
bool hasSuggestButton = false;
- NSView* sectionView = nil;
+ ASSERT_EQ(3U, [[[container_ view] subviews] count]);
for (NSView* view in [[container_ view] subviews]) {
- if ([view isKindOfClass:[MenuButton class]])
- hasSuggestButton = true;
- else
- sectionView = view;
- }
-
- ASSERT_EQ(2U, [[sectionView subviews] count]);
- for (NSView* view in [sectionView subviews]) {
if ([view isKindOfClass:[NSTextField class]]) {
hasTextField = true;
} else if ([view isKindOfClass:[LayoutView class]]) {
hasLayoutView = true;
+ } else if ([view isKindOfClass:[MenuButton class]]) {
+ hasSuggestButton = true;
}
}
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index cd580e1d6..6702f75 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -420,8 +420,7 @@
'browser/ui/cocoa/autofill/autofill_dialog_cocoa.h',
'browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm',
'browser/ui/cocoa/autofill/autofill_dialog_constants.h',
- 'browser/ui/cocoa/autofill/layout_view.h',
- 'browser/ui/cocoa/autofill/layout_view.mm',
+ 'browser/ui/cocoa/autofill/autofill_layout.h',
'browser/ui/cocoa/autofill/autofill_main_container.h',
'browser/ui/cocoa/autofill/autofill_main_container.mm',
'browser/ui/cocoa/autofill/autofill_popup_view_bridge.h',
@@ -436,6 +435,8 @@
'browser/ui/cocoa/autofill/autofill_textfield.mm',
'browser/ui/cocoa/autofill/down_arrow_popup_menu_cell.h',
'browser/ui/cocoa/autofill/down_arrow_popup_menu_cell.mm',
+ 'browser/ui/cocoa/autofill/layout_view.h',
+ 'browser/ui/cocoa/autofill/layout_view.mm',
'browser/ui/cocoa/autofill/simple_grid_layout.h',
'browser/ui/cocoa/autofill/simple_grid_layout.mm',
'browser/ui/cocoa/background_gradient_view.h',