Commit 1a0569b9 authored by groby@chromium.org's avatar groby@chromium.org

[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
parent 1d889a84
...@@ -504,7 +504,7 @@ ...@@ -504,7 +504,7 @@
}], }],
# Enable autofill dialog for Android and Views-enabled platforms for now. # 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 'enable_autofill_dialog%': 1
}], }],
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/memory/scoped_nsobject.h" #include "base/memory/scoped_nsobject.h"
#include "chrome/browser/ui/autofill/autofill_dialog_types.h" #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
#import "chrome/browser/ui/cocoa/autofill/autofill_layout.h"
namespace autofill { namespace autofill {
class AutofillDialogController; class AutofillDialogController;
...@@ -17,7 +18,7 @@ class AutofillDialogController; ...@@ -17,7 +18,7 @@ class AutofillDialogController;
@class AutofillSectionContainer; @class AutofillSectionContainer;
// UI controller for details for current payment instrument. // UI controller for details for current payment instrument.
@interface AutofillDetailsContainer : NSViewController { @interface AutofillDetailsContainer : NSViewController<AutofillLayout> {
@private @private
scoped_nsobject<NSMutableArray> details_; // The individual detail sections. scoped_nsobject<NSMutableArray> details_; // The individual detail sections.
autofill::AutofillDialogController* controller_; // Not owned. autofill::AutofillDialogController* controller_; // Not owned.
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import "chrome/browser/ui/cocoa/autofill/autofill_details_container.h" #import "chrome/browser/ui/cocoa/autofill/autofill_details_container.h"
#include <algorithm>
#include "chrome/browser/ui/autofill/autofill_dialog_controller.h" #include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
#import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h" #import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h"
...@@ -33,15 +35,33 @@ ...@@ -33,15 +35,33 @@
[self addSection:autofill::SECTION_SHIPPING]; [self addSection:autofill::SECTION_SHIPPING];
[self setView:[[NSView alloc] init]]; [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; NSRect rect = NSZeroRect;
for (AutofillSectionContainer* container in for (AutofillSectionContainer* container in
[details_ reverseObjectEnumerator]) { [details_ reverseObjectEnumerator]) {
[container performLayout];
[[container view] setFrameOrigin:NSMakePoint(0, NSMaxY(rect))]; [[container view] setFrameOrigin:NSMakePoint(0, NSMaxY(rect))];
rect = NSUnionRect(rect, [[container view] frame]); 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 { - (AutofillSectionContainer*)sectionForId:(autofill::DialogSection)section {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/autofill/autofill_dialog_types.h" #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
#include "chrome/browser/ui/autofill/autofill_dialog_view.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" #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
namespace content { namespace content {
...@@ -71,8 +72,8 @@ class AutofillDialogCocoa : public AutofillDialogView, ...@@ -71,8 +72,8 @@ class AutofillDialogCocoa : public AutofillDialogView,
} // autofill } // autofill
@interface AutofillDialogWindowController : NSWindowController @interface AutofillDialogWindowController :
<NSWindowDelegate> { NSWindowController<NSWindowDelegate, AutofillLayout> {
@private @private
content::WebContents* webContents_; // weak. content::WebContents* webContents_; // weak.
autofill::AutofillDialogCocoa* autofillDialog_; // weak. autofill::AutofillDialogCocoa* autofillDialog_; // weak.
...@@ -86,6 +87,9 @@ class AutofillDialogCocoa : public AutofillDialogView, ...@@ -86,6 +87,9 @@ class AutofillDialogCocoa : public AutofillDialogView,
- (id)initWithWebContents:(content::WebContents*)webContents - (id)initWithWebContents:(content::WebContents*)webContents
autofillDialog:(autofill::AutofillDialogCocoa*)autofillDialog; 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 // Validate data. If it is valid, notify the controller that the user would
// like to use the data. // like to use the data.
- (IBAction)accept:(id)sender; - (IBAction)accept:(id)sender;
......
...@@ -19,6 +19,13 @@ ...@@ -19,6 +19,13 @@
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_window.h" #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_window.h"
#include "ui/base/cocoa/window_size_constants.h" #include "ui/base/cocoa/window_size_constants.h"
namespace {
const CGFloat kAccountChooserHeight = 20.0;
const CGFloat kRelatedControlVerticalSpacing = 8.0;
} // namespace;
namespace autofill { namespace autofill {
// static // static
...@@ -143,7 +150,6 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( ...@@ -143,7 +150,6 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed(
[[mainContainer_ view] setFrame:clientRect]; [[mainContainer_ view] setFrame:clientRect];
[[signInContainer_ view] setFrame:clientRect]; [[signInContainer_ view] setFrame:clientRect];
const CGFloat kAccountChooserHeight = 20.0;
NSRect headerRect = clientRect; NSRect headerRect = clientRect;
headerRect.size.height = kAccountChooserHeight; headerRect.size.height = kAccountChooserHeight;
headerRect.origin.y = NSMaxY(clientRect); headerRect.origin.y = NSMaxY(clientRect);
...@@ -159,16 +165,60 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( ...@@ -159,16 +165,60 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed(
contentRect.size.height += NSHeight(headerRect) + contentRect.size.height += NSHeight(headerRect) +
chrome_style::kClientBottomPadding + chrome_style::kClientBottomPadding +
chrome_style::kTitleTopPadding; chrome_style::kTitleTopPadding;
[[[self window] contentView] setFrame:contentRect]; [self performLayout];
NSRect frame = [[self window] frameRectForContentRect:contentRect];
[[self window] setFrame:frame display:YES];
[accountChooser_
setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)];
} }
return self; 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 { - (IBAction)accept:(id)sender {
// TODO(groby): Validation goes here. // TODO(groby): Validation goes here.
autofillDialog_->controller()->OnAccept(); autofillDialog_->controller()->OnAccept();
...@@ -188,6 +238,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( ...@@ -188,6 +238,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed(
[signInContainer_ loadSignInPage]; [signInContainer_ loadSignInPage];
[[mainContainer_ view] setHidden:YES]; [[mainContainer_ view] setHidden:YES];
[[signInContainer_ view] setHidden:NO]; [[signInContainer_ view] setHidden:NO];
[self performLayout];
return [signInContainer_ navigationController]; return [signInContainer_ navigationController];
} }
...@@ -200,6 +251,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( ...@@ -200,6 +251,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed(
- (void)hideSignIn { - (void)hideSignIn {
[[signInContainer_ view] setHidden:YES]; [[signInContainer_ view] setHidden:YES];
[[mainContainer_ view] setHidden:NO]; [[mainContainer_ view] setHidden:NO];
[self performLayout];
} }
- (void)modelChanged { - (void)modelChanged {
......
// 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_
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/memory/scoped_nsobject.h" #include "base/memory/scoped_nsobject.h"
#include "chrome/browser/ui/autofill/autofill_dialog_types.h" #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
#import "chrome/browser/ui/cocoa/autofill/autofill_layout.h"
@class AutofillDetailsContainer; @class AutofillDetailsContainer;
@class AutofillDialogWindowController; @class AutofillDialogWindowController;
...@@ -22,7 +23,7 @@ namespace autofill { ...@@ -22,7 +23,7 @@ namespace autofill {
// NSViewController for the main portion of the autofill dialog. Contains // NSViewController for the main portion of the autofill dialog. Contains
// account chooser, details for current payment instruments, OK/Cancel. // account chooser, details for current payment instruments, OK/Cancel.
// Might dynamically add and remove other elements. // Might dynamically add and remove other elements.
@interface AutofillMainContainer : NSViewController { @interface AutofillMainContainer : NSViewController<AutofillLayout> {
@private @private
scoped_nsobject<GTMWidthBasedTweaker> buttonContainer_; scoped_nsobject<GTMWidthBasedTweaker> buttonContainer_;
scoped_nsobject<AutofillDetailsContainer> detailsContainer_; scoped_nsobject<AutofillDetailsContainer> detailsContainer_;
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#import "chrome/browser/ui/cocoa/autofill/autofill_main_container.h" #import "chrome/browser/ui/cocoa/autofill/autofill_main_container.h"
#include <algorithm>
#include <cmath>
#include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h" #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/constrained_window/constrained_window_button.h"
#import "chrome/browser/ui/cocoa/autofill/autofill_details_container.h" #import "chrome/browser/ui/cocoa/autofill/autofill_details_container.h"
...@@ -49,6 +52,22 @@ ...@@ -49,6 +52,22 @@
[[self view] addSubview:[detailsContainer_ view]]; [[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 { - (void)buildWindowButtonsForFrame:(NSRect)frame {
if (buttonContainer_.get()) if (buttonContainer_.get())
return; return;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/memory/scoped_nsobject.h" #include "base/memory/scoped_nsobject.h"
#include "chrome/browser/ui/autofill/autofill_dialog_types.h" #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
#import "chrome/browser/ui/cocoa/autofill/autofill_layout.h"
namespace autofill { namespace autofill {
class AutofillDialogController; class AutofillDialogController;
...@@ -21,10 +22,13 @@ namespace autofill { ...@@ -21,10 +22,13 @@ namespace autofill {
// View controller for a section of the payment details. Contains a label // View controller for a section of the payment details. Contains a label
// describing the section as well as associated inputs and controls. Built // describing the section as well as associated inputs and controls. Built
// dynamically based on data retrieved from AutofillDialogController. // dynamically based on data retrieved from AutofillDialogController.
@interface AutofillSectionContainer : NSViewController { @interface AutofillSectionContainer : NSViewController<AutofillLayout> {
@private @private
scoped_nsobject<LayoutView> inputs_; scoped_nsobject<LayoutView> inputs_;
scoped_nsobject<MenuButton> suggestButton_; scoped_nsobject<MenuButton> suggestButton_;
scoped_nsobject<NSTextField> label_;
scoped_nsobject<NSView> view_; // The view for the container.
scoped_nsobject<MenuController> menuController_; scoped_nsobject<MenuController> menuController_;
autofill::DialogSection section_; autofill::DialogSection section_;
autofill::AutofillDialogController* controller_; // Not owned. autofill::AutofillDialogController* controller_; // Not owned.
......
...@@ -50,10 +50,6 @@ const size_t kDetailSectionInset = 10; ...@@ -50,10 +50,6 @@ const size_t kDetailSectionInset = 10;
// Create properly styled label for section. Autoreleased. // Create properly styled label for section. Autoreleased.
- (NSTextField*)makeDetailSectionLabel:(NSString*)labelText; - (NSTextField*)makeDetailSectionLabel:(NSString*)labelText;
// Create NSView containing inputs & labelling. Autoreleased.
- (NSView*)makeSectionView:(NSString*)labelText
withControls:(LayoutView*)controls;
// Create a button offering input suggestions. // Create a button offering input suggestions.
- (MenuButton*)makeSuggestionButton; - (MenuButton*)makeSuggestionButton;
...@@ -103,22 +99,67 @@ const size_t kDetailSectionInset = 10; ...@@ -103,22 +99,67 @@ const size_t kDetailSectionInset = 10;
inputs_.reset([[self makeInputControls] retain]); inputs_.reset([[self makeInputControls] retain]);
string16 labelText = controller_->LabelForSection(section_); string16 labelText = controller_->LabelForSection(section_);
scoped_nsobject<NSView> sectionView( label_.reset([[self makeDetailSectionLabel:
[[self makeSectionView:base::SysUTF16ToNSString(labelText) base::SysUTF16ToNSString(labelText)] retain]);
withControls:inputs_] retain]);
suggestButton_.reset([[self makeSuggestionButton] 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 modelChanged];
[self setView:[[[NSView alloc] initWithFrame:frame] autorelease]]; view_.reset([[NSView alloc] initWithFrame:NSZeroRect]);
[[self view] setSubviews:@[sectionView, suggestButton_]]; [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 { - (NSTextField*)makeDetailSectionLabel:(NSString*)labelText {
...@@ -134,37 +175,6 @@ const size_t kDetailSectionInset = 10; ...@@ -134,37 +175,6 @@ const size_t kDetailSectionInset = 10;
return label.autorelease(); 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 { - (MenuButton*)makeSuggestionButton {
scoped_nsobject<MenuButton> button([[MenuButton alloc] init]); scoped_nsobject<MenuButton> button([[MenuButton alloc] init]);
...@@ -272,4 +282,4 @@ const size_t kDetailSectionInset = 10; ...@@ -272,4 +282,4 @@ const size_t kDetailSectionInset = 10;
return nil; return nil;
} }
@end @end
\ No newline at end of file \ No newline at end of file
...@@ -50,26 +50,18 @@ class AutofillSectionContainerTest : public ui::CocoaTest { ...@@ -50,26 +50,18 @@ class AutofillSectionContainerTest : public ui::CocoaTest {
TEST_VIEW(AutofillSectionContainerTest, [container_ view]) TEST_VIEW(AutofillSectionContainerTest, [container_ view])
TEST_F(AutofillSectionContainerTest, HasSubviews) { TEST_F(AutofillSectionContainerTest, HasSubviews) {
ASSERT_EQ(2U, [[[container_ view] subviews] count]);
bool hasLayoutView = false; bool hasLayoutView = false;
bool hasTextField = false; bool hasTextField = false;
bool hasSuggestButton = false; bool hasSuggestButton = false;
NSView* sectionView = nil; ASSERT_EQ(3U, [[[container_ view] subviews] count]);
for (NSView* view in [[container_ view] subviews]) { 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]]) { if ([view isKindOfClass:[NSTextField class]]) {
hasTextField = true; hasTextField = true;
} else if ([view isKindOfClass:[LayoutView class]]) { } else if ([view isKindOfClass:[LayoutView class]]) {
hasLayoutView = true; hasLayoutView = true;
} else if ([view isKindOfClass:[MenuButton class]]) {
hasSuggestButton = true;
} }
} }
......
...@@ -420,8 +420,7 @@ ...@@ -420,8 +420,7 @@
'browser/ui/cocoa/autofill/autofill_dialog_cocoa.h', 'browser/ui/cocoa/autofill/autofill_dialog_cocoa.h',
'browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm', 'browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm',
'browser/ui/cocoa/autofill/autofill_dialog_constants.h', 'browser/ui/cocoa/autofill/autofill_dialog_constants.h',
'browser/ui/cocoa/autofill/layout_view.h', 'browser/ui/cocoa/autofill/autofill_layout.h',
'browser/ui/cocoa/autofill/layout_view.mm',
'browser/ui/cocoa/autofill/autofill_main_container.h', 'browser/ui/cocoa/autofill/autofill_main_container.h',
'browser/ui/cocoa/autofill/autofill_main_container.mm', 'browser/ui/cocoa/autofill/autofill_main_container.mm',
'browser/ui/cocoa/autofill/autofill_popup_view_bridge.h', 'browser/ui/cocoa/autofill/autofill_popup_view_bridge.h',
...@@ -436,6 +435,8 @@ ...@@ -436,6 +435,8 @@
'browser/ui/cocoa/autofill/autofill_textfield.mm', '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.h',
'browser/ui/cocoa/autofill/down_arrow_popup_menu_cell.mm', '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.h',
'browser/ui/cocoa/autofill/simple_grid_layout.mm', 'browser/ui/cocoa/autofill/simple_grid_layout.mm',
'browser/ui/cocoa/background_gradient_view.h', 'browser/ui/cocoa/background_gradient_view.h',
......
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