Chromium Code Reviews| Index: ios/chrome/browser/ui/ntp/new_tab_page_view.mm |
| diff --git a/ios/chrome/browser/ui/ntp/new_tab_page_view.mm b/ios/chrome/browser/ui/ntp/new_tab_page_view.mm |
| index 7f9f7ab87e63cfe169c902b229e1c613ae416218..52790970460013eda28bab97a55cbe4cc6c6ee45 100644 |
| --- a/ios/chrome/browser/ui/ntp/new_tab_page_view.mm |
| +++ b/ios/chrome/browser/ui/ntp/new_tab_page_view.mm |
| @@ -80,11 +80,15 @@ |
| [self.scrollView setContentOffset:point animated:NO]; |
| } |
| - // Trigger a layout. The |-layoutIfNeeded| call is required because sometimes |
| - // |-layoutSubviews| is not successfully triggered when |-setNeedsLayout| is |
| - // called after frame changes due to autoresizing masks. |
| - [self setNeedsLayout]; |
| - [self layoutIfNeeded]; |
| + // This should never be needed in autolayout. |
| + if (self.translatesAutoresizingMaskIntoConstraints) { |
| + // Trigger a layout. The |-layoutIfNeeded| call is required because |
| + // sometimes |
| + // |-layoutSubviews| is not successfully triggered when |-setNeedsLayout| is |
|
lpromero
2017/04/06 13:01:04
Reflow the comment.
justincohen
2017/04/06 18:25:09
Done.
|
| + // called after frame changes due to autoresizing masks. |
| + [self setNeedsLayout]; |
| + [self layoutIfNeeded]; |
| + } |
| } |
| - (void)layoutSubviews { |
| @@ -102,6 +106,14 @@ |
| CGRectGetMinX(self.bounds), CGRectGetMinY(self.bounds), |
| CGRectGetWidth(self.bounds), CGRectGetMinY(self.tabBar.frame)); |
| } |
| + |
| + // When using a new_tab_page_view in autolayout -setFrame is never called, |
| + // which means all the logic to keep the selected scroll index set is never |
| + // called. Rather than refactor away all of this to support ios/clean, just |
| + // make sure -setFrame is called when loaded in autolayout. |
| + if (!self.translatesAutoresizingMaskIntoConstraints) { |
| + [self setFrame:self.frame]; |
| + } |
| } |
| - (void)updateScrollViewContentSize { |