OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/ntp/most_visited_layout.h" | 5 #import "ios/chrome/browser/ui/ntp/most_visited_layout.h" |
6 | 6 |
7 #import "ios/chrome/browser/ui/ntp/new_tab_page_header_constants.h" | 7 #import "ios/chrome/browser/ui/ntp/new_tab_page_header_constants.h" |
8 #include "ios/chrome/browser/ui/ui_util.h" | 8 #include "ios/chrome/browser/ui/ui_util.h" |
9 | 9 |
| 10 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 11 #error "This file requires ARC support." |
| 12 #endif |
| 13 |
10 @implementation MostVisitedLayout | 14 @implementation MostVisitedLayout |
11 | 15 |
12 - (NSArray*)layoutAttributesForElementsInRect:(CGRect)rect { | 16 - (NSArray*)layoutAttributesForElementsInRect:(CGRect)rect { |
13 NSMutableArray* layoutAttributes = [ | 17 NSMutableArray* layoutAttributes = |
14 [[super layoutAttributesForElementsInRect:rect] mutableCopy] autorelease]; | 18 [[super layoutAttributesForElementsInRect:rect] mutableCopy]; |
15 UICollectionViewLayoutAttributes* fixedHeaderAttributes = nil; | 19 UICollectionViewLayoutAttributes* fixedHeaderAttributes = nil; |
16 NSIndexPath* fixedHeaderIndexPath = | 20 NSIndexPath* fixedHeaderIndexPath = |
17 [NSIndexPath indexPathForItem:0 inSection:0]; | 21 [NSIndexPath indexPathForItem:0 inSection:0]; |
18 | 22 |
19 for (UICollectionViewLayoutAttributes* attributes in layoutAttributes) { | 23 for (UICollectionViewLayoutAttributes* attributes in layoutAttributes) { |
20 if ([attributes.representedElementKind | 24 if ([attributes.representedElementKind |
21 isEqualToString:UICollectionElementKindSectionHeader] && | 25 isEqualToString:UICollectionElementKindSectionHeader] && |
22 attributes.indexPath.section == fixedHeaderIndexPath.section) { | 26 attributes.indexPath.section == fixedHeaderIndexPath.section) { |
23 fixedHeaderAttributes = [self | 27 fixedHeaderAttributes = [self |
24 layoutAttributesForSupplementaryViewOfKind: | 28 layoutAttributesForSupplementaryViewOfKind: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 minimumHeight -= ntp_header::kToolbarHeight; | 98 minimumHeight -= ntp_header::kToolbarHeight; |
95 | 99 |
96 CGSize contentSize = [super collectionViewContentSize]; | 100 CGSize contentSize = [super collectionViewContentSize]; |
97 if (contentSize.height < minimumHeight) { | 101 if (contentSize.height < minimumHeight) { |
98 contentSize.height = minimumHeight; | 102 contentSize.height = minimumHeight; |
99 } | 103 } |
100 return contentSize; | 104 return contentSize; |
101 } | 105 } |
102 | 106 |
103 @end | 107 @end |
OLD | NEW |