| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/infobars/infobar_container_view.h" | 5 #import "ios/chrome/browser/infobars/infobar_container_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ios/chrome/browser/infobars/infobar.h" | 8 #include "ios/chrome/browser/infobars/infobar.h" |
| 9 #include "ios/chrome/browser/ui/infobars/infobar_view_protocol.h" | 9 #include "ios/chrome/browser/ui/infobars/infobar_view.h" |
| 10 #include "ui/base/device_form_factor.h" | 10 #include "ui/base/device_form_factor.h" |
| 11 | 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) | 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." | 13 #error "This file requires ARC support." |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 @implementation InfoBarContainerView | 16 @implementation InfoBarContainerView |
| 17 | 17 |
| 18 - (void)addInfoBar:(InfoBarIOS*)infoBarIOS position:(NSInteger)position { | 18 - (void)addInfoBar:(InfoBarIOS*)infoBarIOS position:(NSInteger)position { |
| 19 DCHECK_LE((NSUInteger)position, [[self subviews] count]); | 19 DCHECK_LE((NSUInteger)position, [[self subviews] count]); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 35 CGFloat elementHeight = [view sizeThatFits:size].height; | 35 CGFloat elementHeight = [view sizeThatFits:size].height; |
| 36 if (elementHeight > height) | 36 if (elementHeight > height) |
| 37 height = elementHeight; | 37 height = elementHeight; |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 size.height = height; | 40 size.height = height; |
| 41 return size; | 41 return size; |
| 42 } | 42 } |
| 43 | 43 |
| 44 - (void)layoutSubviews { | 44 - (void)layoutSubviews { |
| 45 for (UIView<InfoBarViewProtocol>* view in self.subviews) { | 45 for (InfoBarView* view in self.subviews) { |
| 46 [view sizeToFit]; | 46 [view sizeToFit]; |
| 47 CGRect frame = view.frame; | 47 CGRect frame = view.frame; |
| 48 frame.origin.y = CGRectGetHeight(frame) - [view visibleHeight]; | 48 frame.origin.y = CGRectGetHeight(frame) - [view visibleHeight]; |
| 49 [view setFrame:frame]; | 49 [view setFrame:frame]; |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 - (CGFloat)topmostVisibleInfoBarHeight { | 53 - (CGFloat)topmostVisibleInfoBarHeight { |
| 54 for (UIView<InfoBarViewProtocol>* view in | 54 for (InfoBarView* view in [self.subviews reverseObjectEnumerator]) { |
| 55 [self.subviews reverseObjectEnumerator]) { | |
| 56 return [view sizeThatFits:self.frame.size].height; | 55 return [view sizeThatFits:self.frame.size].height; |
| 57 } | 56 } |
| 58 return 0; | 57 return 0; |
| 59 } | 58 } |
| 60 | 59 |
| 61 @end | 60 @end |
| OLD | NEW |